41 IN OUT VOID *Data OPTIONAL,
47 UINT32 TransferResult;
51 PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
53 EndpointDescriptor =
NULL;
56 if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
57 (Request->RequestType == USB_DEV_CLEAR_FEATURE_REQ_TYPE_E) &&
58 (Request->Value == USB_FEATURE_ENDPOINT_HALT))
63 while (EndpointIndex < MAX_ENDPOINT) {
65 if (EFI_ERROR (Status)) {
66 return EFI_INVALID_PARAMETER;
69 if (EndpointDescriptor->EndpointAddress == Request->Index) {
76 if (EndpointIndex == MAX_ENDPOINT) {
77 return EFI_INVALID_PARAMETER;
81 if (PeiUsbDev->Usb2HcPpi !=
NULL) {
82 Status = PeiUsbDev->Usb2HcPpi->ControlTransfer (
85 PeiUsbDev->DeviceAddress,
86 PeiUsbDev->DeviceSpeed,
87 PeiUsbDev->MaxPacketSize0,
93 &(PeiUsbDev->Translator),
97 Status = PeiUsbDev->UsbHcPpi->ControlTransfer (
100 PeiUsbDev->DeviceAddress,
101 PeiUsbDev->DeviceSpeed,
102 (UINT8)PeiUsbDev->MaxPacketSize0,
115 if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
116 (Request->RequestType == USB_DEV_CLEAR_FEATURE_REQ_TYPE_E) &&
117 (Request->Value == USB_FEATURE_ENDPOINT_HALT))
119 if ((PeiUsbDev->DataToggle & (1 << EndpointIndex)) != 0) {
120 PeiUsbDev->DataToggle = (UINT16)(PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
124 DEBUG ((DEBUG_INFO,
"PeiUsbControlTransfer: %r\n", Status));
154 IN UINT8 DeviceEndpoint,
162 UINT32 TransferResult;
163 UINTN MaxPacketLength;
168 VOID *Data2[EFI_USB_MAX_BULK_BUFFER_NUM];
170 PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
172 EndpointDescriptor =
NULL;
177 while (EndpointIndex < MAX_ENDPOINT) {
179 if (EFI_ERROR (Status)) {
180 return EFI_INVALID_PARAMETER;
183 if (EndpointDescriptor->EndpointAddress == DeviceEndpoint) {
190 if (EndpointIndex == MAX_ENDPOINT) {
191 return EFI_INVALID_PARAMETER;
194 MaxPacketLength = PeiUsbDev->EndpointDesc[EndpointIndex]->MaxPacketSize;
195 if ((PeiUsbDev->DataToggle & (1 << EndpointIndex)) != 0) {
201 OldToggle = DataToggle;
203 if (PeiUsbDev->Usb2HcPpi !=
NULL) {
204 Status = PeiUsbDev->Usb2HcPpi->BulkTransfer (
206 PeiUsbDev->Usb2HcPpi,
207 PeiUsbDev->DeviceAddress,
209 PeiUsbDev->DeviceSpeed,
215 &(PeiUsbDev->Translator),
219 Status = PeiUsbDev->UsbHcPpi->BulkTransfer (
222 PeiUsbDev->DeviceAddress,
224 (UINT8)MaxPacketLength,
233 if (OldToggle != DataToggle) {
234 PeiUsbDev->DataToggle = (UINT16)(PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
237 DEBUG ((DEBUG_INFO,
"PeiUsbBulkTransfer: %r\n", Status));
262 PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
263 *InterfaceDescriptor = PeiUsbDev->InterfaceDesc;
284 IN UINT8 EndpointIndex,
290 PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
292 ASSERT (EndpointDescriptor !=
NULL);
299 ASSERT (EndpointIndex <= 15);
301 if (EndpointIndex >= PeiUsbDev->InterfaceDesc->NumEndpoints) {
302 return EFI_NOT_FOUND;
305 *EndpointDescriptor = PeiUsbDev->EndpointDesc[EndpointIndex];
331 PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
336 PeiUsbDev->Usb2HcPpi,
337 PeiUsbDev->DeviceAddress,
344 Address = PeiUsbDev->DeviceAddress;
345 PeiUsbDev->DeviceAddress = 0;
353 if (EFI_ERROR (Status)) {
357 PeiUsbDev->DeviceAddress = Address;
#define DEBUG(Expression)
EFI_STATUS PeiUsbSetDeviceAddress(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *UsbIoPpi, IN UINT16 AddressValue)
EFI_STATUS PeiUsbSetConfiguration(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *UsbIoPpi)
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)
EFI_STATUS EFIAPI PeiUsbGetInterfaceDescriptor(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This, OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor)
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)
EFI_STATUS EFIAPI PeiUsbGetEndpointDescriptor(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This, IN UINT8 EndpointIndex, OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor)
EFI_STATUS EFIAPI PeiUsbPortReset(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB_IO_PPI *This)
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)