]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtualizationPkg: move early UART discovery to PlatformPeim
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 28 Feb 2015 20:25:48 +0000 (20:25 +0000)
committerlersek <lersek@Edk2>
Sat, 28 Feb 2015 20:25:48 +0000 (20:25 +0000)
This is partially motivated by the desire to use PrePi in a virt
environment, and in that configuration, ArmPlatformInitializeSystemMemory()
is never called. But actually, this is a more suitable place anyway.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16958 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/Virt.c
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf

index d1572882af1b44b79eda26274c657c0955fa7905..43b3c6ca1befb6fe5483ab661cebf3b252e2e9f7 100644 (file)
@@ -62,6 +62,3 @@
   gArmTokenSpaceGuid.PcdArmPrimaryCore\r
   gArmTokenSpaceGuid.PcdFdBaseAddress\r
   gArmTokenSpaceGuid.PcdFdSize\r
-\r
-[Guids]\r
-  gEarlyPL011BaseAddressGuid\r
index 3e3074af72f105f0ae5c1f9ab9730afb464e42d8..17f2686975831d11c9d36fde87dbb436b7807c77 100644 (file)
@@ -24,9 +24,6 @@
 #include <Pi/PiBootMode.h>\r
 #include <Uefi/UefiBaseType.h>\r
 #include <Uefi/UefiMultiPhase.h>\r
-#include <Pi/PiHob.h>\r
-#include <Library/HobLib.h>\r
-#include <Guid/EarlyPL011BaseAddress.h>\r
 \r
 /**\r
   Return the current Boot Mode\r
@@ -77,25 +74,13 @@ ArmPlatformInitializeSystemMemory (
   INT32        Node, Prev;\r
   UINT64       NewBase;\r
   UINT64       NewSize;\r
-  BOOLEAN      HaveMemory, HaveUART;\r
-  UINT64       *HobData;\r
   CONST CHAR8  *Type;\r
-  CONST CHAR8  *Compatible;\r
-  CONST CHAR8  *CompItem;\r
   INT32        Len;\r
   CONST UINT64 *RegProp;\r
-  UINT64       UartBase;\r
 \r
   NewBase = 0;\r
   NewSize = 0;\r
 \r
-  HaveMemory = FALSE;\r
-  HaveUART   = FALSE;\r
-\r
-  HobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *HobData);\r
-  ASSERT (HobData != NULL);\r
-  *HobData = 0;\r
-\r
   DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);\r
   ASSERT (DeviceTreeBase != NULL);\r
 \r
@@ -107,7 +92,7 @@ ArmPlatformInitializeSystemMemory (
   //\r
   // Look for a memory node\r
   //\r
-  for (Prev = 0; !(HaveMemory && HaveUART); Prev = Node) {\r
+  for (Prev = 0;; Prev = Node) {\r
     Node = fdt_next_node (DeviceTreeBase, Prev, NULL);\r
     if (Node < 0) {\r
       break;\r
@@ -140,34 +125,7 @@ ArmPlatformInitializeSystemMemory (
         DEBUG ((EFI_D_ERROR, "%a: Failed to parse FDT memory node\n",\r
                __FUNCTION__));\r
       }\r
-      HaveMemory = TRUE;\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Check for UART node\r
-    //\r
-    Compatible = fdt_getprop (DeviceTreeBase, Node, "compatible", &Len);\r
-\r
-    //\r
-    // Iterate over the NULL-separated items in the compatible string\r
-    //\r
-    for (CompItem = Compatible; CompItem != NULL && CompItem < Compatible + Len;\r
-      CompItem += 1 + AsciiStrLen (CompItem)) {\r
-\r
-      if (AsciiStrCmp (CompItem, "arm,pl011") == 0) {\r
-        RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);\r
-        ASSERT (Len == 16);\r
-\r
-        UartBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));\r
-\r
-        DEBUG ((EFI_D_INFO, "%a: PL011 UART @ 0x%lx\n", __FUNCTION__, UartBase));\r
-\r
-        *HobData = UartBase;\r
-\r
-        HaveUART = TRUE;\r
-        continue;\r
-      }\r
+      break;\r
     }\r
   }\r
 \r
index af0d6e87da9f31fa7e9880e112f59983001a85b1..58bc2b828dcd8da001b5f9670175667e8558dc8b 100644 (file)
@@ -21,6 +21,8 @@
 #include <Library/PcdLib.h>\r
 #include <libfdt.h>\r
 \r
+#include <Guid/EarlyPL011BaseAddress.h>\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 PlatformPeim (\r
@@ -30,6 +32,14 @@ PlatformPeim (
   VOID               *Base;\r
   VOID               *NewBase;\r
   UINTN              FdtSize;\r
+  UINT64             *UartHobData;\r
+  INT32              Node, Prev;\r
+  CONST CHAR8        *Compatible;\r
+  CONST CHAR8        *CompItem;\r
+  INT32              Len;\r
+  CONST UINT64       *RegProp;\r
+  UINT64             UartBase;\r
+\r
 \r
   Base = (VOID*)(UINTN)FixedPcdGet64 (PcdDeviceTreeInitialBaseAddress);\r
   ASSERT (fdt_check_header (Base) == 0);\r
@@ -41,6 +51,44 @@ PlatformPeim (
   CopyMem (NewBase, Base, FdtSize);\r
   PcdSet64 (PcdDeviceTreeBaseAddress, (UINT64)(UINTN)NewBase);\r
 \r
+  UartHobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *UartHobData);\r
+  ASSERT (UartHobData != NULL);\r
+  *UartHobData = 0;\r
+\r
+  //\r
+  // Look for a UART node\r
+  //\r
+  for (Prev = 0;; Prev = Node) {\r
+    Node = fdt_next_node (Base, Prev, NULL);\r
+    if (Node < 0) {\r
+      break;\r
+    }\r
+\r
+    //\r
+    // Check for UART node\r
+    //\r
+    Compatible = fdt_getprop (Base, Node, "compatible", &Len);\r
+\r
+    //\r
+    // Iterate over the NULL-separated items in the compatible string\r
+    //\r
+    for (CompItem = Compatible; CompItem != NULL && CompItem < Compatible + Len;\r
+      CompItem += 1 + AsciiStrLen (CompItem)) {\r
+\r
+      if (AsciiStrCmp (CompItem, "arm,pl011") == 0) {\r
+        RegProp = fdt_getprop (Base, Node, "reg", &Len);\r
+        ASSERT (Len == 16);\r
+\r
+        UartBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));\r
+\r
+        DEBUG ((EFI_D_INFO, "%a: PL011 UART @ 0x%lx\n", __FUNCTION__, UartBase));\r
+\r
+        *UartHobData = UartBase;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+\r
   BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize));\r
 \r
   return EFI_SUCCESS;\r
index e544b528d26110a96916b5cf5f4502aa497ed2f1..a376fbd1f345d36e37fbf7e8152fa104fede3280 100644 (file)
@@ -44,5 +44,8 @@
 [Pcd]\r
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress\r
 \r
+[Guids]\r
+  gEarlyPL011BaseAddressGuid\r
+\r
 [Depex]\r
   gEfiPeiMemoryDiscoveredPpiGuid\r