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