diff options
Diffstat (limited to 'MdeModulePkg/Bus/Usb')
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c | 36 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h | 149 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c | 64 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h | 21 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c | 45 | ||||
-rw-r--r-- | MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h | 6 |
6 files changed, 67 insertions, 254 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c index 2a8fde07ff..46c1a06444 100644 --- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c +++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c @@ -1,7 +1,7 @@ /** @file
Common Libarary for PEI USB.
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -215,15 +215,24 @@ PeiUsbClearEndpointHalt ( IN UINT8 EndpointAddress
)
{
- EFI_STATUS Status;
- PEI_USB_DEVICE *PeiUsbDev;
- EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
- UINT8 EndpointIndex;
+ EFI_STATUS Status;
+ EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
+ EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
+ UINT8 EndpointIndex;
- EndpointIndex = 0;
- PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (UsbIoPpi);
- while (EndpointIndex < MAX_ENDPOINT) {
+ //
+ // Check its interface
+ //
+ Status = UsbIoPpi->UsbGetInterfaceDescriptor (
+ PeiServices,
+ UsbIoPpi,
+ &InterfaceDesc
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ for (EndpointIndex = 0; EndpointIndex < InterfaceDesc->NumEndpoints; EndpointIndex++) {
Status = UsbIoPpi->UsbGetEndpointDescriptor (PeiServices, UsbIoPpi, EndpointIndex, &EndpointDescriptor);
if (EFI_ERROR (Status)) {
return EFI_INVALID_PARAMETER;
@@ -232,11 +241,9 @@ PeiUsbClearEndpointHalt ( if (EndpointDescriptor->EndpointAddress == EndpointAddress) {
break;
}
-
- EndpointIndex++;
}
- if (EndpointIndex == MAX_ENDPOINT) {
+ if (EndpointIndex == InterfaceDesc->NumEndpoints) {
return EFI_INVALID_PARAMETER;
}
@@ -248,13 +255,6 @@ PeiUsbClearEndpointHalt ( EndpointAddress
);
- //
- // set data toggle to zero.
- //
- if ((PeiUsbDev->DataToggle & (1 << EndpointIndex)) != 0) {
- PeiUsbDev->DataToggle = (UINT8) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
- }
-
return Status;
}
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h index 4f3f57f0bc..6dcd189f77 100644 --- a/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h +++ b/MdeModulePkg/Bus/Usb/UsbBotPei/UsbPeim.h @@ -1,7 +1,7 @@ /** @file
Usb Peim definition.
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -21,7 +21,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <PiPei.h>
#include <Ppi/UsbIo.h>
-#include <Ppi/UsbHostController.h>
#include <Ppi/BlockIo.h>
#include <Library/DebugLib.h>
@@ -30,150 +29,4 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <IndustryStandard/Usb.h>
-#define MAX_ROOT_PORT 2
-#define MAX_ENDPOINT 16
-
-#define USB_SLOW_SPEED_DEVICE 0x01
-#define USB_FULL_SPEED_DEVICE 0x02
-
-#define PEI_USB_DEVICE_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'D')
-typedef struct {
- UINTN Signature;
- PEI_USB_IO_PPI UsbIoPpi;
- EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList;
- UINT8 DeviceAddress;
- UINT8 MaxPacketSize0;
- UINT8 DeviceSpeed;
- UINT8 DataToggle;
- UINT8 IsHub;
- UINT8 DownStreamPortNo;
- UINT8 Reserved[2]; // Padding for IPF
- UINTN AllocateAddress;
- PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
- UINT8 ConfigurationData[1024];
- EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
- EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;
- EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc[MAX_ENDPOINT];
-} PEI_USB_DEVICE;
-
-#define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)
-
-
-/**
- Submits control transfer to a target USB device.
-
- @param PeiServices The pointer of EFI_PEI_SERVICES.
- @param This The pointer of PEI_USB_IO_PPI.
- @param Request USB device request to send.
- @param Direction Specifies the data direction for the data stage.
- @param Timeout Indicates the maximum timeout, in millisecond.
- @param Data Data buffer to be transmitted or received from USB device.
- @param DataLength The size (in bytes) of the data buffer.
-
- @retval EFI_SUCCESS Transfer was completed successfully.
- @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.
- @retval EFI_INVALID_PARAMETER Some parameters are invalid.
- @retval EFI_TIMEOUT Transfer failed due to timeout.
- @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.
-
-**/
-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
- );
-
-/**
- Submits bulk transfer to a bulk endpoint of a USB device.
-
- @param PeiServices The pointer of EFI_PEI_SERVICES.
- @param This The pointer of PEI_USB_IO_PPI.
- @param DeviceEndpoint Endpoint number and its direction in bit 7.
- @param Data A pointer to the buffer of data to transmit
- from or receive into.
- @param DataLength The lenght of the data buffer.
- @param Timeout Indicates the maximum time, in millisecond, which the
- transfer is allowed to complete.
-
- @retval EFI_SUCCESS The transfer was completed successfully.
- @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.
- @retval EFI_INVALID_PARAMETER Parameters are invalid.
- @retval EFI_TIMEOUT The transfer failed due to timeout.
- @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.
-
-**/
-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
- );
-
-/**
- Get the usb interface descriptor.
-
- @param PeiServices General-purpose services that are available to every PEIM.
- @param This Indicates the PEI_USB_IO_PPI instance.
- @param InterfaceDescriptor Request interface descriptor.
-
-
- @retval EFI_SUCCESS Usb interface descriptor is obtained successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-PeiUsbGetInterfaceDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor
- );
-
-/**
- Get the usb endpoint descriptor.
-
- @param PeiServices General-purpose services that are available to every PEIM.
- @param This Indicates the PEI_USB_IO_PPI instance.
- @param EndpointIndex The valid index of the specified endpoint.
- @param EndpointDescriptor Request endpoint descriptor.
-
- @retval EFI_SUCCESS Usb endpoint descriptor is obtained successfully.
- @retval EFI_NOT_FOUND Usb endpoint descriptor is NOT found.
-
-**/
-EFI_STATUS
-EFIAPI
-PeiUsbGetEndpointDescriptor (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This,
- IN UINT8 EndpointIndex,
- OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor
- );
-
-/**
- Reset the port and re-configure the usb device.
-
- @param PeiServices General-purpose services that are available to every PEIM.
- @param This Indicates the PEI_USB_IO_PPI instance.
-
- @retval EFI_SUCCESS Usb device is reset and configured successfully.
- @retval Others Other failure occurs.
-
-**/
-EFI_STATUS
-EFIAPI
-PeiUsbPortReset (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *This
- );
-
#endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c index 2ac8d7bae3..6fef61e565 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c +++ b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c @@ -1,7 +1,7 @@ /** @file
Common Libarary for PEI USB
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -197,68 +197,6 @@ PeiUsbSetConfiguration ( }
/**
- Clear Endpoint Halt.
-
- @param PeiServices General-purpose services that are available to every PEIM.
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
- @param EndpointAddress The endpoint address.
-
- @retval EFI_SUCCESS Endpoint halt is cleared successfully.
- @retval EFI_DEVICE_ERROR Cannot clear the endpoint halt status due to a hardware error.
- @retval Others Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbClearEndpointHalt (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 EndpointAddress
- )
-{
- EFI_STATUS Status;
- PEI_USB_DEVICE *PeiUsbDev;
- EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
- UINT8 EndpointIndex;
-
- EndpointIndex = 0;
- PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (UsbIoPpi);
-
- while (EndpointIndex < MAX_ENDPOINT) {
- Status = UsbIoPpi->UsbGetEndpointDescriptor (PeiServices, UsbIoPpi, EndpointIndex, &EndpointDescriptor);
- if (EFI_ERROR (Status)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (EndpointDescriptor->EndpointAddress == EndpointAddress) {
- break;
- }
-
- EndpointIndex++;
- }
-
- if (EndpointIndex == MAX_ENDPOINT) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = PeiUsbClearDeviceFeature (
- PeiServices,
- UsbIoPpi,
- EfiUsbEndpoint,
- EfiUsbEndpointHalt,
- EndpointAddress
- );
-
- //
- // set data toggle to zero.
- //
- if ((PeiUsbDev->DataToggle & (1 << EndpointIndex)) != 0) {
- PeiUsbDev->DataToggle = (UINT8) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
- }
-
- return Status;
-}
-
-/**
Judge if the port is connected with a usb device or not.
@param PortStatus The usb port status gotten.
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h index dd4ce1befc..e0557f8eea 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h +++ b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h @@ -1,7 +1,7 @@ /** @file
Common Libarary for PEI USB
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -188,25 +188,6 @@ PeiUsbSetConfiguration ( );
/**
- Clear Endpoint Halt.
-
- @param PeiServices General-purpose services that are available to every PEIM.
- @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
- @param EndpointAddress The endpoint address.
-
- @retval EFI_SUCCESS Endpoint halt is cleared successfully.
- @retval EFI_DEVICE_ERROR Cannot clear the endpoint halt status due to a hardware error.
- @retval Others Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbClearEndpointHalt (
- IN EFI_PEI_SERVICES **PeiServices,
- IN PEI_USB_IO_PPI *UsbIoPpi,
- IN UINT8 EndpointAddress
- );
-
-/**
Judge if the port is connected with a usb device or not.
@param PortStatus The usb port status gotten.
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c index e647cc46df..492f124296 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c +++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbIoPeim.c @@ -1,7 +1,7 @@ /** @file
The module is used to implement Usb Io PPI interfaces.
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -52,9 +52,38 @@ PeiUsbControlTransfer ( EFI_STATUS Status;
PEI_USB_DEVICE *PeiUsbDev;
UINT32 TransferResult;
+ EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescriptor;
+ UINT8 EndpointIndex;
PeiUsbDev = PEI_USB_DEVICE_FROM_THIS (This);
+ EndpointDescriptor = NULL;
+ EndpointIndex = 0;
+
+ if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
+ (Request->RequestType == USB_DEV_CLEAR_FEATURE_REQ_TYPE_E) &&
+ (Request->Value == USB_FEATURE_ENDPOINT_HALT)) {
+ //
+ // Request->Index is the Endpoint Address, use it to get the Endpoint Index.
+ //
+ while (EndpointIndex < MAX_ENDPOINT) {
+ Status = PeiUsbGetEndpointDescriptor (PeiServices, This, EndpointIndex, &EndpointDescriptor);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (EndpointDescriptor->EndpointAddress == Request->Index) {
+ break;
+ }
+
+ EndpointIndex++;
+ }
+
+ if (EndpointIndex == MAX_ENDPOINT) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
if (PeiUsbDev->Usb2HcPpi != NULL) {
Status = PeiUsbDev->Usb2HcPpi->ControlTransfer (
PeiServices,
@@ -85,6 +114,18 @@ PeiUsbControlTransfer ( &TransferResult
);
}
+
+ //
+ // Reset the endpoint toggle when endpoint stall is cleared
+ //
+ if ((Request->Request == USB_REQ_CLEAR_FEATURE) &&
+ (Request->RequestType == USB_DEV_CLEAR_FEATURE_REQ_TYPE_E) &&
+ (Request->Value == USB_FEATURE_ENDPOINT_HALT)) {
+ if ((PeiUsbDev->DataToggle & (1 << EndpointIndex)) != 0) {
+ PeiUsbDev->DataToggle = (UINT16) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
+ }
+ }
+
return Status;
}
@@ -194,7 +235,7 @@ PeiUsbBulkTransfer ( }
if (OldToggle != DataToggle) {
- PeiUsbDev->DataToggle = (UINT8) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
+ PeiUsbDev->DataToggle = (UINT16) (PeiUsbDev->DataToggle ^ (1 << EndpointIndex));
}
return Status;
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h index 336a6373ae..21235b5699 100644 --- a/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h +++ b/MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h @@ -1,7 +1,7 @@ /** @file
Usb Peim definition.
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -47,10 +47,10 @@ typedef struct { UINT8 DeviceAddress;
UINT8 MaxPacketSize0;
UINT8 DeviceSpeed;
- UINT8 DataToggle;
UINT8 IsHub;
+ UINT16 DataToggle;
UINT8 DownStreamPortNo;
- UINT8 Reserved[2]; // Padding for IPF
+ UINT8 Reserved; // Padding for IPF
UINTN AllocateAddress;
PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;
|