GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)\r
GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdCoreCount)\r
\r
-.LFdtMagic:\r
- .byte 0xd0, 0x0d, 0xfe, 0xed\r
-\r
.LArm64LinuxMagic:\r
.byte 0x41, 0x52, 0x4d, 0x64\r
\r
// );\r
ASM_PFX(ArmPlatformPeiBootAction):\r
mov x29, x30 // preserve LR\r
+ mov x28, x0 // preserve DTB pointer\r
+ mov x27, x1 // preserve base of image pointer\r
\r
//\r
// If we are booting from RAM using the Linux kernel boot protocol, x0 will\r
// point to the DTB image in memory. Otherwise, we are just coming out of\r
- // reset, and x0 will be 0. Check also the FDT magic.\r
+ // reset, and x0 will be 0.\r
//\r
cbz x0, .Lout\r
- ldr w8, .LFdtMagic\r
- ldr w9, [x0]\r
- cmp w8, w9\r
- bne .Lout\r
\r
//\r
// The base of the runtime image has been preserved in x1. Check whether\r
str x1, [x8]\r
str x7, [x9]\r
\r
+ //\r
+ // Discover the memory size and offset from the DTB, and record in the\r
+ // respective PCDs. This will also return false if a corrupt DTB is\r
+ // encountered. Since we are calling a C function, use the window at the\r
+ // beginning of the FD image as a temp stack.\r
+ //\r
+ adr x1, PcdGet64 (PcdSystemMemorySize)\r
+ adr x2, PcdGet64 (PcdSystemMemoryBase)\r
+ mov sp, x7\r
+ bl FindMemnode\r
+ cbz x0, .Lout\r
+\r
//\r
// Copy the DTB to the slack space right after the 64 byte arm64/Linux style\r
// image header at the base of this image (defined in the FDF), and record the\r
// pointer in PcdDeviceTreeInitialBaseAddress.\r
//\r
adr x8, PcdGet64 (PcdDeviceTreeInitialBaseAddress)\r
- add x1, x1, #0x40\r
- str x1, [x8]\r
-\r
- ldr w8, [x0, #4] // get DTB size (BE)\r
- mov x9, x1\r
- rev w8, w8\r
- add x8, x8, x0\r
-0:ldp x6, x7, [x0], #16\r
- stp x6, x7, [x9], #16\r
- cmp x0, x8\r
- blt 0b\r
-\r
- //\r
- // Discover the memory size and offset from the DTB, and record in the\r
- // respective PCDs\r
- //\r
- mov x0, x1\r
- bl find_memnode // returns (size, base) size in (x0, x1)\r
- cbz x0, .Lout\r
+ add x27, x27, #0x40\r
+ str x27, [x8]\r
\r
- adr x8, PcdGet64 (PcdSystemMemorySize)\r
- adr x9, PcdGet64 (PcdSystemMemoryBase)\r
- str x0, [x8]\r
- str x1, [x9]\r
+ mov x0, x27\r
+ mov x1, x28\r
+ bl CopyFdt\r
\r
.Lout:\r
ret x29\r