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