]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/UsbLib.h
Updated bootscript to remove conflicts from R8.x
[mirror_edk2.git] / MdePkg / Include / Library / UsbLib.h
CommitLineData
fb3df220 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12 Module Name:\r
13\r
14 UsbDxeLib.h\r
15\r
16 Abstract:\r
17\r
18 Common Dxe Libarary for USB\r
19 Add Constants & structure definitions for Usb HID\r
20\r
21 Revision History\r
22\r
23--*/\r
24\r
25#ifndef _USB_DXE_LIB_H\r
26#define _USB_DXE_LIB_H\r
27\r
c7d265a9 28#include <Protocol/UsbIo.h>\r
fb3df220 29//\r
30// define the timeout time as 3ms\r
31//\r
32#define TIMEOUT_VALUE 3 * 1000\r
33\r
34//\r
35// HID constants definition, see HID rev1.0\r
36//\r
37//\r
38// HID report item format\r
39//\r
40#define HID_ITEM_FORMAT_SHORT 0\r
41#define HID_ITEM_FORMAT_LONG 1\r
42\r
43//\r
44// Special tag indicating long items\r
45//\r
46#define HID_ITEM_TAG_LONG 15\r
47\r
48//\r
49// HID report descriptor item type (prefix bit 2,3)\r
50//\r
51#define HID_ITEM_TYPE_MAIN 0\r
52#define HID_ITEM_TYPE_GLOBAL 1\r
53#define HID_ITEM_TYPE_LOCAL 2\r
54#define HID_ITEM_TYPE_RESERVED 3\r
55\r
56//\r
57// HID report descriptor main item tags\r
58//\r
59#define HID_MAIN_ITEM_TAG_INPUT 8\r
60#define HID_MAIN_ITEM_TAG_OUTPUT 9\r
61#define HID_MAIN_ITEM_TAG_FEATURE 11\r
62#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10\r
63#define HID_MAIN_ITEM_TAG_END_COLLECTION 12\r
64\r
65//\r
66// HID report descriptor main item contents\r
67//\r
68#define HID_MAIN_ITEM_CONSTANT 0x001\r
69#define HID_MAIN_ITEM_VARIABLE 0x002\r
70#define HID_MAIN_ITEM_RELATIVE 0x004\r
71#define HID_MAIN_ITEM_WRAP 0x008\r
72#define HID_MAIN_ITEM_NONLINEAR 0x010\r
73#define HID_MAIN_ITEM_NO_PREFERRED 0x020\r
74#define HID_MAIN_ITEM_NULL_STATE 0x040\r
75#define HID_MAIN_ITEM_VOLATILE 0x080\r
76#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100\r
77\r
78//\r
79// HID report descriptor collection item types\r
80//\r
81#define HID_COLLECTION_PHYSICAL 0\r
82#define HID_COLLECTION_APPLICATION 1\r
83#define HID_COLLECTION_LOGICAL 2\r
84\r
85//\r
86// HID report descriptor global item tags\r
87//\r
88#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0\r
89#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1\r
90#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2\r
91#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3\r
92#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4\r
93#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5\r
94#define HID_GLOBAL_ITEM_TAG_UNIT 6\r
95#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7\r
96#define HID_GLOBAL_ITEM_TAG_REPORT_ID 8\r
97#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9\r
98#define HID_GLOBAL_ITEM_TAG_PUSH 10\r
99#define HID_GLOBAL_ITEM_TAG_POP 11\r
100\r
101//\r
102// HID report descriptor local item tags\r
103//\r
104#define HID_LOCAL_ITEM_TAG_USAGE 0\r
105#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1\r
106#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2\r
107#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3\r
108#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4\r
109#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5\r
110#define HID_LOCAL_ITEM_TAG_STRING_INDEX 7\r
111#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8\r
112#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9\r
113#define HID_LOCAL_ITEM_TAG_DELIMITER 10\r
114\r
115//\r
116// HID usage tables\r
117//\r
118#define HID_USAGE_PAGE 0xffff0000\r
119\r
120#define HID_UP_GENDESK 0x00010000\r
121#define HID_UP_KEYBOARD 0x00070000\r
122#define HID_UP_LED 0x00080000\r
123#define HID_UP_BUTTON 0x00090000\r
124#define HID_UP_CONSUMER 0x000c0000\r
125#define HID_UP_DIGITIZER 0x000d0000\r
126#define HID_UP_PID 0x000f0000\r
127\r
128#define HID_USAGE 0x0000ffff\r
129\r
130#define HID_GD_POINTER 0x00010001\r
131#define HID_GD_MOUSE 0x00010002\r
132#define HID_GD_JOYSTICK 0x00010004\r
133#define HID_GD_GAMEPAD 0x00010005\r
134#define HID_GD_HATSWITCH 0x00010039\r
135\r
136//\r
137// HID report types\r
138//\r
139#define HID_INPUT_REPORT 1\r
140#define HID_OUTPUT_REPORT 2\r
141#define HID_FEATURE_REPORT 3\r
142\r
143//\r
144// HID device quirks.\r
145//\r
146#define HID_QUIRK_INVERT 0x01\r
147#define HID_QUIRK_NOTOUCH 0x02\r
148\r
149//\r
150// HID class protocol request\r
151//\r
152#define EFI_USB_GET_REPORT_REQUEST 0x01\r
153#define EFI_USB_GET_IDLE_REQUEST 0x02\r
154#define EFI_USB_GET_PROTOCOL_REQUEST 0x03\r
155#define EFI_USB_SET_REPORT_REQUEST 0x09\r
156#define EFI_USB_SET_IDLE_REQUEST 0x0a\r
157#define EFI_USB_SET_PROTOCOL_REQUEST 0x0b\r
158\r
159#pragma pack(1)\r
160//\r
161// Descriptor header for Report/Physical Descriptors\r
162//\r
163typedef struct hid_class_descriptor {\r
164 UINT8 DescriptorType;\r
165 UINT16 DescriptorLength;\r
166} EFI_USB_HID_CLASS_DESCRIPTOR;\r
167\r
168typedef struct hid_descriptor {\r
169 UINT8 Length;\r
170 UINT8 DescriptorType;\r
171 UINT16 BcdHID;\r
172 UINT8 CountryCode;\r
173 UINT8 NumDescriptors;\r
174 EFI_USB_HID_CLASS_DESCRIPTOR HidClassDesc[1];\r
175} EFI_USB_HID_DESCRIPTOR;\r
176\r
177#pragma pack()\r
178\r
179EFI_STATUS\r
180UsbGetHidDescriptor (\r
181 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
182 IN UINT8 InterfaceNum,\r
183 OUT EFI_USB_HID_DESCRIPTOR *HidDescriptor\r
184 );\r
185\r
186EFI_STATUS\r
187UsbGetReportDescriptor (\r
188 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
189 IN UINT8 InterfaceNum,\r
190 IN UINT16 DescriptorSize,\r
191 OUT UINT8 *DescriptorBuffer\r
192 );\r
193\r
194EFI_STATUS\r
195UsbGetProtocolRequest (\r
196 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
197 IN UINT8 Interface,\r
198 IN UINT8 *Protocol\r
199 );\r
200\r
201EFI_STATUS\r
202UsbSetProtocolRequest (\r
203 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
204 IN UINT8 Interface,\r
205 IN UINT8 Protocol\r
206 );\r
207\r
208EFI_STATUS\r
209UsbSetIdleRequest (\r
210 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
211 IN UINT8 Interface,\r
212 IN UINT8 ReportId,\r
213 IN UINT8 Duration\r
214 );\r
215\r
216EFI_STATUS\r
217UsbGetIdleRequest (\r
218 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
219 IN UINT8 Interface,\r
220 IN UINT8 ReportId,\r
221 OUT UINT8 *Duration\r
222 );\r
223\r
224EFI_STATUS\r
225UsbSetReportRequest (\r
226 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
227 IN UINT8 Interface,\r
228 IN UINT8 ReportId,\r
229 IN UINT8 ReportType,\r
230 IN UINT16 ReportLen,\r
231 IN UINT8 *Report\r
232 );\r
233\r
234EFI_STATUS\r
235UsbGetReportRequest (\r
236 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
237 IN UINT8 Interface,\r
238 IN UINT8 ReportId,\r
239 IN UINT8 ReportType,\r
240 IN UINT16 ReportLen,\r
241 IN UINT8 *Report\r
242 );\r
243\r
244//\r
245// Get Device Descriptor\r
246//\r
247EFI_STATUS\r
248UsbGetDescriptor (\r
249 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
250 IN UINT16 Value,\r
251 IN UINT16 Index,\r
252 IN UINT16 DescriptorLength,\r
253 OUT VOID *Descriptor,\r
254 OUT UINT32 *Status\r
255 );\r
256\r
257//\r
258// Set Device Descriptor\r
259//\r
260EFI_STATUS\r
261UsbSetDescriptor (\r
262 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
263 IN UINT16 Value,\r
264 IN UINT16 Index,\r
265 IN UINT16 DescriptorLength,\r
266 IN VOID *Descriptor,\r
267 OUT UINT32 *Status\r
268 );\r
269\r
270//\r
271// Get device Interface\r
272//\r
273EFI_STATUS\r
274UsbGetDeviceInterface (\r
275 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
276 IN UINT16 Index,\r
277 OUT UINT8 *AltSetting,\r
278 OUT UINT32 *Status\r
279 );\r
280\r
281//\r
282// Set device interface\r
283//\r
284EFI_STATUS\r
285UsbSetDeviceInterface (\r
286 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
287 IN UINT16 InterfaceNo,\r
288 IN UINT16 AltSetting,\r
289 OUT UINT32 *Status\r
290 );\r
291\r
292//\r
293// Get device configuration\r
294//\r
295EFI_STATUS\r
296UsbGetDeviceConfiguration (\r
297 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
298 OUT UINT8 *ConfigValue,\r
299 OUT UINT32 *Status\r
300 );\r
301\r
302//\r
303// Set device configuration\r
304//\r
305EFI_STATUS\r
306UsbSetDeviceConfiguration (\r
307 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
308 IN UINT16 Value,\r
309 OUT UINT32 *Status\r
310 );\r
311\r
312//\r
313// Set Device Feature\r
314//\r
315EFI_STATUS\r
316UsbSetDeviceFeature (\r
317 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
318 IN EFI_USB_RECIPIENT Recipient,\r
319 IN UINT16 Value,\r
320 IN UINT16 Target,\r
321 OUT UINT32 *Status\r
322 );\r
323\r
324//\r
325// Clear Device Feature\r
326//\r
327EFI_STATUS\r
328UsbClearDeviceFeature (\r
329 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
330 IN EFI_USB_RECIPIENT Recipient,\r
331 IN UINT16 Value,\r
332 IN UINT16 Target,\r
333 OUT UINT32 *Status\r
334 );\r
335\r
336//\r
337// Get Device Status\r
338//\r
339EFI_STATUS\r
340UsbGetDeviceStatus (\r
341 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
342 IN EFI_USB_RECIPIENT Recipient,\r
343 IN UINT16 Target,\r
344 OUT UINT16 *DevStatus,\r
345 OUT UINT32 *Status\r
346 );\r
347\r
348//\r
349// The following APIs are not basic library, but they are common used.\r
350//\r
351//\r
352// Usb Get String\r
353//\r
354EFI_STATUS\r
355UsbGetString (\r
356 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
357 IN UINT16 LangID,\r
358 IN UINT8 Index,\r
359 IN VOID *Buf,\r
360 IN UINTN BufSize,\r
361 OUT UINT32 *Status\r
362 );\r
363\r
364//\r
365// Clear endpoint stall\r
366//\r
367EFI_STATUS\r
368UsbClearEndpointHalt (\r
369 IN EFI_USB_IO_PROTOCOL *UsbIo,\r
370 IN UINT8 EndpointNo,\r
371 OUT UINT32 *Status\r
372 );\r
373\r
374#endif\r