summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/Pci
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Bus/Pci')
-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
8 files changed, 118 insertions, 99 deletions
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.