4 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
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
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.
17 #ifndef _PEI_USB_PEIM_H_
18 #define _PEI_USB_PEIM_H_
23 #include <Ppi/UsbIo.h>
24 #include <Ppi/UsbHostController.h>
25 #include <Ppi/BlockIo.h>
27 #include <Library/DebugLib.h>
28 #include <Library/BaseMemoryLib.h>
29 #include <Library/PcdLib.h>
31 #include <IndustryStandard/Usb.h>
33 #define MAX_ROOT_PORT 2
34 #define MAX_ENDPOINT 16
36 #define USB_SLOW_SPEED_DEVICE 0x01
37 #define USB_FULL_SPEED_DEVICE 0x02
39 #define PEI_USB_DEVICE_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'D')
42 PEI_USB_IO_PPI UsbIoPpi
;
43 EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList
;
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
];
59 #define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)
63 Submits control transfer to a target USB device.
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.
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.
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
,
88 IN OUT VOID
*Data
, OPTIONAL
89 IN UINTN DataLength OPTIONAL
93 Submits bulk transfer to a bulk endpoint of a USB device.
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
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.
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.
114 IN EFI_PEI_SERVICES
**PeiServices
,
115 IN PEI_USB_IO_PPI
*This
,
116 IN UINT8 DeviceEndpoint
,
118 IN OUT UINTN
*DataLength
,
123 Get the usb interface descriptor.
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.
130 @retval EFI_SUCCESS Usb interface descriptor is obtained successfully.
135 PeiUsbGetInterfaceDescriptor (
136 IN EFI_PEI_SERVICES
**PeiServices
,
137 IN PEI_USB_IO_PPI
*This
,
138 OUT EFI_USB_INTERFACE_DESCRIPTOR
**InterfaceDescriptor
142 Get the usb endpoint descriptor.
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.
149 @retval EFI_SUCCESS Usb endpoint descriptor is obtained successfully.
150 @retval EFI_NOT_FOUND Usb endpoint descriptor is NOT found.
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
163 Reset the port and re-configure the usb device.
165 @param PeiServices General-purpose services that are available to every PEIM.
166 @param This Indicates the PEI_USB_IO_PPI instance.
168 @retval EFI_SUCCESS Usb device is reset and configured successfully.
169 @retval Others Other failure occurs.
175 IN EFI_PEI_SERVICES
**PeiServices
,
176 IN PEI_USB_IO_PPI
*This