MdeModulePkg UsbBotPei: The UsbBotPei module contains the private structure definition used by the UsbBusPei module.

If the structure layout in UsbBusPei is changed, then the UsbBotPei will not work.

1. As the maximum number of endpoints is 16, use UINT16 type rather than UINT8 for DataToggle.
2. DataToggle needs to be reset to 0 when endpoint stall is cleared, do it in PeiUsbControlTransfer().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15185 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Star Zeng
2014-01-26 02:49:41 +00:00
committed by lzeng14
parent 6ddc2ff3ef
commit 506560e75a
6 changed files with 67 additions and 254 deletions

View File

@@ -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
@@ -196,68 +196,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.

View File

@@ -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
@@ -187,25 +187,6 @@ PeiUsbSetConfiguration (
IN PEI_USB_IO_PPI *UsbIoPpi
);
/**
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.

View File

@@ -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;

View File

@@ -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;