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_mem.h" 26 #include "osal_thread.h" 27 28 #define HDF_PROCESS_STACK_SIZE 10000 29 30 struct ReqList { 31 struct UsbFnRequest req; 32 struct DListHead entry; 33 uint8_t pipe; 34 int fd; 35 uint32_t buf; 36 uint32_t bufLen; 37 struct UsbHandleMgr *handle; 38 }; 39 40 struct UsbHandleMgr { 41 uint32_t numFd; 42 int fds[MAX_EP]; 43 struct UsbFnInterfaceMgr *intfMgr; 44 struct DListHead reqEntry; 45 struct UsbFnReqEvent *reqEvent[MAX_EP]; 46 }; 47 48 struct UsbFnFuncMgr { 49 const struct UsbObject *object; 50 int fd; 51 char name[MAX_NAMELEN]; 52 UsbFnEventCallback callback; 53 uint32_t eventMask; 54 void *context; 55 struct DListHead reqEntry; 56 }; 57 58 struct UsbFnInterfaceMgr { 59 struct UsbFnInterface interface; 60 struct UsbFnFuncMgr *funcMgr; 61 struct UsbHandleMgr *handle; 62 uint8_t startEpId; 63 bool isOpen; 64 }; 65 66 struct UsbFnRequest *UsbFnIoMgrRequestAlloc(struct UsbHandleMgr *handle, uint8_t pipe, uint32_t len); 67 int UsbFnIoMgrRequestFree(struct UsbFnRequest *req); 68 int UsbFnIoMgrRequestGetStatus(struct UsbFnRequest *req, UsbRequestStatus *status); 69 int UsbFnIoMgrRequestSubmitAsync(struct UsbFnRequest *req); 70 int UsbFnIoMgrRequestSubmitSync(struct UsbFnRequest *req, uint32_t timeout); 71 int UsbFnIoMgrRequestCancel(struct UsbFnRequest *req); 72 struct UsbHandleMgr *UsbFnIoMgrInterfaceOpen(struct UsbFnInterface *interface); 73 int UsbFnIoMgrInterfaceClose(struct UsbHandleMgr *handle); 74 int UsbFnIoMgrInterfaceGetPipeInfo(struct UsbFnInterface *interface, uint8_t pipeId, struct UsbFnPipeInfo *info); 75 int OpenEp0AndMapAddr(struct UsbFnFuncMgr *funcMgr); 76 #endif /* USBFN_IO_MGR_H */ 77 78