]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
The PCI host bridge can signal failures in its initialization to
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciLib.c
index 87ee61956ac92f501c181294b7cde4534fe1ab71..a5cea9e52a0d2b590569c7dc63cfd275f505c0c4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Internal library implementation for PCI Bus module.\r
 \r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, 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
@@ -182,7 +182,7 @@ DumpBridgeResource (
 \r
   if ((BridgeResource != NULL) && (BridgeResource->Length != 0)) {\r
     DEBUG ((\r
-      EFI_D_INFO, "Type = %s; Base = 0x%x;\tLength = 0x%x;\tAlignment = 0x%x\n",\r
+      EFI_D_INFO, "Type = %s; Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx\n",\r
       mBarTypeStr[MIN (BridgeResource->ResType, PciBarTypeMaxType)],\r
       BridgeResource->PciDev->PciBar[BridgeResource->Bar].BaseAddress,\r
       BridgeResource->Length, BridgeResource->Alignment\r
@@ -195,7 +195,7 @@ DumpBridgeResource (
       if (Resource->ResourceUsage == PciResUsageTypical) {\r
         Bar = Resource->Virtual ? Resource->PciDev->VfPciBar : Resource->PciDev->PciBar;\r
         DEBUG ((\r
-          EFI_D_INFO, " Base = 0x%x;\tLength = 0x%x;\tAlignment = 0x%x;\tOwner = %s ",\r
+          EFI_D_INFO, " Base = 0x%lx;\tLength = 0x%lx;\tAlignment = 0x%lx;\tOwner = %s ",\r
           Bar[Resource->Bar].BaseAddress, Resource->Length, Resource->Alignment,\r
           IS_PCI_BRIDGE (&Resource->PciDev->Pci)     ? L"PPB" :\r
           IS_CARDBUS_BRIDGE (&Resource->PciDev->Pci) ? L"P2C" :\r
@@ -225,7 +225,7 @@ DumpBridgeResource (
             ));\r
         }\r
       } else {\r
-        DEBUG ((EFI_D_INFO, " Padding:Length = 0x%x;\tAlignment = 0x%x\n", Resource->Length, Resource->Alignment));\r
+        DEBUG ((EFI_D_INFO, " Padding:Length = 0x%lx;\tAlignment = 0x%lx\n", Resource->Length, Resource->Alignment));\r
       }\r
     }\r
   }\r
@@ -568,6 +568,12 @@ PciHostBridgeResourceAllocator (
                                 RootBridgeDev->Handle,\r
                                 AcpiConfig\r
                                 );\r
+        //\r
+        // If SubmitResources returns error, PciBus isn't able to start.\r
+        // It's a fatal error so assertion is added.\r
+        //\r
+        DEBUG ((EFI_D_INFO, "PciBus: HostBridge->SubmitResources() - %r\n", Status));\r
+        ASSERT_EFI_ERROR (Status);\r
       }\r
 \r
       //\r
@@ -598,6 +604,7 @@ PciHostBridgeResourceAllocator (
     // Notify platform to start to program the resource\r
     //\r
     Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeAllocateResources);\r
+    DEBUG ((EFI_D_INFO, "PciBus: HostBridge->NotifyPhase(AllocateResources) - %r\n", Status));\r
     if (!FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {\r
       //\r
       // If Hot Plug is not supported\r
@@ -752,7 +759,11 @@ PciHostBridgeResourceAllocator (
   //\r
   // Notify pci bus driver starts to program the resource\r
   //\r
-  NotifyPhase (PciResAlloc, EfiPciHostBridgeSetResources);\r
+  Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeSetResources);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
 \r
   RootBridgeDev     = NULL;\r
 \r
@@ -891,9 +902,9 @@ PciHostBridgeResourceAllocator (
   //\r
   // Notify the resource allocation phase is to end\r
   //\r
-  NotifyPhase (PciResAlloc, EfiPciHostBridgeEndResourceAllocation);\r
+  Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeEndResourceAllocation);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 /**\r
@@ -937,13 +948,13 @@ PciAllocateBusNumber (
   while (BusNumberRanges->Desc != ACPI_END_TAG_DESCRIPTOR) {\r
     MaxNumberInRange = BusNumberRanges->AddrRangeMin + BusNumberRanges->AddrLen - 1;\r
     if (StartBusNumber >= BusNumberRanges->AddrRangeMin && StartBusNumber <=  MaxNumberInRange) {\r
-      NextNumber = StartBusNumber + NumberOfBuses;\r
+      NextNumber = (UINT8)(StartBusNumber + NumberOfBuses);\r
       while (NextNumber > MaxNumberInRange) {\r
         ++BusNumberRanges;\r
         if (BusNumberRanges->Desc == ACPI_END_TAG_DESCRIPTOR) {\r
           return EFI_OUT_OF_RESOURCES;\r
         }\r
-        NextNumber += (UINT8)(BusNumberRanges->AddrRangeMin - (MaxNumberInRange + 1));\r
+        NextNumber = (UINT8)(NextNumber + (BusNumberRanges->AddrRangeMin - (MaxNumberInRange + 1)));\r
         MaxNumberInRange = BusNumberRanges->AddrRangeMin + BusNumberRanges->AddrLen - 1;\r
       }\r
       *NextBusNumber = NextNumber;\r
@@ -1436,7 +1447,11 @@ PciHostBridgeEnumerator (
   //\r
   // Notify the bus allocation phase is about to start\r
   //\r
-  NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginBusAllocation);\r
+  Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginBusAllocation);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
 \r
   DEBUG((EFI_D_INFO, "PCI Bus First Scanning\n"));\r
   RootBridgeHandle = NULL;\r
@@ -1524,7 +1539,11 @@ PciHostBridgeEnumerator (
     //\r
     // Notify the bus allocation phase is about to start for the 2nd time\r
     //\r
-    NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginBusAllocation);\r
+    Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginBusAllocation);\r
+\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
 \r
     DEBUG((EFI_D_INFO, "PCI Bus Second Scanning\n"));\r
     RootBridgeHandle = NULL;\r
@@ -1562,7 +1581,11 @@ PciHostBridgeEnumerator (
   //\r
   // Notify the resource allocation phase is to start\r
   //\r
-  NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginResourceAllocation);\r
+  Status = NotifyPhase (PciResAlloc, EfiPciHostBridgeBeginResourceAllocation);\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
 \r
   RootBridgeHandle = NULL;\r
   while (PciResAlloc->GetNextRootBridge (PciResAlloc, &RootBridgeHandle) == EFI_SUCCESS) {\r