]> git.proxmox.com Git - mirror_edk2.git/blame - ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/ARM/RelocatableVirtHelper.S
ArmVirtPkg/RelocatableVirtHelper: use correct FindMemNode argument order
[mirror_edk2.git] / ArmVirtPkg / Library / ArmXenRelocatablePlatformLib / ARM / RelocatableVirtHelper.S
CommitLineData
40082598
AB
1#\r
2# Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
3# Copyright (c) 2014, Linaro Limited. All rights reserved.\r
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
16#include <Base.h>\r
17#include <Library/ArmLib.h>\r
18#include <Library/PcdLib.h>\r
19#include <AutoGen.h>\r
20\r
21.text\r
22.align 2\r
23\r
24GCC_ASM_EXPORT(ArmPlatformPeiBootAction)\r
25GCC_ASM_EXPORT(ArmPlatformIsPrimaryCore)\r
26GCC_ASM_EXPORT(ArmPlatformGetPrimaryCoreMpId)\r
27GCC_ASM_EXPORT(ArmPlatformGetCorePosition)\r
28GCC_ASM_EXPORT(ArmGetPhysAddrTop)\r
29\r
30GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCore)\r
31GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdArmPrimaryCoreMask)\r
32GCC_ASM_IMPORT(_gPcd_FixedAtBuild_PcdCoreCount)\r
33\r
34.LArm32LinuxMagic:\r
35 .byte 0x18, 0x28, 0x6f, 0x01\r
36\r
37ASM_PFX(ArmPlatformPeiBootAction):\r
38 mov r11, r14 // preserve LR\r
39 mov r10, r0 // preserve DTB pointer\r
40 mov r9, r1 // preserve base of image pointer\r
41\r
42 //\r
43 // If we are booting from RAM using the Linux kernel boot protocol, r0 will\r
44 // point to the DTB image in memory. Otherwise, we are just coming out of\r
45 // reset, and r0 will be 0.\r
46 //\r
47 teq r0, #0\r
48 beq .Lout\r
49\r
50 //\r
51 // The base of the runtime image has been preserved in r1. Check whether\r
52 // the expected magic number can be found in the header.\r
53 //\r
54 ldr r8, .LArm32LinuxMagic\r
55 ldr r7, [r1, #0x24]\r
56 cmp r7, r8\r
57 bne .Lout\r
58\r
59 //\r
60 //\r
61 // OK, so far so good. We have confirmed that we likely have a DTB and are\r
62 // booting via the ARM Linux boot protocol. Update the base-of-image PCD\r
63 // to the actual relocated value, and add the shift of PcdFdBaseAddress to\r
64 // PcdFvBaseAddress as well\r
65 //\r
66 ldr r8, =PcdGet64 (PcdFdBaseAddress)\r
67 ldr r7, =PcdGet64 (PcdFvBaseAddress)\r
68 ldr r6, [r8]\r
69 ldr r5, [r7]\r
70 sub r5, r5, r6\r
71 add r5, r5, r1\r
72 str r1, [r8]\r
73 str r5, [r7]\r
74\r
75 //\r
76 // Discover the memory size and offset from the DTB, and record in the\r
77 // respective PCDs. This will also return false if a corrupt DTB is\r
78 // encountered. Since we are calling a C function, use the window at the\r
79 // beginning of the FD image as a temp stack.\r
80 //\r
8457f5e4
AB
81 ldr r1, =PcdGet64 (PcdSystemMemoryBase)\r
82 ldr r2, =PcdGet64 (PcdSystemMemorySize)\r
40082598
AB
83 mov sp, r5\r
84 bl FindMemnode\r
85 teq r0, #0\r
86 beq .Lout\r
87\r
88 //\r
89 // Copy the DTB to the slack space right after the 64 byte arm64/Linux style\r
90 // image header at the base of this image (defined in the FDF), and record the\r
91 // pointer in PcdDeviceTreeInitialBaseAddress.\r
92 //\r
93 ldr r8, =PcdGet64 (PcdDeviceTreeInitialBaseAddress)\r
94 add r9, r9, #0x40\r
95 str r9, [r8]\r
96\r
97 mov r0, r9\r
98 mov r1, r10\r
99 bl CopyFdt\r
100\r
101.Lout:\r
102 bx r11\r
103\r
104//UINTN\r
105//ArmPlatformGetPrimaryCoreMpId (\r
106// VOID\r
107// );\r
108ASM_PFX(ArmPlatformGetPrimaryCoreMpId):\r
109 LoadConstantToReg (_gPcd_FixedAtBuild_PcdArmPrimaryCore, r0)\r
110 ldr r0, [r0]\r
111 bx lr\r
112\r
113//UINTN\r
114//ArmPlatformIsPrimaryCore (\r
115// IN UINTN MpId\r
116// );\r
117ASM_PFX(ArmPlatformIsPrimaryCore):\r
118 mov r0, #1\r
119 bx lr\r
120\r
121//UINTN\r
122//ArmPlatformGetCorePosition (\r
123// IN UINTN MpId\r
124// );\r
125// With this function: CorePos = (ClusterId * 4) + CoreId\r
126ASM_PFX(ArmPlatformGetCorePosition):\r
127 and r1, r0, #ARM_CORE_MASK\r
128 and r0, r0, #ARM_CLUSTER_MASK\r
129 add r0, r1, r0, LSR #6\r
130 bx lr\r
131\r
132//EFI_PHYSICAL_ADDRESS\r
133//GetPhysAddrTop (\r
134// VOID\r
135// );\r
136ASM_PFX(ArmGetPhysAddrTop):\r
137 mov r0, #0x00000000\r
138 mov r1, #0x10000\r
139 bx lr\r
140\r