Remove the special logic on EFI_PCI_DEVICE_ENABLE in PciBus driver. And update driver...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 15 Oct 2007 07:44:27 +0000 (07:44 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 15 Oct 2007 07:44:27 +0000 (07:44 +0000)
PciIoAttributes() in PciIo.c treats EFI_PCI_DEVICE_ENABLE specially so that when EFI_PCI_DEVICE_ENABLE is passed in, only the supported bits of driver will be enabled. Now many drivers use EFI_PCI_DEVICE_ENABLE to enable PCI device even if some of them don't support some of the attributes like EFI_PCI_IO_ATTRIBUTE_MEMORY. This doesn't conform to UEFI 2.0 spec.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4115 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/idebus.c
IntelFrameworkModulePkg/Bus/Pci/PciBusDxe/PciIo.c
MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c
MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
MdeModulePkg/Bus/Pci/UndiRuntimeDxe/Init.c
Nt32Pkg/Library/EdkGenericBdsLib/BdsBoot.c

index 8f555c7..48c2184 100644 (file)
@@ -182,6 +182,7 @@ IDEBusDriverBindingStart (
   UINT16                            ControlBlockBaseAddr;\r
   UINTN                             DataSize;\r
   IDE_BUS_DRIVER_PRIVATE_DATA       *IdeBusDriverPrivateData;\r
+  UINT64                            Supports;\r
 \r
   //\r
   // Local variables declaration for IdeControllerInit support\r
@@ -297,10 +298,20 @@ IDEBusDriverBindingStart (
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationEnable,\r
+                      Supports,\r
+                      NULL\r
+                      );\r
+  }\r
+\r
   if (EFI_ERROR (Status)) {\r
     goto ErrorExit;\r
   }\r
@@ -835,6 +846,7 @@ IDEBusDriverBindingStop (
   BOOLEAN                     AllChildrenStopped;\r
   UINTN                       Index;\r
   IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;\r
+  UINT64                      Supports;\r
 \r
   IdeBusDriverPrivateData = NULL;\r
 \r
@@ -849,12 +861,21 @@ IDEBusDriverBindingStop (
                     EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                     );\r
     if (!EFI_ERROR (Status)) {\r
-      PciIo->Attributes (\r
-              PciIo,\r
-              EfiPciIoAttributeOperationDisable,\r
-              EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO | EFI_PCI_DEVICE_ENABLE,\r
-              NULL\r
-              );\r
+      Status = PciIo->Attributes (\r
+                        PciIo,\r
+                        EfiPciIoAttributeOperationSupported,\r
+                        0,\r
+                        &Supports\r
+                        );\r
+      if (!EFI_ERROR (Status)) {\r
+        Supports &= EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO | EFI_PCI_DEVICE_ENABLE;\r
+        PciIo->Attributes (\r
+                PciIo,\r
+                EfiPciIoAttributeOperationDisable,\r
+                Supports,\r
+                NULL\r
+                );\r
+      }\r
     }\r
 \r
     gBS->OpenProtocol (\r
index 5a40789..63ab8e5 100644 (file)
@@ -1462,19 +1462,21 @@ Returns:
   }\r
   //\r
   // Just a trick for ENABLE attribute\r
+  // EFI_PCI_DEVICE_ENABLE is not defined in UEFI spec, which is the internal usage.\r
+  // So, this logic doesn't confrom to UEFI spec, which should be removed.\r
   //\r
-  if ((Attributes & EFI_PCI_DEVICE_ENABLE) == EFI_PCI_DEVICE_ENABLE) {\r
-    Attributes &= (PciIoDevice->Supports);\r
-\r
-    //\r
-    // Raise the EFI_P_PC_ENABLE Status code\r
-    //\r
-    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
-      EFI_PROGRESS_CODE,\r
-      EFI_IO_BUS_PCI | EFI_P_PC_ENABLE,\r
-      PciIoDevice->DevicePath\r
-      );\r
-  }\r
+  //  if ((Attributes & EFI_PCI_DEVICE_ENABLE) == EFI_PCI_DEVICE_ENABLE) {\r
+  //    Attributes &= (PciIoDevice->Supports);\r
+  //\r
+  //    //\r
+  //    // Raise the EFI_P_PC_ENABLE Status code\r
+  //    //\r
+  //    REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+  //      EFI_PROGRESS_CODE,\r
+  //      EFI_IO_BUS_PCI | EFI_P_PC_ENABLE,\r
+  //      PciIoDevice->DevicePath\r
+  //      );\r
+  //  }\r
 \r
   //\r
   // If no attributes can be supported, then return.\r
index 07a690e..488c963 100644 (file)
@@ -1491,6 +1491,7 @@ EhcDriverBindingStart (
   EFI_STATUS              Status;\r
   USB2_HC_DEV             *Ehc;\r
   EFI_PCI_IO_PROTOCOL     *PciIo;\r
+  UINT64                  Supports;\r
 \r
   //\r
   // Open the PciIo Protocol, then enable the USB host controller\r
@@ -1511,10 +1512,19 @@ EhcDriverBindingStart (
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationEnable,\r
+                      Supports,\r
+                      NULL\r
+                      );\r
+  }\r
 \r
   if (EFI_ERROR (Status)) {\r
     EHC_ERROR (("EhcDriverBindingStart: failed to enable controller\n"));\r
@@ -1643,6 +1653,7 @@ EhcDriverBindingStop (
   EFI_USB2_HC_PROTOCOL  *Usb2Hc;\r
   EFI_PCI_IO_PROTOCOL   *PciIo;\r
   USB2_HC_DEV           *Ehc;\r
+  UINT64                Supports;\r
 \r
   //\r
   // Test whether the Controller handler passed in is a valid\r
@@ -1695,12 +1706,21 @@ EhcDriverBindingStop (
   //\r
   // Disable the USB Host Controller\r
   //\r
-  PciIo->Attributes (\r
-           PciIo,\r
-           EfiPciIoAttributeOperationDisable,\r
-           EFI_PCI_DEVICE_ENABLE,\r
-           NULL\r
-           );\r
+  Status = PciIo->Attributes (\r
+                    PciIo,\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
+                    );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationDisable,\r
+                      Supports,\r
+                      NULL\r
+                      );\r
+  }\r
 \r
   gBS->CloseProtocol (\r
          Controller,\r
@@ -1710,7 +1730,7 @@ EhcDriverBindingStop (
          );\r
 \r
   gBS->FreePool (Ehc);\r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL\r
index 00108b8..36ce1bd 100644 (file)
@@ -2068,6 +2068,7 @@ UhciCleanDevUp (
   )\r
 {\r
   USB_HC_DEV          *Uhc;\r
+  UINT64              Supports;\r
 \r
   //\r
   // Uninstall the USB_HC and USB_HC2 protocol, then disable the controller\r
@@ -2089,11 +2090,18 @@ UhciCleanDevUp (
 \r
   UhciFreeAllAsyncReq (Uhc);\r
   UhciDestoryFrameList (Uhc);\r
-\r
+  \r
+  Uhc->PciIo->Attributes (\r
+                Uhc->PciIo,\r
+                EfiPciIoAttributeOperationSupported,\r
+                0,\r
+                &Supports\r
+                );\r
+  Supports &= EFI_PCI_DEVICE_ENABLE;\r
   Uhc->PciIo->Attributes (\r
                 Uhc->PciIo,\r
                 EfiPciIoAttributeOperationDisable,\r
-                EFI_PCI_DEVICE_ENABLE,\r
+                Supports,\r
                 NULL\r
                 );\r
 \r
@@ -2126,6 +2134,7 @@ UhciDriverBindingStart (
   EFI_STATUS          Status;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
   USB_HC_DEV          *Uhc;\r
+  UINT64              Supports;\r
 \r
   //\r
   // Open PCIIO, then enable the EHC device and turn off emulation\r
@@ -2148,10 +2157,19 @@ UhciDriverBindingStart (
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = PciIo->Attributes (\r
+                      PciIo,\r
+                      EfiPciIoAttributeOperationEnable,\r
+                      Supports,\r
+                      NULL\r
+                      );\r
+  }\r
 \r
   if (EFI_ERROR (Status)) {\r
     goto CLOSE_PCIIO;\r
index 8315bc4..784bf55 100644 (file)
@@ -287,6 +287,7 @@ Returns:
   UINT8                     *TmpPxePointer;\r
   EFI_PCI_IO_PROTOCOL       *PciIoFncs;\r
   UINTN                     Len;   \r
+  UINT64                    Supports;\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -380,10 +381,19 @@ Returns:
 \r
   Status = PciIoFncs->Attributes (\r
                         PciIoFncs,\r
-                        EfiPciIoAttributeOperationEnable,\r
-                        EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER,\r
-                        NULL\r
+                        EfiPciIoAttributeOperationSupported,\r
+                        0,\r
+                        &Supports\r
                         );\r
+  if (!EFI_ERROR (Status)) {\r
+    Supports &= EFI_PCI_DEVICE_ENABLE;\r
+    Status = PciIoFncs->Attributes (\r
+                          PciIoFncs,\r
+                          EfiPciIoAttributeOperationEnable,\r
+                          Supports,\r
+                          NULL\r
+                          );\r
+  }\r
   //\r
   // Read all the registers from device's PCI Configuration space\r
   //\r
index cc6adcd..2c97bb0 100644 (file)
@@ -1232,7 +1232,7 @@ Returns:
   Status = gBS->HandleProtocol (\r
              mBdsImageHandle,\r
              &gEfiLoadedImageProtocolGuid,\r
-             &LoadedImage\r
+             (VOID **) &LoadedImage\r
              );\r
   if (!EFI_ERROR (Status)) {\r
     Status = gBS->HandleProtocol (\r