TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbPeim.h
Go to the documentation of this file.
1
10#ifndef _PEI_USB_PEIM_H_
11#define _PEI_USB_PEIM_H_
12
13#include <PiPei.h>
14
17#include <Ppi/UsbIo.h>
18
19#include <Library/DebugLib.h>
23#include <Library/TimerLib.h>
24#include <Library/PcdLib.h>
25
27
28//
29// A common header for usb standard descriptor.
30// Each stand descriptor has a length and type.
31//
32#pragma pack(1)
33typedef struct {
34 UINT8 Len;
35 UINT8 Type;
37#pragma pack()
38
39#define MAX_INTERFACE 8
40#define MAX_ENDPOINT 16
41
42#define PEI_USB_DEVICE_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'D')
43typedef struct {
44 UINTN Signature;
45 PEI_USB_IO_PPI UsbIoPpi;
46 EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList;
47 UINT16 MaxPacketSize0;
48 UINT16 DataToggle;
49 UINT8 DeviceAddress;
50 UINT8 DeviceSpeed;
51 UINT8 IsHub;
52 UINT8 DownStreamPortNo;
56 UINT8 ConfigurationData[1024];
57 EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
58 EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
59 EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDescList[MAX_INTERFACE];
60 EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc[MAX_ENDPOINT];
61 EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescList[MAX_INTERFACE][MAX_ENDPOINT];
63 UINT8 Tier;
65
66#define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)
67
68#define USB_BIT_IS_SET(Data, Bit) ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
69
70#define USB_BUS_1_MILLISECOND 1000
71
72//
73// Wait for port reset, refers to specification
74// [USB20-7.1.7.5, it says 10ms for hub and 50ms for
75// root hub]
76//
77// According to USB2.0, Chapter 11.5.1.5 Resetting,
78// the worst case for TDRST is 20ms
79//
80#define USB_SET_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND)
81#define USB_SET_ROOT_PORT_RESET_STALL (50 * USB_BUS_1_MILLISECOND)
82
83//
84// Wait for clear roothub port reset, set by experience
85//
86#define USB_CLR_ROOT_PORT_RESET_STALL (20 * USB_BUS_1_MILLISECOND)
87
88//
89// Wait for port statue reg change, set by experience
90//
91#define USB_WAIT_PORT_STS_CHANGE_STALL (100)
92
93//
94// Host software return timeout if port status doesn't change
95// after 500ms(LOOP * STALL = 5000 * 0.1ms), set by experience
96//
97#define USB_WAIT_PORT_STS_CHANGE_LOOP 5000
98
99//
100// Wait for hub port power-on, refers to specification
101// [USB20-11.23.2]
102//
103#define USB_SET_PORT_POWER_STALL (2 * USB_BUS_1_MILLISECOND)
104
105//
106// Wait for set device address, refers to specification
107// [USB20-9.2.6.3, it says 2ms]
108//
109#define USB_SET_DEVICE_ADDRESS_STALL (2 * USB_BUS_1_MILLISECOND)
110
111//
112// Wait for get configuration descriptor, set by experience
113//
114#define USB_GET_CONFIG_DESCRIPTOR_STALL (1 * USB_BUS_1_MILLISECOND)
115
137EFIAPI
139 IN EFI_PEI_SERVICES **PeiServices,
140 IN PEI_USB_IO_PPI *This,
141 IN EFI_USB_DEVICE_REQUEST *Request,
142 IN EFI_USB_DATA_DIRECTION Direction,
143 IN UINT32 Timeout,
144 IN OUT VOID *Data OPTIONAL,
145 IN UINTN DataLength OPTIONAL
146 );
147
170EFIAPI
172 IN EFI_PEI_SERVICES **PeiServices,
173 IN PEI_USB_IO_PPI *This,
174 IN UINT8 DeviceEndpoint,
175 IN OUT VOID *Data,
176 IN OUT UINTN *DataLength,
177 IN UINTN Timeout
178 );
179
192EFIAPI
194 IN EFI_PEI_SERVICES **PeiServices,
195 IN PEI_USB_IO_PPI *This,
196 OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor
197 );
198
212EFIAPI
214 IN EFI_PEI_SERVICES **PeiServices,
215 IN PEI_USB_IO_PPI *This,
216 IN UINT8 EndpointIndex,
217 OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor
218 );
219
231EFIAPI
233 IN EFI_PEI_SERVICES **PeiServices,
234 IN PEI_USB_IO_PPI *This
235 );
236
247VOID
249 IN EFI_PEI_SERVICES **PeiServices,
252 IN UINT8 PortNum,
253 IN UINT8 RetryIndex
254 );
255
256#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_USB_DATA_DIRECTION
Definition: UsbIo.h:44
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
@ AllocateAddress
Definition: UefiSpec.h:42
VOID ResetRootPort(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi, IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi, IN UINT8 PortNum, IN UINT8 RetryIndex)
Definition: UsbPeim.c:1033
EFI_STATUS EFIAPI PeiUsbBulkTransfer(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This, IN UINT8 DeviceEndpoint, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN Timeout)
Definition: UsbIoPeim.c:151
EFI_STATUS EFIAPI PeiUsbGetInterfaceDescriptor(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This, OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor)
Definition: UsbIoPeim.c:254
EFI_STATUS EFIAPI PeiUsbControlTransfer(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION Direction, IN UINT32 Timeout, IN OUT VOID *Data OPTIONAL, IN UINTN DataLength OPTIONAL)
Definition: UsbIoPeim.c:35
EFI_STATUS EFIAPI PeiUsbGetEndpointDescriptor(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This, IN UINT8 EndpointIndex, OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor)
Definition: UsbIoPeim.c:281
EFI_STATUS EFIAPI PeiUsbPortReset(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This)
Definition: UsbIoPeim.c:322