]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/BdsLinuxFdt.c: Introduce cpu_to_fdtn() function.
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 12 May 2013 23:55:22 +0000 (23:55 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 12 May 2013 23:55:22 +0000 (23:55 +0000)
Introduce cpu_to_fdtn() function which will call the appropriate 32-bit
or 64-bit version based on the size of a native integer.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14350 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/BdsLib/BdsLinuxFdt.c

index 380a666d0f2a0a321d9d49cd3597581c47efa415..b07b3e465d2c0aaf92d144651e38d6a0bcd526c0 100644 (file)
 #define PALIGN(p, a)    ((void *)(ALIGN((unsigned long)(p), (a))))\r
 #define GET_CELL(p)     (p += 4, *((const UINT32 *)(p-4)))\r
 \r
+STATIC inline\r
+UINTN\r
+cpu_to_fdtn (UINTN x) {\r
+  if (sizeof (UINTN) == sizeof (UINT32)) {\r
+    return cpu_to_fdt32 (x);\r
+  } else {\r
+    return cpu_to_fdt64 (x);\r
+  }\r
+}\r
+\r
 typedef struct {\r
   UINTN   Base;\r
   UINTN   Size;\r
@@ -452,13 +462,8 @@ PrepareFdt (
       GetSystemMemoryResources (&ResourceList);\r
       Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;\r
 \r
-      if (sizeof(UINTN) == sizeof(UINT32)) {\r
-        Region.Base = cpu_to_fdt32((UINTN)Resource->PhysicalStart);\r
-        Region.Size = cpu_to_fdt32((UINTN)Resource->ResourceLength);\r
-      } else {\r
-        Region.Base = cpu_to_fdt64((UINTN)Resource->PhysicalStart);\r
-        Region.Size = cpu_to_fdt64((UINTN)Resource->ResourceLength);\r
-      }\r
+      Region.Base = cpu_to_fdtn ((UINTN)Resource->PhysicalStart);\r
+      Region.Size = cpu_to_fdtn ((UINTN)Resource->ResourceLength);\r
 \r
       err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));\r
       if (err) {\r