1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#ifndef USBFN_IO_MGR_H 17094332d3Sopenharmony_ci#define USBFN_IO_MGR_H 18094332d3Sopenharmony_ci 19094332d3Sopenharmony_ci#include "usb_object.h" 20094332d3Sopenharmony_ci#include "device_resource_if.h" 21094332d3Sopenharmony_ci#include "usbfn_device.h" 22094332d3Sopenharmony_ci#include "usbfn_request.h" 23094332d3Sopenharmony_ci#include "usbfn_interface.h" 24094332d3Sopenharmony_ci#include "adapter_if.h" 25094332d3Sopenharmony_ci#include "osal_thread.h" 26094332d3Sopenharmony_ci 27094332d3Sopenharmony_ci#define HDF_PROCESS_STACK_SIZE 100000 28094332d3Sopenharmony_ci 29094332d3Sopenharmony_cistruct ReqList { 30094332d3Sopenharmony_ci struct UsbFnRequest req; 31094332d3Sopenharmony_ci struct DListHead entry; 32094332d3Sopenharmony_ci uint8_t pipe; 33094332d3Sopenharmony_ci int32_t fd; 34094332d3Sopenharmony_ci uint64_t buf; 35094332d3Sopenharmony_ci uint32_t bufLen; 36094332d3Sopenharmony_ci struct UsbHandleMgr *handle; 37094332d3Sopenharmony_ci}; 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_cistruct UsbHandleMgr { 40094332d3Sopenharmony_ci uint32_t numFd; 41094332d3Sopenharmony_ci int32_t fds[MAX_EP]; 42094332d3Sopenharmony_ci struct UsbFnInterfaceMgr *intfMgr; 43094332d3Sopenharmony_ci struct DListHead reqEntry; 44094332d3Sopenharmony_ci struct UsbFnReqEvent *reqEvent[MAX_EP]; 45094332d3Sopenharmony_ci}; 46094332d3Sopenharmony_ci 47094332d3Sopenharmony_cistruct UsbFnFuncMgr { 48094332d3Sopenharmony_ci const struct UsbObject *object; 49094332d3Sopenharmony_ci int32_t fd; 50094332d3Sopenharmony_ci char name[MAX_NAMELEN]; 51094332d3Sopenharmony_ci UsbFnEventCallback callback; 52094332d3Sopenharmony_ci uint32_t eventMask; 53094332d3Sopenharmony_ci void *context; 54094332d3Sopenharmony_ci struct DListHead reqEntry; 55094332d3Sopenharmony_ci}; 56094332d3Sopenharmony_ci 57094332d3Sopenharmony_cistruct UsbFnInterfaceMgr { 58094332d3Sopenharmony_ci struct UsbFnInterface interface; 59094332d3Sopenharmony_ci struct UsbFnFuncMgr *funcMgr; 60094332d3Sopenharmony_ci struct UsbHandleMgr *handle; 61094332d3Sopenharmony_ci uint8_t startEpId; 62094332d3Sopenharmony_ci bool isOpen; 63094332d3Sopenharmony_ci}; 64094332d3Sopenharmony_ci 65094332d3Sopenharmony_cistruct UsbFnRequest *UsbFnIoMgrRequestAlloc(struct UsbHandleMgr *handle, uint8_t pipe, uint32_t len); 66094332d3Sopenharmony_ciint32_t UsbFnIoMgrRequestFree(struct UsbFnRequest *req); 67094332d3Sopenharmony_ciint32_t UsbFnIoMgrRequestGetStatus(struct UsbFnRequest *req, UsbRequestStatus *status); 68094332d3Sopenharmony_ciint32_t UsbFnIoMgrRequestSubmitAsync(struct UsbFnRequest *req); 69094332d3Sopenharmony_ciint32_t UsbFnIoMgrRequestSubmitSync(struct UsbFnRequest *req, uint32_t timeout); 70094332d3Sopenharmony_ciint32_t UsbFnIoMgrRequestCancel(struct UsbFnRequest *req); 71094332d3Sopenharmony_cistruct UsbHandleMgr *UsbFnIoMgrInterfaceOpen(struct UsbFnInterface *interface); 72094332d3Sopenharmony_ciint32_t UsbFnIoMgrInterfaceClose(struct UsbHandleMgr *handle); 73094332d3Sopenharmony_ciint32_t UsbFnIoMgrInterfaceGetPipeInfo(struct UsbFnInterface *interface, uint8_t pipeId, struct UsbFnPipeInfo *info); 74094332d3Sopenharmony_ciint32_t OpenEp0AndMapAddr(struct UsbFnFuncMgr *funcMgr); 75094332d3Sopenharmony_ci#endif /* USBFN_IO_MGR_H */ 76094332d3Sopenharmony_ci 77