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