1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef USBFN_IO_MGR_H 17 #define USBFN_IO_MGR_H 18 19 #include "usb_object.h" 20 #include "device_resource_if.h" 21 #include "usbfn_device.h" 22 #include "usbfn_request.h" 23 #include "usbfn_interface.h" 24 #include "adapter_if.h" 25 #include "osal_thread.h" 26 27 #define HDF_PROCESS_STACK_SIZE 100000 28 29 struct ReqList { 30 struct UsbFnRequest req; 31 struct DListHead entry; 32 uint8_t pipe; 33 int32_t fd; 34 uint64_t buf; 35 uint32_t bufLen; 36 struct UsbHandleMgr *handle; 37 }; 38 39 struct UsbHandleMgr { 40 uint32_t numFd; 41 int32_t fds[MAX_EP]; 42 struct UsbFnInterfaceMgr *intfMgr; 43 struct DListHead reqEntry; 44 struct UsbFnReqEvent *reqEvent[MAX_EP]; 45 }; 46 47 struct UsbFnFuncMgr { 48 const struct UsbObject *object; 49 int32_t fd; 50 char name[MAX_NAMELEN]; 51 UsbFnEventCallback callback; 52 uint32_t eventMask; 53 void *context; 54 struct DListHead reqEntry; 55 }; 56 57 struct UsbFnInterfaceMgr { 58 struct UsbFnInterface interface; 59 struct UsbFnFuncMgr *funcMgr; 60 struct UsbHandleMgr *handle; 61 uint8_t startEpId; 62 bool isOpen; 63 }; 64 65 struct UsbFnRequest *UsbFnIoMgrRequestAlloc(struct UsbHandleMgr *handle, uint8_t pipe, uint32_t len); 66 int32_t UsbFnIoMgrRequestFree(struct UsbFnRequest *req); 67 int32_t UsbFnIoMgrRequestGetStatus(struct UsbFnRequest *req, UsbRequestStatus *status); 68 int32_t UsbFnIoMgrRequestSubmitAsync(struct UsbFnRequest *req); 69 int32_t UsbFnIoMgrRequestSubmitSync(struct UsbFnRequest *req, uint32_t timeout); 70 int32_t UsbFnIoMgrRequestCancel(struct UsbFnRequest *req); 71 struct UsbHandleMgr *UsbFnIoMgrInterfaceOpen(struct UsbFnInterface *interface); 72 int32_t UsbFnIoMgrInterfaceClose(struct UsbHandleMgr *handle); 73 int32_t UsbFnIoMgrInterfaceGetPipeInfo(struct UsbFnInterface *interface, uint8_t pipeId, struct UsbFnPipeInfo *info); 74 int32_t OpenEp0AndMapAddr(struct UsbFnFuncMgr *funcMgr); 75 #endif /* USBFN_IO_MGR_H */ 76 77