summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c95
-rw-r--r--MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c75
-rw-r--r--MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c97
-rw-r--r--MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c14
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c125
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c6
-rw-r--r--MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf1
-rw-r--r--MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c17
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c27
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c12
-rw-r--r--MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h15
-rw-r--r--MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c81
12 files changed, 343 insertions, 222 deletions
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
index cc575b98c..c397a04cf 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.c
@@ -870,54 +870,18 @@ AtaAtapiPassThruStop (
Instance = ATA_PASS_THRU_PRIVATE_DATA_FROM_THIS (AtaPassThru);
- //
- // Close Non-Blocking timer and free Task list.
- //
- if (Instance->TimerEvent != NULL) {
- gBS->CloseEvent (Instance->TimerEvent);
- Instance->TimerEvent = NULL;
- }
- DestroyAsynTaskList (Instance, FALSE);
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ Controller,
+ &gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),
+ &gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),
+ NULL
+ );
- //
- // Disable this ATA host controller.
- //
- PciIo = Instance->PciIo;
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
- );
- if (!EFI_ERROR (Status)) {
- Supports &= EFI_PCI_DEVICE_ENABLE;
- PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationDisable,
- Supports,
- NULL
- );
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
}
//
- // Restore original PCI attributes
- //
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSet,
- Instance->OriginalPciAttributes,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiAtaPassThruProtocolGuid, &(Instance->AtaPassThru),
- &gEfiExtScsiPassThruProtocolGuid, &(Instance->ExtScsiPassThru),
- NULL
- );
-
- //
// Close protocols opened by AtaAtapiPassThru controller driver
//
gBS->CloseProtocol (
@@ -928,14 +892,24 @@ AtaAtapiPassThruStop (
);
//
+ // Close Non-Blocking timer and free Task list.
+ //
+ if (Instance->TimerEvent != NULL) {
+ gBS->CloseEvent (Instance->TimerEvent);
+ Instance->TimerEvent = NULL;
+ }
+ DestroyAsynTaskList (Instance, FALSE);
+ //
// Free allocated resource
//
- DestroyDeviceInfoList(Instance);
+ DestroyDeviceInfoList (Instance);
//
// If the current working mode is AHCI mode, then pre-allocated resource
// for AHCI initialization should be released.
//
+ PciIo = Instance->PciIo;
+
if (Instance->Mode == EfiAtaAhciMode) {
AhciRegisters = &Instance->AhciRegisters;
PciIo->Unmap (
@@ -966,6 +940,37 @@ AtaAtapiPassThruStop (
AhciRegisters->AhciRFis
);
}
+
+ //
+ // Disable this ATA host controller.
+ //
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationSupported,
+ 0,
+ &Supports
+ );
+ if (!EFI_ERROR (Status)) {
+ Supports &= EFI_PCI_DEVICE_ENABLE;
+ PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationDisable,
+ Supports,
+ NULL
+ );
+ }
+
+ //
+ // Restore original PCI attributes
+ //
+ Status = PciIo->Attributes (
+ PciIo,
+ EfiPciIoAttributeOperationSet,
+ Instance->OriginalPciAttributes,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
FreePool (Instance);
return Status;
diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
index 3da1474ed..c9913c07c 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cBus.c
@@ -2,7 +2,7 @@
This file implements I2C IO Protocol which enables the user to manipulate a single
I2C device independent of the host controller and I2C design.
- Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
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
@@ -1408,6 +1408,8 @@ I2cBusUnload (
EFI_HANDLE *DeviceHandleBuffer;
UINTN DeviceHandleCount;
UINTN Index;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Get the list of all I2C Controller handles in the handle database.
@@ -1422,22 +1424,20 @@ I2cBusUnload (
&DeviceHandleBuffer
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Disconnect the driver specified by Driver BindingHandle from all
- // the devices in the handle database.
- //
- for (Index = 0; Index < DeviceHandleCount; Index++) {
- Status = gBS->DisconnectController (
- DeviceHandleBuffer[Index],
- gI2cBusDriverBinding.DriverBindingHandle,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto Done;
+ if (!EFI_ERROR (Status)) {
+ //
+ // Disconnect the driver specified by Driver BindingHandle from all
+ // the devices in the handle database.
+ //
+ for (Index = 0; Index < DeviceHandleCount; Index++) {
+ Status = gBS->DisconnectController (
+ DeviceHandleBuffer[Index],
+ gI2cBusDriverBinding.DriverBindingHandle,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
}
}
@@ -1448,14 +1448,47 @@ I2cBusUnload (
gI2cBusDriverBinding.DriverBindingHandle,
&gEfiDriverBindingProtocolGuid,
&gI2cBusDriverBinding,
- &gEfiComponentNameProtocolGuid,
- &gI2cBusComponentName,
- &gEfiComponentName2ProtocolGuid,
- &gI2cBusComponentName2,
NULL
);
ASSERT_EFI_ERROR (Status);
+ //
+ // Note we have to one by one uninstall the following protocols.
+ // It's because some of them are optionally installed based on
+ // the following PCD settings.
+ // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable
+ // gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable
+ // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable
+ // gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable
+ //
+ Status = gBS->HandleProtocol (
+ gI2cBusDriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ (VOID **) &ComponentName
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->UninstallProtocolInterface (
+ gI2cBusDriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ ComponentName
+ );
+ }
+
+ Status = gBS->HandleProtocol (
+ gI2cBusDriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **) &ComponentName2
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->UninstallProtocolInterface (
+ gI2cBusDriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ ComponentName2
+ );
+ }
+
+ Status = EFI_SUCCESS;
+
Done:
//
// Free the buffer containing the list of handles from the handle database
diff --git a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
index e153a4dc2..0cc8e3384 100644
--- a/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
+++ b/MdeModulePkg/Bus/I2c/I2cDxe/I2cHost.c
@@ -2,7 +2,7 @@
This file implements I2C Host Protocol which provides callers with the ability to
do I/O transactions to all of the devices on the I2C bus.
- Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
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
@@ -930,6 +930,7 @@ I2cHostQueueRequest (
I2C_HOST_CONTEXT *I2cHostContext;
BOOLEAN FirstRequest;
UINTN RequestPacketSize;
+ UINTN StartBit;
SyncEvent = NULL;
FirstRequest = FALSE;
@@ -938,6 +939,27 @@ I2cHostQueueRequest (
if (RequestPacket == NULL) {
return EFI_INVALID_PARAMETER;
}
+
+ if ((SlaveAddress & I2C_ADDRESSING_10_BIT) != 0) {
+ //
+ // 10-bit address, bits 0-9 are used for 10-bit I2C slave addresses,
+ // bits 10-30 are reserved bits and must be zero
+ //
+ StartBit = 10;
+ } else {
+ //
+ // 7-bit address, Bits 0-6 are used for 7-bit I2C slave addresses,
+ // bits 7-30 are reserved bits and must be zero
+ //
+ StartBit = 7;
+ }
+
+ if (BitFieldRead32 ((UINT32)SlaveAddress, StartBit, 30) != 0) {
+ //
+ // Reserved bit set in the SlaveAddress parameter
+ //
+ return EFI_NOT_FOUND;
+ }
I2cHostContext = I2C_HOST_CONTEXT_FROM_PROTOCOL (This);
@@ -1109,6 +1131,8 @@ I2cHostUnload (
EFI_HANDLE *DeviceHandleBuffer;
UINTN DeviceHandleCount;
UINTN Index;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
// Get the list of all I2C Controller handles in the handle database.
@@ -1123,22 +1147,20 @@ I2cHostUnload (
&DeviceHandleBuffer
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Disconnect the driver specified by ImageHandle from all
- // the devices in the handle database.
- //
- for (Index = 0; Index < DeviceHandleCount; Index++) {
- Status = gBS->DisconnectController (
- DeviceHandleBuffer[Index],
- ImageHandle,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto Done;
+ if (!EFI_ERROR (Status)) {
+ //
+ // Disconnect the driver specified by ImageHandle from all
+ // the devices in the handle database.
+ //
+ for (Index = 0; Index < DeviceHandleCount; Index++) {
+ Status = gBS->DisconnectController (
+ DeviceHandleBuffer[Index],
+ ImageHandle,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
}
}
@@ -1149,14 +1171,47 @@ I2cHostUnload (
gI2cHostDriverBinding.DriverBindingHandle,
&gEfiDriverBindingProtocolGuid,
&gI2cHostDriverBinding,
- &gEfiComponentNameProtocolGuid,
- &gI2cHostComponentName,
- &gEfiComponentName2ProtocolGuid,
- &gI2cHostComponentName2,
NULL
);
ASSERT_EFI_ERROR (Status);
+ //
+ // Note we have to one by one uninstall the following protocols.
+ // It's because some of them are optionally installed based on
+ // the following PCD settings.
+ // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable
+ // gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable
+ // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable
+ // gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable
+ //
+ Status = gBS->HandleProtocol (
+ gI2cHostDriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ (VOID **) &ComponentName
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->UninstallProtocolInterface (
+ gI2cHostDriverBinding.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ ComponentName
+ );
+ }
+
+ Status = gBS->HandleProtocol (
+ gI2cHostDriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **) &ComponentName2
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->UninstallProtocolInterface (
+ gI2cHostDriverBinding.DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ ComponentName2
+ );
+ }
+
+ Status = EFI_SUCCESS;
+
Done:
//
// Free the buffer containing the list of handles from the handle database
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
index 59891b814..700e69e49 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
@@ -2049,13 +2049,6 @@ EhcDriverBindingStop (
Ehc = EHC_FROM_THIS (Usb2Hc);
PciIo = Ehc->PciIo;
- //
- // Stop AsyncRequest Polling timer then stop the EHCI driver
- // and uninstall the EHCI protocl.
- //
- gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_INTERVAL);
- EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);
-
Status = gBS->UninstallProtocolInterface (
Controller,
&gEfiUsb2HcProtocolGuid,
@@ -2066,6 +2059,13 @@ EhcDriverBindingStop (
return Status;
}
+ //
+ // Stop AsyncRequest Polling timer then stop the EHCI driver
+ // and uninstall the EHCI protocl.
+ //
+ gBS->SetTimer (Ehc->PollTimer, TimerCancel, EHC_ASYNC_POLL_INTERVAL);
+ EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);
+
if (Ehc->PollTimer != NULL) {
gBS->CloseEvent (Ehc->PollTimer);
}
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
index 4f187e3ab..ee40ba05c 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c
@@ -928,97 +928,102 @@ NvmExpressUnload (
EFI_HANDLE *DeviceHandleBuffer;
UINTN DeviceHandleCount;
UINTN Index;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
//
- // Get the list of all the handles in the handle database.
- // If there is an error getting the list, then the unload
- // operation fails.
+ // Get the list of the device handles managed by this driver.
+ // If there is an error getting the list, then means the driver
+ // doesn't manage any device. At this way, we would only close
+ // those protocols installed at image handle.
//
+ DeviceHandleBuffer = NULL;
Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
+ ByProtocol,
+ &gEfiCallerIdGuid,
NULL,
&DeviceHandleCount,
&DeviceHandleBuffer
);
- if (EFI_ERROR (Status)) {
- return Status;
+ if (!EFI_ERROR (Status)) {
+ //
+ // Disconnect the driver specified by ImageHandle from all
+ // the devices in the handle database.
+ //
+ for (Index = 0; Index < DeviceHandleCount; Index++) {
+ Status = gBS->DisconnectController (
+ DeviceHandleBuffer[Index],
+ ImageHandle,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ goto EXIT;
+ }
+ }
}
//
- // Disconnect the driver specified by ImageHandle from all
- // the devices in the handle database.
+ // Uninstall all the protocols installed in the driver entry point
//
- for (Index = 0; Index < DeviceHandleCount; Index++) {
- Status = gBS->DisconnectController (
- DeviceHandleBuffer[Index],
- ImageHandle,
- NULL
- );
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ ImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &gNvmExpressDriverBinding,
+ &gEfiDriverSupportedEfiVersionProtocolGuid,
+ &gNvmExpressDriverSupportedEfiVersion,
+ NULL
+ );
+
+ if (EFI_ERROR (Status)) {
+ goto EXIT;
}
//
- // Uninstall all the protocols installed in the driver entry point
+ // Note we have to one by one uninstall the following protocols.
+ // It's because some of them are optionally installed based on
+ // the following PCD settings.
+ // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnosticsDisable
+ // gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable
+ // gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable
+ // gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable
//
- for (Index = 0; Index < DeviceHandleCount; Index++) {
- Status = gBS->HandleProtocol (
- DeviceHandleBuffer[Index],
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding
- );
-
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- if (DriverBinding->ImageHandle != ImageHandle) {
- continue;
- }
-
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiComponentNameProtocolGuid,
+ (VOID **) &ComponentName
+ );
+ if (!EFI_ERROR (Status)) {
gBS->UninstallProtocolInterface (
ImageHandle,
- &gEfiDriverBindingProtocolGuid,
- DriverBinding
+ &gEfiComponentNameProtocolGuid,
+ ComponentName
);
+ }
- Status = gBS->HandleProtocol (
- DeviceHandleBuffer[Index],
- &gEfiComponentNameProtocolGuid,
- (VOID **) &ComponentName
- );
- if (!EFI_ERROR (Status)) {
- gBS->UninstallProtocolInterface (
- ImageHandle,
- &gEfiComponentNameProtocolGuid,
- ComponentName
- );
- }
-
- Status = gBS->HandleProtocol (
- DeviceHandleBuffer[Index],
- &gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
- );
- if (!EFI_ERROR (Status)) {
- gBS->UninstallProtocolInterface (
- ImageHandle,
- &gEfiComponentName2ProtocolGuid,
- ComponentName2
- );
- }
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **) &ComponentName2
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->UninstallProtocolInterface (
+ ImageHandle,
+ &gEfiComponentName2ProtocolGuid,
+ ComponentName2
+ );
}
+ Status = EFI_SUCCESS;
+
+EXIT:
//
// Free the buffer containing the list of handles from the handle database
//
if (DeviceHandleBuffer != NULL) {
gBS->FreePool (DeviceHandleBuffer);
}
- return EFI_SUCCESS;
+ return Status;
}
/**
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
index 5afbb8229..2252235bc 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
@@ -284,7 +284,11 @@ PciBusDriverBindingStart (
);
}
- gFullEnumeration = (BOOLEAN) ((SearchHostBridgeHandle (Controller) ? FALSE : TRUE));
+ if (PcdGetBool (PcdPciDisableBusEnumeration)) {
+ gFullEnumeration = FALSE;
+ } else {
+ gFullEnumeration = (BOOLEAN) ((SearchHostBridgeHandle (Controller) ? FALSE : TRUE));
+ }
//
// Open Device Path Protocol for PCI root bridge
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index 34eb672df..917889ca0 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -108,6 +108,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSupport
gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport
gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
# [Event]
# ##
diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
index 00a109437..a3a28f3ed 100644
--- a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
+++ b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
@@ -1550,19 +1550,24 @@ UhciCleanDevUp (
)
{
USB_HC_DEV *Uhc;
+ EFI_STATUS Status;
//
// Uninstall the USB_HC and USB_HC2 protocol, then disable the controller
//
Uhc = UHC_FROM_USB2_HC_PROTO (This);
- UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);
- gBS->UninstallProtocolInterface (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- &Uhc->Usb2Hc
- );
+ Status = gBS->UninstallProtocolInterface (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ &Uhc->Usb2Hc
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ UhciStopHc (Uhc, UHC_GENERIC_TIMEOUT);
UhciFreeAllAsyncReq (Uhc);
UhciDestoryFrameList (Uhc);
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
index 5ca58fbb9..a831abe77 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -451,7 +451,7 @@ XhcGetRootHubPortStatus (
for (Index = 0; Index < MapSize; Index++) {
if (XHC_BIT_IS_SET (State, mUsbClearPortChangeMap[Index].HwState)) {
- XhcClearRootHubPortFeature (This, PortNumber, mUsbClearPortChangeMap[Index].Selector);
+ XhcClearRootHubPortFeature (This, PortNumber, (EFI_USB_PORT_FEATURE)mUsbClearPortChangeMap[Index].Selector);
}
}
@@ -2129,6 +2129,16 @@ XhcDriverBindingStop (
return Status;
}
+ Status = gBS->UninstallProtocolInterface (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ Usb2Hc
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
Xhc = XHC_FROM_THIS (Usb2Hc);
PciIo = Xhc->PciIo;
@@ -2154,19 +2164,6 @@ XhcDriverBindingStop (
}
}
- XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT);
- XhcClearBiosOwnership (Xhc);
-
- Status = gBS->UninstallProtocolInterface (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- Usb2Hc
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
if (Xhc->PollTimer != NULL) {
gBS->CloseEvent (Xhc->PollTimer);
}
@@ -2175,6 +2172,8 @@ XhcDriverBindingStop (
gBS->CloseEvent (Xhc->ExitBootServiceEvent);
}
+ XhcHaltHC (Xhc, XHC_GENERIC_TIMEOUT);
+ XhcClearBiosOwnership (Xhc);
XhciDelAllAsyncIntTransfers (Xhc);
XhcFreeSched (Xhc);
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
index a66d7cd95..a513dd958 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
@@ -2,7 +2,7 @@
The XHCI register operation routines.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
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
@@ -499,7 +499,7 @@ XhcClearOpRegBit (
@param Offset The offset of the operation register.
@param Bit The bit of the register to wait for.
@param WaitToSet Wait the bit to set or clear.
- @param Timeout The time to wait before abort (in millisecond, ms).
+ @param Timeout The time to wait before abort (in microsecond, us).
@retval EFI_SUCCESS The bit successfully changed by host controller.
@retval EFI_TIMEOUT The time out occurred.
@@ -517,7 +517,7 @@ XhcWaitOpRegBit (
UINT32 Index;
UINTN Loop;
- Loop = (Timeout * XHC_1_MILLISECOND / XHC_POLL_DELAY) + 1;
+ Loop = (Timeout / XHC_POLL_DELAY) + 1;
for (Index = 0; Index < Loop; Index++) {
if (XHC_REG_BIT_IS_SET (Xhc, Offset, Bit) == WaitToSet) {
@@ -656,7 +656,7 @@ XhcIsSysError (
Reset the XHCI host controller.
@param Xhc The XHCI Instance.
- @param Timeout Time to wait before abort (in millisecond, ms).
+ @param Timeout Time to wait before abort (in microsecond, us).
@retval EFI_SUCCESS The XHCI host controller is reset.
@return Others Failed to reset the XHCI before Timeout.
@@ -698,7 +698,7 @@ XhcResetHC (
Halt the XHCI host controller.
@param Xhc The XHCI Instance.
- @param Timeout Time to wait before abort (in millisecond, ms).
+ @param Timeout Time to wait before abort (in microsecond, us).
@return EFI_SUCCESS The XHCI host controller is halt.
@return EFI_TIMEOUT Failed to halt the XHCI before Timeout.
@@ -722,7 +722,7 @@ XhcHaltHC (
Set the XHCI host controller to run.
@param Xhc The XHCI Instance.
- @param Timeout Time to wait before abort (in millisecond, ms).
+ @param Timeout Time to wait before abort (in microsecond, us).
@return EFI_SUCCESS The XHCI host controller is running.
@return EFI_TIMEOUT Failed to set the XHCI to run before Timeout.
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
index dc8281198..b748c8d39 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
@@ -198,8 +198,13 @@ typedef union {
//
// Hub Class Feature Selector for Clear Port Feature Request
+// It's the extension of hub class feature selector of USB 2.0 in USB 3.0 Spec.
+// For more details, Please refer to USB 3.0 Spec Table 10-7.
//
-#define Usb3PortBHPortResetChange 29
+typedef enum {
+ Usb3PortBHPortReset = 28,
+ Usb3PortBHPortResetChange = 29
+} XHC_PORT_FEATURE;
//
// Structure to map the hardware port states to the
@@ -394,7 +399,7 @@ XhcClearOpRegBit (
@param Offset The offset of the operational register.
@param Bit The bit of the register to wait for.
@param WaitToSet Wait the bit to set or clear.
- @param Timeout The time to wait before abort (in millisecond, ms).
+ @param Timeout The time to wait before abort (in microsecond, us).
@retval EFI_SUCCESS The bit successfully changed by host controller.
@retval EFI_TIMEOUT The time out occurred.
@@ -516,7 +521,7 @@ XhcIsSysError (
Reset the XHCI host controller.
@param Xhc The XHCI Instance.
- @param Timeout Time to wait before abort (in millisecond, ms).
+ @param Timeout Time to wait before abort (in microsecond, us).
@retval EFI_SUCCESS The XHCI host controller is reset.
@return Others Failed to reset the XHCI before Timeout.
@@ -532,7 +537,7 @@ XhcResetHC (
Halt the XHCI host controller.
@param Xhc The XHCI Instance.
- @param Timeout Time to wait before abort (in millisecond, ms).
+ @param Timeout Time to wait before abort (in microsecond, us).
@return EFI_SUCCESS The XHCI host controller is halt.
@return EFI_TIMEOUT Failed to halt the XHCI before Timeout.
@@ -548,7 +553,7 @@ XhcHaltHC (
Set the XHCI host controller to run.
@param Xhc The XHCI Instance.
- @param Timeout Time to wait before abort (in millisecond, ms).
+ @param Timeout Time to wait before abort (in microsecond, us).
@return EFI_SUCCESS The XHCI host controller is running.
@return EFI_TIMEOUT Failed to set the XHCI to run before Timeout.
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
index ff6b99c87..ef002f53b 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
@@ -1402,6 +1402,7 @@ UsbBusControllerDriverStop (
EFI_TPL OldTpl;
UINTN Index;
EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
Status = EFI_SUCCESS;
@@ -1411,6 +1412,7 @@ UsbBusControllerDriverStop (
//
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ ReturnStatus = EFI_SUCCESS;
for (Index = 0; Index < NumberOfChildren; Index++) {
Status = gBS->OpenProtocol (
ChildHandleBuffer[Index],
@@ -1434,11 +1436,11 @@ UsbBusControllerDriverStop (
UsbIf = USB_INTERFACE_FROM_USBIO (UsbIo);
UsbDev = UsbIf->Device;
- UsbRemoveDevice (UsbDev);
+ ReturnStatus = UsbRemoveDevice (UsbDev);
}
gBS->RestoreTPL (OldTpl);
- return EFI_SUCCESS;
+ return ReturnStatus;
}
DEBUG (( EFI_D_INFO, "UsbBusStop: usb bus stopped on %p\n", Controller));
@@ -1471,53 +1473,60 @@ UsbBusControllerDriverStop (
RootHub = Bus->Devices[0];
RootIf = RootHub->Interfaces[0];
- mUsbRootHubApi.Release (RootIf);
-
ASSERT (Bus->MaxDevices <= 256);
+ ReturnStatus = EFI_SUCCESS;
for (Index = 1; Index < Bus->MaxDevices; Index++) {
if (Bus->Devices[Index] != NULL) {
- UsbRemoveDevice (Bus->Devices[Index]);
+ Status = UsbRemoveDevice (Bus->Devices[Index]);
+ if (EFI_ERROR (Status)) {
+ ReturnStatus = Status;
+ }
}
}
gBS->RestoreTPL (OldTpl);
- gBS->FreePool (RootIf);
- gBS->FreePool (RootHub);
- Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
- ASSERT (!EFI_ERROR (Status));
+ if (!EFI_ERROR (ReturnStatus)) {
+ mUsbRootHubApi.Release (RootIf);
+ gBS->FreePool (RootIf);
+ gBS->FreePool (RootHub);
- //
- // Uninstall the bus identifier and close USB_HC/USB2_HC protocols
- //
- gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);
+ Status = UsbBusFreeUsbDPList (&Bus->WantedUsbIoDPList);
+ ASSERT (!EFI_ERROR (Status));
- if (Bus->Usb2Hc != NULL) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
+ //
+ // Uninstall the bus identifier and close USB_HC/USB2_HC protocols
+ //
+ gBS->UninstallProtocolInterface (Controller, &gEfiCallerIdGuid, &Bus->BusId);
- if (Bus->UsbHc != NULL) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbHcProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
+ if (Bus->Usb2Hc != NULL) {
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiUsb2HcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ }
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ if (Bus->UsbHc != NULL) {
+ Status = gBS->CloseProtocol (
+ Controller,
+ &gEfiUsbHcProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ }
- gBS->FreePool (Bus);
+ if (!EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ gBS->FreePool (Bus);
+ }
+ }
return Status;
}