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