mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
cc9f215770
commit
8255c56957
|
@ -25,6 +25,16 @@
|
||||||
#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
|
#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
|
||||||
#define GET_CELL(p) (p += 4, *((const UINT32 *)(p-4)))
|
#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 {
|
typedef struct {
|
||||||
UINTN Base;
|
UINTN Base;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
|
@ -452,13 +462,8 @@ PrepareFdt (
|
||||||
GetSystemMemoryResources (&ResourceList);
|
GetSystemMemoryResources (&ResourceList);
|
||||||
Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;
|
Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;
|
||||||
|
|
||||||
if (sizeof(UINTN) == sizeof(UINT32)) {
|
Region.Base = cpu_to_fdtn ((UINTN)Resource->PhysicalStart);
|
||||||
Region.Base = cpu_to_fdt32((UINTN)Resource->PhysicalStart);
|
Region.Size = cpu_to_fdtn ((UINTN)Resource->ResourceLength);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));
|
err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in New Issue