]> git.proxmox.com Git - mirror_edk2.git/commitdiff
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 8f555c7cd5326d4b3175081149e5103ea211c1d1..48c2184696494da8e0de3300f94d3a52b79339a2 100644 (file)
@@ -182,6 +182,7 @@ IDEBusDriverBindingStart (
   UINT16                            ControlBlockBaseAddr;\r
   UINTN                             DataSize;\r
   IDE_BUS_DRIVER_PRIVATE_DATA       *IdeBusDriverPrivateData;\r
   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
 \r
   //\r
   // Local variables declaration for IdeControllerInit support\r
@@ -297,10 +298,20 @@ IDEBusDriverBindingStart (
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\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
   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
   BOOLEAN                     AllChildrenStopped;\r
   UINTN                       Index;\r
   IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;\r
+  UINT64                      Supports;\r
 \r
   IdeBusDriverPrivateData = NULL;\r
 \r
 \r
   IdeBusDriverPrivateData = NULL;\r
 \r
@@ -849,12 +861,21 @@ IDEBusDriverBindingStop (
                     EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                     );\r
     if (!EFI_ERROR (Status)) {\r
                     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
     }\r
 \r
     gBS->OpenProtocol (\r
index 5a407892b00502e3aa55138da9b70d36f21c1790..63ab8e551a77c45a29b4307db17d9683bb41d584 100644 (file)
@@ -1462,19 +1462,21 @@ Returns:
   }\r
   //\r
   // Just a trick for ENABLE attribute\r
   }\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
   //\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
 \r
   //\r
   // If no attributes can be supported, then return.\r
index 07a690edce0788237587137a6e9853cdbd29c3b6..488c963952d7264c95f205ed8d983673293c6fad 100644 (file)
@@ -1491,6 +1491,7 @@ EhcDriverBindingStart (
   EFI_STATUS              Status;\r
   USB2_HC_DEV             *Ehc;\r
   EFI_PCI_IO_PROTOCOL     *PciIo;\r
   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
 \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
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\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
 \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
   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
 \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
   //\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
 \r
   gBS->CloseProtocol (\r
          Controller,\r
@@ -1710,7 +1730,7 @@ EhcDriverBindingStop (
          );\r
 \r
   gBS->FreePool (Ehc);\r
          );\r
 \r
   gBS->FreePool (Ehc);\r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL\r
 }\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL\r
index 00108b87e2b218afad494582bd5ca99032c84d72..36ce1bd4fec88f2069ebac925262b616563ec20d 100644 (file)
@@ -2068,6 +2068,7 @@ UhciCleanDevUp (
   )\r
 {\r
   USB_HC_DEV          *Uhc;\r
   )\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
 \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
   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
   Uhc->PciIo->Attributes (\r
                 Uhc->PciIo,\r
                 EfiPciIoAttributeOperationDisable,\r
-                EFI_PCI_DEVICE_ENABLE,\r
+                Supports,\r
                 NULL\r
                 );\r
 \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
   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
 \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
 \r
   Status = PciIo->Attributes (\r
                     PciIo,\r
-                    EfiPciIoAttributeOperationEnable,\r
-                    EFI_PCI_DEVICE_ENABLE,\r
-                    NULL\r
+                    EfiPciIoAttributeOperationSupported,\r
+                    0,\r
+                    &Supports\r
                     );\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
 \r
   if (EFI_ERROR (Status)) {\r
     goto CLOSE_PCIIO;\r
index 8315bc41d0fc620c5224d4f3c2722b19d6e97f18..784bf5560eb26bca93d895865da12a23a90b6935 100644 (file)
@@ -287,6 +287,7 @@ Returns:
   UINT8                     *TmpPxePointer;\r
   EFI_PCI_IO_PROTOCOL       *PciIoFncs;\r
   UINTN                     Len;   \r
   UINT8                     *TmpPxePointer;\r
   EFI_PCI_IO_PROTOCOL       *PciIoFncs;\r
   UINTN                     Len;   \r
+  UINT64                    Supports;\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
 \r
   Status = gBS->OpenProtocol (\r
                   Controller,\r
@@ -380,10 +381,19 @@ Returns:
 \r
   Status = PciIoFncs->Attributes (\r
                         PciIoFncs,\r
 \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
                         );\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
   //\r
   // Read all the registers from device's PCI Configuration space\r
   //\r
index cc6adcd78e3c93548672c6c1c853455b37e90ee7..2c97bb0525ec4ad7be34b4da6e8060ff40e29181 100644 (file)
@@ -1232,7 +1232,7 @@ Returns:
   Status = gBS->HandleProtocol (\r
              mBdsImageHandle,\r
              &gEfiLoadedImageProtocolGuid,\r
   Status = gBS->HandleProtocol (\r
              mBdsImageHandle,\r
              &gEfiLoadedImageProtocolGuid,\r
-             &LoadedImage\r
+             (VOID **) &LoadedImage\r
              );\r
   if (!EFI_ERROR (Status)) {\r
     Status = gBS->HandleProtocol (\r
              );\r
   if (!EFI_ERROR (Status)) {\r
     Status = gBS->HandleProtocol (\r