]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h
MdeModulePkg: Add PEI USB drivers and related PPIs
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBotPei / UsbPeim.h
1 /** @file
2 Usb Peim definition.
3
4 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef _PEI_USB_PEIM_H_
18 #define _PEI_USB_PEIM_H_
19
20
21 #include <PiPei.h>
22
23 #include <Ppi/UsbIo.h>
24 #include <Ppi/UsbHostController.h>
25 #include <Ppi/BlockIo.h>
26
27 #include <Library/DebugLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/PcdLib.h>
30
31 #include <IndustryStandard/Usb.h>
32
33 #define MAX_ROOT_PORT 2
34 #define MAX_ENDPOINT 16
35
36 #define USB_SLOW_SPEED_DEVICE 0x01
37 #define USB_FULL_SPEED_DEVICE 0x02
38
39 #define PEI_USB_DEVICE_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'D')
40 typedef struct {
41 UINTN Signature;
42 PEI_USB_IO_PPI UsbIoPpi;
43 EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList;
44 UINT8 DeviceAddress;
45 UINT8 MaxPacketSize0;
46 UINT8 DeviceSpeed;
47 UINT8 DataToggle;
48 UINT8 IsHub;
49 UINT8 DownStreamPortNo;
50 UINT8 Reserved[2]; // Padding for IPF
51 UINTN AllocateAddress;
52 PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
53 UINT8 ConfigurationData[1024];
54 EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
55 EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
56 EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc[MAX_ENDPOINT];
57 } PEI_USB_DEVICE;
58
59 #define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)
60
61
62 /**
63 Submits control transfer to a target USB device.
64
65 @param PeiServices The pointer of EFI_PEI_SERVICES.
66 @param This The pointer of PEI_USB_IO_PPI.
67 @param Request USB device request to send.
68 @param Direction Specifies the data direction for the data stage.
69 @param Timeout Indicates the maximum timeout, in millisecond.
70 @param Data Data buffer to be transmitted or received from USB device.
71 @param DataLength The size (in bytes) of the data buffer.
72
73 @retval EFI_SUCCESS Transfer was completed successfully.
74 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.
75 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
76 @retval EFI_TIMEOUT Transfer failed due to timeout.
77 @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.
78
79 **/
80 EFI_STATUS
81 EFIAPI
82 PeiUsbControlTransfer (
83 IN EFI_PEI_SERVICES **PeiServices,
84 IN PEI_USB_IO_PPI *This,
85 IN EFI_USB_DEVICE_REQUEST *Request,
86 IN EFI_USB_DATA_DIRECTION Direction,
87 IN UINT32 Timeout,
88 IN OUT VOID *Data, OPTIONAL
89 IN UINTN DataLength OPTIONAL
90 );
91
92 /**
93 Submits bulk transfer to a bulk endpoint of a USB device.
94
95 @param PeiServices The pointer of EFI_PEI_SERVICES.
96 @param This The pointer of PEI_USB_IO_PPI.
97 @param DeviceEndpoint Endpoint number and its direction in bit 7.
98 @param Data A pointer to the buffer of data to transmit
99 from or receive into.
100 @param DataLength The lenght of the data buffer.
101 @param Timeout Indicates the maximum time, in millisecond, which the
102 transfer is allowed to complete.
103
104 @retval EFI_SUCCESS The transfer was completed successfully.
105 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.
106 @retval EFI_INVALID_PARAMETER Parameters are invalid.
107 @retval EFI_TIMEOUT The transfer failed due to timeout.
108 @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.
109
110 **/
111 EFI_STATUS
112 EFIAPI
113 PeiUsbBulkTransfer (
114 IN EFI_PEI_SERVICES **PeiServices,
115 IN PEI_USB_IO_PPI *This,
116 IN UINT8 DeviceEndpoint,
117 IN OUT VOID *Data,
118 IN OUT UINTN *DataLength,
119 IN UINTN Timeout
120 );
121
122 /**
123 Get the usb interface descriptor.
124
125 @param PeiServices General-purpose services that are available to every PEIM.
126 @param This Indicates the PEI_USB_IO_PPI instance.
127 @param InterfaceDescriptor Request interface descriptor.
128
129
130 @retval EFI_SUCCESS Usb interface descriptor is obtained successfully.
131
132 **/
133 EFI_STATUS
134 EFIAPI
135 PeiUsbGetInterfaceDescriptor (
136 IN EFI_PEI_SERVICES **PeiServices,
137 IN PEI_USB_IO_PPI *This,
138 OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor
139 );
140
141 /**
142 Get the usb endpoint descriptor.
143
144 @param PeiServices General-purpose services that are available to every PEIM.
145 @param This Indicates the PEI_USB_IO_PPI instance.
146 @param EndpointIndex The valid index of the specified endpoint.
147 @param EndpointDescriptor Request endpoint descriptor.
148
149 @retval EFI_SUCCESS Usb endpoint descriptor is obtained successfully.
150 @retval EFI_NOT_FOUND Usb endpoint descriptor is NOT found.
151
152 **/
153 EFI_STATUS
154 EFIAPI
155 PeiUsbGetEndpointDescriptor (
156 IN EFI_PEI_SERVICES **PeiServices,
157 IN PEI_USB_IO_PPI *This,
158 IN UINT8 EndpointIndex,
159 OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor
160 );
161
162 /**
163 Reset the port and re-configure the usb device.
164
165 @param PeiServices General-purpose services that are available to every PEIM.
166 @param This Indicates the PEI_USB_IO_PPI instance.
167
168 @retval EFI_SUCCESS Usb device is reset and configured successfully.
169 @retval Others Other failure occurs.
170
171 **/
172 EFI_STATUS
173 EFIAPI
174 PeiUsbPortReset (
175 IN EFI_PEI_SERVICES **PeiServices,
176 IN PEI_USB_IO_PPI *This
177 );
178
179 #endif