]>
Commit | Line | Data |
---|---|---|
40082598 AB |
1 | #\r |
2 | # Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r | |
dfc28388 | 3 | # Copyright (c) 2014-2016, Linaro Limited. All rights reserved.\r |
40082598 AB |
4 | #\r |
5 | # This program and the accompanying materials\r | |
6 | # are licensed and made available under the terms and conditions of the BSD License\r | |
7 | # which accompanies this distribution. The full text of the license may be found at\r | |
8 | # http://opensource.org/licenses/bsd-license.php\r | |
9 | #\r | |
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | #\r | |
13 | #\r | |
14 | \r | |
15 | #include <AsmMacroIoLib.h>\r | |
40082598 | 16 | #include <Library/ArmLib.h>\r |
40082598 | 17 | \r |
dfc28388 | 18 | ASM_FUNC(ArmPlatformPeiBootAction)\r |
40082598 AB |
19 | mov r11, r14 // preserve LR\r |
20 | mov r10, r0 // preserve DTB pointer\r | |
21 | mov r9, r1 // preserve base of image pointer\r | |
22 | \r | |
23 | //\r | |
24 | // If we are booting from RAM using the Linux kernel boot protocol, r0 will\r | |
25 | // point to the DTB image in memory. Otherwise, we are just coming out of\r | |
26 | // reset, and r0 will be 0.\r | |
27 | //\r | |
28 | teq r0, #0\r | |
29 | beq .Lout\r | |
30 | \r | |
31 | //\r | |
32 | // The base of the runtime image has been preserved in r1. Check whether\r | |
33 | // the expected magic number can be found in the header.\r | |
34 | //\r | |
35 | ldr r8, .LArm32LinuxMagic\r | |
36 | ldr r7, [r1, #0x24]\r | |
37 | cmp r7, r8\r | |
38 | bne .Lout\r | |
39 | \r | |
40 | //\r | |
41 | //\r | |
42 | // OK, so far so good. We have confirmed that we likely have a DTB and are\r | |
43 | // booting via the ARM Linux boot protocol. Update the base-of-image PCD\r | |
44 | // to the actual relocated value, and add the shift of PcdFdBaseAddress to\r | |
45 | // PcdFvBaseAddress as well\r | |
46 | //\r | |
dfc28388 AB |
47 | ADRL (r8, PcdGet64 (PcdFdBaseAddress))\r |
48 | ADRL (r7, PcdGet64 (PcdFvBaseAddress))\r | |
40082598 AB |
49 | ldr r6, [r8]\r |
50 | ldr r5, [r7]\r | |
51 | sub r5, r5, r6\r | |
52 | add r5, r5, r1\r | |
53 | str r1, [r8]\r | |
54 | str r5, [r7]\r | |
55 | \r | |
56 | //\r | |
57 | // Discover the memory size and offset from the DTB, and record in the\r | |
58 | // respective PCDs. This will also return false if a corrupt DTB is\r | |
59 | // encountered. Since we are calling a C function, use the window at the\r | |
60 | // beginning of the FD image as a temp stack.\r | |
61 | //\r | |
dfc28388 AB |
62 | ADRL (r1, PcdGet64 (PcdSystemMemoryBase))\r |
63 | ADRL (r2, PcdGet64 (PcdSystemMemorySize))\r | |
40082598 AB |
64 | mov sp, r5\r |
65 | bl FindMemnode\r | |
66 | teq r0, #0\r | |
67 | beq .Lout\r | |
68 | \r | |
69 | //\r | |
70 | // Copy the DTB to the slack space right after the 64 byte arm64/Linux style\r | |
71 | // image header at the base of this image (defined in the FDF), and record the\r | |
72 | // pointer in PcdDeviceTreeInitialBaseAddress.\r | |
73 | //\r | |
dfc28388 | 74 | ADRL (r8, PcdGet64 (PcdDeviceTreeInitialBaseAddress))\r |
40082598 AB |
75 | add r9, r9, #0x40\r |
76 | str r9, [r8]\r | |
77 | \r | |
78 | mov r0, r9\r | |
79 | mov r1, r10\r | |
80 | bl CopyFdt\r | |
81 | \r | |
82 | .Lout:\r | |
83 | bx r11\r | |
84 | \r | |
dfc28388 AB |
85 | .LArm32LinuxMagic:\r |
86 | .byte 0x18, 0x28, 0x6f, 0x01\r | |
87 | \r | |
40082598 AB |
88 | //UINTN\r |
89 | //ArmPlatformGetPrimaryCoreMpId (\r | |
90 | // VOID\r | |
91 | // );\r | |
dfc28388 AB |
92 | ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)\r |
93 | MOV32 (r0, FixedPcdGet32 (PcdArmPrimaryCore))\r | |
40082598 AB |
94 | bx lr\r |
95 | \r | |
96 | //UINTN\r | |
97 | //ArmPlatformIsPrimaryCore (\r | |
98 | // IN UINTN MpId\r | |
99 | // );\r | |
dfc28388 | 100 | ASM_FUNC(ArmPlatformIsPrimaryCore)\r |
40082598 AB |
101 | mov r0, #1\r |
102 | bx lr\r | |
103 | \r | |
104 | //UINTN\r | |
105 | //ArmPlatformGetCorePosition (\r | |
106 | // IN UINTN MpId\r | |
107 | // );\r | |
108 | // With this function: CorePos = (ClusterId * 4) + CoreId\r | |
dfc28388 | 109 | ASM_FUNC(ArmPlatformGetCorePosition)\r |
40082598 AB |
110 | and r1, r0, #ARM_CORE_MASK\r |
111 | and r0, r0, #ARM_CLUSTER_MASK\r | |
112 | add r0, r1, r0, LSR #6\r | |
113 | bx lr\r | |
114 | \r | |
115 | //EFI_PHYSICAL_ADDRESS\r | |
116 | //GetPhysAddrTop (\r | |
117 | // VOID\r | |
118 | // );\r | |
dfc28388 | 119 | ASM_FUNC(ArmGetPhysAddrTop)\r |
40082598 AB |
120 | mov r0, #0x00000000\r |
121 | mov r1, #0x10000\r | |
122 | bx lr\r | |
123 | \r |