summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-05-12 23:55:22 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-05-12 23:55:22 +0000
commit8255c56957718bc2f43c68cbb90d4ffe14d7437f (patch)
tree19863aa3cb7efa0714952b60aa843d517096b1db
parentcc9f215770a96fcbb897afb7f598f02d329a5955 (diff)
downloadedk2-platforms-8255c56957718bc2f43c68cbb90d4ffe14d7437f.tar.xz
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 <olivier.martin@arm.com git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14350 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--ArmPkg/Library/BdsLib/BdsLinuxFdt.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
index 380a666d0f..b07b3e465d 100644
--- a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
+++ b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
@@ -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 @@ PrepareFdt (
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) {