+\r
+ASM_PFX(ArmPlatformPeiBootAction):\r
+ //\r
+ // If we are booting from RAM using the Linux kernel boot protocol, r0 will\r
+ // point to the DTB image in memory. Otherwise, use the default value defined\r
+ // by the platform.\r
+ //\r
+ teq r0, #0\r
+ bne 0f\r
+ LDRL (r0, PcdGet64 (PcdDeviceTreeInitialBaseAddress))\r
+\r
+0:mov r11, r14 // preserve LR\r
+ mov r10, r0 // preserve DTB pointer\r
+ mov r9, r1 // preserve base of image pointer\r
+\r
+ //\r
+ // The base of the runtime image has been preserved in r1. Check whether\r
+ // the expected magic number can be found in the header.\r
+ //\r
+ ldr r8, .LArm32LinuxMagic\r
+ ldr r7, [r1, #0x24]\r
+ cmp r7, r8\r
+ bne .Lout\r
+\r
+ //\r
+ //\r
+ // OK, so far so good. We have confirmed that we likely have a DTB and are\r
+ // booting via the ARM Linux boot protocol. Update the base-of-image PCD\r
+ // to the actual relocated value, and add the shift of PcdFdBaseAddress to\r
+ // PcdFvBaseAddress as well\r
+ //\r
+ ADRL (r8, PcdGet64 (PcdFdBaseAddress))\r
+ ADRL (r7, PcdGet64 (PcdFvBaseAddress))\r
+ ldr r6, [r8]\r
+ ldr r5, [r7]\r
+ sub r5, r5, r6\r
+ add r5, r5, r1\r
+ str r1, [r8]\r
+ str r5, [r7]\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
+ ADRL (r1, PcdGet64 (PcdSystemMemoryBase))\r
+ ADRL (r2, PcdGet64 (PcdSystemMemorySize))\r
+ mov sp, r5\r
+ bl FindMemnode\r
+ teq r0, #0\r
+ beq .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
+ ADRL (r8, PcdGet64 (PcdDeviceTreeInitialBaseAddress))\r
+ add r9, r9, #0x40\r
+ str r9, [r8]\r
+\r
+ mov r0, r9\r
+ mov r1, r10\r
+ bl CopyFdt\r
+\r
+.Lout:\r
+ bx r11\r
+\r
+.LArm32LinuxMagic:\r
+ .byte 0x18, 0x28, 0x6f, 0x01\r