diff options
Diffstat (limited to 'EdkModulePkg/Bus')
-rw-r--r-- | EdkModulePkg/Bus/Pci/Ehci/Dxe/Debug.c | 5 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.c | 767 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.h | 692 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciMem.c | 110 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciReg.c | 310 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciSched.c | 737 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c | 39 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbBot/Dxe/ComponentName.c | 62 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.c | 435 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.h | 19 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/ComponentName.c | 62 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c | 157 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.h | 19 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageData.h | 18 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c | 417 | ||||
-rw-r--r-- | EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.h | 16 |
16 files changed, 1985 insertions, 1880 deletions
diff --git a/EdkModulePkg/Bus/Pci/Ehci/Dxe/Debug.c b/EdkModulePkg/Bus/Pci/Ehci/Dxe/Debug.c index d9942129ca..a700d8f2cf 100644 --- a/EdkModulePkg/Bus/Pci/Ehci/Dxe/Debug.c +++ b/EdkModulePkg/Bus/Pci/Ehci/Dxe/Debug.c @@ -22,7 +22,8 @@ Revision History #include "Ehci.h"
-void
+
+VOID
DumpEHCIPortsStatus (
IN USB2_HC_DEV *HcDev
)
@@ -47,6 +48,8 @@ DumpEHCIPortsStatus ( );
DEBUG((gEHCDebugLevel, "Port[%d] = 0x%x\n", Index, Value));
}
+
+
}
diff --git a/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.c b/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.c index baea1f608d..e6a4f6130b 100644 --- a/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.c +++ b/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.c @@ -1,20 +1,20 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Ehci.c
-
-Abstract:
-
+
+Abstract:
+
Revision History
--*/
@@ -23,7 +23,7 @@ Revision History #include "Ehci.h"
-GLOBAL_REMOVE_IF_UNREFERENCED UINTN gEHCDebugLevel = EFI_D_INFO;
+GLOBAL_REMOVE_IF_UNREFERENCED UINTN gEHCDebugLevel = EFI_D_ERROR;
GLOBAL_REMOVE_IF_UNREFERENCED UINTN gEHCErrorLevel = EFI_D_ERROR;
@@ -234,18 +234,18 @@ EhciDriverBindingSupported ( /*++
Routine Description:
-
+
Test to see if this driver supports ControllerHandle. Any ControllerHandle
that has Usb2HcProtocol installed will be supported.
Arguments:
-
+
This - Protocol instance pointer.
Controlle - Handle of device to test
RemainingDevicePath - Not used
Returns:
-
+
EFI_SUCCESS This driver supports this device.
EFI_UNSUPPORTED This driver does not support this device.
@@ -255,7 +255,7 @@ EhciDriverBindingSupported ( EFI_PCI_IO_PROTOCOL *PciIo;
USB_CLASSC UsbClassCReg;
-
+
//
// Test whether there is PCI IO Protocol attached on the controller handle.
//
@@ -288,7 +288,7 @@ EhciDriverBindingSupported ( Status = EFI_UNSUPPORTED;
goto exit;
}
-
+
//
// Test whether the controller belongs to Ehci type
//
@@ -329,17 +329,17 @@ EhciDriverBindingStart ( /*++
Routine Description:
-
+
Starting the Usb EHCI Driver
Arguments:
-
+
This - Protocol instance pointer.
Controller - Handle of device to test
RemainingDevicePath - Not used
Returns:
-
+
EFI_SUCCESS supports this device.
EFI_UNSUPPORTED do not support this device.
EFI_DEVICE_ERROR cannot be started due to device Error
@@ -353,7 +353,8 @@ EhciDriverBindingStart ( UINT8 MaxSpeed;
UINT8 PortNumber;
UINT8 Is64BitCapable;
-
+ UINT64 Supports;
+
//
// Open the PciIo Protocol
//
@@ -369,21 +370,30 @@ EhciDriverBindingStart ( Status = EFI_OUT_OF_RESOURCES;
goto exit;
}
-
+
//
// Enable the USB Host Controller
//
Status = PciIo->Attributes (
PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_DEVICE_ENABLE,
- NULL
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &Supports
);
+ if (!EFI_ERROR (Status)) {
+ Supports &= EFI_PCI_DEVICE_ENABLE;
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ Supports,
+ NULL
+ );
+ }
if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
goto close_pciio_protocol;
}
-
+
//
// Allocate memory for EHC private data structure
//
@@ -392,7 +402,7 @@ EhciDriverBindingStart ( Status = EFI_OUT_OF_RESOURCES;
goto close_pciio_protocol;
}
-
+
//
// Init EFI_USB2_HC_PROTOCOL interface and private data structure
//
@@ -430,7 +440,7 @@ EhciDriverBindingStart ( Status = EFI_OUT_OF_RESOURCES;
goto free_pool;
}
-
+
//
// Get Capability Register Length
//
@@ -446,14 +456,14 @@ EhciDriverBindingStart ( DEBUG_CODE (
DumpEHCIPortsStatus (HcDev);
);
-
+
//
// Create and Init Perodic Frame List
//
Status = EhciGetCapability (
- &HcDev->Usb2Hc,
- &MaxSpeed,
- &PortNumber,
+ &HcDev->Usb2Hc,
+ &MaxSpeed,
+ &PortNumber,
&Is64BitCapable
);
if (EFI_ERROR (Status)) {
@@ -461,19 +471,19 @@ EhciDriverBindingStart ( goto uninstall_usb2hc_protocol;
}
HcDev->Is64BitCapable = Is64BitCapable;
-
+
//
// Create and Init Perodic Frame List
//
Status = InitialPeriodicFrameList (
- HcDev,
+ HcDev,
EHCI_MAX_FRAME_LIST_LENGTH
);
if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
goto uninstall_usb2hc_protocol;
}
-
+
//
// Init memory pool management
//
@@ -482,21 +492,26 @@ EhciDriverBindingStart ( Status = EFI_OUT_OF_RESOURCES;
goto deinit_perodic_frame_list;
}
-
+
+ Status = CreateNULLQH (HcDev);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto deinit_perodic_frame_list;
+ }
//
// Create AsyncRequest Polling Timer
//
Status = CreatePollingTimer (HcDev, (EFI_EVENT_NOTIFY) AsyncRequestMoniter);
if (EFI_ERROR (Status)) {
Status = EFI_OUT_OF_RESOURCES;
- goto deinit_memory_management;
+ goto deinit_null_qh;
}
-
+
//
- // Default Maxximum Interrupt Interval is 8,
+ // Default Maxximum Interrupt Interval is 8,
// it means that 8 micro frame = 1ms
//
-
+
//
// Start the Host Controller
//
@@ -507,7 +522,7 @@ EhciDriverBindingStart ( goto deinit_timer;
}
}
-
+
//
// Set all ports routing to EHC
//
@@ -516,7 +531,7 @@ EhciDriverBindingStart ( Status = EFI_DEVICE_ERROR;
goto deinit_timer;
}
-
+
//
// Component name protocol
//
@@ -538,7 +553,8 @@ EhciDriverBindingStart ( //
deinit_timer:
DestoryPollingTimer (HcDev);
-deinit_memory_management:
+deinit_null_qh:
+ DestroyNULLQH(HcDev);
DeinitialMemoryManagement (HcDev);
deinit_perodic_frame_list:
DeinitialPeriodicFrameList (HcDev);
@@ -573,19 +589,19 @@ EhciDriverBindingStop ( /*++
Routine Description:
-
+
Stop this driver on ControllerHandle. Support stoping any child handles
created by this driver.
Arguments:
-
+
This - Protocol instance pointer.
Controller - Handle of device to stop driver on
NumberOfChildren - Number of Children in the ChildHandleBuffer
ChildHandleBuffer - List of handles for the children we need to stop.
Returns:
-
+
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
--*/
@@ -593,6 +609,7 @@ EhciDriverBindingStop ( EFI_STATUS Status;
EFI_USB2_HC_PROTOCOL *Usb2Hc;
USB2_HC_DEV *HcDev;
+ UINT64 Supports;
//
// Test whether the Controller handler passed in is a valid
@@ -626,19 +643,19 @@ EhciDriverBindingStop ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Set Host Controller state as halt
//
Status = Usb2Hc->SetState (
- Usb2Hc,
+ Usb2Hc,
EfiUsbHcStateHalt
);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Stop AsyncRequest Polling Timer
//
@@ -647,7 +664,7 @@ EhciDriverBindingStop ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Destroy Asynchronous Request Event
//
@@ -659,6 +676,11 @@ EhciDriverBindingStop ( DeinitialPeriodicFrameList (HcDev);
//
+ // Destroy NULLQH
+ //
+ DestroyNULLQH (HcDev);
+
+ //
// Deinit Ehci pool memory management
//
DeinitialMemoryManagement (HcDev);
@@ -673,10 +695,19 @@ EhciDriverBindingStop ( //
Status = HcDev->PciIo->Attributes (
HcDev->PciIo,
- EfiPciIoAttributeOperationDisable,
- EFI_PCI_DEVICE_ENABLE,
- NULL
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &Supports
);
+ if (!EFI_ERROR (Status)) {
+ Supports &= EFI_PCI_DEVICE_ENABLE;
+ Status = HcDev->PciIo->Attributes (
+ HcDev->PciIo,
+ EfiPciIoAttributeOperationDisable,
+ Supports,
+ NULL
+ );
+ }
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto exit;
@@ -704,25 +735,25 @@ EhciGetCapability ( OUT UINT8 *Is64BitCapable
)
/*++
-
+
Routine Description:
-
+
Retrieves the capablility of root hub ports.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB_HC_PROTOCOL instance.
MaxSpeed - A pointer to the number of the host controller.
PortNumber - A pointer to the number of the root hub ports.
- Is64BitCapable - A pointer to the flag for whether controller supports
+ Is64BitCapable - A pointer to the flag for whether controller supports
64-bit memory addressing.
-
+
Returns:
-
+
EFI_SUCCESS host controller capability were retrieved successfully.
EFI_INVALID_PARAMETER MaxSpeed or PortNumber or Is64BitCapable is NULL.
- EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the capabilities.
-
+ EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the capabilities.
+
--*/
{
EFI_STATUS Status;
@@ -776,58 +807,58 @@ EhciReset ( IN UINT16 Attributes
)
/*++
-
+
Routine Description:
-
+
Provides software reset for the USB host controller.
-
+
Arguments:
-
- This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
- Attributes - A bit mask of the reset operation to perform.
+
+ This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
+ Attributes - A bit mask of the reset operation to perform.
See below for a list of the supported bit mask values.
-
+
#define EFI_USB_HC_RESET_GLOBAL 0x0001
#define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002
#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004
#define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008
- EFI_USB_HC_RESET_GLOBAL
+ EFI_USB_HC_RESET_GLOBAL
If this bit is set, a global reset signal will be sent to the USB bus.
- This resets all of the USB bus logic, including the USB host
+ This resets all of the USB bus logic, including the USB host
controller hardware and all the devices attached on the USB bus.
- EFI_USB_HC_RESET_HOST_CONTROLLER
- If this bit is set, the USB host controller hardware will be reset.
+ EFI_USB_HC_RESET_HOST_CONTROLLER
+ If this bit is set, the USB host controller hardware will be reset.
No reset signal will be sent to the USB bus.
EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG
If this bit is set, a global reset signal will be sent to the USB bus.
- This resets all of the USB bus logic, including the USB host
- controller hardware and all the devices attached on the USB bus.
- If this is an EHCI controller and the debug port has configured, then
+ This resets all of the USB bus logic, including the USB host
+ controller hardware and all the devices attached on the USB bus.
+ If this is an EHCI controller and the debug port has configured, then
this is will still reset the host controller.
EFI_USB_HC_RESET_HOST_WITH_DEBUG
- If this bit is set, the USB host controller hardware will be reset.
+ If this bit is set, the USB host controller hardware will be reset.
If this is an EHCI controller and the debug port has been configured,
then this will still reset the host controller.
-
+
Returns:
-
- EFI_SUCCESS
+
+ EFI_SUCCESS
The reset operation succeeded.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
Attributes is not valid.
EFI_UNSUPPOURTED
The type of reset specified by Attributes is not currently supported by
the host controller hardware.
EFI_ACCESS_DENIED
- Reset operation is rejected due to the debug port being configured and
- active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
+ Reset operation is rejected due to the debug port being configured and
+ active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Atrributes can be used to
perform reset operation for this host controller.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to perform
+ EFI_DEVICE_ERROR
+ An error was encountered while attempting to perform
the reset operation.
-
+
--*/
{
EFI_STATUS Status;
@@ -840,7 +871,7 @@ EhciReset ( switch (Attributes) {
case EFI_USB_HC_RESET_GLOBAL:
-
+
//
// Same behavior as Host Controller Reset
//
@@ -892,7 +923,7 @@ EhciReset ( // Init Perodic List Base Addr and Frame List
//
Status = SetFrameListBaseAddr (
- HcDev,
+ HcDev,
(UINT32)GET_0B_TO_31B (HcDev->PeriodicFrameListBuffer)
);
if (EFI_ERROR (Status)) {
@@ -951,34 +982,34 @@ EhciGetState ( OUT EFI_USB_HC_STATE *State
)
/*++
-
+
Routine Description:
-
+
Retrieves current state of the USB host controller.
-
+
Arguments:
-
+
This A pointer to the EFI_USB2_HC_PROTOCOL instance.
- State A pointer to the EFI_USB_HC_STATE data structure that
- indicates current state of the USB host controller.
+ State A pointer to the EFI_USB_HC_STATE data structure that
+ indicates current state of the USB host controller.
Type EFI_USB_HC_STATE is defined below.
-
+
typedef enum {
EfiUsbHcStateHalt,
EfiUsbHcStateOperational,
EfiUsbHcStateSuspend,
EfiUsbHcStateMaximum
} EFI_USB_HC_STATE;
-
+
Returns:
-
- EFI_SUCCESS
+
+ EFI_SUCCESS
The state information of the host controller was returned in State.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
State is NULL.
- EFI_DEVICE_ERROR
- An error was encountered while attempting to retrieve the
- host controller's current state.
+ EFI_DEVICE_ERROR
+ An error was encountered while attempting to retrieve the
+ host controller's current state.
--*/
{
EFI_STATUS Status;
@@ -1021,26 +1052,26 @@ EhciSetState ( IN EFI_USB_HC_STATE State
)
/*++
-
+
Routine Description:
-
+
Sets the USB host controller to a specific state.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
State - Indicates the state of the host controller that will be set.
-
+
Returns:
-
- EFI_SUCCESS
- The USB host controller was successfully placed in the state
+
+ EFI_SUCCESS
+ The USB host controller was successfully placed in the state
specified by State.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
State is invalid.
- EFI_DEVICE_ERROR
- Failed to set the state specified by State due to device error.
-
+ EFI_DEVICE_ERROR
+ Failed to set the state specified by State due to device error.
+
--*/
{
EFI_STATUS Status;
@@ -1154,28 +1185,28 @@ EhciGetRootHubPortStatus ( OUT EFI_USB_PORT_STATUS *PortStatus
)
/*++
-
+
Routine Description:
-
+
Retrieves the current status of a USB root hub port.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL.
- PortNumber - Specifies the root hub port from which the status
- is to be retrieved. This value is zero-based. For example,
+ PortNumber - Specifies the root hub port from which the status
+ is to be retrieved. This value is zero-based. For example,
if a root hub has two ports, then the first port is numbered 0,
and the second port is numbered 1.
- PortStatus - A pointer to the current port status bits and
- port status change bits.
-
+ PortStatus - A pointer to the current port status bits and
+ port status change bits.
+
Returns:
-
- EFI_SUCCESS The status of the USB root hub port specified
+
+ EFI_SUCCESS The status of the USB root hub port specified
by PortNumber was returned in PortStatus.
- EFI_INVALID_PARAMETER PortNumber is invalid.
- EFI_DEVICE_ERROR Can't read register
-
+ EFI_INVALID_PARAMETER PortNumber is invalid.
+ EFI_DEVICE_ERROR Can't read register
+
--*/
{
EFI_STATUS Status;
@@ -1192,12 +1223,12 @@ EhciGetRootHubPortStatus ( }
EhciGetCapability (
- This,
- &MaxSpeed,
- &TotalPortNumber,
+ This,
+ &MaxSpeed,
+ &TotalPortNumber,
&Is64BitCapable
);
-
+
if (PortNumber >= TotalPortNumber) {
Status = EFI_INVALID_PARAMETER;
goto exit;
@@ -1221,11 +1252,11 @@ EhciGetRootHubPortStatus ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Fill Port Status bits
//
-
+
//
// Current Connect Status
//
@@ -1319,29 +1350,29 @@ EhciSetRootHubPortFeature ( IN EFI_USB_PORT_FEATURE PortFeature
)
/*++
-
+
Routine Description:
-
+
Sets a feature for the specified root hub port.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL.
- PortNumber - Specifies the root hub port whose feature
+ PortNumber - Specifies the root hub port whose feature
is requested to be set.
- PortFeature - Indicates the feature selector associated
- with the feature set request.
-
+ PortFeature - Indicates the feature selector associated
+ with the feature set request.
+
Returns:
-
- EFI_SUCCESS
- The feature specified by PortFeature was set for the
+
+ EFI_SUCCESS
+ The feature specified by PortFeature was set for the
USB root hub port specified by PortNumber.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
PortNumber is invalid or PortFeature is invalid.
EFI_DEVICE_ERROR
Can't read register
-
+
--*/
{
EFI_STATUS Status;
@@ -1353,9 +1384,9 @@ EhciSetRootHubPortFeature ( UINT8 Is64BitCapable;
EhciGetCapability (
- This,
- &MaxSpeed,
- &TotalPortNumber,
+ This,
+ &MaxSpeed,
+ &TotalPortNumber,
&Is64BitCapable
);
@@ -1380,7 +1411,7 @@ EhciSetRootHubPortFeature ( switch (PortFeature) {
case EfiUsbPortEnable:
-
+
//
// Sofeware can't set this bit, Port can only be enable by the Host Controller
// as a part of the reset and enable
@@ -1390,13 +1421,13 @@ EhciSetRootHubPortFeature ( break;
case EfiUsbPortSuspend:
-
+
PortStatusControlReg &= 0xffffffd5;
PortStatusControlReg |= PORTSC_SUSP;
break;
case EfiUsbPortReset:
-
+
//
// Make sure Host Controller not halt before reset it
//
@@ -1422,14 +1453,14 @@ EhciSetRootHubPortFeature ( break;
case EfiUsbPortPower:
-
+
//
// No support, no operation
//
goto exit;
case EfiUsbPortOwner:
-
+
PortStatusControlReg &= 0xffffffd5;
PortStatusControlReg |= PORTSC_PO;
break;
@@ -1461,29 +1492,29 @@ EhciClearRootHubPortFeature ( IN EFI_USB_PORT_FEATURE PortFeature
)
/*++
-
+
Routine Description:
-
+
Clears a feature for the specified root hub port.
-
+
Arguments:
-
- This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
- PortNumber - Specifies the root hub port whose feature
+
+ This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
+ PortNumber - Specifies the root hub port whose feature
is requested to be cleared.
- PortFeature - Indicates the feature selector associated with the
+ PortFeature - Indicates the feature selector associated with the
feature clear request.
-
+
Returns:
-
- EFI_SUCCESS
- The feature specified by PortFeature was cleared for the
+
+ EFI_SUCCESS
+ The feature specified by PortFeature was cleared for the
USB root hub port specified by PortNumber.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
PortNumber is invalid or PortFeature is invalid.
EFI_DEVICE_ERROR
Can't read register
-
+
--*/
{
EFI_STATUS Status;
@@ -1495,9 +1526,9 @@ EhciClearRootHubPortFeature ( UINT8 Is64BitCapable;
EhciGetCapability (
- This,
- &MaxSpeed,
- &TotalPortNumber,
+ This,
+ &MaxSpeed,
+ &TotalPortNumber,
&Is64BitCapable
);
@@ -1522,7 +1553,7 @@ EhciClearRootHubPortFeature ( switch (PortFeature) {
case EfiUsbPortEnable:
-
+
//
// Clear PORT_ENABLE feature means disable port.
//
@@ -1531,7 +1562,7 @@ EhciClearRootHubPortFeature ( break;
case EfiUsbPortSuspend:
-
+
//
// A write of zero to this bit is ignored by the host controller.
// The host controller will unconditionally set this bit to a zero when:
@@ -1543,7 +1574,7 @@ EhciClearRootHubPortFeature ( break;
case EfiUsbPortReset:
-
+
//
// Clear PORT_RESET means clear the reset signal.
//
@@ -1552,14 +1583,14 @@ EhciClearRootHubPortFeature ( break;
case EfiUsbPortPower:
-
+
//
// No support, no operation
//
goto exit;
case EfiUsbPortOwner:
-
+
//
// Clear port owner means this port owned by EHC
//
@@ -1568,7 +1599,7 @@ EhciClearRootHubPortFeature ( break;
case EfiUsbPortConnectChange:
-
+
//
// Clear connect status change
//
@@ -1577,7 +1608,7 @@ EhciClearRootHubPortFeature ( break;
case EfiUsbPortEnableChange:
-
+
//
// Clear enable status change
//
@@ -1586,14 +1617,14 @@ EhciClearRootHubPortFeature ( break;
case EfiUsbPortSuspendChange:
-
+
//
// No related bit, no operation
//
goto exit;
case EfiUsbPortOverCurrentChange:
-
+
//
// Clear PortOverCurrent change
//
@@ -1602,7 +1633,7 @@ EhciClearRootHubPortFeature ( break;
case EfiUsbPortResetChange:
-
+
//
// No related bit, no operation
//
@@ -1644,47 +1675,47 @@ EhciControlTransfer ( OUT UINT32 *TransferResult
)
/*++
-
+
Routine Description:
-
+
Submits control transfer to a target USB device.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
DeviceSpeed - Indicates target device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
+ MaximumPacketLength - Indicates the maximum packet size that the
+ default control transfer endpoint is capable of
sending or receiving.
- Request - A pointer to the USB device request that will be sent
- to the USB device.
+ Request - A pointer to the USB device request that will be sent
+ to the USB device.
TransferDirection - Specifies the data direction for the transfer.
- There are three values available, DataIn, DataOut
+ There are three values available, DataIn, DataOut
and NoData.
- Data - A pointer to the buffer of data that will be transmitted
+ Data - A pointer to the buffer of data that will be transmitted
to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
+ DataLength - Indicates the size, in bytes, of the data buffer
specified by Data.
- TimeOut - Indicates the maximum time, in microseconds,
+ TimeOut - Indicates the maximum time, in microseconds,
which the transfer is allowed to complete.
Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information generated
+ TransferResult - A pointer to the detailed result information generated
by this control transfer.
-
+
Returns:
-
- EFI_SUCCESS
+
+ EFI_SUCCESS
The control transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
+ EFI_OUT_OF_RESOURCES
The control transfer could not be completed due to a lack of resources.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
Some parameters are invalid.
- EFI_TIMEOUT
+ EFI_TIMEOUT
The control transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The control transfer failed due to host controller or device error.
+ EFI_DEVICE_ERROR
+ The control transfer failed due to host controller or device error.
Caller should check TranferResult for detailed error information.
--*/
@@ -1748,7 +1779,7 @@ EhciControlTransfer ( Status = EFI_INVALID_PARAMETER;
goto exit;
}
-
+
//
// If errors exist that cause host controller halt,
// then return EFI_DEVICE_ERROR.
@@ -1759,7 +1790,7 @@ EhciControlTransfer ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Map the Request for bus master access.
// BusMasterRead means cpu write
@@ -1775,7 +1806,7 @@ EhciControlTransfer ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Map the source data buffer for bus master access.
//
@@ -1793,7 +1824,7 @@ EhciControlTransfer ( Status = EFI_DEVICE_ERROR;
goto unmap_request;
}
-
+
//
// Create and init control Qh
//
@@ -1810,7 +1841,7 @@ EhciControlTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto unmap_data;
}
-
+
//
// Create and init control Qtds
//
@@ -1828,7 +1859,7 @@ EhciControlTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto destory_qh;
}
-
+
//
// Link Qtds to Qh
//
@@ -1845,7 +1876,7 @@ EhciControlTransfer ( Status = EFI_DEVICE_ERROR;
goto destory_qtds;
}
-
+
//
// Poll Qh-Qtds execution and get result.
// detail status is returned
@@ -1862,7 +1893,7 @@ EhciControlTransfer ( if (EFI_ERROR (Status)) {
goto destory_qtds;
}
-
+
//
// If has errors that cause host controller halt,
// then return EFI_DEVICE_ERROR directly.
@@ -1904,54 +1935,54 @@ EhciBulkTransfer ( OUT UINT32 *TransferResult
)
/*++
-
+
Routine Description:
-
+
Submits bulk transfer to a bulk endpoint of a USB device.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an
- endpoint direction of the target USB device.
- Each endpoint address supports data transfer in
- one direction except the control endpoint
- (whose default endpoint address is 0).
- It is the caller's responsibility to make sure that
- the EndPointAddress represents a bulk endpoint.
+ which is assigned during USB enumeration.
+ EndPointAddress - The combination of an endpoint number and an
+ endpoint direction of the target USB device.
+ Each endpoint address supports data transfer in
+ one direction except the control endpoint
+ (whose default endpoint address is 0).
+ It is the caller's responsibility to make sure that
+ the EndPointAddress represents a bulk endpoint.
DeviceSpeed - Indicates device speed. The supported values are EFI_USB_SPEED_FULL
and EFI_USB_SPEED_HIGH.
MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
+ is capable of sending or receiving.
DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be transmitted
- to USB device or received from USB device.
+ Data - Array of pointers to the buffers of data that will be transmitted
+ to USB device or received from USB device.
DataLength - When input, indicates the size, in bytes, of the data buffer
- specified by Data. When output, indicates the actually
- transferred data size.
- DataToggle - A pointer to the data toggle value. On input, it indicates
+ specified by Data. When output, indicates the actually
+ transferred data size.
+ DataToggle - A pointer to the data toggle value. On input, it indicates
the initial data toggle value the bulk transfer should adopt;
- on output, it is updated to indicate the data toggle value
- of the subsequent bulk transfer.
- Translator - A pointr to the transaction translator data.
- TimeOut - Indicates the maximum time, in microseconds, which the
- transfer is allowed to complete.
- TransferResult - A pointer to the detailed result information of the
+ on output, it is updated to indicate the data toggle value
+ of the subsequent bulk transfer.
+ Translator - A pointr to the transaction translator data.
+ TimeOut - Indicates the maximum time, in microseconds, which the
+ transfer is allowed to complete.
+ TransferResult - A pointer to the detailed result information of the
bulk transfer.
Returns:
-
- EFI_SUCCESS
+
+ EFI_SUCCESS
The bulk transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
+ EFI_OUT_OF_RESOURCES
The bulk transfer could not be submitted due to lack of resource.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
Some parameters are invalid.
- EFI_TIMEOUT
+ EFI_TIMEOUT
The bulk transfer failed due to timeout.
- EFI_DEVICE_ERROR
+ EFI_DEVICE_ERROR
The bulk transfer failed due to host controller or device error.
Caller should check TranferResult for detailed error information.
@@ -1976,8 +2007,8 @@ EhciBulkTransfer ( // Parameters Checking
//
if (NULL == DataLength ||
- NULL == Data ||
- NULL == Data[0] ||
+ NULL == Data ||
+ NULL == Data[0] ||
NULL == TransferResult
) {
Status = EFI_INVALID_PARAMETER;
@@ -2012,7 +2043,7 @@ EhciBulkTransfer ( goto exit;
}
}
-
+
//
// if has errors that cause host controller halt,
// then return EFI_DEVICE_ERROR directly.
@@ -2029,7 +2060,7 @@ EhciBulkTransfer ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// construct QH and TD data structures,
// and link them together
@@ -2054,7 +2085,7 @@ EhciBulkTransfer ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Create and init Bulk Qh
//
@@ -2073,7 +2104,7 @@ EhciBulkTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto unmap_data;
}
-
+
//
// Create and init Bulk Qtds
//
@@ -2090,7 +2121,7 @@ EhciBulkTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto destory_qh;
}
-
+
//
// Link Qtds to Qh
//
@@ -2107,7 +2138,7 @@ EhciBulkTransfer ( Status = EFI_DEVICE_ERROR;
goto destory_qtds;
}
-
+
//
// Poll QH-TDs execution and get result.
// detail status is returned
@@ -2124,7 +2155,7 @@ EhciBulkTransfer ( if (EFI_ERROR (Status)) {
goto destory_qtds;
}
-
+
//
// if has errors that cause host controller halt,
// then return EFI_DEVICE_ERROR directly.
@@ -2164,65 +2195,65 @@ EhciAsyncInterruptTransfer ( IN VOID *Context OPTIONAL
)
/*++
-
+
Routine Description:
-
- Submits an asynchronous interrupt transfer to an
+
+ Submits an asynchronous interrupt transfer to an
interrupt endpoint of a USB device.
- Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated
+ Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated
in the following specification version.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
DeviceAddress - Represents the address of the target device on the USB,
- which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an endpoint
- direction of the target USB device. Each endpoint address
- supports data transfer in one direction except the
- control endpoint (whose default endpoint address is 0).
- It is the caller's responsibility to make sure that
- the EndPointAddress represents an interrupt endpoint.
+ which is assigned during USB enumeration.
+ EndPointAddress - The combination of an endpoint number and an endpoint
+ direction of the target USB device. Each endpoint address
+ supports data transfer in one direction except the
+ control endpoint (whose default endpoint address is 0).
+ It is the caller's responsibility to make sure that
+ the EndPointAddress represents an interrupt endpoint.
DeviceSpeed - Indicates device speed.
MaximumPacketLength - Indicates the maximum packet size the target endpoint
- is capable of sending or receiving.
+ is capable of sending or receiving.
IsNewTransfer - If TRUE, an asynchronous interrupt pipe is built between
- the host and the target interrupt endpoint.
- If FALSE, the specified asynchronous interrupt pipe
- is canceled.
- DataToggle - A pointer to the data toggle value. On input, it is valid
- when IsNewTransfer is TRUE, and it indicates the initial
- data toggle value the asynchronous interrupt transfer
- should adopt.
- On output, it is valid when IsNewTransfer is FALSE,
- and it is updated to indicate the data toggle value of
- the subsequent asynchronous interrupt transfer.
- PollingInterval - Indicates the interval, in milliseconds, that the
- asynchronous interrupt transfer is polled.
- This parameter is required when IsNewTransfer is TRUE.
- DataLength - Indicates the length of data to be received at the
- rate specified by PollingInterval from the target
- asynchronous interrupt endpoint. This parameter
- is only required when IsNewTransfer is TRUE.
+ the host and the target interrupt endpoint.
+ If FALSE, the specified asynchronous interrupt pipe
+ is canceled.
+ DataToggle - A pointer to the data toggle value. On input, it is valid
+ when IsNewTransfer is TRUE, and it indicates the initial
+ data toggle value the asynchronous interrupt transfer
+ should adopt.
+ On output, it is valid when IsNewTransfer is FALSE,
+ and it is updated to indicate the data toggle value of
+ the subsequent asynchronous interrupt transfer.
+ PollingInterval - Indicates the interval, in milliseconds, that the
+ asynchronous interrupt transfer is polled.
+ This parameter is required when IsNewTransfer is TRUE.
+ DataLength - Indicates the length of data to be received at the
+ rate specified by PollingInterval from the target
+ asynchronous interrupt endpoint. This parameter
+ is only required when IsNewTransfer is TRUE.
Translator - A pointr to the transaction translator data.
- CallBackFunction - The Callback function.This function is called at the
- rate specified by PollingInterval.This parameter is
- only required when IsNewTransfer is TRUE.
+ CallBackFunction - The Callback function.This function is called at the
+ rate specified by PollingInterval.This parameter is
+ only required when IsNewTransfer is TRUE.
Context - The context that is passed to the CallBackFunction.
- This is an optional parameter and may be NULL.
-
+
Returns:
-
- EFI_SUCCESS
- The asynchronous interrupt transfer request has been successfully
+
+ EFI_SUCCESS
+ The asynchronous interrupt transfer request has been successfully
submitted or canceled.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
Some parameters are invalid.
- EFI_OUT_OF_RESOURCES
- The request could not be completed due to a lack of resources.
+ EFI_OUT_OF_RESOURCES
+ The request could not be completed due to a lack of resources.
EFI_DEVICE_ERROR
Can't read register
-
+
--*/
{
EFI_STATUS Status;
@@ -2269,7 +2300,7 @@ EhciAsyncInterruptTransfer ( goto exit;
}
}
-
+
//
// if has errors that cause host controller halt,
// then return EFI_DEVICE_ERROR directly.
@@ -2285,7 +2316,7 @@ EhciAsyncInterruptTransfer ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Delete Async interrupt transfer request
//
@@ -2306,8 +2337,8 @@ EhciAsyncInterruptTransfer ( }
Status = EhciAllocatePool (
- HcDev,
- (UINT8 **) &AsyncRequestPtr,
+ HcDev,
+ (UINT8 **) &AsyncRequestPtr,
sizeof (EHCI_ASYNC_REQUEST)
);
if (EFI_ERROR (Status)) {
@@ -2335,7 +2366,7 @@ EhciAsyncInterruptTransfer ( Status = EFI_DEVICE_ERROR;
goto free_data;
}
-
+
//
// Create and init Interrupt Qh
//
@@ -2354,7 +2385,7 @@ EhciAsyncInterruptTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto unmap_data;
}
-
+
//
// Create and init Interrupt Qtds
//
@@ -2370,7 +2401,7 @@ EhciAsyncInterruptTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto destory_qh;
}
-
+
//
// Link Qtds to Qh
//
@@ -2394,7 +2425,7 @@ EhciAsyncInterruptTransfer ( goto exit;
}
}
-
+
//
// Link Entry to AsyncRequest List
//
@@ -2413,7 +2444,7 @@ EhciAsyncInterruptTransfer ( Status = EFI_TIMEOUT;
goto exit;
}
-
+
//
// Link Qh and Qtds to Periodic Schedule List
//
@@ -2448,8 +2479,8 @@ free_data: EhciFreePool (HcDev, DataPtr, DataLength);
free_request:
EhciFreePool (
- HcDev,
- (UINT8 *) AsyncRequestPtr,
+ HcDev,
+ (UINT8 *) AsyncRequestPtr,
sizeof (EHCI_ASYNC_REQUEST)
);
unmap_data:
@@ -2474,60 +2505,60 @@ EhciSyncInterruptTransfer ( OUT UINT32 *TransferResult
)
/*++
-
+
Routine Description:
-
- Submits synchronous interrupt transfer to an interrupt endpoint
- of a USB device.
- Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated
+
+ Submits synchronous interrupt transfer to an interrupt endpoint
+ of a USB device.
+ Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated
in the following specification version.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
- DeviceAddress - Represents the address of the target device on the USB,
+ DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
- EndPointAddress - The combination of an endpoint number and an endpoint
- direction of the target USB device. Each endpoint
- address supports data transfer in one direction
- except the control endpoint (whose default
+ EndPointAddress - The combination of an endpoint number and an endpoint
+ direction of the target USB device. Each endpoint
+ address supports data transfer in one direction
+ except the control endpoint (whose default
endpoint address is 0). It is the caller's responsibility
- to make sure that the EndPointAddress represents
- an interrupt endpoint.
+ to make sure that the EndPointAddress represents
+ an interrupt endpoint.
DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size the target endpoint
+ MaximumPacketLength - Indicates the maximum packet size the target endpoint
is capable of sending or receiving.
- Data - A pointer to the buffer of data that will be transmitted
+ Data - A pointer to the buffer of data that will be transmitted
to USB device or received from USB device.
- DataLength - On input, the size, in bytes, of the data buffer specified
+ DataLength - On input, the size, in bytes, of the data buffer specified
by Data. On output, the number of bytes transferred.
DataToggle - A pointer to the data toggle value. On input, it indicates
- the initial data toggle value the synchronous interrupt
- transfer should adopt;
- on output, it is updated to indicate the data toggle value
- of the subsequent synchronous interrupt transfer.
- TimeOut - Indicates the maximum time, in microseconds, which the
+ the initial data toggle value the synchronous interrupt
+ transfer should adopt;
+ on output, it is updated to indicate the data toggle value
+ of the subsequent synchronous interrupt transfer.
+ TimeOut - Indicates the maximum time, in microseconds, which the
transfer is allowed to complete.
Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information from
- the synchronous interrupt transfer.
+ TransferResult - A pointer to the detailed result information from
+ the synchronous interrupt transfer.
Returns:
-
- EFI_SUCCESS
+
+ EFI_SUCCESS
The synchronous interrupt transfer was completed successfully.
- EFI_OUT_OF_RESOURCES
- The synchronous interrupt transfer could not be submitted due
+ EFI_OUT_OF_RESOURCES
+ The synchronous interrupt transfer could not be submitted due
to lack of resource.
- EFI_INVALID_PARAMETER
+ EFI_INVALID_PARAMETER
Some parameters are invalid.
- EFI_TIMEOUT
+ EFI_TIMEOUT
The synchronous interrupt transfer failed due to timeout.
- EFI_DEVICE_ERROR
- The synchronous interrupt transfer failed due to host controller
- or device error. Caller should check TranferResult for detailed
- error information.
-
+ EFI_DEVICE_ERROR
+ The synchronous interrupt transfer failed due to host controller
+ or device error. Caller should check TranferResult for detailed
+ error information.
+
--*/
{
EFI_STATUS Status;
@@ -2548,7 +2579,7 @@ EhciSyncInterruptTransfer ( // Parameters Checking
//
if (DataLength == NULL ||
- Data == NULL ||
+ Data == NULL ||
TransferResult == NULL
) {
Status = EFI_INVALID_PARAMETER;
@@ -2584,7 +2615,7 @@ EhciSyncInterruptTransfer ( Status = EFI_INVALID_PARAMETER;
goto exit;
}
-
+
//
// if has errors that cause host controller halt,
// then return EFI_DEVICE_ERROR directly.
@@ -2616,7 +2647,7 @@ EhciSyncInterruptTransfer ( Status = EFI_DEVICE_ERROR;
goto exit;
}
-
+
//
// Create and init Interrupt Qh
//
@@ -2635,7 +2666,7 @@ EhciSyncInterruptTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto unmap_data;
}
-
+
//
// Create and init Interrupt Qtds
//
@@ -2652,7 +2683,7 @@ EhciSyncInterruptTransfer ( Status = EFI_OUT_OF_RESOURCES;
goto destory_qh;
}
-
+
//
// Link Qtds to Qh
//
@@ -2671,7 +2702,7 @@ EhciSyncInterruptTransfer ( Status = EFI_TIMEOUT;
goto exit;
}
-
+
//
// Link Qh and Qtds to Periodic Schedule List
//
@@ -2696,7 +2727,7 @@ EhciSyncInterruptTransfer ( goto exit;
}
}
-
+
//
// Poll QH-TDs execution and get result.
// detail status is returned
@@ -2713,7 +2744,7 @@ EhciSyncInterruptTransfer ( if (EFI_ERROR (Status)) {
goto destory_qtds;
}
-
+
//
// if has errors that cause host controller halt,
// then return EFI_DEVICE_ERROR directly.
@@ -2751,33 +2782,33 @@ EhciIsochronousTransfer ( OUT UINT32 *TransferResult
)
/*++
-
+
Routine Description:
-
+
Submits isochronous transfer to a target USB device.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
EndPointAddress - End point address
DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
+ MaximumPacketLength - Indicates the maximum packet size that the
+ default control transfer endpoint is capable of
sending or receiving.
DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be
+ Data - Array of pointers to the buffers of data that will be
transmitted to USB device or received from USB device.
- DataLength - Indicates the size, in bytes, of the data buffer
+ DataLength - Indicates the size, in bytes, of the data buffer
specified by Data.
Translator - A pointr to the transaction translator data.
- TransferResult - A pointer to the detailed result information generated
- by this control transfer.
-
+ TransferResult - A pointer to the detailed result information generated
+ by this control transfer.
+
Returns:
-
- EFI_UNSUPPORTED
+
+ EFI_UNSUPPORTED
--*/
{
@@ -2800,31 +2831,31 @@ EhciAsyncIsochronousTransfer ( IN VOID *Context
)
/*++
-
+
Routine Description:
-
+
Submits Async isochronous transfer to a target USB device.
-
+
Arguments:
-
+
This - A pointer to the EFI_USB2_HC_PROTOCOL instance.
DeviceAddress - Represents the address of the target device on the USB,
which is assigned during USB enumeration.
EndPointAddress - End point address
DeviceSpeed - Indicates device speed.
- MaximumPacketLength - Indicates the maximum packet size that the
- default control transfer endpoint is capable of
+ MaximumPacketLength - Indicates the maximum packet size that the
+ default control transfer endpoint is capable of
sending or receiving.
DataBuffersNumber - Number of data buffers prepared for the transfer.
- Data - Array of pointers to the buffers of data that will be transmitted
+ Data - Array of pointers to the buffers of data that will be transmitted
to USB device or received from USB device.
Translator - A pointr to the transaction translator data.
IsochronousCallBack - When the transfer complete, the call back function will be called
Context - Pass to the call back function as parameter
-
+
Returns:
-
- EFI_UNSUPPORTED
+
+ EFI_UNSUPPORTED
--*/
{
diff --git a/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.h b/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.h index 747e1ee124..603bb2665a 100644 --- a/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.h +++ b/EdkModulePkg/Bus/Pci/Ehci/Dxe/Ehci.h @@ -1,20 +1,20 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Ehci.h
-
-Abstract:
-
+
+Abstract:
+
Revision History
--*/
@@ -36,6 +36,9 @@ extern UINTN gEHCErrorLevel; #define STALL_1_MILLI_SECOND 1000 * STALL_1_MACRO_SECOND
#define STALL_1_SECOND 1000 * STALL_1_MILLI_SECOND
+#define MEM_UNIT_SIZE 128
+
+
#define SETUP_PACKET_PID_CODE 0x02
#define INPUT_PACKET_PID_CODE 0x01
#define OUTPUT_PACKET_PID_CODE 0x0
@@ -54,7 +57,7 @@ extern UINTN gEHCErrorLevel; #define USB_BAR_INDEX 0 /* how many bytes away from USB_BASE to 0x10 */
-#define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 1
+#define NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES 16
#define EHCI_MIN_PACKET_SIZE 8
#define EHCI_MAX_PACKET_SIZE 1024
@@ -64,7 +67,7 @@ extern UINTN gEHCErrorLevel; #define EHCI_MAX_QTD_CAPACITY (EFI_PAGE_SIZE * 5)
#define NAK_COUNT_RELOAD 3
-#define QTD_ERROR_COUNTER 1
+#define QTD_ERROR_COUNTER 3
#define HIGH_BANDWIDTH_PIPE_MULTIPLIER 1
#define QTD_STATUS_ACTIVE 0x80
@@ -210,6 +213,9 @@ typedef struct { UINT8 BaseCode;
} USB_CLASSC;
+//
+//32 Bytes Aligned
+//
typedef struct {
UINT32 NextQtdTerminate : 1;
UINT32 Rsvd1 : 4;
@@ -242,13 +248,12 @@ typedef struct { UINT32 Rsvd6 : 12;
UINT32 BufferPointer4 : 20;
- UINT32 ExtBufferPointer0;
- UINT32 ExtBufferPointer1;
- UINT32 ExtBufferPointer2;
- UINT32 ExtBufferPointer3;
- UINT32 ExtBufferPointer4;
+ UINT32 PAD[5];
} EHCI_QTD_HW;
+//
+//32 Bytes Aligned
+//
typedef struct {
UINT32 QhTerminate : 1;
UINT32 SelectType : 2;
@@ -307,11 +312,7 @@ typedef struct { UINT32 Rsvd6 : 12;
UINT32 BufferPointer4 : 20;
- UINT32 ExtBufferPointer0;
- UINT32 ExtBufferPointer1;
- UINT32 ExtBufferPointer2;
- UINT32 ExtBufferPointer3;
- UINT32 ExtBufferPointer4;
+ UINT32 Pad[5];
} EHCI_QH_HW;
typedef struct {
@@ -326,7 +327,9 @@ typedef struct { typedef struct _EHCI_QTD_ENTITY EHCI_QTD_ENTITY;
typedef struct _EHCI_QH_ENTITY EHCI_QH_ENTITY;
typedef struct _EHCI_ASYNC_REQUEST EHCI_ASYNC_REQUEST;
-
+//
+//Aligan On 32 Bytes
+//
struct _EHCI_QTD_ENTITY {
EHCI_QTD_HW Qtd;
UINT32 TotalBytes;
@@ -337,7 +340,9 @@ struct _EHCI_QTD_ENTITY { EHCI_QTD_ENTITY *AltNext;
EHCI_QH_ENTITY *SelfQh;
};
-
+//
+//Aligan On 32 Bytes
+//
struct _EHCI_QH_ENTITY {
EHCI_QH_HW Qh;
EHCI_QH_ENTITY *Next;
@@ -390,8 +395,9 @@ typedef struct _USB2_HC_DEV { EFI_EVENT AsyncRequestEvent;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
MEMORY_MANAGE_HEADER *MemoryHeader;
- UINT8 Is64BitCapable;
+ UINT8 Is64BitCapable;
UINT32 High32BitAddr;
+ EHCI_QH_ENTITY *NULLQH;
UINT32 UsbCapabilityLen;
UINT16 DeviceSpeed[16];
} USB2_HC_DEV;
@@ -422,13 +428,13 @@ Arguments: HcDev - USB2_HC_DEV
MemoryHeader - MEMORY_MANAGE_HEADER to output
MemoryBlockSizeInPages - MemoryBlockSizeInPages
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Fail for no resources
EFI_UNSUPPORTED Unsupported currently
-
+
--*/
;
@@ -500,7 +506,7 @@ Arguments: Returns:
EFI_SUCCESS Success
- EFI_NOT_FOUND Can't find the free memory
+ EFI_NOT_FOUND Can't find the free memory
--*/
;
@@ -522,7 +528,7 @@ Arguments: Returns:
TRUE Empty
- FALSE Not Empty
+ FALSE Not Empty
--*/
;
@@ -590,7 +596,7 @@ Returns: EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -616,7 +622,7 @@ Returns: EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -659,18 +665,18 @@ ReadEhcCapabiltiyReg ( Routine Description:
Read Ehc Capabitlity register
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
CapabiltiyRegAddr - Ehc Capability register address
Data - A pointer to data read from register
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -685,18 +691,18 @@ ReadEhcOperationalReg ( Routine Description:
Read Ehc Operation register
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
OperationalRegAddr - Ehc Operation register address
Data - A pointer to data read from register
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -711,18 +717,18 @@ WriteEhcOperationalReg ( Routine Description:
Write Ehc Operation register
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
OperationalRegAddr - Ehc Operation register address
Data - 32bit write to register
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -735,16 +741,16 @@ SetEhcDoorbell ( Routine Description:
Set Ehc door bell bit
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -758,18 +764,18 @@ SetFrameListLen ( Routine Description:
Set the length of Frame List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Length - the required length of frame list
-
+
Returns:
EFI_SUCCESS Success
EFI_INVALID_PARAMETER Invalid parameter
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -782,16 +788,16 @@ IsFrameListProgrammable ( Routine Description:
Whether frame list is programmable
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Programmable
FALSE Unprogrammable
-
+
--*/
;
@@ -804,16 +810,16 @@ IsPeriodicScheduleEnabled ( Routine Description:
Whether periodic schedule is enabled
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Enabled
FALSE Disabled
-
+
--*/
;
@@ -826,16 +832,16 @@ IsAsyncScheduleEnabled ( Routine Description:
Whether asynchronous schedule is enabled
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Enabled
FALSE Disabled
-
+
--*/
;
@@ -849,16 +855,16 @@ IsEhcPortEnabled ( Routine Description:
Whether port is enabled
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Enabled
FALSE Disabled
-
+
--*/
;
@@ -871,16 +877,16 @@ IsEhcReseted ( Routine Description:
Whether Ehc is halted
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Reseted
FALSE Unreseted
-
+
--*/
;
@@ -893,16 +899,16 @@ IsEhcHalted ( Routine Description:
Whether Ehc is halted
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Halted
FALSE Not halted
-
+
--*/
;
@@ -915,39 +921,39 @@ IsEhcSysError ( Routine Description:
Whether Ehc is system error
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE System error
FALSE No system error
-
+
--*/
;
BOOLEAN
IsHighSpeedDevice (
IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 PortNum
+ IN UINT8 PortNum
)
/*++
Routine Description:
Whether high speed device attached
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE High speed
FALSE Full speed
-
+
--*/
;
@@ -961,17 +967,17 @@ WaitForEhcReset ( Routine Description:
wait for Ehc reset or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -985,17 +991,17 @@ WaitForEhcHalt ( Routine Description:
wait for Ehc halt or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -1009,17 +1015,17 @@ WaitForEhcNotHalt ( Routine Description:
wait for Ehc not halt or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -1036,14 +1042,14 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -1057,17 +1063,17 @@ WaitForAsyncScheduleEnable ( Routine Description:
Wait for Ehc asynchronous schedule enable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -1081,17 +1087,17 @@ WaitForAsyncScheduleDisable ( Routine Description:
Wait for Ehc asynchronous schedule disable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -1105,17 +1111,17 @@ WaitForPeriodicScheduleEnable ( Routine Description:
Wait for Ehc periodic schedule enable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -1129,17 +1135,17 @@ WaitForPeriodicScheduleDisable ( Routine Description:
Wait for periodic schedule disable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
;
@@ -1152,16 +1158,16 @@ GetCapabilityLen ( Routine Description:
Get the length of capability register
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1175,17 +1181,17 @@ SetFrameListBaseAddr ( Routine Description:
Set base address of frame list first entry
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
FrameBuffer - base address of first entry of frame list
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1199,17 +1205,17 @@ SetAsyncListAddr ( Routine Description:
Set address of first Async schedule Qh
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to first Qh in the Async schedule
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1222,17 +1228,17 @@ SetCtrlDataStructSeg ( Routine Description:
Set address of first Async schedule Qh
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to first Qh in the Async schedule
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1245,16 +1251,16 @@ SetPortRoutingEhc ( Routine Description:
Set Ehc port routing bit
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1267,16 +1273,16 @@ EnablePeriodicSchedule ( Routine Description:
Enable periodic schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1289,16 +1295,16 @@ DisablePeriodicSchedule ( Routine Description:
Disable periodic schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1311,16 +1317,16 @@ EnableAsynchronousSchedule ( Routine Description:
Enable asynchrounous schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1333,16 +1339,16 @@ DisableAsynchronousSchedule ( Routine Description:
Disable asynchrounous schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1355,16 +1361,16 @@ StartScheduleExecution ( Routine Description:
Start Ehc schedule execution
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1377,16 +1383,16 @@ ResetEhc ( Routine Description:
Reset Ehc
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1399,16 +1405,16 @@ ClearEhcAllStatus ( Routine Description:
Clear Ehc all status bits
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1430,12 +1436,12 @@ Arguments: HcDev - USB2_HC_DEV
Length - Frame List Length
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1456,7 +1462,7 @@ Arguments: Returns:
VOID
-
+
--*/
;
@@ -1475,12 +1481,12 @@ Arguments: HcDev - USB2_HC_DEV
NotifyFunction - Timer Notify Function
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1497,12 +1503,12 @@ Routine Description: Arguments:
HcDev - USB2_HC_DEV
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1519,12 +1525,12 @@ Routine Description: Arguments:
HcDev - USB2_HC_DEV
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1541,12 +1547,12 @@ Routine Description: Arguments:
HcDev - USB2_HC_DEV
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1567,18 +1573,18 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
Endpoint - Endpoint Number
DeviceSpeed - Device Speed
MaxPacketLen - Max Length of one Packet
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1599,18 +1605,18 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
DeviceSpeed - Device Speed
MaxPacketLen - Max Length of one Packet
Translator - Translator Transaction for SplitX
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1633,19 +1639,19 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
EndPointAddr - Address of Endpoint
DeviceSpeed - Device Speed
MaxPacketLen - Max Length of one Packet
Translator - Translator Transaction for SplitX
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1669,7 +1675,7 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
EndPointAddr - Address of Endpoint
DeviceSpeed - Device Speed
@@ -1677,12 +1683,12 @@ Arguments: Interval - value of interval
Translator - Translator Transaction for SplitX
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1695,17 +1701,17 @@ DestoryQh ( Routine Description:
- Destory Qh Structure
-
+ Destory Qh Structure
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
VOID
-
+
--*/
;
@@ -1727,19 +1733,19 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DataPtr - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
PktId - Packet Identification of this Qtd
Toggle - Data Toggle of this Qtd
QtdStatus - Default value of status of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
;
@@ -1753,19 +1759,19 @@ CreateSetupQtd ( Routine Description:
- Create Qtd Structure for Setup
+ Create Qtd Structure for Setup
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DevReqPtr - A pointer to Device Request Data
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
;
@@ -1782,22 +1788,22 @@ CreateDataQtd ( Routine Description:
- Create Qtd Structure for data
+ Create Qtd Structure for data
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DataPtr - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
PktId - Packet Identification of this Qtd
Toggle - Data Toggle of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
;
@@ -1811,19 +1817,19 @@ CreateStatusQtd ( Routine Description:
- Create Qtd Structure for status
+ Create Qtd Structure for status
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
PktId - Packet Identification of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
;
@@ -1837,19 +1843,19 @@ CreateAltQtd ( Routine Description:
- Create Qtd Structure for Alternative
+ Create Qtd Structure for Alternative
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
PktId - Packet Identification of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
;
@@ -1867,22 +1873,22 @@ CreateControlQtds ( Routine Description:
- Create Qtds list for Control Transfer
+ Create Qtds list for Control Transfer
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DataPktId - Packet Identification of Data Qtds
RequestCursor - A pointer to request structure buffer to transfer
DataCursor - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
ControlQtdsHead - A pointer of pointer to first Qtd for control tranfer for return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1899,23 +1905,23 @@ CreateBulkOrInterruptQtds ( Routine Description:
- Create Qtds list for Bulk or Interrupt Transfer
+ Create Qtds list for Bulk or Interrupt Transfer
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
PktId - Packet Identification of Qtds
DataCursor - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
DataToggle - Data Toggle to start
Translator - Translator Transaction for SplitX
QtdsHead - A pointer of pointer to first Qtd for control tranfer for return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -1932,9 +1938,9 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
- FirstQtdPtr - A pointer to first Qtd in the list
-
+ HcDev - USB2_HC_DEV
+ FirstQtdPtr - A pointer to first Qtd in the list
+
Returns:
VOID
@@ -1952,12 +1958,12 @@ LinkQtdToQtd ( Routine Description:
Link Qtds together
-
+
Arguments:
PreQtdPtr - A pointer to pre Qtd
QtdPtr - A pointer to next Qtd
-
+
Returns:
VOID
@@ -1975,12 +1981,12 @@ LinkQtdsToAltQtd ( Routine Description:
Link AlterQtds together
-
+
Arguments:
FirstQtdPtr - A pointer to first Qtd in the list
AltQtdPtr - A pointer to alternative Qtd
-
+
Returns:
VOID
@@ -1997,12 +2003,12 @@ LinkQtdToQh ( Routine Description:
Link Qtds list to Qh
-
+
Arguments:
QhPtr - A pointer to Qh
QtdPtr - A pointer to first Qtd in the list
-
+
Returns:
VOID
@@ -2020,17 +2026,17 @@ LinkQhToAsyncList ( Routine Description:
Link Qh to Async Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -2044,17 +2050,17 @@ UnlinkQhFromAsyncList ( Routine Description:
Unlink Qh from Async Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -2068,12 +2074,12 @@ LinkQhToPeriodicList ( Routine Description:
Link Qh to Periodic Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
VOID
@@ -2092,17 +2098,17 @@ UnlinkQhFromPeriodicList ( Routine Description:
Unlink Qh from Periodic Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
Interval - Interval of this periodic transfer
-
+
Returns:
VOID
-
+
--*/
;
@@ -2116,16 +2122,16 @@ LinkToAsyncReqeust ( Routine Description:
Llink AsyncRequest Entry to Async Request List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
AsyncRequestPtr - A pointer to Async Request Entry
-
+
Returns:
VOID
-
+
--*/
;
@@ -2139,16 +2145,16 @@ UnlinkFromAsyncReqeust ( Routine Description:
Unlink AsyncRequest Entry from Async Request List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
AsyncRequestPtr - A pointer to Async Request Entry
-
+
Returns:
VOID
-
+
--*/
;
@@ -2161,11 +2167,11 @@ GetNumberOfQtd ( Routine Description:
Number of Qtds in the list
-
+
Arguments:
FirstQtdPtr - A pointer to first Qtd in the list
-
+
Returns:
Number of Qtds in the list
@@ -2173,28 +2179,7 @@ Returns: --*/
;
-UINTN
-GetNumberOfTransaction (
- IN UINTN SizeOfData,
- IN UINTN SizeOfTransaction
- )
-/*++
-
-Routine Description:
- Number of Transactions in one Qtd
-
-Arguments:
-
- SizeOfData - Size of one Qtd
- SizeOfTransaction - Size of one Transaction
-
-Returns:
-
- Number of Transactions in this Qtd
-
---*/
-;
UINTN
GetCapacityOfQtd (
@@ -2205,11 +2190,11 @@ GetCapacityOfQtd ( Routine Description:
Get Capacity of Qtd
-
+
Arguments:
BufferCursor - BufferCursor of the Qtd
-
+
Returns:
Capacity of Qtd
@@ -2226,15 +2211,15 @@ GetApproxiOfInterval ( Routine Description:
Get the approximate value in the 2 index sequence
-
+
Arguments:
Interval - the value of interval
-
+
Returns:
approximate value of interval in the 2 index sequence
-
+
--*/
;
@@ -2247,15 +2232,15 @@ GetQtdNextPointer ( Routine Description:
Get Qtd next pointer field
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
A pointer to next hardware Qtd structure
-
+
--*/
;
@@ -2268,16 +2253,16 @@ IsQtdStatusActive ( Routine Description:
Whether Qtd status is active or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Active
FALSE Inactive
-
+
--*/
;
@@ -2290,16 +2275,16 @@ IsQtdStatusHalted ( Routine Description:
Whether Qtd status is halted or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Halted
FALSE Not halted
-
+
--*/
;
@@ -2312,16 +2297,16 @@ IsQtdStatusBufferError ( Routine Description:
Whether Qtd status is buffer error or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Buffer error
FALSE No buffer error
-
+
--*/
;
@@ -2334,16 +2319,16 @@ IsQtdStatusBabbleError ( Routine Description:
Whether Qtd status is babble error or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Babble error
FALSE No babble error
-
+
--*/
;
@@ -2356,16 +2341,16 @@ IsQtdStatusTransactionError ( Routine Description:
Whether Qtd status is transaction error or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Transaction error
FALSE No transaction error
-
+
--*/
;
@@ -2378,16 +2363,16 @@ IsDataInTransfer ( Routine Description:
Whether is a DataIn direction transfer
-
+
Arguments:
- EndPointAddress - address of the endpoint
-
+ EndPointAddress - address of the endpoint
+
Returns:
TRUE DataIn
FALSE DataOut
-
+
--*/
;
@@ -2406,22 +2391,22 @@ MapDataBuffer ( Routine Description:
Map address of user data buffer
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
TransferDirection - direction of transfer
- Data - A pointer to user data buffer
+ Data - A pointer to user data buffer
DataLength - length of user data
PktId - Packte Identificaion
DataCursor - mapped address to return
DataMap - identificaion of this mapping to return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -2437,19 +2422,19 @@ MapRequestBuffer ( Routine Description:
Map address of request structure buffer
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Request - A pointer to request structure
RequestCursor - Mapped address of request structure to return
RequestMap - Identificaion of this mapping to return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
;
@@ -2467,10 +2452,10 @@ Routine Description: Arguments:
- QtdHwPtr - A pointer to Qtd hardware structure
+ QtdHwPtr - A pointer to Qtd hardware structure
DataPtr - A pointer to user data buffer
DataLen - Length of the user data buffer
-
+
Returns:
VOID
@@ -2487,15 +2472,15 @@ GetQtdAlternateNextPointer ( Routine Description:
Get Qtd alternate next pointer field
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
A pointer to hardware alternate Qtd
-
+
--*/
;
@@ -2508,15 +2493,15 @@ ZeroOutQhOverlay ( Routine Description:
Zero out the fields in Qh structure
-
+
Arguments:
QhPtr - A pointer to Qh structure
-
+
Returns:
VOID
-
+
--*/
;
@@ -2531,17 +2516,17 @@ UpdateAsyncRequestTransfer ( Routine Description:
Update asynchronous request transfer
-
+
Arguments:
- AsyncRequestPtr - A pointer to async request
- TransferResult - transfer result
+ AsyncRequestPtr - A pointer to async request
+ TransferResult - transfer result
ErrQtdPos - postion of error Qtd
-
+
Returns:
VOID
-
+
--*/
;
@@ -2558,14 +2543,14 @@ DeleteAsyncRequestTransfer ( Routine Description:
Delete all asynchronous request transfer
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddress - address of usb device
EndPointAddress - address of endpoint
DataToggle - stored data toggle
-
+
Returns:
EFI_SUCCESS Success
@@ -2583,14 +2568,14 @@ CleanUpAllAsyncRequestTransfer ( Routine Description:
Clean up all asynchronous request transfer
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
VOID
-
+
--*/
;
@@ -2615,16 +2600,16 @@ Arguments: HcDev - USB2_HC_DEV
IsControl - Is control transfer or not
QhPtr - A pointer to Qh
- ActualLen - Actual transfered Len
+ ActualLen - Actual transfered Len
DataToggle - Data Toggle
TimeOut - TimeOut threshold
TransferResult - Transfer result
-
+
Returns:
EFI_SUCCESS Sucess
EFI_DEVICE_ERROR Error
-
+
--*/
;
@@ -2654,7 +2639,7 @@ Returns: TRUE Qtds finished
FALSE Not finish
-
+
--*/
;
@@ -2666,23 +2651,49 @@ AsyncRequestMoniter ( /*++
Routine Description:
-
+
Interrupt transfer periodic check handler
-
+
Arguments:
Event - Interrupt event
Context - Pointer to USB2_HC_DEV
-
+
Returns:
-
+
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
+--*/
+;
+
+
+EFI_STATUS
+CreateNULLQH (
+ IN USB2_HC_DEV *HcDev
+ )
+/*++
+
+Routine Description:
+
+ Create the NULL QH to make it as the Async QH header
+
+Arguments:
+
+ HcDev - USB2_HC_DEV
+
+Returns:
+
+ EFI_SUCCESS Success
--*/
;
VOID
+DestroyNULLQH (
+ IN USB2_HC_DEV *HcDev
+ );
+
+VOID
ClearLegacySupport (
IN USB2_HC_DEV *HcDev
);
@@ -2692,8 +2703,11 @@ HostReset ( IN USB2_HC_DEV *HcDev
);
-VOID
+
+VOID
DumpEHCIPortsStatus (
IN USB2_HC_DEV *HcDev
);
+
+
#endif
diff --git a/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciMem.c b/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciMem.c index aba27cb82c..9eef0537d0 100644 --- a/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciMem.c +++ b/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciMem.c @@ -1,20 +1,20 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
EhciMem.c
-
-Abstract:
-
+
+Abstract:
+
Revision History
--*/
@@ -40,13 +40,13 @@ Arguments: HcDev - USB2_HC_DEV
MemoryHeader - MEMORY_MANAGE_HEADER to output
MemoryBlockSizeInPages - MemoryBlockSizeInPages
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Fail for no resources
EFI_UNSUPPORTED Unsupported currently
-
+
--*/
{
EFI_STATUS Status;
@@ -73,7 +73,7 @@ Returns: //
// each bit in Bit Array will manage 32 bytes memory in memory block
//
- (*MemoryHeader)->BitArraySizeInBytes = ((*MemoryHeader)->MemoryBlockSizeInBytes / 32) / 8;
+ (*MemoryHeader)->BitArraySizeInBytes = ((*MemoryHeader)->MemoryBlockSizeInBytes / MEM_UNIT_SIZE) / 8;
//
// Allocate memory for BitArray
@@ -83,7 +83,7 @@ Returns: gBS->FreePool (*MemoryHeader);
return EFI_OUT_OF_RESOURCES;
}
-
+
//
// Memory Block uses MemoryBlockSizeInPages pages,
// and it is allocated as common buffer use.
@@ -112,7 +112,7 @@ Returns: &Mapping
);
//
- // If returned Mapped size is less than the size
+ // If returned Mapped size is less than the size
// we request,do not support.
//
if (EFI_ERROR (Status) || (MemoryBlockSizeInBytes != EFI_PAGES_TO_SIZE (MemoryBlockSizeInPages))) {
@@ -121,9 +121,9 @@ Returns: gBS->FreePool (*MemoryHeader);
return EFI_UNSUPPORTED;
}
-
+
//
- // Data structure involved by host controller
+ // Data structure involved by host controller
// should be restricted into the same 4G
//
if (HcDev->Is64BitCapable != 0) {
@@ -135,7 +135,7 @@ Returns: return EFI_UNSUPPORTED;
}
}
-
+
//
// Set Memory block initial address
//
@@ -240,16 +240,16 @@ Returns: ASSERT (MemoryHeader != NULL);
OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY + 1);
-
+
//
// allocate unit is 32 bytes (align on 32 byte)
//
- if (AllocSize & 0x1F) {
- RealAllocSize = (AllocSize / 32 + 1) * 32;
+ if (AllocSize & (MEM_UNIT_SIZE - 1)) {
+ RealAllocSize = (AllocSize / MEM_UNIT_SIZE + 1) * MEM_UNIT_SIZE;
} else {
RealAllocSize = AllocSize;
}
-
+
//
// There may be linked MemoryHeaders.
// To allocate a free pool in Memory blocks,
@@ -262,22 +262,26 @@ Returns: Status = AllocMemInMemoryBlock (
TempHeaderPtr,
(VOID **) Pool,
- RealAllocSize / 32
+ RealAllocSize / MEM_UNIT_SIZE
);
if (!EFI_ERROR (Status)) {
- ZeroMem (*Pool, AllocSize);
- gBS->RestoreTPL (OldTpl);
- return EFI_SUCCESS;
+ break;
}
}
gBS->RestoreTPL (OldTpl);
-
+
+ if (!EFI_ERROR (Status)) {
+ ZeroMem (*Pool, AllocSize);
+ return EFI_SUCCESS;
+ }
+
+
//
// There is no enough memory,
// Create a new Memory Block
//
-
+
//
// if pool size is larger than NORMAL_MEMORY_BLOCK_UNIT_IN_PAGES,
// just allocate a large enough memory block.
@@ -303,13 +307,15 @@ Returns: Status = AllocMemInMemoryBlock (
NewMemoryHeader,
(VOID **) Pool,
- RealAllocSize / 32
+ RealAllocSize / MEM_UNIT_SIZE
);
+
+ gBS->RestoreTPL (OldTpl);
+
if (!EFI_ERROR (Status)) {
ZeroMem (*Pool, AllocSize);
}
- gBS->RestoreTPL (OldTpl);
return Status;
}
@@ -354,12 +360,12 @@ Returns: //
// allocate unit is 32 byte (align on 32 byte)
//
- if (AllocSize & 0x1F) {
- RealAllocSize = (AllocSize / 32 + 1) * 32;
+ if (AllocSize & (MEM_UNIT_SIZE - 1)) {
+ RealAllocSize = (AllocSize / MEM_UNIT_SIZE + 1) * MEM_UNIT_SIZE;
} else {
RealAllocSize = AllocSize;
}
-
+
//
// scan the memory header linked list for
// the asigned memory to free.
@@ -373,14 +379,16 @@ Returns: // Pool is in the Memory Block area,
// find the start byte and bit in the bit array
//
- StartBytePos = ((Pool - TempHeaderPtr->MemoryBlockPtr) / 32) / 8;
- StartBitPos = (UINT8) (((Pool - TempHeaderPtr->MemoryBlockPtr) / 32) & 0x7);
+ StartBytePos = ((Pool - TempHeaderPtr->MemoryBlockPtr) / MEM_UNIT_SIZE) / 8;
+ StartBitPos = (UINT8) (((Pool - TempHeaderPtr->MemoryBlockPtr) / MEM_UNIT_SIZE) & 0x7);
//
// reset associated bits in bit arry
//
- for (Index = StartBytePos, Index2 = StartBitPos, Count = 0; Count < (RealAllocSize / 32); Count++) {
- TempHeaderPtr->BitArrayPtr[Index] = (UINT8) (TempHeaderPtr->BitArrayPtr[Index] ^ (bit (Index2)));
+ for (Index = StartBytePos, Index2 = StartBitPos, Count = 0; Count < (RealAllocSize / MEM_UNIT_SIZE); Count++) {
+ ASSERT ((TempHeaderPtr->BitArrayPtr[Index] & bit (Index2) )== bit (Index2));
+
+ TempHeaderPtr->BitArrayPtr[Index] ^= (UINT8) (bit (Index2));
Index2++;
if (Index2 == 8) {
Index += 1;
@@ -393,7 +401,7 @@ Returns: break;
}
}
-
+
//
// Release emptied memory blocks (only if the memory block is not
// the first one in the memory header list
@@ -479,7 +487,7 @@ Arguments: Returns:
EFI_SUCCESS Success
- EFI_NOT_FOUND Can't find the free memory
+ EFI_NOT_FOUND Can't find the free memory
--*/
{
@@ -508,7 +516,7 @@ Returns: //
// right shift the byte
//
- ByteValue /= 2;
+ ByteValue = ByteValue >> 1;
if (BitValue == 0) {
//
@@ -564,11 +572,11 @@ Returns: if (NumberOfZeros < NumberOfMemoryUnit) {
return EFI_NOT_FOUND;
}
-
+
//
// Found enough free space.
//
-
+
//
// The values recorded in (FoundBytePos,FoundBitPos) have two conditions:
// 1)(FoundBytePos,FoundBitPos) record the position
@@ -581,7 +589,7 @@ Returns: if ((MemoryHeader->BitArrayPtr[FoundBytePos] & bit (FoundBitPos)) != 0) {
FoundBitPos += 1;
}
-
+
//
// Have the (FoundBytePos,FoundBitPos) make sense.
//
@@ -589,13 +597,14 @@ Returns: FoundBytePos += 1;
FoundBitPos -= 8;
}
-
+
//
// Set the memory as allocated
//
for (TempBytePos = FoundBytePos, Index = FoundBitPos, Count = 0; Count < NumberOfMemoryUnit; Count++) {
- MemoryHeader->BitArrayPtr[TempBytePos] = (UINT8) (MemoryHeader->BitArrayPtr[TempBytePos] | (bit (Index)));
+ ASSERT ((MemoryHeader->BitArrayPtr[TempBytePos] & bit (Index) )== 0);
+ MemoryHeader->BitArrayPtr[TempBytePos] |= bit (Index);
Index++;
if (Index == 8) {
TempBytePos += 1;
@@ -603,7 +612,7 @@ Returns: }
}
- *Pool = MemoryHeader->MemoryBlockPtr + (FoundBytePos * 8 + FoundBitPos) * 32;
+ *Pool = MemoryHeader->MemoryBlockPtr + (FoundBytePos * 8 + FoundBitPos) * MEM_UNIT_SIZE;
return EFI_SUCCESS;
}
@@ -625,7 +634,7 @@ Arguments: Returns:
TRUE Empty
- FALSE Not Empty
+ FALSE Not Empty
--*/
{
@@ -675,6 +684,7 @@ Returns: // Link the before and after
//
TempHeaderPtr->Next = NeedFreeMemoryHeader->Next;
+ NeedFreeMemoryHeader->Next = NULL;
break;
}
}
@@ -698,7 +708,7 @@ Returns: EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -736,7 +746,7 @@ Returns: EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
MEMORY_MANAGE_HEADER *TempHeaderPtr;
diff --git a/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciReg.c b/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciReg.c index d5271c25b2..78bca3b767 100644 --- a/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciReg.c +++ b/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciReg.c @@ -1,20 +1,20 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Ehchlp.c
-
-Abstract:
-
+
+Abstract:
+
Revision History
--*/
@@ -29,7 +29,7 @@ HostReset ( {
UINT32 Value;
UINT32 TimeOut;
-
+
ReadEhcOperationalReg (
HcDev,
USBCMD,
@@ -102,18 +102,18 @@ ReadEhcCapabiltiyReg ( Routine Description:
Read Ehc Capabitlity register
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
CapabiltiyRegAddr - Ehc Capability register address
Data - A pointer to data read from register
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
return HcDev->PciIo->Mem.Read (
@@ -137,18 +137,18 @@ ReadEhcOperationalReg ( Routine Description:
Read Ehc Operation register
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
OperationalRegAddr - Ehc Operation register address
Data - A pointer to data read from register
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
ASSERT (HcDev->UsbCapabilityLen);
@@ -173,18 +173,18 @@ WriteEhcOperationalReg ( Routine Description:
Write Ehc Operation register
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
OperationalRegAddr - Ehc Operation register address
Data - 32bit write to register
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
ASSERT (HcDev->UsbCapabilityLen);
@@ -198,6 +198,8 @@ Returns: );
}
+
+
VOID
ClearLegacySupport (
IN USB2_HC_DEV *HcDev
@@ -239,7 +241,7 @@ Returns: EfiPciIoWidthUint32,
EECP,
1,
- &Value
+ &Value
);
DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value));
@@ -249,7 +251,7 @@ Returns: EfiPciIoWidthUint32,
EECP + 0x4,
1,
- &Value
+ &Value
);
DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value));
@@ -259,7 +261,7 @@ Returns: EfiPciIoWidthUint32,
EECP,
1,
- &Value
+ &Value
);
Value = Value | (0x1 << 24);
@@ -270,7 +272,7 @@ Returns: EfiPciIoWidthUint32,
EECP,
1,
- &Value
+ &Value
);
TimeOut = 40;
@@ -282,7 +284,7 @@ Returns: EfiPciIoWidthUint32,
EECP,
1,
- &Value
+ &Value
);
if ((Value & 0x01010000) == 0x01000000) {
break;
@@ -291,8 +293,8 @@ Returns: if (TimeOut == 0) {
DEBUG((gEHCErrorLevel, "Timeout for getting HC OS Owned Semaphore\n" ));
- }
-
+ }
+
DEBUG((gEHCErrorLevel, "After Release Value\n" ));
HcDev->PciIo->Pci.Read (
@@ -300,7 +302,7 @@ Returns: EfiPciIoWidthUint32,
EECP,
1,
- &Value
+ &Value
);
DEBUG((gEHCDebugLevel, "EECP[0] = 0x%x\n", Value));
@@ -310,7 +312,7 @@ Returns: EfiPciIoWidthUint32,
EECP + 0x4,
1,
- &Value
+ &Value
);
DEBUG((gEHCDebugLevel, "EECP[4] = 0x%x\n", Value));
@@ -327,16 +329,16 @@ GetCapabilityLen ( Routine Description:
Get the length of capability register
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -364,18 +366,18 @@ SetFrameListLen ( Routine Description:
Set the length of Frame List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Length - the required length of frame list
-
+
Returns:
EFI_SUCCESS Success
EFI_INVALID_PARAMETER Invalid parameter
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -428,14 +430,14 @@ SetFrameListBaseAddr ( Routine Description:
Set base address of frame list first entry
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
FrameBuffer - base address of first entry of frame list
-
+
Returns:
-
+
--*/
{
EFI_STATUS Status;
@@ -474,17 +476,17 @@ SetAsyncListAddr ( Routine Description:
Set address of first Async schedule Qh
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to first Qh in the Async schedule
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -512,16 +514,16 @@ SetCtrlDataStructSeg ( Routine Description:
Set register of control and data structure segment
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
@@ -550,16 +552,16 @@ SetPortRoutingEhc ( Routine Description:
Set Ehc port routing bit
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -601,16 +603,16 @@ SetEhcDoorbell ( Routine Description:
Set Ehc door bell bit
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -652,16 +654,16 @@ ClearEhcAllStatus ( Routine Description:
Clear Ehc all status bits
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
UINT32 UsbStatusAddr;
@@ -684,16 +686,16 @@ EnablePeriodicSchedule ( Routine Description:
Enable periodic schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -735,16 +737,16 @@ DisablePeriodicSchedule ( Routine Description:
Disable periodic schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -784,16 +786,16 @@ EnableAsynchronousSchedule ( Routine Description:
Enable asynchrounous schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -835,16 +837,16 @@ DisableAsynchronousSchedule ( Routine Description:
Disable asynchrounous schedule
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -884,16 +886,16 @@ ResetEhc ( Routine Description:
Reset Ehc
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -935,16 +937,16 @@ StartScheduleExecution ( Routine Description:
Start Ehc schedule execution
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -986,16 +988,16 @@ IsFrameListProgrammable ( Routine Description:
Whether frame list is programmable
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Programmable
FALSE Unprogrammable
-
+
--*/
{
BOOLEAN Value;
@@ -1028,16 +1030,16 @@ IsPeriodicScheduleEnabled ( Routine Description:
Whether periodic schedule is enabled
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Enabled
FALSE Disabled
-
+
--*/
{
BOOLEAN Value;
@@ -1070,16 +1072,16 @@ IsAsyncScheduleEnabled ( Routine Description:
Whether asynchronous schedule is enabled
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Enabled
FALSE Disabled
-
+
--*/
{
BOOLEAN Value;
@@ -1113,16 +1115,16 @@ IsEhcPortEnabled ( Routine Description:
Whether port is enabled
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Enabled
FALSE Disabled
-
+
--*/
{
UINT32 PortStatusControlAddr;
@@ -1148,16 +1150,16 @@ IsEhcReseted ( Routine Description:
Whether Ehc is reseted
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Reseted
FALSE Unreseted
-
+
--*/
{
BOOLEAN Value;
@@ -1190,16 +1192,16 @@ IsEhcHalted ( Routine Description:
Whether Ehc is halted
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE Halted
FALSE Not halted
-
+
--*/
{
BOOLEAN Value;
@@ -1232,16 +1234,16 @@ IsEhcSysError ( Routine Description:
Whether Ehc is system error
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE System error
FALSE No system error
-
+
--*/
{
BOOLEAN Value;
@@ -1268,29 +1270,29 @@ Returns: BOOLEAN
IsHighSpeedDevice (
IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 PortNum
+ IN UINT8 PortNum
)
/*++
Routine Description:
Whether high speed device attached
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
TRUE High speed
FALSE Full speed
-
+
--*/
{
USB2_HC_DEV *HcDev;
UINT32 PortStatusControlAddr;
UINT32 PortStatusControlReg;
-
+
HcDev = USB2_HC_DEV_FROM_THIS (This);
PortStatusControlAddr = (UINT32) (PORTSC + (4 * PortNum));
@@ -1360,17 +1362,17 @@ WaitForEhcReset ( Routine Description:
wait for Ehc reset or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1406,17 +1408,17 @@ WaitForEhcHalt ( Routine Description:
wait for Ehc halt or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1452,17 +1454,17 @@ WaitForEhcNotHalt ( Routine Description:
wait for Ehc not halt or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1498,17 +1500,17 @@ WaitForAsyncScheduleEnable ( Routine Description:
Wait for Ehc asynchronous schedule enable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1544,17 +1546,17 @@ WaitForAsyncScheduleDisable ( Routine Description:
Wait for Ehc asynchronous schedule disable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1590,17 +1592,17 @@ WaitForPeriodicScheduleEnable ( Routine Description:
Wait for Ehc periodic schedule enable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1636,17 +1638,17 @@ WaitForPeriodicScheduleDisable ( Routine Description:
Wait for periodic schedule disable or timeout
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
-
+
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1685,14 +1687,14 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Timeout - timeout threshold
Returns:
EFI_SUCCESS Success
EFI_TIMEOUT Timeout
-
+
--*/
{
EFI_STATUS Status;
@@ -1702,7 +1704,7 @@ Returns: UsbCommandAddr = USBCMD;
Delay = (Timeout / 50) + 1;
-
+
do {
Status = ReadEhcOperationalReg (
HcDev,
diff --git a/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciSched.c b/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciSched.c index 48432c0b98..34e31a896f 100644 --- a/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciSched.c +++ b/EdkModulePkg/Bus/Pci/Ehci/Dxe/EhciSched.c @@ -1,26 +1,175 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
EhciSched.c
-
-Abstract:
-
+
+Abstract:
+
Revision History
--*/
#include "Ehci.h"
+
+EFI_STATUS
+SetAndWaitDoorBell (
+ IN USB2_HC_DEV *HcDev,
+ IN UINTN Timeout
+ )
+/*++
+
+Routine Description:
+
+ Set DoorBell and wait it to complete
+
+Arguments:
+
+ HcDev - USB2_HC_DEV
+
+Returns:
+
+ EFI_SUCCESS Success
+ EFI_DEVICE_ERROR Fail
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 Data;
+ UINTN Delay;
+
+ Status = ReadEhcOperationalReg (
+ HcDev,
+ USBCMD,
+ &Data
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto exit;
+ }
+
+ Data |= USBCMD_IAAD;
+ Status = WriteEhcOperationalReg (
+ HcDev,
+ USBCMD,
+ Data
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Timeout is in US unit
+ //
+ Delay = (Timeout / 50) + 1;
+ do {
+ Status = ReadEhcOperationalReg (
+ HcDev,
+ USBSTS,
+ &Data
+ );
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto exit;
+ }
+
+ if ((Data & USBSTS_IAA) == USBSTS_IAA) {
+ break;
+ }
+
+ gBS->Stall (EHCI_GENERIC_RECOVERY_TIME);
+
+ } while (Delay--);
+
+ Data = Data & 0xFFFFFFC0;
+ Data |= USBSTS_IAA;
+ Status = WriteEhcOperationalReg (
+ HcDev,
+ USBSTS,
+ Data
+ );
+
+exit:
+ return Status;
+}
+
+
+
+
+
+EFI_STATUS
+CreateNULLQH (
+ IN USB2_HC_DEV *HcDev
+ )
+/*++
+
+Routine Description:
+
+ Create the NULL QH to make it as the Async QH header
+
+Arguments:
+
+ HcDev - USB2_HC_DEV
+
+Returns:
+
+ EFI_SUCCESS Success
+--*/
+{
+ EFI_STATUS Status;
+ EHCI_QH_ENTITY *NULLQhPtr;
+ //
+ // Allocate memory for Qh structure
+ //
+ Status = EhciAllocatePool (
+ HcDev,
+ (UINT8 **) &NULLQhPtr,
+ sizeof (EHCI_QH_ENTITY)
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ NULLQhPtr->Qh.Status = QTD_STATUS_HALTED;
+ NULLQhPtr->Qh.HeadReclamationFlag = 1;
+ NULLQhPtr->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(NULLQhPtr->Qh) >> 5));
+ NULLQhPtr->Qh.SelectType = QH_SELECT_TYPE;
+ NULLQhPtr->Qh.NextQtdTerminate = 1;
+
+ NULLQhPtr->Next = NULLQhPtr;
+ NULLQhPtr->Prev = NULLQhPtr;
+
+ HcDev->NULLQH = NULLQhPtr;
+
+ return Status;
+}
+
+
+
+VOID
+DestroyNULLQH (
+ IN USB2_HC_DEV *HcDev
+ )
+{
+
+ if (HcDev->NULLQH != NULL) {
+ EhciFreePool (HcDev, (UINT8 *)HcDev->NULLQH, sizeof (EHCI_QH_ENTITY));
+ HcDev->NULLQH = NULL;
+ }
+}
+
+
+
EFI_STATUS
InitialPeriodicFrameList (
IN USB2_HC_DEV *HcDev,
@@ -36,7 +185,7 @@ Arguments: HcDev - USB2_HC_DEV
Length - Frame List Length
-
+
Returns:
EFI_SUCCESS Success
@@ -52,7 +201,7 @@ Returns: UINTN BufferSizeInBytes;
UINTN FrameIndex;
FRAME_LIST_ENTRY *FrameEntryPtr;
-
+
//
// The Frame List is a common buffer that will be
// accessed by both the cpu and the usb bus master
@@ -99,7 +248,7 @@ Returns: }
//
- // Put high 32bit into CtrlDataStructSeg reg
+ // Put high 32bit into CtrlDataStructSeg reg
// when 64bit addressing range capability
//
if (HcDev->Is64BitCapable != 0) {
@@ -112,7 +261,7 @@ Returns: goto unmap_buffer;
}
}
-
+
//
// Tell the Host Controller where the Frame List lies,
// by set the Frame List Base Address Register.
@@ -166,7 +315,7 @@ Arguments: Returns:
VOID
-
+
--*/
{
HcDev->PciIo->Unmap (HcDev->PciIo, HcDev->PeriodicFrameListMap);
@@ -189,12 +338,12 @@ Arguments: HcDev - USB2_HC_DEV
NotifyFunction - Timer Notify Function
-
+
Returns:
-
+
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
return gBS->CreateEvent (
@@ -219,12 +368,12 @@ Routine Description: Arguments:
HcDev - USB2_HC_DEV
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
return gBS->CloseEvent (HcDev->AsyncRequestEvent);
@@ -243,12 +392,12 @@ Routine Description: Arguments:
HcDev - USB2_HC_DEV
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
return gBS->SetTimer (
@@ -271,12 +420,12 @@ Routine Description: Arguments:
HcDev - USB2_HC_DEV
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
return gBS->SetTimer (
@@ -303,18 +452,18 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
Endpoint - Endpoint Number
DeviceSpeed - Device Speed
MaxPacketLen - Max Length of one Packet
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
EFI_STATUS Status;
@@ -337,10 +486,6 @@ Returns: Status = EFI_OUT_OF_RESOURCES;
goto exit;
}
- //
- // Init fields in Qh
- //
- ZeroMem (*QhPtrPtr, sizeof (EHCI_QH_ENTITY));
//
// Software field
@@ -359,8 +504,8 @@ Returns: QhHwPtr->SelectType = 0;
QhHwPtr->MaxPacketLen = (UINT32) MaxPacketLen;
QhHwPtr->EndpointSpeed = (DeviceSpeed & 0x3);
- QhHwPtr->EndpointNum = (Endpoint & 0x0f);
- QhHwPtr->DeviceAddr = (DeviceAddr & 0x7f);
+ QhHwPtr->EndpointNum = (Endpoint & 0x0F);
+ QhHwPtr->DeviceAddr = (DeviceAddr & 0x7F);
QhHwPtr->Multiplier = HIGH_BANDWIDTH_PIPE_MULTIPLIER;
QhHwPtr->Rsvd1 = 0;
QhHwPtr->Rsvd2 = 0;
@@ -382,18 +527,18 @@ DestoryQh ( Routine Description:
- Destory Qh Structure
-
+ Destory Qh Structure
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
ASSERT (HcDev);
@@ -420,18 +565,18 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
DeviceSpeed - Device Speed
MaxPacketLen - Max Length of one Packet
Translator - Translator Transaction for SplitX
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
EFI_STATUS Status;
@@ -467,7 +612,9 @@ Returns: (*QhPtrPtr)->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&((*QhPtrPtr)->Qh)) >> 5);
(*QhPtrPtr)->Qh.SelectType = QH_SELECT_TYPE;
(*QhPtrPtr)->Qh.QhTerminate = FALSE;
- (*QhPtrPtr)->Qh.ControlEndpointFlag = TRUE;
+ if (EFI_USB_SPEED_HIGH != DeviceSpeed) {
+ (*QhPtrPtr)->Qh.ControlEndpointFlag = TRUE;
+ }
(*QhPtrPtr)->Qh.NakCountReload = NAK_COUNT_RELOAD;
if (NULL != Translator) {
(*QhPtrPtr)->Qh.PortNum = Translator->TranslatorPortNumber;
@@ -498,19 +645,19 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
EndPointAddr - Address of Endpoint
DeviceSpeed - Device Speed
MaxPacketLen - Max Length of one Packet
Translator - Translator Transaction for SplitX
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
EFI_STATUS Status;
@@ -530,7 +677,7 @@ Returns: Status = EFI_OUT_OF_RESOURCES;
goto exit;
}
-
+
//
// Software fields
//
@@ -543,7 +690,7 @@ Returns: //
// BulkTransfer don't use DataToggleControl
//
- (*QhPtrPtr)->Qh.DataToggleControl = FALSE;
+ (*QhPtrPtr)->Qh.DataToggleControl = FALSE;
(*QhPtrPtr)->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&((*QhPtrPtr)->Qh)) >> 5);
(*QhPtrPtr)->Qh.SelectType = QH_SELECT_TYPE;
(*QhPtrPtr)->Qh.QhTerminate = FALSE;
@@ -579,7 +726,7 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddr - Address of Device
EndPointAddr - Address of Endpoint
DeviceSpeed - Device Speed
@@ -587,12 +734,12 @@ Arguments: Interval - value of interval
Translator - Translator Transaction for SplitX
QhPtrPtr - A pointer of pointer to Qh for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
EFI_STATUS Status;
@@ -612,7 +759,7 @@ Returns: Status = EFI_OUT_OF_RESOURCES;
goto exit;
}
-
+
//
// Software fields
//
@@ -663,19 +810,19 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DataPtr - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
PktId - Packet Identification of this Qtd
Toggle - Data Toggle of this Qtd
QtdStatus - Default value of status of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
EFI_STATUS Status;
@@ -696,11 +843,6 @@ Returns: Status = EFI_OUT_OF_RESOURCES;
goto exit;
}
- //
- // Init fields in Qtd
- //
-
- ZeroMem (*QtdPtrPtr, sizeof (EHCI_QTD_ENTITY));
//
// Software field
@@ -750,7 +892,7 @@ Returns: Status = EFI_INVALID_PARAMETER;
goto exit;
}
-
+
//
// Set Data Buffer Pointers
//
@@ -777,19 +919,19 @@ CreateSetupQtd ( Routine Description:
- Create Qtd Structure for Setup
+ Create Qtd Structure for Setup
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DevReqPtr - A pointer to Device Request Data
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
return CreateQtd (
@@ -816,22 +958,22 @@ CreateDataQtd ( Routine Description:
- Create Qtd Structure for data
+ Create Qtd Structure for data
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DataPtr - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
PktId - Packet Identification of this Qtd
Toggle - Data Toggle of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
return CreateQtd (
@@ -855,19 +997,19 @@ CreateAltQtd ( Routine Description:
- Create Qtd Structure for Alternative
+ Create Qtd Structure for Alternative
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
PktId - Packet Identification of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
return CreateQtd (
@@ -891,19 +1033,19 @@ CreateStatusQtd ( Routine Description:
- Create Qtd Structure for status
+ Create Qtd Structure for status
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
PktId - Packet Identification of this Qtd
QtdPtrPtr - A pointer of pointer to Qtd for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
return CreateQtd (
@@ -931,22 +1073,22 @@ CreateControlQtds ( Routine Description:
- Create Qtds list for Control Transfer
+ Create Qtds list for Control Transfer
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DataPktId - Packet Identification of Data Qtds
RequestCursor - A pointer to request structure buffer to transfer
DataCursor - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
ControlQtdsHead - A pointer of pointer to first Qtd for control tranfer for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
EFI_STATUS Status;
@@ -961,8 +1103,7 @@ Returns: UINTN CapacityOfQtd;
UINTN SizePerQtd;
UINTN DataCount;
- UINTN Xnum;
-
+
QtdPtr = NULL;
PreQtdPtr = NULL;
SetupQtdPtr = NULL;
@@ -983,7 +1124,7 @@ Returns: Status = EFI_OUT_OF_RESOURCES;
goto exit;
}
-
+
//
// Data Stage of Control Transfer
//
@@ -1026,14 +1167,8 @@ Returns: LinkQtdToQtd (PreQtdPtr, QtdPtr);
}
- //
- // Reverse Data Toggle or not determined by parity of transactions of one qtd
- //
- Xnum = Translator ? GetNumberOfTransaction (SizePerQtd, EHCI_BLOCK_SIZE_WITH_TT) : GetNumberOfTransaction (SizePerQtd, EHCI_BLOCK_SIZE);
- if (Xnum % 2 != 0) {
- DataToggle ^= 1;
- }
-
+ DataToggle ^= 1;
+
PreQtdPtr = QtdPtr;
DataCursor += SizePerQtd;
DataCount -= SizePerQtd;
@@ -1059,7 +1194,7 @@ Returns: Status = EFI_OUT_OF_RESOURCES;
goto destory_qtds;
}
-
+
//
// Link setup Qtd -> data Qtds -> status Qtd
//
@@ -1095,23 +1230,23 @@ CreateBulkOrInterruptQtds ( Routine Description:
- Create Qtds list for Bulk or Interrupt Transfer
+ Create Qtds list for Bulk or Interrupt Transfer
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
PktId - Packet Identification of Qtds
DataCursor - A pointer to user data buffer to transfer
DataLen - Length of user data to transfer
DataToggle - Data Toggle to start
Translator - Translator Transaction for SplitX
QtdsHead - A pointer of pointer to first Qtd for control tranfer for return
-
+
Returns:
EFI_SUCCESS Success
EFI_OUT_OF_RESOURCES Cannot allocate resources
-
+
--*/
{
EFI_STATUS Status;
@@ -1166,11 +1301,11 @@ Returns: DataCursor += SizePerQtd;
DataCount -= SizePerQtd;
}
-
+
//
// Set Alternate Qtd
//
- if (INPUT_PACKET_ID == PktId && 1 < GetNumberOfQtd (FirstQtdPtr)) {
+ if (INPUT_PACKET_ID == PktId && 0 < GetNumberOfQtd (FirstQtdPtr)) {
Status = CreateAltQtd (
HcDev,
PktId,
@@ -1206,9 +1341,9 @@ Routine Description: Arguments:
- HcDev - USB2_HC_DEV
- FirstQtdPtr - A pointer to first Qtd in the list
-
+ HcDev - USB2_HC_DEV
+ FirstQtdPtr - A pointer to first Qtd in the list
+
Returns:
VOID
@@ -1246,11 +1381,11 @@ GetNumberOfQtd ( Routine Description:
Number of Qtds in the list
-
+
Arguments:
FirstQtdPtr - A pointer to first Qtd in the list
-
+
Returns:
Number of Qtds in the list
@@ -1262,8 +1397,6 @@ Returns: Count = 0;
QtdPtr = FirstQtdPtr;
- ;
-
while (NULL != QtdPtr) {
Count++;
QtdPtr = QtdPtr->Next;
@@ -1273,33 +1406,6 @@ Returns: }
UINTN
-GetNumberOfTransaction (
- IN UINTN SizeOfData,
- IN UINTN SizeOfTransaction
- )
-/*++
-
-Routine Description:
-
- Number of Transactions in one Qtd
-
-Arguments:
-
- SizeOfData - Size of one Qtd
- SizeOfTransaction - Size of one Transaction
-
-Returns:
-
- Number of Transactions in this Qtd
-
---*/
-{
-
- return ((SizeOfData & (SizeOfTransaction - 1)) ? SizeOfData / SizeOfTransaction + 1 : SizeOfData / SizeOfTransaction);
-
-}
-
-UINTN
GetCapacityOfQtd (
IN UINT8 *BufferCursor
)
@@ -1308,11 +1414,11 @@ GetCapacityOfQtd ( Routine Description:
Get Size of First Qtd
-
+
Arguments:
BufferCursor - BufferCursor of the Qtd
-
+
Returns:
Size of First Qtd
@@ -1320,7 +1426,11 @@ Returns: --*/
{
- return (EHCI_MAX_QTD_CAPACITY - (EHCI_BLOCK_SIZE * GetNumberOfTransaction (EFI_PAGE_MASK & GET_0B_TO_31B (BufferCursor), EHCI_BLOCK_SIZE)));
+ if (EFI_PAGE_MASK & GET_0B_TO_31B (BufferCursor)) {
+ return EFI_PAGE_SIZE * 4;
+ } else {
+ return EFI_PAGE_SIZE * 5;
+ }
}
@@ -1333,15 +1443,15 @@ GetApproxiOfInterval ( Routine Description:
Get the approximate value in the 2 index sequence
-
+
Arguments:
Interval - the value of interval
-
+
Returns:
approximate value of interval in the 2 index sequence
-
+
--*/
{
UINTN Orignate;
@@ -1371,15 +1481,15 @@ GetQtdAlternateNextPointer ( Routine Description:
Get Qtd alternate next pointer field
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
A pointer to hardware alternate Qtd
-
+
--*/
{
EHCI_QTD_HW *Value;
@@ -1402,15 +1512,15 @@ GetQtdNextPointer ( Routine Description:
Get Qtd next pointer field
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
A pointer to next hardware Qtd structure
-
+
--*/
{
EHCI_QTD_HW *Value;
@@ -1424,8 +1534,9 @@ Returns: return Value;
}
-VOID LinkQtdToQtd (
- IN EHCI_QTD_ENTITY * PreQtdPtr,
+VOID
+LinkQtdToQtd (
+ IN EHCI_QTD_ENTITY * PreQtdPtr,
IN EHCI_QTD_ENTITY * QtdPtr
)
/*++
@@ -1433,12 +1544,12 @@ VOID LinkQtdToQtd ( Routine Description:
Link Qtds together
-
+
Arguments:
PreQtdPtr - A pointer to pre Qtd
QtdPtr - A pointer to next Qtd
-
+
Returns:
VOID
@@ -1467,8 +1578,9 @@ Returns: }
-VOID LinkQtdsToAltQtd (
- IN EHCI_QTD_ENTITY * FirstQtdPtr,
+VOID
+LinkQtdsToAltQtd (
+ IN EHCI_QTD_ENTITY * FirstQtdPtr,
IN EHCI_QTD_ENTITY * AltQtdPtr
)
/*++
@@ -1476,12 +1588,12 @@ VOID LinkQtdsToAltQtd ( Routine Description:
Link AlterQtds together
-
+
Arguments:
FirstQtdPtr - A pointer to first Qtd in the list
AltQtdPtr - A pointer to alternative Qtd
-
+
Returns:
VOID
@@ -1496,7 +1608,7 @@ Returns: AltQtdHwPtr = &(AltQtdPtr->Qtd);
QtdPtr = FirstQtdPtr;
-
+
while (NULL != QtdPtr) {
//
// Software link
@@ -1523,12 +1635,12 @@ LinkQtdToQh ( Routine Description:
Link Qtds list to Qh
-
+
Arguments:
QhPtr - A pointer to Qh
QtdPtr - A pointer to first Qtd in the list
-
+
Returns:
VOID
@@ -1560,6 +1672,18 @@ Returns: QhPtr->Qh.NextQtdPointer = (UINT32) (GET_0B_TO_31B (QtdHwPtr) >> 5);
QhPtr->Qh.NextQtdTerminate = FALSE;
+ QhPtr->Qh.AltNextQtdPointer = 0;
+ QhPtr->Qh.AltNextQtdTerminate = TRUE;
+
+
+ if ((QtdPtr->Qtd.PidCode == OUTPUT_PACKET_PID_CODE) &&
+ (QhPtr->TransferType == BULK_TRANSFER)) {
+ //
+ //Start PING first
+ //
+ QhPtr->Qh.Status |= QTD_STATUS_DO_PING;
+ }
+
return ;
}
@@ -1573,17 +1697,17 @@ LinkQhToAsyncList ( Routine Description:
Link Qh to Async Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -1591,9 +1715,23 @@ Returns: ASSERT (HcDev);
ASSERT (QhPtr);
- QhPtr->Qh.HeadReclamationFlag = TRUE;
- Status = SetAsyncListAddr (HcDev, QhPtr);
+ //
+ // NULL QH created before
+ //
+
+ HcDev->NULLQH->Next = QhPtr;
+ HcDev->NULLQH->Prev = QhPtr;
+
+ QhPtr->Next = HcDev->NULLQH;
+ QhPtr->Prev = HcDev->NULLQH;
+
+
+ HcDev->NULLQH->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(QhPtr->Qh) >> 5));
+ QhPtr->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(HcDev->NULLQH->Qh) >> 5));
+
+
+ Status = SetAsyncListAddr (HcDev, HcDev->NULLQH);
if (EFI_ERROR (Status)) {
Status = EFI_DEVICE_ERROR;
goto exit;
@@ -1609,7 +1747,7 @@ Returns: Status = WaitForAsyncScheduleEnable (HcDev, EHCI_GENERIC_TIMEOUT);
if (EFI_ERROR (Status)) {
- DEBUG ((gEHCDebugLevel, "WaitForAsyncScheduleEnable TimeOut"));
+ DEBUG ((gEHCDebugLevel, "EHCI: WaitForAsyncScheduleEnable TimeOut"));
Status = EFI_TIMEOUT;
goto exit;
}
@@ -1637,17 +1775,17 @@ UnlinkQhFromAsyncList ( Routine Description:
Unlink Qh from Async Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -1657,23 +1795,37 @@ Returns: ASSERT (HcDev);
ASSERT (QhPtr);
- if (QhPtr == QhPtr->Next) {
- Status = DisableAsynchronousSchedule (HcDev);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto exit;
- }
+ HcDev->NULLQH->Next = HcDev->NULLQH;
+ HcDev->NULLQH->Prev = HcDev->NULLQH;
- Status = WaitForAsyncScheduleDisable (HcDev, EHCI_GENERIC_TIMEOUT);
- if (EFI_ERROR (Status)) {
- DEBUG ((gEHCErrorLevel, "WaitForAsyncScheduleDisable TimeOut\n"));
- Status = EFI_TIMEOUT;
- goto exit;
- }
+ QhPtr->Next = QhPtr;
+ QhPtr->Prev = QhPtr;
+
+ HcDev->NULLQH->Qh.QhHorizontalPointer = (UINT32) (GET_0B_TO_31B (&(HcDev->NULLQH->Qh) >> 5));
+
+
+ SetAndWaitDoorBell (HcDev, 2 * EHCI_GENERIC_TIMEOUT);
+
+ QhPtr->Qh.QhTerminate = 1;
+ QhPtr->Qh.QhHorizontalPointer = 0;
+
+
+ Status = DisableAsynchronousSchedule (HcDev);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ goto exit;
}
+ Status = WaitForAsyncScheduleDisable (HcDev, EHCI_GENERIC_TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((gEHCErrorLevel, "EHCI: WaitForAsyncScheduleDisable TimeOut\n"));
+ Status = EFI_TIMEOUT;
+ goto exit;
+ }
+
+
exit:
return Status;
}
@@ -1688,16 +1840,16 @@ LinkQhToPeriodicList ( Routine Description:
Link Qh to Periodic Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
-
+
Returns:
VOID
-
+
--*/
{
FRAME_LIST_ENTRY *FrameEntryPtr;
@@ -1720,7 +1872,7 @@ Returns: //
// AsyncInterruptTransfer Qh
//
-
+
//
// Link to Frame[0] List
//
@@ -1835,11 +1987,11 @@ Returns: }
}
} else {
-
+
//
// SyncInterruptTransfer Qh
//
-
+
if (!FrameEntryPtr->LinkTerminate) {
//
// Not Null FrameList
@@ -1883,17 +2035,17 @@ UnlinkQhFromPeriodicList ( Routine Description:
Unlink Qh from Periodic Schedule List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
QhPtr - A pointer to Qh
Interval - Interval of this periodic transfer
-
+
Returns:
VOID
-
+
--*/
{
FRAME_LIST_ENTRY *FrameEntryPtr;
@@ -1908,11 +2060,11 @@ Returns: FrameEntryPtr = (FRAME_LIST_ENTRY *) HcDev->PeriodicFrameListBuffer;
if (QhPtr->TransferType == ASYNC_INTERRUPT_TRANSFER) {
-
+
//
// AsyncInterruptTransfer Qh
//
-
+
if (NULL == QhPtr->Prev) {
//
// Qh is the First one on Frame[0] List
@@ -1938,7 +2090,7 @@ Returns: }
}
} else {
-
+
//
// Not First one on Frame[0] List
//
@@ -2018,16 +2170,16 @@ LinkToAsyncReqeust ( Routine Description:
Llink AsyncRequest Entry to Async Request List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
AsyncRequestPtr - A pointer to Async Request Entry
-
+
Returns:
VOID
-
+
--*/
{
EHCI_ASYNC_REQUEST *CurrentPtr;
@@ -2054,16 +2206,16 @@ UnlinkFromAsyncReqeust ( Routine Description:
Unlink AsyncRequest Entry from Async Request List
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
AsyncRequestPtr - A pointer to Async Request Entry
-
+
Returns:
VOID
-
+
--*/
{
if (NULL == AsyncRequestPtr->Prev) {
@@ -2095,10 +2247,10 @@ Routine Description: Arguments:
- QtdHwPtr - A pointer to Qtd hardware structure
+ QtdHwPtr - A pointer to Qtd hardware structure
DataPtr - A pointer to user data buffer
DataLen - Length of the user data buffer
-
+
Returns:
VOID
@@ -2107,21 +2259,20 @@ Returns: {
UINTN RemainLen;
- RemainLen = DataLen;
ASSERT (QtdHwPtr);
+ ASSERT (DataLen <= 5 * EFI_PAGE_SIZE);
+ RemainLen = DataLen;
//
// Allow buffer address range across 4G.
// But EFI_USB_MAX_BULK_BUFFER_NUM = 1, so don't allow
// seperate buffer array.
//
-
//
// Set BufferPointer0, ExtBufferPointer0 and Offset
//
- QtdHwPtr->BufferPointer0 = (UINT32) (GET_0B_TO_31B (DataPtr) >> 12);
+ QtdHwPtr->BufferPointer0 = (UINT32) (GET_0B_TO_31B (DataPtr) >> EFI_PAGE_SHIFT);
QtdHwPtr->CurrentOffset = (UINT32) (GET_0B_TO_31B (DataPtr) & EFI_PAGE_MASK);
- QtdHwPtr->ExtBufferPointer0 = (UINT32) GET_32B_TO_63B (DataPtr);
//
// Set BufferPointer1 and ExtBufferPointer1
@@ -2132,7 +2283,6 @@ Returns: }
QtdHwPtr->BufferPointer1 = QtdHwPtr->BufferPointer0 + 1;
- QtdHwPtr->ExtBufferPointer1 = (QtdHwPtr->BufferPointer1 == 0) ? (QtdHwPtr->ExtBufferPointer0 + 1) : QtdHwPtr->ExtBufferPointer0;
//
// Set BufferPointer2 and ExtBufferPointer2
@@ -2143,7 +2293,6 @@ Returns: }
QtdHwPtr->BufferPointer2 = QtdHwPtr->BufferPointer1 + 1;
- QtdHwPtr->ExtBufferPointer2 = (QtdHwPtr->BufferPointer2 == 0) ? (QtdHwPtr->ExtBufferPointer1 + 1) : QtdHwPtr->ExtBufferPointer1;
//
// Set BufferPointer3 and ExtBufferPointer3
@@ -2154,7 +2303,6 @@ Returns: }
QtdHwPtr->BufferPointer3 = QtdHwPtr->BufferPointer2 + 1;
- QtdHwPtr->ExtBufferPointer3 = (QtdHwPtr->BufferPointer2 == 0) ? (QtdHwPtr->ExtBufferPointer2 + 1) : QtdHwPtr->ExtBufferPointer2;
//
// Set BufferPointer4 and ExtBufferPointer4
@@ -2165,7 +2313,6 @@ Returns: }
QtdHwPtr->BufferPointer4 = QtdHwPtr->BufferPointer3 + 1;
- QtdHwPtr->ExtBufferPointer4 = (QtdHwPtr->BufferPointer3 == 0) ? (QtdHwPtr->ExtBufferPointer3 + 1) : QtdHwPtr->ExtBufferPointer3;
exit:
return ;
@@ -2180,16 +2327,16 @@ IsQtdStatusActive ( Routine Description:
Whether Qtd status is active or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Active
FALSE Inactive
-
+
--*/
{
UINT8 QtdStatus;
@@ -2197,6 +2344,7 @@ Returns: QtdStatus = (UINT8) (HwQtdPtr->Status);
Value = (BOOLEAN) (QtdStatus & QTD_STATUS_ACTIVE);
+ //DEBUG ((gEHCErrorLevel, "EHCI: IsQtdStatusActive 0x%X, Address = %x\r\n",HwQtdPtr->Status, HwQtdPtr));
return Value;
}
@@ -2210,16 +2358,16 @@ IsQtdStatusHalted ( Routine Description:
Whether Qtd status is halted or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Halted
FALSE Not halted
-
+
--*/
{
UINT8 QtdStatus;
@@ -2240,16 +2388,16 @@ IsQtdStatusBufferError ( Routine Description:
Whether Qtd status is buffer error or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Buffer error
FALSE No buffer error
-
+
--*/
{
UINT8 QtdStatus;
@@ -2270,16 +2418,16 @@ IsQtdStatusBabbleError ( Routine Description:
Whether Qtd status is babble error or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Babble error
FALSE No babble error
-
+
--*/
{
UINT8 QtdStatus;
@@ -2300,16 +2448,16 @@ IsQtdStatusTransactionError ( Routine Description:
Whether Qtd status is transaction error or not
-
+
Arguments:
HwQtdPtr - A pointer to hardware Qtd structure
-
+
Returns:
TRUE Transaction error
FALSE No transaction error
-
+
--*/
{
UINT8 QtdStatus;
@@ -2330,16 +2478,16 @@ IsDataInTransfer ( Routine Description:
Whether is a DataIn direction transfer
-
+
Arguments:
- EndPointAddress - address of the endpoint
-
+ EndPointAddress - address of the endpoint
+
Returns:
TRUE DataIn
FALSE DataOut
-
+
--*/
{
BOOLEAN Value;
@@ -2368,22 +2516,22 @@ MapDataBuffer ( Routine Description:
Map address of user data buffer
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
TransferDirection - direction of transfer
- Data - A pointer to user data buffer
+ Data - A pointer to user data buffer
DataLength - length of user data
PktId - Packte Identificaion
DataCursor - mapped address to return
DataMap - identificaion of this mapping to return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -2408,7 +2556,7 @@ Returns: DataMap
);
if (EFI_ERROR (Status)) {
- DEBUG ((gEHCDebugLevel, "MapDataBuffer Failed\n"));
+ DEBUG ((gEHCDebugLevel, "EHCI: MapDataBuffer Failed\n"));
Status = EFI_DEVICE_ERROR;
goto exit;
}
@@ -2468,19 +2616,19 @@ MapRequestBuffer ( Routine Description:
Map address of request structure buffer
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
Request - A pointer to request structure
RequestCursor - Mapped address of request structure to return
RequestMap - Identificaion of this mapping to return
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -2519,19 +2667,19 @@ DeleteAsyncRequestTransfer ( Routine Description:
Delete all asynchronous request transfer
-
+
Arguments:
- HcDev - USB2_HC_DEV
+ HcDev - USB2_HC_DEV
DeviceAddress - address of usb device
EndPointAddress - address of endpoint
DataToggle - stored data toggle
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -2578,7 +2726,7 @@ Returns: Status = WaitForPeriodicScheduleDisable (HcDev, EHCI_GENERIC_TIMEOUT);
if (EFI_ERROR (Status)) {
- DEBUG ((gEHCErrorLevel, "WaitForPeriodicScheduleDisable TimeOut\n"));
+ DEBUG ((gEHCErrorLevel, "EHCI: WaitForPeriodicScheduleDisable TimeOut\n"));
Status = EFI_TIMEOUT;
goto exit;
}
@@ -2605,7 +2753,7 @@ Returns: Status = WaitForPeriodicScheduleEnable (HcDev, EHCI_GENERIC_TIMEOUT);
if (EFI_ERROR (Status)) {
- DEBUG ((gEHCErrorLevel, "WaitForPeriodicScheduleEnable TimeOut\n"));
+ DEBUG ((gEHCErrorLevel, "EHCI: WaitForPeriodicScheduleEnable TimeOut\n"));
Status = EFI_TIMEOUT;
goto exit;
}
@@ -2637,15 +2785,15 @@ CleanUpAllAsyncRequestTransfer ( Routine Description:
Clean up all asynchronous request transfer
-
+
Arguments:
- HcDev - USB2_HC_DEV
-
+ HcDev - USB2_HC_DEV
+
Returns:
VOID
-
+
--*/
{
EHCI_ASYNC_REQUEST *AsyncRequestPtr;
@@ -2681,15 +2829,15 @@ ZeroOutQhOverlay ( Routine Description:
Zero out the fields in Qh structure
-
+
Arguments:
QhPtr - A pointer to Qh structure
-
+
Returns:
VOID
-
+
--*/
{
QhPtr->Qh.CurrentQtdPointer = 0;
@@ -2711,11 +2859,6 @@ Returns: QhPtr->Qh.FrameTag = 0;
QhPtr->Qh.BufferPointer3 = 0;
QhPtr->Qh.BufferPointer4 = 0;
- QhPtr->Qh.ExtBufferPointer0 = 0;
- QhPtr->Qh.ExtBufferPointer1 = 0;
- QhPtr->Qh.ExtBufferPointer2 = 0;
- QhPtr->Qh.ExtBufferPointer3 = 0;
- QhPtr->Qh.ExtBufferPointer4 = 0;
}
VOID
@@ -2729,17 +2872,17 @@ UpdateAsyncRequestTransfer ( Routine Description:
Update asynchronous request transfer
-
+
Arguments:
- AsyncRequestPtr - A pointer to async request
- TransferResult - transfer result
+ AsyncRequestPtr - A pointer to async request
+ TransferResult - transfer result
ErrQtdPos - postion of error Qtd
-
+
Returns:
VOID
-
+
--*/
{
EHCI_QTD_ENTITY *QtdPtr;
@@ -2747,7 +2890,7 @@ Returns: QtdPtr = NULL;
if (EFI_USB_NOERROR == TransferResult) {
-
+
//
// Update Qh for next trigger
//
@@ -2811,7 +2954,7 @@ Returns: TRUE Qtds finished
FALSE Not finish
-
+
--*/
{
UINTN ActualLenPerQtd;
@@ -2829,25 +2972,37 @@ Returns: QtdHwPtr = &(QtdPtr->Qtd);
while (NULL != QtdHwPtr) {
-
if (IsQtdStatusActive (QtdHwPtr)) {
*Result |= EFI_USB_ERR_NOTEXECUTE;
}
if (IsQtdStatusHalted (QtdHwPtr)) {
+
+ DEBUG ((gEHCErrorLevel, "EHCI: QTD_STATUS_HALTED 0x%X\n", QtdHwPtr->Status));
*Result |= EFI_USB_ERR_STALL;
}
if (IsQtdStatusBufferError (QtdHwPtr)) {
+ DEBUG ((gEHCErrorLevel, "EHCI: QTD_STATUS_BUFFER_ERR 0x%X\n", QtdHwPtr->Status));
*Result |= EFI_USB_ERR_BUFFER;
}
if (IsQtdStatusBabbleError (QtdHwPtr)) {
+ DEBUG ((gEHCErrorLevel, "EHCI: StatusBufferError 0x%X\n", QtdHwPtr->Status));
*Result |= EFI_USB_ERR_BABBLE;
}
if (IsQtdStatusTransactionError (QtdHwPtr)) {
- *Result |= EFI_USB_ERR_TIMEOUT;
+
+ //
+ //Exclude Special Case
+ //
+ if (((QtdHwPtr->Status & QTD_STATUS_HALTED) == QTD_STATUS_HALTED) ||
+ ((QtdHwPtr->Status & QTD_STATUS_ACTIVE) == QTD_STATUS_ACTIVE) ||
+ ((QtdHwPtr->ErrorCount != QTD_ERROR_COUNTER))) {
+ *Result |= EFI_USB_ERR_TIMEOUT;
+ DEBUG ((gEHCErrorLevel, "EHCI: QTD_STATUS_TRANSACTION_ERR: 0x%X\n", QtdHwPtr->Status));
+ }
}
ActualLenPerQtd = QtdPtr->TotalBytes - QtdHwPtr->TotalBytes;
@@ -2864,16 +3019,21 @@ Returns: break;
}
- if ((!IsControl) && (QtdPtr->TotalBytes > 0)) {
+ if ((INPUT_PACKET_PID_CODE == QtdHwPtr->PidCode)&& (QtdPtr->TotalBytes > 0)) {
//
- // Did something, but isn't full workload
+ // Short Packet: IN, Short
//
+ DEBUG ((gEHCDebugLevel, "EHCI: Short Packet Status: 0x%x\n", QtdHwPtr->Status));
break;
}
- (*ErrQtdPos)++;
- QtdPtr = QtdPtr->Next;
- QtdHwPtr = &(QtdPtr->Qtd);
+ if (QtdPtr->Next != NULL) {
+ (*ErrQtdPos)++;
+ QtdPtr = QtdPtr->Next;
+ QtdHwPtr = &(QtdPtr->Qtd);
+ } else {
+ QtdHwPtr = NULL;
+ }
}
@@ -2901,16 +3061,16 @@ Arguments: HcDev - USB2_HC_DEV
IsControl - Is control transfer or not
QhPtr - A pointer to Qh
- ActualLen - Actual transfered Len
+ ActualLen - Actual transfered Len
DataToggle - Data Toggle
TimeOut - TimeOut threshold
TransferResult - Transfer result
-
+
Returns:
EFI_SUCCESS Sucess
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
@@ -2924,7 +3084,7 @@ Returns: *ActualLen = 0;
Finished = FALSE;
- Delay = (TimeOut * STALL_1_MILLI_SECOND / 50) + 1;
+ Delay = (TimeOut * STALL_1_MILLI_SECOND / 50);
do {
*TransferResult = 0;
@@ -2951,6 +3111,7 @@ Returns: if (EFI_USB_NOERROR != *TransferResult) {
if (0 == Delay) {
+ DEBUG((gEHCErrorLevel, "EHCI: QTDS TimeOut\n"));
Status = EFI_TIMEOUT;
} else {
Status = EFI_DEVICE_ERROR;
@@ -2961,7 +3122,7 @@ Returns: // Special for Bulk and Interrupt Transfer
//
*DataToggle = (UINT8) QhPtr->Qh.DataToggle;
-
+
return Status;
}
@@ -2972,30 +3133,30 @@ AsyncRequestMoniter ( )
/*++
Routine Description:
-
+
Interrupt transfer periodic check handler
-
+
Arguments:
Event - Interrupt event
Context - Pointer to USB2_HC_DEV
-
+
Returns:
EFI_SUCCESS Success
EFI_DEVICE_ERROR Fail
-
+
--*/
{
EFI_STATUS Status;
USB2_HC_DEV *HcDev;
EHCI_ASYNC_REQUEST *AsyncRequestPtr;
+ EHCI_ASYNC_REQUEST *NextPtr;
EHCI_QTD_HW *QtdHwPtr;
UINTN ErrQtdPos;
UINTN ActualLen;
UINT32 TransferResult;
UINT8 *ReceiveBuffer;
UINT8 *ProcessBuffer;
- EHCI_ASYNC_REQUEST *NextPtr;
Status = EFI_SUCCESS;
QtdHwPtr = NULL;
@@ -3011,10 +3172,10 @@ Returns: ActualLen = 0;
CheckQtdsTransferResult (
- FALSE,
- AsyncRequestPtr->QhPtr,
- &TransferResult,
- &ErrQtdPos,
+ FALSE,
+ AsyncRequestPtr->QhPtr,
+ &TransferResult,
+ &ErrQtdPos,
&ActualLen
);
@@ -3032,7 +3193,7 @@ Returns: }
QtdHwPtr = &(AsyncRequestPtr->QhPtr->FirstQtdPtr->Qtd);
- ReceiveBuffer = (UINT8 *) GET_0B_TO_31B ((QtdHwPtr->BufferPointer0 << 12) | AsyncRequestPtr->QhPtr->FirstQtdPtr->StaticCurrentOffset);
+ ReceiveBuffer = (UINT8 *) GET_0B_TO_31B ((QtdHwPtr->BufferPointer0 << EFI_PAGE_SHIFT) | AsyncRequestPtr->QhPtr->FirstQtdPtr->StaticCurrentOffset);
CopyMem (
ProcessBuffer,
ReceiveBuffer,
@@ -3052,7 +3213,7 @@ Returns: } else {
//
- // leave error recovery to its related device driver. A common case of
+ // leave error recovery to its related device driver. A common case of
// the error recovery is to re-submit the interrupt transfer.
// When an interrupt transfer is re-submitted, its position in the linked
// list is changed. It is inserted to the head of the linked list, while
diff --git a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c index 3d81d2c5c3..7e033df2df 100644 --- a/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c +++ b/EdkModulePkg/Bus/Pci/Uhci/Dxe/uhci.c @@ -485,6 +485,7 @@ UHCIDriverBindingStart ( UINTN FlBaseAddrReg;
EFI_PCI_IO_PROTOCOL *PciIo;
USB_HC_DEV *HcDev;
+ UINT64 Supports;
HcDev = NULL;
@@ -510,10 +511,19 @@ UHCIDriverBindingStart ( //
Status = PciIo->Attributes (
PciIo,
- EfiPciIoAttributeOperationEnable,
- EFI_PCI_DEVICE_ENABLE,
- NULL
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &Supports
);
+ if (!EFI_ERROR (Status)) {
+ Supports &= EFI_PCI_DEVICE_ENABLE;
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationEnable,
+ Supports,
+ NULL
+ );
+ }
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
Controller,
@@ -777,6 +787,8 @@ UnInstallUHCInterface ( --*/
{
USB_HC_DEV *HcDev;
+ EFI_STATUS Status;
+ UINT64 Supports;
HcDev = USB_HC_DEV_FROM_THIS (This);
@@ -823,12 +835,21 @@ UnInstallUHCInterface ( //
// Disable the USB Host Controller
//
- HcDev->PciIo->Attributes (
- HcDev->PciIo,
- EfiPciIoAttributeOperationDisable,
- EFI_PCI_DEVICE_ENABLE,
- NULL
- );
+ Status = HcDev->PciIo->Attributes (
+ HcDev->PciIo,
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &Supports
+ );
+ if (!EFI_ERROR (Status)) {
+ Supports &= EFI_PCI_DEVICE_ENABLE;
+ Status = HcDev->PciIo->Attributes (
+ HcDev->PciIo,
+ EfiPciIoAttributeOperationDisable,
+ Supports,
+ NULL
+ );
+ }
gBS->FreePool (HcDev);
diff --git a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/ComponentName.c b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/ComponentName.c index 34ab75864f..ca4228583a 100644 --- a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/ComponentName.c +++ b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/ComponentName.c @@ -1,13 +1,13 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
@@ -70,21 +70,21 @@ UsbBotComponentNameGetDriverName ( Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
Language - A pointer to a three character ISO 639-2 language identifier.
- This is the language of the driver name that that the caller
+ This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
- in SupportedLanguages. The number of languages supported by a
+ in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
DriverName - A pointer to the Unicode string to return. This Unicode string
- is the name of the driver specified by This in the language
+ is the name of the driver specified by This in the language
specified by Language.
Returns:
EFI_SUCCESS - The Unicode string for the Driver specified by This
- and the language specified by Language was returned
+ and the language specified by Language was returned
in DriverName.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - DriverName is NULL.
- EFI_UNSUPPORTED - The driver specified by This does not support the
+ EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
@@ -114,39 +114,39 @@ UsbBotComponentNameGetControllerName ( Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- ControllerHandle - The handle of a controller that the driver specified by
- This is managing. This handle specifies the controller
+ ControllerHandle - The handle of a controller that the driver specified by
+ This is managing. This handle specifies the controller
whose name is to be returned.
- ChildHandle - The handle of the child controller to retrieve the name
- of. This is an optional parameter that may be NULL. It
- will be NULL for device drivers. It will also be NULL
- for a bus drivers that wish to retrieve the name of the
- bus controller. It will not be NULL for a bus driver
+ ChildHandle - The handle of the child controller to retrieve the name
+ of. This is an optional parameter that may be NULL. It
+ will be NULL for device drivers. It will also be NULL
+ for a bus drivers that wish to retrieve the name of the
+ bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
- Language - A pointer to a three character ISO 639-2 language
- identifier. This is the language of the controller name
+ Language - A pointer to a three character ISO 639-2 language
+ identifier. This is the language of the controller name
that that the caller is requesting, and it must match one
- of the languages specified in SupportedLanguages. The
- number of languages supported by a driver is up to the
+ of the languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up to the
driver writer.
ControllerName - A pointer to the Unicode string to return. This Unicode
- string is the name of the controller specified by
+ string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified
by Language from the point of view of the driver specified
- by This.
+ by This.
Returns:
- EFI_SUCCESS - The Unicode string for the user readable name in the
- language specified by Language for the driver
+ EFI_SUCCESS - The Unicode string for the user readable name in the
+ language specified by Language for the driver
specified by This was returned in DriverName.
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - ControllerName is NULL.
- EFI_UNSUPPORTED - The driver specified by This is not currently managing
- the controller specified by ControllerHandle and
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing
+ the controller specified by ControllerHandle and
ChildHandle.
- EFI_UNSUPPORTED - The driver specified by This does not support the
+ EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
diff --git a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.c b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.c index acba154842..37b316f875 100644 --- a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.c +++ b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.c @@ -1,13 +1,13 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
@@ -19,6 +19,8 @@ Abstract: #include "bot.h"
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 gBOTDebugLevel = EFI_D_INFO;
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 gBOTErrorLevel = EFI_D_INFO;
//
// Function prototypes
//
@@ -85,7 +87,7 @@ STATIC EFI_STATUS
BotDataPhase (
IN USB_BOT_DEVICE *UsbBotDev,
- IN UINT32 *DataSize,
+ IN UINTN *DataSize,
IN OUT VOID *DataBuffer,
IN EFI_USB_DATA_DIRECTION Direction,
IN UINT16 Timeout
@@ -94,11 +96,10 @@ BotDataPhase ( STATIC
EFI_STATUS
BotStatusPhase (
- IN USB_BOT_DEVICE *UsbBotDev,
- OUT UINT8 *TransferStatus,
- IN UINT16 Timeout
+ IN USB_BOT_DEVICE *UsbBotDev,
+ OUT UINT32 *DataResidue,
+ IN UINT16 Timeout
);
-
//
// USB Atapi protocol prototype
//
@@ -193,7 +194,7 @@ BotDriverBindingSupported ( //
// Check if it is a BOT type Mass Storage Device
//
- if ((InterfaceDescriptor.InterfaceClass != 0x08) ||
+ if ((InterfaceDescriptor.InterfaceClass != MASS_STORAGE_CLASS) ||
(InterfaceDescriptor.InterfaceProtocol != BOT)) {
Status = EFI_UNSUPPORTED;
goto Exit;
@@ -431,7 +432,7 @@ BotDriverBindingStop ( Returns:
EFI_SUCCESS - This driver is removed DeviceHandle
- EFI_UNSUPPORTED - Can't open the gEfiUsbAtapiProtocolGuid protocl
+ EFI_UNSUPPORTED - Can't open the gEfiUsbAtapiProtocolGuid protocl
other - This driver was not removed from this device
--*/
@@ -513,6 +514,38 @@ BotDriverBindingStop ( return Status;
}
+
+
+STATIC
+EFI_STATUS
+ClearBulkInPipe (
+ IN USB_BOT_DEVICE *UsbBotDev
+ )
+{
+ UINT32 Result;
+
+ return UsbClearEndpointHalt (
+ UsbBotDev->UsbIo,
+ UsbBotDev->BulkInEndpointDescriptor->EndpointAddress,
+ &Result
+ );
+}
+
+
+STATIC
+EFI_STATUS
+ClearBulkOutPipe (
+ IN USB_BOT_DEVICE *UsbBotDev
+ )
+{
+ UINT32 Result;
+ return UsbClearEndpointHalt (
+ UsbBotDev->UsbIo,
+ UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress,
+ &Result
+ );
+}
+
STATIC
EFI_STATUS
BotRecoveryReset (
@@ -530,17 +563,12 @@ Arguments: Returns:
EFI_SUCCESS - Success the operation
-
+
--*/
{
EFI_STATUS Status;
- UINT32 Result;
EFI_USB_DEVICE_REQUEST Request;
- EFI_USB_IO_PROTOCOL *UsbIo;
- UINT8 EndpointAddr;
-
- UsbIo = UsbBotDev->UsbIo;
-
+ UINT32 Result;
BotReportStatusCode (
UsbBotDev->DevicePath,
EFI_PROGRESS_CODE,
@@ -555,43 +583,24 @@ Returns: Request.RequestType = 0x21;
Request.Request = 0xFF;
- Status = UsbIo->UsbControlTransfer (
- UsbIo,
- &Request,
- EfiUsbNoData,
- TIMEOUT_VALUE,
- NULL,
- 0,
- &Result
- );
+ Status = UsbBotDev->UsbIo->UsbControlTransfer (
+ UsbBotDev->UsbIo,
+ &Request,
+ EfiUsbNoData,
+ TIMEOUT_VALUE,
+ NULL,
+ 0,
+ &Result
+ );
gBS->Stall (100 * 1000);
- if (!EFI_ERROR (Status)) {
- //
- // clear bulk in endpoint stall feature
- //
- EndpointAddr = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;
-
- Status = UsbClearEndpointHalt (
- UsbIo,
- EndpointAddr,
- &Result
- );
-
- //
- // clear bulk out endpoint stall feature
- //
- EndpointAddr = UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress;
- Status = UsbClearEndpointHalt (
- UsbIo,
- EndpointAddr,
- &Result
- );
- }
+ ClearBulkInPipe (UsbBotDev);
+ ClearBulkOutPipe (UsbBotDev);
return Status;
}
+
//
// Bot Protocol Implementation
//
@@ -639,7 +648,17 @@ BotCommandPhase ( cbw.dCBWSignature = CBWSIG;
cbw.dCBWTag = 0x01;
cbw.dCBWDataTransferLength = DataTransferLength;
- cbw.bmCBWFlags = (UINT8) (Direction << 7);
+ switch (Direction) {
+ case EfiUsbDataOut:
+ case EfiUsbNoData:
+ cbw.bmCBWFlags = 0;
+ break;
+ case EfiUsbDataIn:
+ cbw.bmCBWFlags = 0x80;
+ break;
+ default:
+ break;
+ }
cbw.bCBWCBLength = CommandSize;
CopyMem (cbw.CBWCB, Command, CommandSize);
@@ -648,28 +667,20 @@ BotCommandPhase ( Status = UsbIo->UsbBulkTransfer (
UsbIo,
- (UsbBotDev->BulkOutEndpointDescriptor)->EndpointAddress,
+ UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress,
&cbw,
&DataSize,
Timeout,
&Result
);
- if (EFI_ERROR (Status)) {
- //
- // Command phase fail, we need to recovery reset this device
- //
- BotRecoveryReset (UsbBotDev);
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
+ return Status;
}
STATIC
EFI_STATUS
BotDataPhase (
IN USB_BOT_DEVICE *UsbBotDev,
- IN UINT32 *DataSize,
+ IN UINTN *DataSize,
IN OUT VOID *DataBuffer,
IN EFI_USB_DATA_DIRECTION Direction,
IN UINT16 Timeout
@@ -695,125 +706,52 @@ BotDataPhase ( UINT32 Result;
EFI_USB_IO_PROTOCOL *UsbIo;
UINT8 EndpointAddr;
- UINTN Remain;
- UINTN Increment;
- UINT32 MaxPacketLen;
UINT8 *BufferPtr;
- UINTN TransferredSize;
- UINTN RetryTimes;
- UINTN MaxRetry;
- UINTN BlockSize;
- UINTN PackageNum;
UsbIo = UsbBotDev->UsbIo;
- Remain = *DataSize;
BufferPtr = (UINT8 *) DataBuffer;
- TransferredSize = 0;
- MaxRetry = 10;
- PackageNum = 128;
//
// retrieve the the max packet length of the given endpoint
//
if (Direction == EfiUsbDataIn) {
- MaxPacketLen = (UsbBotDev->BulkInEndpointDescriptor)->MaxPacketSize;
- EndpointAddr = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;
+ EndpointAddr = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;
} else {
- MaxPacketLen = (UsbBotDev->BulkOutEndpointDescriptor)->MaxPacketSize;
- EndpointAddr = (UsbBotDev->BulkOutEndpointDescriptor)->EndpointAddress;
+ EndpointAddr = UsbBotDev->BulkOutEndpointDescriptor->EndpointAddress;
}
- RetryTimes = MaxRetry;
- BlockSize = PackageNum * MaxPacketLen;
- while (Remain > 0) {
- //
- // Using 15 packets to aVOID Bitstuff error
- //
- if (Remain > PackageNum * MaxPacketLen) {
- Increment = BlockSize;
- } else {
- Increment = Remain;
- }
-
Status = UsbIo->UsbBulkTransfer (
UsbIo,
EndpointAddr,
BufferPtr,
- &Increment,
- Timeout,
+ DataSize,
+ (UINT16)(Timeout),
&Result
);
- TransferredSize += Increment;
-
if (EFI_ERROR (Status)) {
- RetryTimes--;
- if ((RetryTimes == 0) || ((Result & EFI_USB_ERR_TIMEOUT) == 0)) {
- goto ErrorExit;
+ if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
+ if (Direction == EfiUsbDataIn) {
+ DEBUG((gBOTErrorLevel, "BOT: Data IN Stall, ClearBulkInPipe\n"));
+ ClearBulkInPipe (UsbBotDev);
+ } else {
+ DEBUG((gBOTErrorLevel, "BOT: Data OUT Stall, ClearBulkInPipe\n"));
+ ClearBulkOutPipe (UsbBotDev);
+ }
}
+ // BotRecoveryReset (UsbBotDev);
+ }
- TransferredSize -= Increment;
- continue;
- } else {
- //
- // we try MaxTetry times for every bulk transfer
- //
- RetryTimes = MaxRetry;
- }
-
- BufferPtr += Increment;
- Remain -= Increment;
- if (Increment < BlockSize && TransferredSize <= *DataSize) {
- //
- // we get to the end of transter and transter size is
- // less than requriedsize
- //
- break;
- }
- }
-
- *DataSize = (UINT32) TransferredSize;
-
- return EFI_SUCCESS;
-
-ErrorExit:
- if (Direction == EfiUsbDataIn) {
- BotReportStatusCode (
- UsbBotDev->DevicePath,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- (EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_INPUT_ERROR)
- );
- } else {
- BotReportStatusCode (
- UsbBotDev->DevicePath,
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- (EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_OUTPUT_ERROR)
- );
- }
-
- if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
- //
- // just endpoint stall happens
- //
- UsbClearEndpointHalt (
- UsbIo,
- EndpointAddr,
- &Result
- );
- }
-
- *DataSize = (UINT32) TransferredSize;
return Status;
-
}
STATIC
EFI_STATUS
BotStatusPhase (
- IN USB_BOT_DEVICE *UsbBotDev,
- OUT UINT8 *TransferStatus,
- IN UINT16 Timeout
+ IN USB_BOT_DEVICE *UsbBotDev,
+ OUT UINT32 *DataResidue,
+ IN UINT16 Timeout
)
/*++
@@ -822,7 +760,6 @@ BotStatusPhase ( Parameters:
UsbBotDev - USB_BOT_DEVICE pointer
- TransferStatus - TransferStatus
Timeout - Time out value in milliseconds
Return Value:
EFI_SUCCESS
@@ -832,47 +769,21 @@ BotStatusPhase ( {
CSW csw;
EFI_STATUS Status;
- UINT32 Result;
EFI_USB_IO_PROTOCOL *UsbIo;
UINT8 EndpointAddr;
UINTN DataSize;
+ UINT32 Result;
+ UINT8 Index;
UsbIo = UsbBotDev->UsbIo;
+ EndpointAddr = UsbBotDev->BulkInEndpointDescriptor->EndpointAddress;
- ZeroMem (&csw, sizeof (CSW));
-
- EndpointAddr = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;
-
- DataSize = sizeof (CSW);
-
- //
- // Get the status field from bulk transfer
- //
- Status = UsbIo->UsbBulkTransfer (
- UsbIo,
- EndpointAddr,
- &csw,
- &DataSize,
- Timeout,
- &Result
- );
- if (EFI_ERROR (Status)) {
- if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
- //
- // just endpoint stall happens
- //
- UsbClearEndpointHalt (
- UsbIo,
- EndpointAddr,
- &Result
- );
- }
+ for (Index = 0; Index < 3; Index ++) {
ZeroMem (&csw, sizeof (CSW));
+ DataSize = sizeof (CSW);
+ Result = 0;
- EndpointAddr = (UsbBotDev->BulkInEndpointDescriptor)->EndpointAddress;
-
- DataSize = sizeof (CSW);
Status = UsbIo->UsbBulkTransfer (
UsbIo,
EndpointAddr,
@@ -883,25 +794,36 @@ BotStatusPhase ( );
if (EFI_ERROR (Status)) {
if ((Result & EFI_USB_ERR_STALL) == EFI_USB_ERR_STALL) {
- UsbClearEndpointHalt (
- UsbIo,
- EndpointAddr,
- &Result
- );
+ DEBUG((gBOTDebugLevel, "BOT: CSW Stall, ClearBulkInPipe\n"));
+ ClearBulkInPipe (UsbBotDev);
+ continue;
+ }
+ }
+
+ if (csw.dCSWSignature == CSWSIG) {
+ if (csw.bCSWStatus == 0 || csw.bCSWStatus == 0x01) {
+ if (DataResidue != NULL) {
+ *DataResidue = csw.dCSWDataResidue;
+ }
+ if (csw.bCSWStatus == 0x01) {
+ return EFI_DEVICE_ERROR;
+ }
+ break;
+ } else if (csw.bCSWStatus == 0x02) {
+ DEBUG((gBOTErrorLevel, "BOT: Bot Phase error\n"));
+ BotRecoveryReset (UsbBotDev);
}
- return Status;
}
}
- if (csw.dCSWSignature == CSWSIG) {
- *TransferStatus = csw.bCSWStatus;
- } else {
+ if (Index == 3) {
return EFI_DEVICE_ERROR;
}
return EFI_SUCCESS;
}
+
//
// Usb Atapi Protocol implementation
//
@@ -938,81 +860,82 @@ BotAtapiCommand ( {
EFI_STATUS Status;
EFI_STATUS BotDataStatus;
- UINT8 TransferStatus;
USB_BOT_DEVICE *UsbBotDev;
- UINT32 BufferSize;
-
- BotDataStatus = EFI_SUCCESS;
- TransferStatus = 0;
+ UINTN BufferSize;
+ UINT8 Index;
+ UINT32 DataResidue;
//
// Get the context
//
- UsbBotDev = USB_BOT_DEVICE_FROM_THIS (This);
+ UsbBotDev = USB_BOT_DEVICE_FROM_THIS (This);
+ BotDataStatus = EFI_SUCCESS;
+ BufferSize = 0;
- //
- // First send ATAPI command through Bot
- //
- Status = BotCommandPhase (
- UsbBotDev,
- Command,
- CommandSize,
- BufferLength,
- Direction,
- TimeOutInMilliSeconds
- );
+ for (Index = 0; Index < 3; Index ++) {
+ //
+ // First send ATAPI command through Bot
+ //
+ Status = BotCommandPhase (
+ UsbBotDev,
+ Command,
+ CommandSize,
+ BufferLength,
+ Direction,
+ 10 * 1000
+ );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Send/Get Data if there is a Data Stage
- //
- switch (Direction) {
+ if (EFI_ERROR (Status)) {
+ DEBUG((gBOTErrorLevel, "BotCommandPhase Fail\n"));
+ return Status;
+ }
+ //
+ // Send/Get Data if there is a Data Stage
+ //
+ switch (Direction) {
- case EfiUsbDataIn:
- case EfiUsbDataOut:
- BufferSize = BufferLength;
-
- BotDataStatus = BotDataPhase (
- UsbBotDev,
- &BufferSize,
- DataBuffer,
- Direction,
- (UINT16) (TimeOutInMilliSeconds)
- );
+ case EfiUsbDataIn:
+ case EfiUsbDataOut:
+ BufferSize = BufferLength;
- break;
+ BotDataStatus = BotDataPhase (
+ UsbBotDev,
+ &BufferSize,
+ DataBuffer,
+ Direction,
+ (UINT16) (TimeOutInMilliSeconds)
+ );
- case EfiUsbNoData:
- break;
- }
-
- //
- // Status Phase
- //
- Status = BotStatusPhase (
- UsbBotDev,
- &TransferStatus,
- TimeOutInMilliSeconds
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
+ if (EFI_ERROR (BotDataStatus)) {
+ DEBUG((gBOTErrorLevel, "BotDataPhase Fail\n"));
+ }
+ break;
- if (TransferStatus == 0x02) {
+ case EfiUsbNoData:
+ break;
+ }
+
+ DataResidue = 0;
//
- // Phase error
+ // Status Phase
//
- BotRecoveryReset (UsbBotDev);
- return EFI_DEVICE_ERROR;
- }
+ Status = BotStatusPhase (
+ UsbBotDev,
+ &DataResidue,
+ 10 * 1000
+ );
- if (TransferStatus == 0x01) {
- return EFI_DEVICE_ERROR;
- }
+ if (EFI_ERROR (Status)) {
+ DEBUG((gBOTErrorLevel, "BotStatusPhase Fail\n"));
+ return Status;
+ }
+ if (!EFI_ERROR (BotDataStatus)) {
+ break;
+ }
+
+ }
return BotDataStatus;
}
diff --git a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.h b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.h index 5f9006b5bd..383cfde48e 100644 --- a/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.h +++ b/EdkModulePkg/Bus/Usb/UsbBot/Dxe/bot.h @@ -1,13 +1,13 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
@@ -22,6 +22,9 @@ Abstract: #include <IndustryStandard/Usb.h>
+extern UINT32 gBOTDebugLevel;
+extern UINT32 gBOTErrorLevel;
+#define MASS_STORAGE_CLASS 0x08
#pragma pack(1)
//
diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/ComponentName.c b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/ComponentName.c index a021d95389..f033361fff 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/ComponentName.c +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/ComponentName.c @@ -1,13 +1,13 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
@@ -69,21 +69,21 @@ UsbMassStorageComponentNameGetDriverName ( Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
Language - A pointer to a three character ISO 639-2 language identifier.
- This is the language of the driver name that that the caller
+ This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
- in SupportedLanguages. The number of languages supported by a
+ in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
DriverName - A pointer to the Unicode string to return. This Unicode string
- is the name of the driver specified by This in the language
+ is the name of the driver specified by This in the language
specified by Language.
Returns:
EFI_SUCCESS - The Unicode string for the Driver specified by This
- and the language specified by Language was returned
+ and the language specified by Language was returned
in DriverName.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - DriverName is NULL.
- EFI_UNSUPPORTED - The driver specified by This does not support the
+ EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
@@ -113,39 +113,39 @@ UsbMassStorageComponentNameGetControllerName ( Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
- ControllerHandle - The handle of a controller that the driver specified by
- This is managing. This handle specifies the controller
+ ControllerHandle - The handle of a controller that the driver specified by
+ This is managing. This handle specifies the controller
whose name is to be returned.
- ChildHandle - The handle of the child controller to retrieve the name
- of. This is an optional parameter that may be NULL. It
- will be NULL for device drivers. It will also be NULL
- for a bus drivers that wish to retrieve the name of the
- bus controller. It will not be NULL for a bus driver
+ ChildHandle - The handle of the child controller to retrieve the name
+ of. This is an optional parameter that may be NULL. It
+ will be NULL for device drivers. It will also be NULL
+ for a bus drivers that wish to retrieve the name of the
+ bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
- Language - A pointer to a three character ISO 639-2 language
- identifier. This is the language of the controller name
+ Language - A pointer to a three character ISO 639-2 language
+ identifier. This is the language of the controller name
that that the caller is requesting, and it must match one
- of the languages specified in SupportedLanguages. The
- number of languages supported by a driver is up to the
+ of the languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up to the
driver writer.
ControllerName - A pointer to the Unicode string to return. This Unicode
- string is the name of the controller specified by
+ string is the name of the controller specified by
ControllerHandle and ChildHandle in the language specified
by Language from the point of view of the driver specified
- by This.
+ by This.
Returns:
- EFI_SUCCESS - The Unicode string for the user readable name in the
- language specified by Language for the driver
+ EFI_SUCCESS - The Unicode string for the user readable name in the
+ language specified by Language for the driver
specified by This was returned in DriverName.
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - ControllerName is NULL.
- EFI_UNSUPPORTED - The driver specified by This is not currently managing
- the controller specified by ControllerHandle and
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing
+ the controller specified by ControllerHandle and
ChildHandle.
- EFI_UNSUPPORTED - The driver specified by This does not support the
+ EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c index b86c06a514..7f6cd4daf2 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.c @@ -1,18 +1,18 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UsbMassStorage.c
-
+
Abstract:
USB Mass Storage Driver
@@ -192,11 +192,11 @@ USBFloppyDriverBindingStart ( EFI_OUT_OF_RESOURCES- Can't allocate memory resources
EFI_ALREADY_STARTED - Thios driver has been started
--*/
-{
- EFI_STATUS Status;
+{
+ EFI_STATUS Status;
EFI_USB_ATAPI_PROTOCOL *AtapiProtocol;
USB_FLOPPY_DEV *UsbFloppyDevice;
-
+
UsbFloppyDevice = NULL;
//
// Check whether Usb Atapi Protocol attached on the controller handle.
@@ -311,7 +311,7 @@ USBFloppyDriverBindingStop ( EFI_DEVICE_ERROR
others
---*/
+--*/
{
EFI_STATUS Status;
USB_FLOPPY_DEV *UsbFloppyDevice;
@@ -373,17 +373,17 @@ USBFloppyReset ( Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.Reset() function.
-
+
Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance.
ExtendedVerification
Indicates that the driver may perform a more exhaustive
verification operation of the device during reset.
(This parameter is ingored in this driver.)
-
- Returns:
+
+ Returns:
EFI_SUCCESS - Success
---*/
+--*/
{
USB_FLOPPY_DEV *UsbFloppyDevice;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
@@ -396,7 +396,7 @@ USBFloppyReset ( //
// directly calling EFI_USB_ATAPI_PROTOCOL.Reset() to implement reset.
//
- Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, TRUE);
+ Status = UsbAtapiInterface->UsbAtapiReset (UsbAtapiInterface, ExtendedVerification);
return Status;
}
@@ -415,26 +415,26 @@ USBFloppyReadBlocks ( Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks() function.
-
+
Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance.
MediaId The media id that the read request is for.
LBA The starting logical block address to read from on the device.
BufferSize
- The size of the Buffer in bytes. This must be a multiple of
+ The size of the Buffer in bytes. This must be a multiple of
the intrinsic block size of the device.
- Buffer A pointer to the destination buffer for the data. The caller
+ Buffer A pointer to the destination buffer for the data. The caller
is responsible for either having implicit or explicit ownership
- of the buffer.
-
- Returns:
+ of the buffer.
+
+ Returns:
EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
+ EFI_SUCCESS - Success
EFI_DEVICE_ERROR - Hardware Error
EFI_NO_MEDIA - No media
EFI_MEDIA_CHANGED - Media Change
EFI_BAD_BUFFER_SIZE - Buffer size is bad
- --*/
+ --*/
{
USB_FLOPPY_DEV *UsbFloppyDevice;
EFI_STATUS Status;
@@ -442,12 +442,9 @@ USBFloppyReadBlocks ( UINTN BlockSize;
UINTN NumberOfBlocks;
BOOLEAN MediaChange;
- EFI_TPL OldTpl;
- OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
Status = EFI_SUCCESS;
MediaChange = FALSE;
-
UsbFloppyDevice = USB_FLOPPY_DEV_FROM_THIS (This);
//
@@ -473,14 +470,12 @@ USBFloppyReadBlocks ( }
if (MediaChange) {
- gBS->RestoreTPL (OldTpl);
gBS->ReinstallProtocolInterface (
UsbFloppyDevice->Handle,
&gEfiBlockIoProtocolGuid,
&UsbFloppyDevice->BlkIo,
&UsbFloppyDevice->BlkIo
);
- gBS->RaiseTPL (EFI_TPL_NOTIFY);
}
Media = UsbFloppyDevice->BlkIo.Media;
@@ -517,33 +512,31 @@ USBFloppyReadBlocks ( goto Done;
}
- if (!EFI_ERROR (Status)) {
-
- Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, 1);
- if (EFI_ERROR (Status)) {
- This->Reset (This, TRUE);
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
-
- LBA += 1;
- NumberOfBlocks -= 1;
- Buffer = (UINT8 *) Buffer + This->Media->BlockSize;
+ while (NumberOfBlocks > 0) {
- if (NumberOfBlocks == 0) {
- Status = EFI_SUCCESS;
- goto Done;
+ if (NumberOfBlocks > BLOCK_UNIT) {
+ Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);
+ } else {
+ Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
}
- Status = USBFloppyRead10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
if (EFI_ERROR (Status)) {
This->Reset (This, TRUE);
Status = EFI_DEVICE_ERROR;
}
- }
-Done:
- gBS->RestoreTPL (OldTpl);
+ if (NumberOfBlocks > BLOCK_UNIT) {
+ NumberOfBlocks -= BLOCK_UNIT;
+ LBA += BLOCK_UNIT;
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;
+ } else {
+ NumberOfBlocks -= NumberOfBlocks;
+ LBA += NumberOfBlocks;
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;
+ }
+ }
+
+ Done:
return Status;
}
@@ -561,29 +554,29 @@ USBFloppyWriteBlocks ( Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks() function.
-
+
Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance.
MediaId The media id that the write request is for.
LBA The starting logical block address to be written.
- The caller is responsible for writing to only
+ The caller is responsible for writing to only
legitimate locations.
BufferSize
- The size of the Buffer in bytes. This must be a multiple of
+ The size of the Buffer in bytes. This must be a multiple of
the intrinsic block size of the device.
- Buffer A pointer to the source buffer for the data. The caller
+ Buffer A pointer to the source buffer for the data. The caller
is responsible for either having implicit or explicit ownership
- of the buffer.
-
- Returns:
+ of the buffer.
+
+ Returns:
EFI_INVALID_PARAMETER - Parameter is error
- EFI_SUCCESS - Success
+ EFI_SUCCESS - Success
EFI_DEVICE_ERROR - Hardware Error
EFI_NO_MEDIA - No media
EFI_MEDIA_CHANGED - Media Change
EFI_BAD_BUFFER_SIZE - Buffer size is bad
---*/
+--*/
{
USB_FLOPPY_DEV *UsbFloppyDevice;
EFI_STATUS Status;
@@ -591,9 +584,7 @@ USBFloppyWriteBlocks ( UINTN BlockSize;
UINTN NumberOfBlocks;
BOOLEAN MediaChange;
- EFI_TPL OldTpl;
- OldTpl = gBS->RaiseTPL (EFI_TPL_NOTIFY);
Status = EFI_SUCCESS;
MediaChange = FALSE;
@@ -622,14 +613,12 @@ USBFloppyWriteBlocks ( }
if (MediaChange) {
- gBS->RestoreTPL (OldTpl);
gBS->ReinstallProtocolInterface (
UsbFloppyDevice->Handle,
&gEfiBlockIoProtocolGuid,
&UsbFloppyDevice->BlkIo,
&UsbFloppyDevice->BlkIo
);
- gBS->RaiseTPL (EFI_TPL_NOTIFY);
}
Media = UsbFloppyDevice->BlkIo.Media;
@@ -671,32 +660,32 @@ USBFloppyWriteBlocks ( goto Done;
}
- if (!EFI_ERROR (Status)) {
- Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, 1);
- if (EFI_ERROR (Status)) {
- This->Reset (This, TRUE);
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
-
- LBA += 1;
- NumberOfBlocks -= 1;
- Buffer = (UINT8 *) Buffer + This->Media->BlockSize;
+ while (NumberOfBlocks > 0) {
- if (NumberOfBlocks == 0) {
- Status = EFI_SUCCESS;
- goto Done;
+ if (NumberOfBlocks > BLOCK_UNIT) {
+ Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, BLOCK_UNIT);
+ } else {
+ Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
}
- Status = USBFloppyWrite10 (UsbFloppyDevice, Buffer, LBA, NumberOfBlocks);
if (EFI_ERROR (Status)) {
This->Reset (This, TRUE);
Status = EFI_DEVICE_ERROR;
}
- }
+
+ if (NumberOfBlocks > BLOCK_UNIT) {
+ NumberOfBlocks -= BLOCK_UNIT;
+ LBA += BLOCK_UNIT;
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * BLOCK_UNIT;
+ } else {
+ NumberOfBlocks -= NumberOfBlocks;
+ LBA += NumberOfBlocks;
+ Buffer = (UINT8 *) Buffer + This->Media->BlockSize * NumberOfBlocks;
+ }
+ }
Done:
- gBS->RestoreTPL (OldTpl);
+
return Status;
}
@@ -711,13 +700,13 @@ USBFloppyFlushBlocks ( Routine Description:
Implements EFI_BLOCK_IO_PROTOCOL.FlushBlocks() function.
(In this driver, this function just returns EFI_SUCCESS.)
-
+
Arguments:
This The EFI_BLOCK_IO_PROTOCOL instance.
-
- Returns:
+
+ Returns:
EFI_SUCCESS - Success
---*/
+--*/
{
return EFI_SUCCESS;
}
diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.h b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.h index fc19930cbd..832befcccc 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.h +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorage.h @@ -1,12 +1,12 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
@@ -37,6 +37,8 @@ Revision History #define USBFLOPPY2 2 // for those that use ReadFormatCapacity(0x23) command to retrieve media capacity
#define USBCDROM 3
+#define BLOCK_UNIT 128
+
#define USB_FLOPPY_DEV_SIGNATURE EFI_SIGNATURE_32 ('u', 'f', 'l', 'p')
typedef struct {
@@ -50,7 +52,6 @@ typedef struct { REQUEST_SENSE_DATA *SenseData;
UINT8 SenseDataNumber;
UINT8 DeviceType;
-
} USB_FLOPPY_DEV;
#define USB_FLOPPY_DEV_FROM_THIS(a) \
diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageData.h b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageData.h index 45433edfc2..cef33bd4f5 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageData.h +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageData.h @@ -1,12 +1,12 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
@@ -30,7 +30,7 @@ Revision History //
// timeout unit is in millisecond.
//
-#define USBFLPTIMEOUT 2000
+#define USBFLPTIMEOUT 1000
#define STALL_1_MILLI_SECOND 1000
//
diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c index de61eeb6d0..c81fbf299e 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.c @@ -1,18 +1,18 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
UsbMassStorageHelper.c
-
+
Abstract:
Helper functions for USB Mass Storage Driver
@@ -80,19 +80,19 @@ USBFloppyPacketCommand ( Routine Description:
Sends Packet Command to USB Floppy Drive.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
Command - A pointer to the command packet.
CommandSize - Indicates the size of the command packet.
DataBuffer - A pointer to the buffer for the data transfer
- after the command packet.
+ after the command packet.
BufferLength - Indicates the size of the Data Buffer.
Direction - Transfer Direction
TimeOutInMilliSeconds - Timeout Value
- Returns:
+ Returns:
EFI_SUCCESS - Success
---*/
+--*/
{
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
EFI_STATUS Status;
@@ -123,14 +123,14 @@ USBFloppyIdentify ( Routine Description:
Retrieves device information to tell the device type.
-
+
Arguments:
UsbFloppyDevice The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
+--*/
{
EFI_STATUS Status;
@@ -144,7 +144,7 @@ USBFloppyIdentify ( if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
-
+
//
// Get media removable info from INQUIRY data.
//
@@ -201,7 +201,7 @@ USBFloppyIdentify ( gBS->FreePool (Idata);
return EFI_DEVICE_ERROR;
}
-
+
//
// Get media information.
//
@@ -221,16 +221,16 @@ USBFloppyInquiry ( Routine Description:
Send Inquiry Packet Command to device and retrieve Inquiry Data.
-
+
Arguments:
UsbFloppyDevice The USB_FLOPPY_DEV instance.
- Idata A pointer pointing to the address of
+ Idata A pointer pointing to the address of
Inquiry Data.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
+--*/
{
ATAPI_PACKET_COMMAND Packet;
EFI_STATUS Status;
@@ -272,31 +272,31 @@ USBFloppyInquiry ( EFI_STATUS
USBFloppyRead10 (
- IN USB_FLOPPY_DEV *UsbFloppyDevice,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
+ IN USB_FLOPPY_DEV *UsbFloppyDevice,
+ IN VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks
)
/*++
Routine Description:
Sends Read10 Packet Command to device to perform data transfer
from device to host.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
- Buffer - A pointer to the destination buffer for the data.
+ Buffer - A pointer to the destination buffer for the data.
The caller is responsible for either having implicit
or explicit ownership of the buffer.
- Lba - The starting logical block address to read from
+ Lba - The starting logical block address to read from
on the device.
- NumberOfBlocks - Indicates the number of blocks that the read
+ NumberOfBlocks - Indicates the number of blocks that the read
operation requests.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
+--*/
{
ATAPI_PACKET_COMMAND Packet;
READ10_CMD *Read10Packet;
@@ -310,7 +310,7 @@ USBFloppyRead10 ( EFI_STATUS Status;
UINT16 TimeOut;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
- UINTN SenseCounts;
+ UINT8 Index;
UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;
@@ -333,78 +333,52 @@ USBFloppyRead10 ( } else {
SectorCount = MaxBlock;
}
- //
- // fill the Packet data structure
- //
- Read10Packet->opcode = READ_10;
- //
- // Lba0 ~ Lba3 specify the start logical block address of the data transfer.
- // Lba0 is MSB, Lba3 is LSB
- //
- Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
- Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
- Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
- Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
+ for (Index = 0; Index < 3; Index ++) {
- //
- // TranLen0 ~ TranLen1 specify the transfer length in block unit.
- // TranLen0 is MSB, TranLen is LSB
- //
- Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
- Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
+ //
+ // fill the Packet data structure
+ //
+ Read10Packet->opcode = READ_10;
+ //
+ // Lba0 ~ Lba3 specify the start logical block address of the data transfer.
+ // Lba0 is MSB, Lba3 is LSB
+ //
+ Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
+ Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
+ Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
+ Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
- ByteCount = SectorCount * BlockSize;
+ //
+ // TranLen0 ~ TranLen1 specify the transfer length in block unit.
+ // TranLen0 is MSB, TranLen is LSB
+ //
+ Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
+ Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
- TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
+ ByteCount = SectorCount * BlockSize;
- Status = USBFloppyPacketCommand (
- UsbFloppyDevice,
- &Packet,
- sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) ptrBuffer,
- ByteCount,
- EfiUsbDataIn,
- TimeOut
- );
- if (EFI_ERROR (Status)) {
+ TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
- Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);
- if (!EFI_ERROR (Status)) {
- if (IsLogicalUnitCommunicationOverRun (
- UsbFloppyDevice->SenseData,
- SenseCounts
- )) {
- Lba32 = (UINT32) Lba;
- ptrBuffer = Buffer;
- BlocksRemaining = (UINT16) NumberOfBlocks;
- MaxBlock = (UINT16) (MaxBlock / 4);
- if (MaxBlock < 1) {
- MaxBlock = 1;
- }
- continue;
- }
- } else {
- return EFI_DEVICE_ERROR;
- }
- //
- // retry read10 command
- //
Status = USBFloppyPacketCommand (
- UsbFloppyDevice,
- &Packet,
- sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) ptrBuffer,
- ByteCount,
- EfiUsbDataIn,
- TimeOut
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ UsbFloppyDevice,
+ &Packet,
+ sizeof (ATAPI_PACKET_COMMAND),
+ (VOID *) ptrBuffer,
+ ByteCount,
+ EfiUsbDataIn,
+ TimeOut
+ );
+ if (!EFI_ERROR (Status)) {
+ break;
}
}
+ if (Index == 3) {
+ return EFI_DEVICE_ERROR;
+ }
+
Lba32 += SectorCount;
ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize;
BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);
@@ -420,17 +394,17 @@ USBFloppyReadCapacity ( /*++
Routine Description:
- Retrieves media capacity information via
+ Retrieves media capacity information via
sending Read Capacity Packet Command.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
-{
+--*/
+{
//
// status returned by Read Capacity Packet Command
//
@@ -483,17 +457,17 @@ USBFloppyReadFormatCapacity ( /*++
Routine Description:
- Retrieves media capacity information via sending Read Format
+ Retrieves media capacity information via sending Read Format
Capacity Packet Command.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
-{
+--*/
+{
//
// status returned by Read Capacity Packet Command
//
@@ -537,7 +511,7 @@ USBFloppyReadFormatCapacity ( } else {
UsbFloppyDevice->BlkIo.Media->LastBlock = (FormatData.LastLba3 << 24) |
- (FormatData.LastLba2 << 16) |
+ (FormatData.LastLba2 << 16) |
(FormatData.LastLba1 << 8) |
FormatData.LastLba0;
@@ -565,17 +539,17 @@ UsbFloppyRequestSense ( /*++
Routine Description:
- Retrieves Sense Data from device via
+ Retrieves Sense Data from device via
sending Request Sense Packet Command.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
SenseCounts - A pointer to the number of Sense Data returned.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
+--*/
{
EFI_STATUS Status;
REQUEST_SENSE_DATA *Sense;
@@ -598,7 +572,7 @@ UsbFloppyRequestSense ( ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
Packet.RequestSense.opcode = REQUEST_SENSE;
Packet.RequestSense.allocation_length = sizeof (REQUEST_SENSE_DATA);
-
+
//
// initialize pointer
//
@@ -666,7 +640,7 @@ UsbFloppyRequestSense ( //
SenseReq = FALSE;
}
-
+
//
// If the sense key numbers exceed Sense Data Buffer size,
// just skip the loop and do not fetch the sense key in this function.
@@ -687,25 +661,25 @@ UsbFloppyTestUnitReady ( Routine Description:
Sends Test Unit ReadyPacket Command to the device.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
-{
- ATAPI_PACKET_COMMAND Packet;
+--*/
+{
+ ATAPI_PACKET_COMMAND Packet;
EFI_STATUS Status;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
UINT32 RetryIndex;
UINT32 MaximumRetryTimes;
-
+
UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;
MaximumRetryTimes = 2;
//
- // fill command packet
+ // fill command packet
//
ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
Packet.TestUnitReady.opcode = TEST_UNIT_READY;
@@ -737,31 +711,31 @@ UsbFloppyTestUnitReady ( EFI_STATUS
USBFloppyWrite10 (
- IN USB_FLOPPY_DEV *UsbFloppyDevice,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
+ IN USB_FLOPPY_DEV *UsbFloppyDevice,
+ IN VOID *Buffer,
+ IN EFI_LBA Lba,
+ IN UINTN NumberOfBlocks
)
/*++
Routine Description:
Sends Write10 Packet Command to device to perform data transfer
from host to device.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
- Buffer - A pointer to the source buffer for the data.
+ Buffer - A pointer to the source buffer for the data.
The caller is responsible for either having implicit
or explicit ownership of the buffer.
- Lba - The starting logical block address to written to
+ Lba - The starting logical block address to written to
the device.
- NumberOfBlocks - Indicates the number of blocks that the write
+ NumberOfBlocks - Indicates the number of blocks that the write
operation requests.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
+--*/
{
ATAPI_PACKET_COMMAND Packet;
READ10_CMD *Write10Packet;
@@ -775,7 +749,7 @@ USBFloppyWrite10 ( EFI_STATUS Status;
UINT16 TimeOut;
EFI_USB_ATAPI_PROTOCOL *UsbAtapiInterface;
- UINTN SenseCounts;
+ UINT8 Index;
UsbAtapiInterface = UsbFloppyDevice->AtapiProtocol;
@@ -795,82 +769,56 @@ USBFloppyWrite10 ( while (BlocksRemaining > 0) {
if (BlocksRemaining <= MaxBlock) {
-
SectorCount = BlocksRemaining;
} else {
-
SectorCount = MaxBlock;
}
- //
- // fill the Packet data structure
- //
- Write10Packet->opcode = WRITE_10;
- //
- // Lba0 ~ Lba3 specify the start logical block address
- // of the data transfer.
- // Lba0 is MSB, Lba3 is LSB
- //
- Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
- Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);
- Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);
- Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);
+ for (Index = 0; Index < 3; Index ++) {
+ //
+ // fill the Packet data structure
+ //
+ Write10Packet->opcode = WRITE_10;
- //
- // TranLen0 ~ TranLen1 specify the transfer length in block unit.
- // TranLen0 is MSB, TranLen is LSB
- //
- Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
- Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
+ //
+ // Lba0 ~ Lba3 specify the start logical block address
+ // of the data transfer.
+ // Lba0 is MSB, Lba3 is LSB
+ //
+ Write10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
+ Write10Packet->Lba2 = (UINT8) (Lba32 >> 8);
+ Write10Packet->Lba1 = (UINT8) (Lba32 >> 16);
+ Write10Packet->Lba0 = (UINT8) (Lba32 >> 24);
- ByteCount = SectorCount * BlockSize;
+ //
+ // TranLen0 ~ TranLen1 specify the transfer length in block unit.
+ // TranLen0 is MSB, TranLen is LSB
+ //
+ Write10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
+ Write10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
- TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
+ ByteCount = SectorCount * BlockSize;
- Status = USBFloppyPacketCommand (
- UsbFloppyDevice,
- &Packet,
- sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) ptrBuffer,
- ByteCount,
- EfiUsbDataOut,
- TimeOut
- );
- if (EFI_ERROR (Status)) {
- Status = UsbFloppyRequestSense (UsbFloppyDevice, &SenseCounts);
- if (!EFI_ERROR (Status)) {
- if (IsLogicalUnitCommunicationOverRun (
- UsbFloppyDevice->SenseData,
- SenseCounts
- )) {
- Lba32 = (UINT32) Lba;
- ptrBuffer = Buffer;
- BlocksRemaining = (UINT16) NumberOfBlocks;
- MaxBlock = (UINT16) (MaxBlock / 4);
- if (MaxBlock < 1) {
- MaxBlock = 1;
- }
+ TimeOut = (UINT16) (SectorCount * USBFLPTIMEOUT);
- continue;
- }
- }
- //
- // retry write10 command
- //
Status = USBFloppyPacketCommand (
- UsbFloppyDevice,
- &Packet,
- sizeof (ATAPI_PACKET_COMMAND),
- (VOID *) ptrBuffer,
- ByteCount,
- EfiUsbDataOut,
- TimeOut
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ UsbFloppyDevice,
+ &Packet,
+ sizeof (ATAPI_PACKET_COMMAND),
+ (VOID *) ptrBuffer,
+ ByteCount,
+ EfiUsbDataOut,
+ TimeOut
+ );
+ if (!EFI_ERROR (Status)) {
+ break;
}
}
+ if (Index == 3) {
+ return EFI_DEVICE_ERROR;
+ }
+
Lba32 += SectorCount;
ptrBuffer = (UINT8 *) ptrBuffer + SectorCount * BlockSize;
BlocksRemaining = (UINT16) (BlocksRemaining - SectorCount);
@@ -888,16 +836,16 @@ UsbFloppyDetectMedia ( Routine Description:
Retrieves media information.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
MediaChange - Indicates whether media was changed.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
EFI_INVALID_PARAMETER - Parameter is error
---*/
+--*/
{
EFI_STATUS Status;
EFI_STATUS FloppyStatus;
@@ -910,11 +858,10 @@ UsbFloppyDetectMedia ( UINTN RetryTimes;
UINTN MaximumRetryTimes;
BOOLEAN NeedRetry;
-
+ BOOLEAN NeedReadCapacity;
//
// a flag used to determine whether need to perform Read Capacity command.
//
- BOOLEAN NeedReadCapacity;
REQUEST_SENSE_DATA *SensePtr;
@@ -955,14 +902,14 @@ UsbFloppyDetectMedia ( if (IsMediaChange (UsbFloppyDevice->SenseData, SenseCounts)) {
UsbFloppyDevice->BlkIo.Media->MediaId++;
}
-
+
//
// Media Write-protected
//
if (IsMediaWriteProtected (UsbFloppyDevice->SenseData, SenseCounts)) {
UsbFloppyDevice->BlkIo.Media->ReadOnly = TRUE;
}
-
+
//
// Media Error
//
@@ -1078,7 +1025,7 @@ UsbFloppyDetectMedia ( }
if (!IsDriveReady (UsbFloppyDevice->SenseData, SenseCounts, &NeedRetry)) {
-
+
//
// Drive not ready: if NeedRetry, then retry once more;
// else return error
@@ -1160,18 +1107,18 @@ UsbFloppyModeSense5APage5 ( /*++
Routine Description:
- Retrieves media capacity information via sending Read Format
+ Retrieves media capacity information via sending Read Format
Capacity Packet Command.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
-
---*/
-{
+
+--*/
+{
//
// status returned by Read Capacity Packet Command
//
@@ -1246,18 +1193,18 @@ UsbFloppyModeSense5APage1C ( /*++
Routine Description:
- Retrieves media capacity information via sending Read Format
+ Retrieves media capacity information via sending Read Format
Capacity Packet Command.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
-
---*/
-{
+
+--*/
+{
//
// status returned by Read Capacity Packet Command
//
@@ -1323,16 +1270,16 @@ UsbFloppyModeSense5APage3F ( Routine Description:
Retrieves mode sense information via sending Mode Sense
Packet Command.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
---*/
-{
+--*/
+{
//
// status returned by Read Capacity Packet Command
//
@@ -1381,16 +1328,16 @@ UsbSCSIModeSense1APage3F ( Routine Description:
Retrieves mode sense information via sending Mode Sense
Packet Command.
-
+
Arguments:
UsbFloppyDevice - The USB_FLOPPY_DEV instance.
-
- Returns:
+
+ Returns:
EFI_DEVICE_ERROR - Hardware error
EFI_SUCCESS - Success
-
---*/
-{
+
+--*/
+{
//
// status returned by Read Capacity Packet Command
//
@@ -1450,7 +1397,7 @@ IsNoMedia ( for (Index = 0; Index < SenseCounts; Index++) {
- if ((SensePtr->sense_key == SK_NOT_READY) &&
+ if ((SensePtr->sense_key == SK_NOT_READY) &&
(SensePtr->addnl_sense_code == ASC_NO_MEDIA)) {
NoMedia = TRUE;
@@ -1479,7 +1426,7 @@ IsMediaError ( for (Index = 0; Index < SenseCounts; Index++) {
switch (SensePtr->sense_key) {
-
+
//
// Medium error case
//
diff --git a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.h b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.h index f41241adc4..dc810bc3dc 100644 --- a/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.h +++ b/EdkModulePkg/Bus/Usb/UsbMassStorage/Dxe/UsbMassStorageHelper.h @@ -1,12 +1,12 @@ /*++
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
|