Revision: 14350
          http://edk2.svn.sourceforge.net/edk2/?rev=14350&view=rev
Author:   oliviermartin
Date:     2013-05-12 23:55:22 +0000 (Sun, 12 May 2013)
Log Message:
-----------
ArmPkg/BdsLinuxFdt.c: Introduce cpu_to_fdtn() function.
    
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 <[email protected]

Modified Paths:
--------------
    trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c

Modified: trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
===================================================================
--- trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c      2013-05-12 23:54:16 UTC 
(rev 14349)
+++ trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c      2013-05-12 23:55:22 UTC 
(rev 14350)
@@ -25,6 +25,16 @@
 #define PALIGN(p, a)    ((void *)(ALIGN((unsigned long)(p), (a))))
 #define GET_CELL(p)     (p += 4, *((const UINT32 *)(p-4)))
 
+STATIC inline
+UINTN
+cpu_to_fdtn (UINTN x) {
+  if (sizeof (UINTN) == sizeof (UINT32)) {
+    return cpu_to_fdt32 (x);
+  } else {
+    return cpu_to_fdt64 (x);
+  }
+}
+
 typedef struct {
   UINTN   Base;
   UINTN   Size;
@@ -452,13 +462,8 @@
       GetSystemMemoryResources (&ResourceList);
       Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;
 
-      if (sizeof(UINTN) == sizeof(UINT32)) {
-        Region.Base = cpu_to_fdt32((UINTN)Resource->PhysicalStart);
-        Region.Size = cpu_to_fdt32((UINTN)Resource->ResourceLength);
-      } else {
-        Region.Base = cpu_to_fdt64((UINTN)Resource->PhysicalStart);
-        Region.Size = cpu_to_fdt64((UINTN)Resource->ResourceLength);
-      }
+      Region.Base = cpu_to_fdtn ((UINTN)Resource->PhysicalStart);
+      Region.Size = cpu_to_fdtn ((UINTN)Resource->ResourceLength);
 
       err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));
       if (err) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to