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