\r
Usb Bus Driver Binding and Bus IO Protocol.\r
\r
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
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
\r
#include "UsbBus.h"\r
\r
-//\r
-// USB_BUS_PROTOCOL is only used to locate USB_BUS\r
-//\r
-EFI_GUID mUsbBusProtocolGuid = EFI_USB_BUS_PROTOCOL_GUID;\r
-\r
EFI_USB_IO_PROTOCOL mUsbIoProtocol = {\r
UsbIoControlTransfer,\r
UsbIoBulkTransfer,\r
NULL\r
};\r
\r
-UINT16 mMaxUsbDeviceNum = USB_MAX_DEVICES;\r
-\r
/**\r
USB_IO function to execute a control transfer. This\r
function will execute the USB transfer. If transfer\r
// Clear TT buffer when CTRL/BULK split transaction failes\r
// Clear the TRANSLATOR TT buffer, not parent's buffer\r
//\r
- ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum);\r
+ ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices);\r
if (Dev->Translator.TranslatorHubAddress != 0) {\r
UsbHubCtrlClearTTBuffer (\r
Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],\r
// Clear TT buffer when CTRL/BULK split transaction failes.\r
// Clear the TRANSLATOR TT buffer, not parent's buffer\r
//\r
- ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum);\r
+ ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices);\r
if (Dev->Translator.TranslatorHubAddress != 0) {\r
UsbHubCtrlClearTTBuffer (\r
Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- UsbBus->Signature = USB_BUS_SIGNATURE;\r
- UsbBus->HostHandle = Controller;\r
+ UsbBus->Signature = USB_BUS_SIGNATURE;\r
+ UsbBus->HostHandle = Controller;\r
+ UsbBus->MaxDevices = USB_MAX_DEVICES;\r
\r
Status = gBS->OpenProtocol (\r
Controller,\r
}\r
\r
if (!EFI_ERROR (Status)) {\r
+ //\r
+ // The EFI_USB2_HC_PROTOCOL is produced for XHCI support.\r
+ // Then its max supported devices are 256. Otherwise it's 128.\r
+ //\r
if (UsbBus->Usb2Hc->MajorRevision == 0x3) {\r
- //\r
- // The EFI_USB2_HC_PROTOCOL is produced for XHCI support.\r
- // Then its max supported devices are 256.\r
- //\r
- mMaxUsbDeviceNum = 256;\r
+ UsbBus->MaxDevices = 256;\r
}\r
}\r
\r
//\r
Status = gBS->InstallProtocolInterface (\r
&Controller,\r
- &mUsbBusProtocolGuid,\r
+ &gEfiCallerIdGuid,\r
EFI_NATIVE_INTERFACE,\r
&UsbBus->BusId\r
);\r
RootIf->Signature = USB_INTERFACE_SIGNATURE;\r
RootIf->Device = RootHub;\r
RootIf->DevicePath = UsbBus->DevicePath;\r
-\r
+ \r
+ //\r
+ // Report Status Code here since we will enumerate the USB devices\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ (EFI_IO_BUS_USB | EFI_IOB_PC_DETECT),\r
+ UsbBus->DevicePath\r
+ );\r
+ \r
Status = mUsbRootHubApi.Init (RootIf);\r
\r
if (EFI_ERROR (Status)) {\r
}\r
\r
UNINSTALL_USBBUS:\r
- gBS->UninstallProtocolInterface (Controller, &mUsbBusProtocolGuid, &UsbBus->BusId);\r
+ gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &UsbBus->BusId);\r
\r
CLOSE_HC:\r
if (UsbBus->Usb2Hc != NULL) {\r
{\r
EFI_USB_BUS_PROTOCOL *UsbBusId;\r
EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &ParentDevicePath,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Report Status Code here since we will initialize the host controller\r
+ //\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ (EFI_IO_BUS_USB | EFI_IOB_PC_INIT),\r
+ ParentDevicePath\r
+ );\r
\r
//\r
// Locate the USB bus protocol, if it is found, USB bus\r
//\r
Status = gBS->OpenProtocol (\r
Controller,\r
- &mUsbBusProtocolGuid,\r
+ &gEfiCallerIdGuid,\r
(VOID **) &UsbBusId,\r
This->DriverBindingHandle,\r
Controller,\r
//\r
Status = gBS->OpenProtocol (\r
Controller,\r
- &mUsbBusProtocolGuid,\r
+ &gEfiCallerIdGuid,\r
(VOID **) &UsbBusId,\r
This->DriverBindingHandle,\r
Controller,\r
//\r
Status = gBS->OpenProtocol (\r
Controller,\r
- &mUsbBusProtocolGuid,\r
+ &gEfiCallerIdGuid,\r
(VOID **) &BusId,\r
This->DriverBindingHandle,\r
Controller,\r
// BugBug: Raise TPL to callback level instead of USB_BUS_TPL to avoid TPL conflict\r
//\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
- UsbHcSetState (Bus, EfiUsbHcStateHalt);\r
\r
RootHub = Bus->Devices[0];\r
RootIf = RootHub->Interfaces[0];\r
\r
mUsbRootHubApi.Release (RootIf);\r
\r
- for (Index = 1; Index < mMaxUsbDeviceNum; Index++) {\r
+ ASSERT (Bus->MaxDevices <= 256);\r
+ for (Index = 1; Index < Bus->MaxDevices; Index++) {\r
if (Bus->Devices[Index] != NULL) {\r
UsbRemoveDevice (Bus->Devices[Index]);\r
}\r
//\r
// Uninstall the bus identifier and close USB_HC/USB2_HC protocols\r
//\r
- gBS->UninstallProtocolInterface (Controller, &mUsbBusProtocolGuid, &Bus->BusId);\r
+ gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);\r
\r
if (Bus->Usb2Hc != NULL) {\r
gBS->CloseProtocol (\r