]>
Commit | Line | Data |
---|---|---|
e237e7ae | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2007, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | UsbDesc.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Manage Usb Descriptor List\r | |
19 | \r | |
20 | Revision History\r | |
21 | \r | |
22 | \r | |
23 | **/\r | |
24 | \r | |
25 | #ifndef _USB_DESCRIPTOR_H_\r | |
26 | #define _USB_DESCRIPTOR_H_\r | |
27 | \r | |
28 | enum {\r | |
c52fa98c | 29 | USB_MAX_INTERFACE_SETTING = 8\r |
e237e7ae | 30 | };\r |
31 | \r | |
32 | //\r | |
33 | // The RequestType in EFI_USB_DEVICE_REQUEST is composed of\r | |
34 | // three fields: One bit direction, 2 bit type, and 5 bit\r | |
35 | // target.\r | |
36 | //\r | |
37 | #define USB_REQUEST_TYPE(Dir, Type, Target) \\r | |
38 | ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target)))\r | |
39 | \r | |
40 | //\r | |
41 | // A common header for usb standard descriptor.\r | |
42 | // Each stand descriptor has a length and type.\r | |
43 | //\r | |
44 | #pragma pack(1)\r | |
45 | typedef struct {\r | |
46 | UINT8 Len;\r | |
47 | UINT8 Type;\r | |
48 | } USB_DESC_HEAD;\r | |
49 | #pragma pack()\r | |
50 | \r | |
51 | \r | |
52 | //\r | |
53 | // Each USB device has a device descriptor. Each device may\r | |
54 | // have several configures. Each configure contains several\r | |
55 | // interfaces. Each interface may have several settings. Each\r | |
56 | // setting has several endpoints.\r | |
57 | //\r | |
58 | // EFI_USB_..._DESCRIPTOR must be the first member of the\r | |
59 | // structure.\r | |
60 | //\r | |
61 | typedef struct {\r | |
62 | EFI_USB_ENDPOINT_DESCRIPTOR Desc;\r | |
63 | UINT8 Toggle;\r | |
64 | } USB_ENDPOINT_DESC;\r | |
65 | \r | |
66 | typedef struct {\r | |
67 | EFI_USB_INTERFACE_DESCRIPTOR Desc;\r | |
68 | USB_ENDPOINT_DESC **Endpoints;\r | |
69 | } USB_INTERFACE_SETTING;\r | |
70 | \r | |
71 | //\r | |
72 | // An interface may have several settings. Use a\r | |
73 | // fixed max number of settings to simplify code.\r | |
74 | // It should sufice in most environments.\r | |
75 | //\r | |
76 | typedef struct {\r | |
77 | USB_INTERFACE_SETTING* Settings[USB_MAX_INTERFACE_SETTING];\r | |
78 | UINTN NumOfSetting;\r | |
79 | UINT8 ActiveIndex; // Index of active setting\r | |
80 | } USB_INTERFACE_DESC;\r | |
81 | \r | |
82 | typedef struct {\r | |
83 | EFI_USB_CONFIG_DESCRIPTOR Desc;\r | |
84 | USB_INTERFACE_DESC **Interfaces;\r | |
85 | } USB_CONFIG_DESC;\r | |
86 | \r | |
87 | typedef struct {\r | |
88 | EFI_USB_DEVICE_DESCRIPTOR Desc;\r | |
89 | USB_CONFIG_DESC **Configs;\r | |
90 | } USB_DEVICE_DESC;\r | |
91 | \r | |
92 | EFI_STATUS\r | |
93 | UsbCtrlRequest (\r | |
94 | IN USB_DEVICE *UsbDev,\r | |
95 | IN EFI_USB_DATA_DIRECTION Direction,\r | |
96 | IN UINTN Type,\r | |
97 | IN UINTN Target,\r | |
98 | IN UINTN Request,\r | |
99 | IN UINT16 Value,\r | |
100 | IN UINT16 Index,\r | |
101 | IN OUT VOID *Buf,\r | |
102 | IN UINTN Length\r | |
103 | );\r | |
104 | \r | |
105 | EFI_STATUS\r | |
106 | UsbGetMaxPacketSize0 (\r | |
107 | IN USB_DEVICE *UsbDev\r | |
108 | );\r | |
109 | \r | |
110 | VOID\r | |
111 | UsbFreeDevDesc (\r | |
112 | IN USB_DEVICE_DESC *DevDesc\r | |
113 | );\r | |
114 | \r | |
115 | EFI_USB_STRING_DESCRIPTOR*\r | |
116 | UsbGetOneString (\r | |
117 | IN USB_DEVICE *UsbDev,\r | |
118 | IN UINT8 StringIndex,\r | |
119 | IN UINT16 LangId\r | |
120 | );\r | |
121 | \r | |
122 | EFI_STATUS\r | |
123 | UsbBuildDescTable (\r | |
124 | IN USB_DEVICE *UsbDev\r | |
125 | );\r | |
126 | \r | |
127 | EFI_STATUS\r | |
128 | UsbSetAddress (\r | |
129 | IN USB_DEVICE *UsbDev,\r | |
130 | IN UINT8 Address\r | |
131 | );\r | |
132 | \r | |
133 | EFI_STATUS\r | |
134 | UsbSetConfig (\r | |
135 | IN USB_DEVICE *UsbDev,\r | |
136 | IN UINT8 ConfigIndex\r | |
137 | );\r | |
138 | \r | |
139 | EFI_STATUS\r | |
140 | UsbIoClearFeature (\r | |
141 | IN EFI_USB_IO_PROTOCOL *UsbIo,\r | |
142 | IN UINTN Target,\r | |
143 | IN UINT16 Feature,\r | |
144 | IN UINT16 Index\r | |
145 | );\r | |
146 | #endif\r |