]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Library / QemuBootOrderLib / ExtraRootBusMap.c
index 25d5494047abc60aacf3d2a6d25c4a504b9727e4..37d488e01c2a1a7d1cf1baa04c34efe58c85abaa 100644 (file)
 // BusNumbers is NULL.\r
 //\r
 struct EXTRA_ROOT_BUS_MAP_STRUCT {\r
-  UINT32 *BusNumbers;\r
-  UINTN  Count;\r
+  UINT32    *BusNumbers;\r
+  UINTN     Count;\r
 };\r
 \r
-\r
 /**\r
   An ORDERED_COLLECTION_USER_COMPARE function that compares root bridge\r
   protocol device paths based on UID.\r
@@ -51,12 +50,12 @@ STATIC
 INTN\r
 EFIAPI\r
 RootBridgePathCompare (\r
-  IN CONST VOID *UserStruct1,\r
-  IN CONST VOID *UserStruct2\r
+  IN CONST VOID  *UserStruct1,\r
+  IN CONST VOID  *UserStruct2\r
   )\r
 {\r
-  CONST ACPI_HID_DEVICE_PATH *Acpi1;\r
-  CONST ACPI_HID_DEVICE_PATH *Acpi2;\r
+  CONST ACPI_HID_DEVICE_PATH  *Acpi1;\r
+  CONST ACPI_HID_DEVICE_PATH  *Acpi2;\r
 \r
   Acpi1 = UserStruct1;\r
   Acpi2 = UserStruct2;\r
@@ -66,7 +65,6 @@ RootBridgePathCompare (
          0;\r
 }\r
 \r
-\r
 /**\r
   An ORDERED_COLLECTION_KEY_COMPARE function that compares a root bridge\r
   protocol device path against a UID.\r
@@ -86,12 +84,12 @@ STATIC
 INTN\r
 EFIAPI\r
 RootBridgePathKeyCompare (\r
-  IN CONST VOID *StandaloneKey,\r
-  IN CONST VOID *UserStruct\r
+  IN CONST VOID  *StandaloneKey,\r
+  IN CONST VOID  *UserStruct\r
   )\r
 {\r
-  CONST UINT32               *Uid;\r
-  CONST ACPI_HID_DEVICE_PATH *Acpi;\r
+  CONST UINT32                *Uid;\r
+  CONST ACPI_HID_DEVICE_PATH  *Acpi;\r
 \r
   Uid  = StandaloneKey;\r
   Acpi = UserStruct;\r
@@ -101,7 +99,6 @@ RootBridgePathKeyCompare (
          0;\r
 }\r
 \r
-\r
 /**\r
   Create a structure that maps the relative positions of PCI root buses to bus\r
   numbers.\r
@@ -129,31 +126,37 @@ RootBridgePathKeyCompare (
 **/\r
 EFI_STATUS\r
 CreateExtraRootBusMap (\r
-  OUT EXTRA_ROOT_BUS_MAP **ExtraRootBusMap\r
+  OUT EXTRA_ROOT_BUS_MAP  **ExtraRootBusMap\r
   )\r
 {\r
-  EFI_STATUS               Status;\r
-  UINTN                    NumHandles;\r
-  EFI_HANDLE               *Handles;\r
-  ORDERED_COLLECTION       *Collection;\r
-  EXTRA_ROOT_BUS_MAP       *Map;\r
-  UINTN                    Idx;\r
-  ORDERED_COLLECTION_ENTRY *Entry, *Entry2;\r
+  EFI_STATUS                Status;\r
+  UINTN                     NumHandles;\r
+  EFI_HANDLE                *Handles;\r
+  ORDERED_COLLECTION        *Collection;\r
+  EXTRA_ROOT_BUS_MAP        *Map;\r
+  UINTN                     Idx;\r
+  ORDERED_COLLECTION_ENTRY  *Entry, *Entry2;\r
 \r
   //\r
   // Handles and Collection are temporary / helper variables, while in Map we\r
   // build the return value.\r
   //\r
 \r
-  Status = gBS->LocateHandleBuffer (ByProtocol,\r
-                  &gEfiPciRootBridgeIoProtocolGuid, NULL /* SearchKey */,\r
-                  &NumHandles, &Handles);\r
-  if (EFI_ERROR (Status))  {\r
+  Status = gBS->LocateHandleBuffer (\r
+                  ByProtocol,\r
+                  &gEfiPciRootBridgeIoProtocolGuid,\r
+                  NULL /* SearchKey */,\r
+                  &NumHandles,\r
+                  &Handles\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  Collection = OrderedCollectionInit (RootBridgePathCompare,\r
-                 RootBridgePathKeyCompare);\r
+  Collection = OrderedCollectionInit (\r
+                 RootBridgePathCompare,\r
+                 RootBridgePathKeyCompare\r
+                 );\r
   if (Collection == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto FreeHandles;\r
@@ -169,10 +172,13 @@ CreateExtraRootBusMap (
   // Collect the ACPI device path protocols of the root bridges.\r
   //\r
   for (Idx = 0; Idx < NumHandles; ++Idx) {\r
-    EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+    EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
 \r
-    Status = gBS->HandleProtocol (Handles[Idx], &gEfiDevicePathProtocolGuid,\r
-                    (VOID**)&DevicePath);\r
+    Status = gBS->HandleProtocol (\r
+                    Handles[Idx],\r
+                    &gEfiDevicePathProtocolGuid,\r
+                    (VOID **)&DevicePath\r
+                    );\r
     if (EFI_ERROR (Status)) {\r
       goto FreeMap;\r
     }\r
@@ -182,14 +188,16 @@ CreateExtraRootBusMap (
     // nonzero (ie. the root bridge that the bus number belongs to is "extra",\r
     // not the main one). In that case, link the device path into Collection.\r
     //\r
-    if (DevicePathType (DevicePath) == ACPI_DEVICE_PATH &&\r
-        DevicePathSubType (DevicePath) == ACPI_DP &&\r
-        ((ACPI_HID_DEVICE_PATH *)DevicePath)->HID == EISA_PNP_ID(0x0A03) &&\r
-        ((ACPI_HID_DEVICE_PATH *)DevicePath)->UID > 0) {\r
+    if ((DevicePathType (DevicePath) == ACPI_DEVICE_PATH) &&\r
+        (DevicePathSubType (DevicePath) == ACPI_DP) &&\r
+        (((ACPI_HID_DEVICE_PATH *)DevicePath)->HID == EISA_PNP_ID (0x0A03)) &&\r
+        (((ACPI_HID_DEVICE_PATH *)DevicePath)->UID > 0))\r
+    {\r
       Status = OrderedCollectionInsert (Collection, NULL, DevicePath);\r
       if (EFI_ERROR (Status)) {\r
         goto FreeMap;\r
       }\r
+\r
       ++Map->Count;\r
     }\r
   }\r
@@ -208,24 +216,29 @@ CreateExtraRootBusMap (
   //\r
   // Now collect the bus numbers of the extra PCI root buses into Map.\r
   //\r
-  Idx = 0;\r
+  Idx   = 0;\r
   Entry = OrderedCollectionMin (Collection);\r
   while (Idx < Map->Count) {\r
-    ACPI_HID_DEVICE_PATH *Acpi;\r
+    ACPI_HID_DEVICE_PATH  *Acpi;\r
 \r
     ASSERT (Entry != NULL);\r
-    Acpi = OrderedCollectionUserStruct (Entry);\r
+    Acpi                 = OrderedCollectionUserStruct (Entry);\r
     Map->BusNumbers[Idx] = Acpi->UID;\r
-    DEBUG ((DEBUG_VERBOSE,\r
+    DEBUG ((\r
+      DEBUG_VERBOSE,\r
       "%a: extra bus position 0x%Lx maps to bus number (UID) 0x%x\n",\r
-      __FUNCTION__, (UINT64)(Idx + 1), Acpi->UID));\r
+      __FUNCTION__,\r
+      (UINT64)(Idx + 1),\r
+      Acpi->UID\r
+      ));\r
     ++Idx;\r
     Entry = OrderedCollectionNext (Entry);\r
   }\r
+\r
   ASSERT (Entry == NULL);\r
 \r
   *ExtraRootBusMap = Map;\r
-  Status = EFI_SUCCESS;\r
+  Status           = EFI_SUCCESS;\r
 \r
   //\r
   // Fall through in order to release temporaries.\r
@@ -236,15 +249,18 @@ FreeMap:
     if (Map->BusNumbers != NULL) {\r
       FreePool (Map->BusNumbers);\r
     }\r
+\r
     FreePool (Map);\r
   }\r
 \r
 FreeCollection:\r
   for (Entry = OrderedCollectionMin (Collection); Entry != NULL;\r
-       Entry = Entry2) {\r
+       Entry = Entry2)\r
+  {\r
     Entry2 = OrderedCollectionNext (Entry);\r
     OrderedCollectionDelete (Collection, Entry, NULL);\r
   }\r
+\r
   OrderedCollectionUninit (Collection);\r
 \r
 FreeHandles:\r
@@ -253,7 +269,6 @@ FreeHandles:
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Release a map created with CreateExtraRootBusMap().\r
 \r
@@ -261,12 +276,13 @@ FreeHandles:
 */\r
 VOID\r
 DestroyExtraRootBusMap (\r
-  IN EXTRA_ROOT_BUS_MAP *ExtraRootBusMap\r
+  IN EXTRA_ROOT_BUS_MAP  *ExtraRootBusMap\r
   )\r
 {\r
   if (ExtraRootBusMap->BusNumbers != NULL) {\r
     FreePool (ExtraRootBusMap->BusNumbers);\r
   }\r
+\r
   FreePool (ExtraRootBusMap);\r
 }\r
 \r
@@ -291,17 +307,19 @@ DestroyExtraRootBusMap (
 **/\r
 EFI_STATUS\r
 MapRootBusPosToBusNr (\r
-  IN  CONST EXTRA_ROOT_BUS_MAP *ExtraRootBusMap,\r
-  IN  UINT64                   RootBusPos,\r
-  OUT UINT32                   *RootBusNr\r
+  IN  CONST EXTRA_ROOT_BUS_MAP  *ExtraRootBusMap,\r
+  IN  UINT64                    RootBusPos,\r
+  OUT UINT32                    *RootBusNr\r
   )\r
 {\r
   if (RootBusPos == 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
+\r
   if (RootBusPos > ExtraRootBusMap->Count) {\r
     return EFI_NOT_FOUND;\r
   }\r
+\r
   *RootBusNr = ExtraRootBusMap->BusNumbers[(UINTN)RootBusPos - 1];\r
   return EFI_SUCCESS;\r
 }\r