/** @file\r
+ \r
+ The Ehci controller driver.\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- Ehci.c\r
-\r
-Abstract:\r
-\r
-\r
-Revision History\r
-\r
**/\r
\r
\r
{PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT}\r
};\r
\r
+EFI_DRIVER_BINDING_PROTOCOL\r
+gEhciDriverBinding = {\r
+ EhcDriverBindingSupported,\r
+ EhcDriverBindingStart,\r
+ EhcDriverBindingStop,\r
+ 0x10,\r
+ NULL,\r
+ NULL\r
+};\r
\r
/**\r
- Retrieves the capablility of root hub ports.\r
+ Retrieves the capability of root hub ports.\r
\r
- @param This This EFI_USB_HC_PROTOCOL instance.\r
- @param MaxSpeed Max speed supported by the controller\r
- @param PortNumber Number of the root hub ports.\r
- @param Is64BitCapable Whether the controller supports 64-bit memory\r
- addressing.\r
+ @param This This EFI_USB_HC_PROTOCOL instance.\r
+ @param MaxSpeed Max speed supported by the controller.\r
+ @param PortNumber Number of the root hub ports.\r
+ @param Is64BitCapable Whether the controller supports 64-bit memory\r
+ addressing.\r
\r
- @return EFI_SUCCESS : host controller capability were retrieved successfully.\r
- @return EFI_INVALID_PARAMETER : Either of the three capability pointer is NULL\r
+ @retval EFI_SUCCESS Host controller capability were retrieved successfully.\r
+ @retval EFI_INVALID_PARAMETER Either of the three capability pointer is NULL.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcGetCapability (\r
*PortNumber = (UINT8) (Ehc->HcStructParams & HCSP_NPORTS);\r
*Is64BitCapable = (UINT8) (Ehc->HcCapParams & HCCP_64BIT);\r
\r
- EHC_DEBUG (("EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable));\r
+ DEBUG ((EFI_D_INFO, "EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable));\r
\r
gBS->RestoreTPL (OldTpl);\r
return EFI_SUCCESS;\r
/**\r
Provides software reset for the USB host controller.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param Attributes A bit mask of the reset operation to perform.\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param Attributes A bit mask of the reset operation to perform.\r
\r
- @return EFI_SUCCESS : The reset operation succeeded.\r
- @return EFI_INVALID_PARAMETER : Attributes is not valid.\r
- @return EFI_UNSUPPOURTED : The type of reset specified by Attributes is\r
- @return not currently supported by the host controller.\r
- @return EFI_DEVICE_ERROR : Host controller isn't halted to reset.\r
+ @retval EFI_SUCCESS The reset operation succeeded.\r
+ @retval EFI_INVALID_PARAMETER Attributes is not valid.\r
+ @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is\r
+ not currently supported by the host controller.\r
+ @retval EFI_DEVICE_ERROR Host controller isn't halted to reset.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcReset (\r
}\r
\r
ON_EXIT:\r
- EHC_DEBUG (("EhcReset: exit status %r\n", Status));\r
+ DEBUG ((EFI_D_INFO, "EhcReset: exit status %r\n", Status));\r
gBS->RestoreTPL (OldTpl);\r
return Status;\r
}\r
/**\r
Retrieve the current state of the USB host controller.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param State Variable to return the current host controller\r
- state.\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param State Variable to return the current host controller\r
+ state.\r
\r
- @return EFI_SUCCESS : Host controller state was returned in State.\r
- @return EFI_INVALID_PARAMETER : State is NULL.\r
- @return EFI_DEVICE_ERROR : An error was encountered while attempting to\r
- @return retrieve the host controller's current state.\r
+ @retval EFI_SUCCESS Host controller state was returned in State.\r
+ @retval EFI_INVALID_PARAMETER State is NULL.\r
+ @retval EFI_DEVICE_ERROR An error was encountered while attempting to\r
+ retrieve the host controller's current state.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcGetState (\r
\r
gBS->RestoreTPL (OldTpl);\r
\r
- EHC_DEBUG (("EhcGetState: current state %d\n", *State));\r
+ DEBUG ((EFI_D_INFO, "EhcGetState: current state %d\n", *State));\r
return EFI_SUCCESS;\r
}\r
\r
/**\r
Sets the USB host controller to a specific state.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param State The state of the host controller that will be set.\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param State The state of the host controller that will be set.\r
\r
- @return EFI_SUCCESS : The USB host controller was successfully placed\r
- @return in the state specified by State.\r
- @return EFI_INVALID_PARAMETER : State is invalid.\r
- @return EFI_DEVICE_ERROR : Failed to set the state due to device error.\r
+ @retval EFI_SUCCESS The USB host controller was successfully placed\r
+ in the state specified by State.\r
+ @retval EFI_INVALID_PARAMETER State is invalid.\r
+ @retval EFI_DEVICE_ERROR Failed to set the state due to device error.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcSetState (\r
Status = EFI_INVALID_PARAMETER;\r
}\r
\r
- EHC_DEBUG (("EhcSetState: exit status %r\n", Status));\r
+ DEBUG ((EFI_D_INFO, "EhcSetState: exit status %r\n", Status));\r
gBS->RestoreTPL (OldTpl);\r
return Status;\r
}\r
/**\r
Retrieves the current status of a USB root hub port.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param PortNumber The root hub port to retrieve the state from. This\r
- value is zero-based.\r
- @param PortStatus Variable to receive the port state\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param PortNumber The root hub port to retrieve the state from.\r
+ This value is zero-based.\r
+ @param PortStatus Variable to receive the port state.\r
\r
- @return EFI_SUCCESS : The status of the USB root hub port specified\r
- @return by PortNumber was returned in PortStatus.\r
- @return EFI_INVALID_PARAMETER : PortNumber is invalid.\r
- @return EFI_DEVICE_ERROR : Can't read register\r
+ @retval EFI_SUCCESS The status of the USB root hub port specified.\r
+ by PortNumber was returned in PortStatus.\r
+ @retval EFI_INVALID_PARAMETER PortNumber is invalid.\r
+ @retval EFI_DEVICE_ERROR Can't read register.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcGetRootHubPortStatus (\r
/**\r
Sets a feature for the specified root hub port.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param PortNumber Root hub port to set.\r
- @param PortFeature Feature to set\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param PortNumber Root hub port to set.\r
+ @param PortFeature Feature to set.\r
\r
- @return EFI_SUCCESS : The feature specified by PortFeature was set\r
- @return EFI_INVALID_PARAMETER : PortNumber is invalid or PortFeature is invalid.\r
- @return EFI_DEVICE_ERROR : Can't read register\r
+ @retval EFI_SUCCESS The feature specified by PortFeature was set.\r
+ @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.\r
+ @retval EFI_DEVICE_ERROR Can't read register.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcSetRootHubPortFeature (\r
Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_DEBUG (("EhcSetRootHubPortFeature :failed to start HC - %r\n", Status));\r
+ DEBUG ((EFI_D_INFO, "EhcSetRootHubPortFeature :failed to start HC - %r\n", Status));\r
break;\r
}\r
}\r
}\r
\r
ON_EXIT:\r
- EHC_DEBUG (("EhcSetRootHubPortFeature: exit status %r\n", Status));\r
+ DEBUG ((EFI_D_INFO, "EhcSetRootHubPortFeature: exit status %r\n", Status));\r
\r
gBS->RestoreTPL (OldTpl);\r
return Status;\r
/**\r
Clears a feature for the specified root hub port.\r
\r
- @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
- @param PortNumber Specifies the root hub port whose feature is\r
- requested to be cleared.\r
- @param PortFeature Indicates the feature selector associated with the\r
- feature clear request.\r
+ @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.\r
+ @param PortNumber Specifies the root hub port whose feature is\r
+ requested to be cleared.\r
+ @param PortFeature Indicates the feature selector associated with the\r
+ feature clear request.\r
\r
- @return EFI_SUCCESS : The feature specified by PortFeature was cleared\r
- @return for the USB root hub port specified by PortNumber.\r
- @return EFI_INVALID_PARAMETER : PortNumber is invalid or PortFeature is invalid.\r
- @return EFI_DEVICE_ERROR : Can't read register\r
+ @retval EFI_SUCCESS The feature specified by PortFeature was cleared\r
+ for the USB root hub port specified by PortNumber.\r
+ @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.\r
+ @retval EFI_DEVICE_ERROR Can't read register.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcClearRootHubPortFeature (\r
}\r
\r
ON_EXIT:\r
- EHC_DEBUG (("EhcClearRootHubPortFeature: exit status %r\n", Status));\r
+ DEBUG ((EFI_D_INFO, "EhcClearRootHubPortFeature: exit status %r\n", Status));\r
gBS->RestoreTPL (OldTpl);\r
return Status;\r
}\r
/**\r
Submits control transfer to a target USB device.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param DeviceAddress The target device address\r
- @param DeviceSpeed Target device speed.\r
- @param MaximumPacketLength Maximum packet size the default control transfer\r
- endpoint is capable of sending or receiving.\r
- @param Request USB device request to send\r
- @param TransferDirection Specifies the data direction for the data stage\r
- @param Data Data buffer to be transmitted or received from USB\r
- device.\r
- @param DataLength The size (in bytes) of the data buffer\r
- @param TimeOut Indicates the maximum timeout, in millisecond,\r
- @param Translator Transaction translator to be used by this device.\r
- @param TransferResult Return the result of this control transfer.\r
-\r
- @return EFI_SUCCESS : Transfer was completed successfully.\r
- @return EFI_OUT_OF_RESOURCES : The transfer failed due to lack of resources.\r
- @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
- @return EFI_TIMEOUT : Transfer failed due to timeout.\r
- @return EFI_DEVICE_ERROR : Transfer failed due to host controller or device error.\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param DeviceAddress The target device address.\r
+ @param DeviceSpeed Target device speed.\r
+ @param MaximumPacketLength Maximum packet size the default control transfer\r
+ endpoint is capable of sending or receiving.\r
+ @param Request USB device request to send.\r
+ @param TransferDirection Specifies the data direction for the data stage\r
+ @param Data Data buffer to be transmitted or received from USB\r
+ device.\r
+ @param DataLength The size (in bytes) of the data buffer.\r
+ @param TimeOut Indicates the maximum timeout, in millisecond.\r
+ @param Translator Transaction translator to be used by this device.\r
+ @param TransferResult Return the result of this control transfer.\r
+\r
+ @retval EFI_SUCCESS Transfer was completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.\r
+ @retval EFI_INVALID_PARAMETER Some parameters are invalid.\r
+ @retval EFI_TIMEOUT Transfer failed due to timeout.\r
+ @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcControlTransfer (\r
*TransferResult = EFI_USB_ERR_SYSTEM;\r
\r
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {\r
- EHC_ERROR (("EhcControlTransfer: HC halted at entrance\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcControlTransfer: HC halted at entrance\n"));\r
\r
EhcAckAllInterrupt (Ehc);\r
goto ON_EXIT;\r
);\r
\r
if (Urb == NULL) {\r
- EHC_ERROR (("EhcControlTransfer: failed to create URB"));\r
+ DEBUG ((EFI_D_ERROR, "EhcControlTransfer: failed to create URB"));\r
\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
gBS->RestoreTPL (OldTpl);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult));\r
+ DEBUG ((EFI_D_ERROR, "EhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult));\r
}\r
\r
return Status;\r
/**\r
Submits bulk transfer to a bulk endpoint of a USB device.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param DeviceAddress Target device address\r
- @param EndPointAddress Endpoint number and its direction in bit 7. .\r
- @param DeviceSpeed Device speed, Low speed device doesn't support bulk\r
- transfer.\r
- @param MaximumPacketLength Maximum packet size the endpoint is capable of\r
- sending or receiving.\r
- @param DataBuffersNumber Number of data buffers prepared for the transfer.\r
- @param Data Array of pointers to the buffers of data to transmit\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param DeviceAddress Target device address.\r
+ @param EndPointAddress Endpoint number and its direction in bit 7.\r
+ @param DeviceSpeed Device speed, Low speed device doesn't support bulk\r
+ transfer.\r
+ @param MaximumPacketLength Maximum packet size the endpoint is capable of\r
+ sending or receiving.\r
+ @param DataBuffersNumber Number of data buffers prepared for the transfer.\r
+ @param Data Array of pointers to the buffers of data to transmit\r
from or receive into.\r
- @param DataLength The lenght of the data buffer\r
- @param DataToggle On input, the initial data toggle for the transfer;\r
- On output, it is updated to to next data toggle to\r
- use of the subsequent bulk\r
- transfer.\r
- @param Translator A pointr to the transaction translator data.\r
- @param TimeOut Indicates the maximum time, in millisecond, which\r
- the transfer is allowed to complete.\r
- @param TransferResult A pointer to the detailed result information of the\r
- bulk transfer.\r
-\r
- @return EFI_SUCCESS : The transfer was completed successfully.\r
- @return EFI_OUT_OF_RESOURCES : The transfer failed due to lack of resource.\r
- @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
- @return EFI_TIMEOUT : The transfer failed due to timeout.\r
- @return EFI_DEVICE_ERROR : The transfer failed due to host controller error.\r
+ @param DataLength The lenght of the data buffer.\r
+ @param DataToggle On input, the initial data toggle for the transfer;\r
+ On output, it is updated to to next data toggle to\r
+ use of the subsequent bulk transfer.\r
+ @param TimeOut Indicates the maximum time, in millisecond, which\r
+ the transfer is allowed to complete.\r
+ @param Translator A pointr to the transaction translator data.\r
+ @param TransferResult A pointer to the detailed result information of the\r
+ bulk transfer.\r
+\r
+ @retval EFI_SUCCESS The transfer was completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.\r
+ @retval EFI_INVALID_PARAMETER Some parameters are invalid.\r
+ @retval EFI_TIMEOUT The transfer failed due to timeout.\r
+ @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcBulkTransfer (\r
Status = EFI_DEVICE_ERROR;\r
\r
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {\r
- EHC_ERROR (("EhcBulkTransfer: HC is halted\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: HC is halted\n"));\r
\r
EhcAckAllInterrupt (Ehc);\r
goto ON_EXIT;\r
);\r
\r
if (Urb == NULL) {\r
- EHC_ERROR (("EhcBulkTransfer: failed to create URB\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: failed to create URB\n"));\r
\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
gBS->RestoreTPL (OldTpl);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult));\r
+ DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult));\r
}\r
\r
return Status;\r
Submits an asynchronous interrupt transfer to an\r
interrupt endpoint of a USB device.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param DeviceAddress Target device address\r
- @param EndPointAddress Endpoint number and its direction encoded in bit 7\r
- @param DeviceSpeed Indicates device speed.\r
- @param MaximumPacketLength Maximum packet size the target endpoint is capable\r
- @param IsNewTransfer If TRUE, to submit an new asynchronous interrupt\r
- transfer If FALSE, to remove the specified\r
- asynchronous interrupt\r
- @param DataToggle On input, the initial data toggle to use; on output,\r
- it is updated to indicate the next data toggle\r
- @param PollingInterval The he interval, in milliseconds, that the transfer\r
- is polled.\r
- @param DataLength The length of data to receive at the rate specified\r
- by PollingInterval.\r
- @param Translator Transaction translator to use.\r
- @param CallBackFunction Function to call at the rate specified by\r
- PollingInterval\r
- @param Context Context to CallBackFunction.\r
-\r
- @return EFI_SUCCESS : The request has been successfully submitted or canceled.\r
- @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
- @return EFI_OUT_OF_RESOURCES : The request failed due to a lack of resources.\r
- @return EFI_DEVICE_ERROR : The transfer failed due to host controller error.\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param DeviceAddress Target device address.\r
+ @param EndPointAddress Endpoint number and its direction encoded in bit 7\r
+ @param DeviceSpeed Indicates device speed.\r
+ @param MaximumPacketLength Maximum packet size the target endpoint is capable\r
+ @param IsNewTransfer If TRUE, to submit an new asynchronous interrupt\r
+ transfer If FALSE, to remove the specified\r
+ asynchronous interrupt.\r
+ @param DataToggle On input, the initial data toggle to use; on output,\r
+ it is updated to indicate the next data toggle.\r
+ @param PollingInterval The he interval, in milliseconds, that the transfer\r
+ is polled.\r
+ @param DataLength The length of data to receive at the rate specified\r
+ by PollingInterval.\r
+ @param Translator Transaction translator to use.\r
+ @param CallBackFunction Function to call at the rate specified by\r
+ PollingInterval.\r
+ @param Context Context to CallBackFunction.\r
+\r
+ @retval EFI_SUCCESS The request has been successfully submitted or canceled.\r
+ @retval EFI_INVALID_PARAMETER Some parameters are invalid.\r
+ @retval EFI_OUT_OF_RESOURCES The request failed due to a lack of resources.\r
+ @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcAsyncInterruptTransfer (\r
if (!IsNewTransfer) {\r
Status = EhciDelAsyncIntTransfer (Ehc, DeviceAddress, EndPointAddress, DataToggle);\r
\r
- EHC_DEBUG (("EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status));\r
+ DEBUG ((EFI_D_INFO, "EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status));\r
goto ON_EXIT;\r
}\r
\r
Status = EFI_SUCCESS;\r
\r
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {\r
- EHC_ERROR (("EhcAsyncInterruptTransfer: HC is halt\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: HC is halt\n"));\r
EhcAckAllInterrupt (Ehc);\r
\r
Status = EFI_DEVICE_ERROR;\r
Data = AllocatePool (DataLength);\r
\r
if (Data == NULL) {\r
- EHC_ERROR (("EhcAsyncInterruptTransfer: failed to allocate buffer\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to allocate buffer\n"));\r
\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
);\r
\r
if (Urb == NULL) {\r
- EHC_ERROR (("EhcAsyncInterruptTransfer: failed to create URB\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to create URB\n"));\r
\r
gBS->FreePool (Data);\r
Status = EFI_OUT_OF_RESOURCES;\r
Submits synchronous interrupt transfer to an interrupt endpoint\r
of a USB device.\r
\r
- @param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param DeviceAddress Target device address\r
- @param EndPointAddress Endpoint number and its direction encoded in bit 7\r
- @param DeviceSpeed Indicates device speed.\r
- @param MaximumPacketLength Maximum packet size the target endpoint is capable\r
- of sending or receiving.\r
- @param Data Buffer of data that will be transmitted to USB\r
- device or received from USB device.\r
- @param DataLength On input, the size, in bytes, of the data buffer; On\r
- output, the number of bytes transferred.\r
- @param DataToggle On input, the initial data toggle to use; on output,\r
- it is updated to indicate the next data toggle\r
- @param TimeOut Maximum time, in second, to complete\r
- @param Translator Transaction translator to use.\r
- @param TransferResult Variable to receive the transfer result\r
-\r
- @return EFI_SUCCESS : The transfer was completed successfully.\r
- @return EFI_OUT_OF_RESOURCES : The transfer failed due to lack of resource.\r
- @return EFI_INVALID_PARAMETER : Some parameters are invalid.\r
- @return EFI_TIMEOUT : The transfer failed due to timeout.\r
- @return EFI_DEVICE_ERROR : The failed due to host controller or device error\r
+ @param This This EFI_USB2_HC_PROTOCOL instance.\r
+ @param DeviceAddress Target device address.\r
+ @param EndPointAddress Endpoint number and its direction encoded in bit 7\r
+ @param DeviceSpeed Indicates device speed.\r
+ @param MaximumPacketLength Maximum packet size the target endpoint is capable\r
+ of sending or receiving.\r
+ @param Data Buffer of data that will be transmitted to USB\r
+ device or received from USB device.\r
+ @param DataLength On input, the size, in bytes, of the data buffer; On\r
+ output, the number of bytes transferred.\r
+ @param DataToggle On input, the initial data toggle to use; on output,\r
+ it is updated to indicate the next data toggle.\r
+ @param TimeOut Maximum time, in second, to complete.\r
+ @param Translator Transaction translator to use.\r
+ @param TransferResult Variable to receive the transfer result.\r
+\r
+ @return EFI_SUCCESS The transfer was completed successfully.\r
+ @return EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.\r
+ @return EFI_INVALID_PARAMETER Some parameters are invalid.\r
+ @return EFI_TIMEOUT The transfer failed due to timeout.\r
+ @return EFI_DEVICE_ERROR The failed due to host controller or device error\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcSyncInterruptTransfer (\r
Status = EFI_DEVICE_ERROR;\r
\r
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {\r
- EHC_ERROR (("EhcSyncInterruptTransfer: HC is halt\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: HC is halt\n"));\r
\r
EhcAckAllInterrupt (Ehc);\r
goto ON_EXIT;\r
);\r
\r
if (Urb == NULL) {\r
- EHC_ERROR (("EhcSyncInterruptTransfer: failed to create URB\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: failed to create URB\n"));\r
\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ON_EXIT;\r
gBS->RestoreTPL (OldTpl);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult));\r
+ DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult));\r
}\r
\r
return Status;\r
Submits isochronous transfer to a target USB device.\r
\r
@param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param DeviceAddress Target device address\r
- @param EndPointAddress End point address with its direction\r
+ @param DeviceAddress Target device address.\r
+ @param EndPointAddress End point address with its direction.\r
@param DeviceSpeed Device speed, Low speed device doesn't support this\r
type.\r
@param MaximumPacketLength Maximum packet size that the endpoint is capable of\r
@param Data Array of pointers to the buffers of data that will\r
be transmitted to USB device or received from USB\r
device.\r
- @param DataLength The size, in bytes, of the data buffer\r
+ @param DataLength The size, in bytes, of the data buffer.\r
@param Translator Transaction translator to use.\r
- @param TransferResult Variable to receive the transfer result\r
+ @param TransferResult Variable to receive the transfer result.\r
\r
- @return EFI_UNSUPPORTED : Isochronous transfer is unsupported.\r
+ @return EFI_UNSUPPORTED Isochronous transfer is unsupported.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcIsochronousTransfer (\r
Submits Async isochronous transfer to a target USB device.\r
\r
@param This This EFI_USB2_HC_PROTOCOL instance.\r
- @param DeviceAddress Target device address\r
- @param EndPointAddress End point address with its direction\r
+ @param DeviceAddress Target device address.\r
+ @param EndPointAddress End point address with its direction.\r
@param DeviceSpeed Device speed, Low speed device doesn't support this\r
type.\r
@param MaximumPacketLength Maximum packet size that the endpoint is capable of\r
@param Data Array of pointers to the buffers of data that will\r
be transmitted to USB device or received from USB\r
device.\r
- @param DataLength The size, in bytes, of the data buffer\r
+ @param DataLength The size, in bytes, of the data buffer.\r
@param Translator Transaction translator to use.\r
- @param IsochronousCallBack Function to be called when the transfer complete\r
+ @param IsochronousCallBack Function to be called when the transfer complete.\r
@param Context Context passed to the call back function as\r
- parameter\r
+ parameter.\r
\r
- @return EFI_UNSUPPORTED : Isochronous transfer isn't supported\r
+ @return EFI_UNSUPPORTED Isochronous transfer isn't supported.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
EFIAPI\r
EhcAsyncIsochronousTransfer (\r
return EFI_UNSUPPORTED;\r
}\r
\r
+/**\r
+ Entry point for EFI drivers.\r
+\r
+ @param ImageHandle EFI_HANDLE.\r
+ @param SystemTable EFI_SYSTEM_TABLE.\r
+\r
+ @return EFI_SUCCESS Success.\r
+ EFI_DEVICE_ERROR Fail.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
EhcDriverEntryPoint (\r
IN EFI_HANDLE ImageHandle,\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Entry point for EFI drivers.\r
-\r
-Arguments:\r
-\r
- ImageHandle - EFI_HANDLE\r
- SystemTable - EFI_SYSTEM_TABLE\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS Success\r
- EFI_DEVICE_ERROR Fail\r
-\r
---*/\r
{\r
return EfiLibInstallDriverBindingComponentName2 (\r
ImageHandle,\r
be supported.\r
\r
@param This Protocol instance pointer.\r
- @param Controlle Handle of device to test\r
- @param RemainingDevicePath Not used\r
+ @param Controller Handle of device to test.\r
+ @param RemainingDevicePath Not used.\r
\r
- @return EFI_SUCCESS : This driver supports this device.\r
- @return EFI_UNSUPPORTED : This driver does not support this device.\r
+ @return EFI_SUCCESS This driver supports this device.\r
+ @return EFI_UNSUPPORTED This driver does not support this device.\r
\r
**/\r
EFI_STATUS\r
\r
\r
/**\r
- Create and initialize a USB2_HC_DEV\r
+ Create and initialize a USB2_HC_DEV.\r
\r
- @param PciIo The PciIo on this device\r
- @param OriginalPciAttributes Original PCI attributes\r
+ @param PciIo The PciIo on this device.\r
+ @param OriginalPciAttributes Original PCI attributes.\r
\r
- @return The allocated and initialized USB2_HC_DEV structure\r
- @return if created, otherwise NULL.\r
+ @return The allocated and initialized USB2_HC_DEV structure if created,\r
+ otherwise NULL.\r
\r
**/\r
-STATIC\r
USB2_HC_DEV *\r
EhcCreateUsb2Hc (\r
IN EFI_PCI_IO_PROTOCOL *PciIo,\r
Ehc->Usb2Hc.GetRootHubPortStatus = EhcGetRootHubPortStatus;\r
Ehc->Usb2Hc.SetRootHubPortFeature = EhcSetRootHubPortFeature;\r
Ehc->Usb2Hc.ClearRootHubPortFeature = EhcClearRootHubPortFeature;\r
- Ehc->Usb2Hc.MajorRevision = 0x1;\r
- Ehc->Usb2Hc.MinorRevision = 0x1;\r
+ Ehc->Usb2Hc.MajorRevision = 0x2;\r
+ Ehc->Usb2Hc.MinorRevision = 0x0;\r
\r
Ehc->PciIo = PciIo;\r
Ehc->OriginalPciAttributes = OriginalPciAttributes;\r
Ehc->HcCapParams = EhcReadCapRegister (Ehc, EHC_HCCPARAMS_OFFSET);\r
Ehc->CapLen = EhcReadCapRegister (Ehc, EHC_CAPLENGTH_OFFSET) & 0x0FF;\r
\r
- EHC_DEBUG (("EhcCreateUsb2Hc: capability length %d\n", Ehc->CapLen));\r
+ DEBUG ((EFI_D_INFO, "EhcCreateUsb2Hc: capability length %d\n", Ehc->CapLen));\r
\r
//\r
// Create AsyncRequest Polling Timer\r
Status = gBS->CreateEvent (\r
EVT_TIMER | EVT_NOTIFY_SIGNAL,\r
TPL_CALLBACK,\r
- EhcMoniteAsyncRequests,\r
+ EhcMonitorAsyncRequests,\r
Ehc,\r
&Ehc->PollTimer\r
);\r
return Ehc;\r
}\r
\r
+/**\r
+ One notified function to stop the Host Controller when gBS->ExitBootServices() called.\r
+\r
+ @param Event Pointer to this event\r
+ @param Context Event hanlder private data\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EhcExitBootService (\r
+ EFI_EVENT Event,\r
+ VOID *Context\r
+ )\r
+\r
+{\r
+ USB2_HC_DEV *Ehc;\r
+\r
+ Ehc = (USB2_HC_DEV *) Context;\r
+\r
+ //\r
+ // Stop the Host Controller\r
+ //\r
+ EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
+\r
+ return;\r
+}\r
+\r
\r
/**\r
- Starting the Usb EHCI Driver\r
+ Starting the Usb EHCI Driver.\r
\r
@param This Protocol instance pointer.\r
- @param Controller Handle of device to test\r
- @param RemainingDevicePath Not used\r
+ @param Controller Handle of device to test.\r
+ @param RemainingDevicePath Not used.\r
\r
- @return EFI_SUCCESS : supports this device.\r
- @return EFI_UNSUPPORTED : do not support this device.\r
- @return EFI_DEVICE_ERROR : cannot be started due to device Error\r
- @return EFI_OUT_OF_RESOURCES : cannot allocate resources\r
+ @return EFI_SUCCESS supports this device.\r
+ @return EFI_UNSUPPORTED do not support this device.\r
+ @return EFI_DEVICE_ERROR cannot be started due to device Error.\r
+ @return EFI_OUT_OF_RESOURCES cannot allocate resources.\r
\r
**/\r
EFI_STATUS\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcDriverBindingStart: failed to open PCI_IO\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to open PCI_IO\n"));\r
return EFI_DEVICE_ERROR;\r
}\r
\r
}\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcDriverBindingStart: failed to enable controller\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to enable controller\n"));\r
goto CLOSE_PCIIO;\r
}\r
\r
Ehc = EhcCreateUsb2Hc (PciIo, OriginalPciAttributes);\r
\r
if (Ehc == NULL) {\r
- EHC_ERROR (("EhcDriverBindingStart: failed to create USB2_HC\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to create USB2_HC\n"));\r
\r
Status = EFI_OUT_OF_RESOURCES;\r
goto CLOSE_PCIIO;\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcDriverBindingStart: failed to install USB2_HC Protocol\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to install USB2_HC Protocol\n"));\r
goto FREE_POOL;\r
}\r
\r
//\r
// Robustnesss improvement such as for UoL\r
+ // Default is not required.\r
//\r
- EhcClearLegacySupport (Ehc);\r
+ if (FeaturePcdGet (PcdTurnOffUsbLegacySupport)) {\r
+ EhcClearLegacySupport (Ehc);\r
+ }\r
EhcResetHC (Ehc, EHC_RESET_TIMEOUT);\r
\r
Status = EhcInitHC (Ehc);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcDriverBindingStart: failed to init host controller\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to init host controller\n"));\r
goto UNINSTALL_USBHC;\r
}\r
\r
Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_INTERVAL);\r
\r
if (EFI_ERROR (Status)) {\r
- EHC_ERROR (("EhcDriverBindingStart: failed to start async interrupt monitor\n"));\r
+ DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to start async interrupt monitor\n"));\r
\r
EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);\r
goto UNINSTALL_USBHC;\r
}\r
\r
+ //\r
+ // Create event to stop the HC when exit boot service.\r
+ //\r
+ Status = gBS->CreateEventEx (\r
+ EVT_NOTIFY_SIGNAL,\r
+ TPL_NOTIFY,\r
+ EhcExitBootService,\r
+ Ehc,\r
+ &gEfiEventExitBootServicesGuid,\r
+ &Ehc->ExitBootServiceEvent\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto UNINSTALL_USBHC;\r
+ }\r
+\r
//\r
// Install the component name protocol, don't fail the start\r
// because of something for display.\r
);\r
\r
\r
- EHC_DEBUG (("EhcDriverBindingStart: EHCI started for controller @ %x\n", Controller));\r
+ DEBUG ((EFI_D_INFO, "EhcDriverBindingStart: EHCI started for controller @ %p\n", Controller));\r
return EFI_SUCCESS;\r
\r
UNINSTALL_USBHC:\r
gBS->FreePool (Ehc);\r
\r
CLOSE_PCIIO:\r
- if (PciAttributesSaved == TRUE) {\r
+ if (PciAttributesSaved) {\r
//\r
// Restore original PCI attributes\r
//\r
created by this driver.\r
\r
@param This Protocol instance pointer.\r
- @param Controller Handle of device to stop driver on\r
- @param NumberOfChildren Number of Children in the ChildHandleBuffer\r
+ @param Controller Handle of device to stop driver on.\r
+ @param NumberOfChildren Number of Children in the ChildHandleBuffer.\r
@param ChildHandleBuffer List of handles for the children we need to stop.\r
\r
- @return EFI_SUCCESS Success\r
- @return EFI_DEVICE_ERROR Fail\r
+ @return EFI_SUCCESS Success.\r
+ @return EFI_DEVICE_ERROR Fail.\r
\r
**/\r
EFI_STATUS\r
gBS->CloseEvent (Ehc->PollTimer);\r
}\r
\r
+ if (Ehc->ExitBootServiceEvent != NULL) {\r
+ gBS->CloseEvent (Ehc->ExitBootServiceEvent);\r
+ }\r
+\r
EhcFreeSched (Ehc);\r
\r
- if (Ehc->ControllerNameTable) {\r
+ if (Ehc->ControllerNameTable != NULL) {\r
FreeUnicodeStringTable (Ehc->ControllerNameTable);\r
}\r
\r
return EFI_SUCCESS;\r
}\r
\r
-EFI_DRIVER_BINDING_PROTOCOL\r
-gEhciDriverBinding = {\r
- EhcDriverBindingSupported,\r
- EhcDriverBindingStart,\r
- EhcDriverBindingStop,\r
- 0x10,\r
- NULL,\r
- NULL\r
-};\r