]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbDesc.h
1. Sync the latest network stack. Add NetLibCreateIPv4DPathNode () in netlib library.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbDesc.h
CommitLineData
e237e7ae 1/** @file\r
2\r
3Copyright (c) 2007, 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 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
28enum {\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
45typedef 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
61typedef struct {\r
62 EFI_USB_ENDPOINT_DESCRIPTOR Desc;\r
63 UINT8 Toggle;\r
64} USB_ENDPOINT_DESC;\r
65\r
66typedef 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
76typedef 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
82typedef struct {\r
83 EFI_USB_CONFIG_DESCRIPTOR Desc;\r
84 USB_INTERFACE_DESC **Interfaces;\r
85} USB_CONFIG_DESC;\r
86\r
87typedef struct {\r
88 EFI_USB_DEVICE_DESCRIPTOR Desc;\r
89 USB_CONFIG_DESC **Configs;\r
90} USB_DEVICE_DESC;\r
91\r
92EFI_STATUS\r
93UsbCtrlRequest (\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
105EFI_STATUS\r
106UsbGetMaxPacketSize0 (\r
107 IN USB_DEVICE *UsbDev\r
108 );\r
109\r
110VOID\r
111UsbFreeDevDesc (\r
112 IN USB_DEVICE_DESC *DevDesc\r
113 );\r
114\r
115EFI_USB_STRING_DESCRIPTOR*\r
116UsbGetOneString (\r
117 IN USB_DEVICE *UsbDev,\r
118 IN UINT8 StringIndex,\r
119 IN UINT16 LangId\r
120 );\r
121\r
122EFI_STATUS\r
123UsbBuildDescTable (\r
124 IN USB_DEVICE *UsbDev\r
125 );\r
126\r
127EFI_STATUS\r
128UsbSetAddress (\r
129 IN USB_DEVICE *UsbDev,\r
130 IN UINT8 Address\r
131 );\r
132\r
133EFI_STATUS\r
134UsbSetConfig (\r
135 IN USB_DEVICE *UsbDev,\r
136 IN UINT8 ConfigIndex\r
137 );\r
138\r
139EFI_STATUS\r
140UsbIoClearFeature (\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