]> git.proxmox.com Git - mirror_edk2.git/blame - ArmVirtPkg/Library/ArmXenRelocatablePlatformLib/AARCH64/RelocatableVirtHelper.S
ArmVirtPkg: clean up assembly source files
[mirror_edk2.git] / ArmVirtPkg / Library / ArmXenRelocatablePlatformLib / AARCH64 / RelocatableVirtHelper.S
CommitLineData
f9849036
AB
1#\r
2# Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
dfc28388 3# Copyright (c) 2016, Linaro Limited. All rights reserved.\r
f9849036
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 <AsmMacroIoLibV8.h>\r
f9849036 16#include <Library/ArmLib.h>\r
f9849036
AB
17\r
18// VOID\r
19// ArmPlatformPeiBootAction (\r
20// VOID *DeviceTreeBaseAddress, // passed by loader in x0\r
21// VOID *ImageBase // passed by FDF trampoline in x1\r
22// );\r
dfc28388 23ASM_FUNC(ArmPlatformPeiBootAction)\r
f9849036 24 mov x29, x30 // preserve LR\r
03b6bed1
AB
25 mov x28, x0 // preserve DTB pointer\r
26 mov x27, x1 // preserve base of image pointer\r
f9849036
AB
27\r
28 //\r
29 // If we are booting from RAM using the Linux kernel boot protocol, x0 will\r
30 // point to the DTB image in memory. Otherwise, we are just coming out of\r
03b6bed1 31 // reset, and x0 will be 0.\r
f9849036
AB
32 //\r
33 cbz x0, .Lout\r
f9849036
AB
34\r
35 //\r
36 // The base of the runtime image has been preserved in x1. Check whether\r
37 // the expected magic number can be found in the header.\r
38 //\r
39 ldr w8, .LArm64LinuxMagic\r
40 ldr w9, [x1, #0x38]\r
41 cmp w8, w9\r
42 bne .Lout\r
43\r
44 //\r
45 //\r
46 // OK, so far so good. We have confirmed that we likely have a DTB and are\r
47 // booting via the arm64 Linux boot protocol. Update the base-of-image PCD\r
48 // to the actual relocated value, and add the shift of PcdFdBaseAddress to\r
49 // PcdFvBaseAddress as well\r
50 //\r
51 adr x8, PcdGet64 (PcdFdBaseAddress)\r
52 adr x9, PcdGet64 (PcdFvBaseAddress)\r
53 ldr x6, [x8]\r
54 ldr x7, [x9]\r
55 sub x7, x7, x6\r
56 add x7, x7, x1\r
57 str x1, [x8]\r
58 str x7, [x9]\r
59\r
03b6bed1
AB
60 //\r
61 // Discover the memory size and offset from the DTB, and record in the\r
62 // respective PCDs. This will also return false if a corrupt DTB is\r
63 // encountered. Since we are calling a C function, use the window at the\r
64 // beginning of the FD image as a temp stack.\r
65 //\r
8457f5e4
AB
66 adr x1, PcdGet64 (PcdSystemMemoryBase)\r
67 adr x2, PcdGet64 (PcdSystemMemorySize)\r
03b6bed1
AB
68 mov sp, x7\r
69 bl FindMemnode\r
70 cbz x0, .Lout\r
71\r
f9849036
AB
72 //\r
73 // Copy the DTB to the slack space right after the 64 byte arm64/Linux style\r
74 // image header at the base of this image (defined in the FDF), and record the\r
75 // pointer in PcdDeviceTreeInitialBaseAddress.\r
76 //\r
77 adr x8, PcdGet64 (PcdDeviceTreeInitialBaseAddress)\r
03b6bed1
AB
78 add x27, x27, #0x40\r
79 str x27, [x8]\r
f9849036 80\r
03b6bed1
AB
81 mov x0, x27\r
82 mov x1, x28\r
83 bl CopyFdt\r
f9849036
AB
84\r
85.Lout:\r
86 ret x29\r
87\r
dfc28388
AB
88.LArm64LinuxMagic:\r
89 .byte 0x41, 0x52, 0x4d, 0x64\r
90\r
f9849036
AB
91//UINTN\r
92//ArmPlatformGetPrimaryCoreMpId (\r
93// VOID\r
94// );\r
dfc28388
AB
95ASM_FUNC(ArmPlatformGetPrimaryCoreMpId)\r
96 MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))\r
f9849036
AB
97 ret\r
98\r
99//UINTN\r
100//ArmPlatformIsPrimaryCore (\r
101// IN UINTN MpId\r
102// );\r
dfc28388 103ASM_FUNC(ArmPlatformIsPrimaryCore)\r
f9849036
AB
104 mov x0, #1\r
105 ret\r
106\r
107//UINTN\r
108//ArmPlatformGetCorePosition (\r
109// IN UINTN MpId\r
110// );\r
111// With this function: CorePos = (ClusterId * 4) + CoreId\r
dfc28388 112ASM_FUNC(ArmPlatformGetCorePosition)\r
f9849036
AB
113 and x1, x0, #ARM_CORE_MASK\r
114 and x0, x0, #ARM_CLUSTER_MASK\r
115 add x0, x1, x0, LSR #6\r
116 ret\r
117\r
118//EFI_PHYSICAL_ADDRESS\r
119//GetPhysAddrTop (\r
120// VOID\r
121// );\r
dfc28388 122ASM_FUNC(ArmGetPhysAddrTop)\r
f9849036
AB
123 mrs x0, id_aa64mmfr0_el1\r
124 adr x1, .LPARanges\r
125 and x0, x0, #7\r
126 ldrb w1, [x1, x0]\r
127 mov x0, #1\r
128 lsl x0, x0, x1\r
129 ret\r
130\r
131//\r
132// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the\r
133// physical address space support on this CPU:\r
134// 0 == 32 bits, 1 == 36 bits, etc etc\r
135// 6 and 7 are reserved\r
136//\r
137.LPARanges:\r
138 .byte 32, 36, 40, 42, 44, 48, -1, -1\r
139\r
140ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r