1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #ifndef USB_DDK_PNP_LOADER_H
10 #define USB_DDK_PNP_LOADER_H
11 
12 #include "hdf_dlist.h"
13 #include "hdf_sbuf.h"
14 #include "hdf_usb_pnp_manage.h"
15 
16 typedef enum { USB_PNP_NORMAL_STATUS, USB_PNP_ADD_STATUS, USB_PNP_REMOVE_STATUS } UsbPnpDriverStatus;
17 
18 struct UsbPnpMatchIdTable {
19     const char *moduleName;
20     const char *serviceName;
21     const char *deviceMatchAttr;
22 
23     int32_t interfaceClassLength;
24     uint32_t interfaceClassMask;
25     int32_t interfaceSubClassLength;
26     uint32_t interfaceSubClassMask;
27     int32_t interfaceProtocolLength;
28     uint32_t interfaceProtocolMask;
29     int32_t interfaceLength;
30     uint32_t interfaceMask;
31 
32     uint8_t pnpMatchFlag;
33 
34     uint8_t length;
35 
36     uint16_t matchFlag;
37 
38     uint16_t vendorId;
39     uint16_t productId;
40 
41     uint16_t bcdDeviceLow;
42     uint16_t bcdDeviceHigh;
43 
44     uint8_t deviceClass;
45     uint8_t deviceSubClass;
46     uint8_t deviceProtocol;
47 
48     uint8_t interfaceClass[USB_PNP_INFO_MAX_INTERFACES];
49     uint8_t interfaceSubClass[USB_PNP_INFO_MAX_INTERFACES];
50     uint8_t interfaceProtocol[USB_PNP_INFO_MAX_INTERFACES];
51 
52     uint8_t interfaceNumber[USB_PNP_INFO_MAX_INTERFACES];
53 };
54 
55 struct UsbPnpDeviceListTable {
56     struct DListHead list;
57     const char *moduleName;
58     const char *serviceName;
59     const char *deviceMatchAttr;
60     UsbPnpDriverStatus status;
61     uint64_t usbDevAddr;
62     int32_t devNum;
63     int32_t busNum;
64     int32_t interfaceLength;
65     uint8_t interfaceNumber[USB_PNP_INFO_MAX_INTERFACES];
66 };
67 
68 struct UsbPnpRemoveInfo {
69     uint8_t removeType;
70     uint64_t usbDevAddr;
71     int32_t devNum;
72     int32_t busNum;
73     uint8_t interfaceNum;
74 };
75 
76 int32_t UsbDdkPnpLoaderEventReceived(void *usbPnpManagerPtr, uint32_t id, struct HdfSBuf *data);
77 int32_t UsbDdkPnpLoaderEventHandle(void);
78 
79 #endif /* USB_DDK_PNP_LOADER_H */
80