3 * Copyright (c) 2011-2013, ARM Limited. All rights reserved.
4 * Copyright (c) 2014, Linaro Limited. All rights reserved.
5 * Copyright (c) 2014, Red Hat, Inc.
8 * This program and the accompanying materials
9 * are licensed and made available under the terms and conditions of the BSD License
10 * which accompanies this distribution. The full text of the license may be found at
11 * http://opensource.org/licenses/bsd-license.php
13 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/IoLib.h>
19 #include <Library/ArmPlatformLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/PcdLib.h>
22 #include <ArmPlatform.h>
24 #include <Pi/PiBootMode.h>
25 #include <Uefi/UefiBaseType.h>
26 #include <Uefi/UefiMultiPhase.h>
29 Return the current Boot Mode
31 This function returns the boot reason on the platform
33 @return Return the current Boot Mode of the platform
37 ArmPlatformGetBootMode (
41 return BOOT_WITH_FULL_CONFIGURATION
;
45 This function is called by PrePeiCore, in the SEC phase.
48 ArmPlatformInitialize (
53 // We are relying on ArmPlatformInitializeSystemMemory () being called from
54 // InitializeMemory (), which only occurs if the following feature is disabled
56 ASSERT (!FeaturePcdGet (PcdSystemMemoryInitializeInSec
));
57 return RETURN_SUCCESS
;
61 Initialize the system (or sometimes called permanent) memory
63 This memory is generally represented by the DRAM.
65 This function is called from InitializeMemory() in MemoryInitPeim, in the PEI
69 ArmPlatformInitializeSystemMemory (
79 CONST UINT64
*RegProp
;
84 DeviceTreeBase
= (VOID
*)(UINTN
)PcdGet64 (PcdDeviceTreeInitialBaseAddress
);
85 ASSERT (DeviceTreeBase
!= NULL
);
88 // Make sure we have a valid device tree blob
90 ASSERT (fdt_check_header (DeviceTreeBase
) == 0);
93 // Look for a memory node
95 for (Prev
= 0;; Prev
= Node
) {
96 Node
= fdt_next_node (DeviceTreeBase
, Prev
, NULL
);
102 // Check for memory node
104 Type
= fdt_getprop (DeviceTreeBase
, Node
, "device_type", &Len
);
105 if (Type
&& AsciiStrnCmp (Type
, "memory", Len
) == 0) {
107 // Get the 'reg' property of this node. For now, we will assume
108 // two 8 byte quantities for base and size, respectively.
110 RegProp
= fdt_getprop (DeviceTreeBase
, Node
, "reg", &Len
);
111 if (RegProp
!= 0 && Len
== (2 * sizeof (UINT64
))) {
113 NewBase
= fdt64_to_cpu (ReadUnaligned64 (RegProp
));
114 NewSize
= fdt64_to_cpu (ReadUnaligned64 (RegProp
+ 1));
117 // Make sure the start of DRAM matches our expectation
119 ASSERT (FixedPcdGet64 (PcdSystemMemoryBase
) == NewBase
);
120 PcdSet64 (PcdSystemMemorySize
, NewSize
);
122 DEBUG ((EFI_D_INFO
, "%a: System RAM @ 0x%lx - 0x%lx\n",
123 __FUNCTION__
, NewBase
, NewBase
+ NewSize
- 1));
125 DEBUG ((EFI_D_ERROR
, "%a: Failed to parse FDT memory node\n",
133 // We need to make sure that the machine we are running on has at least
134 // 128 MB of memory configured, and is currently executing this binary from
135 // NOR flash. This prevents a device tree image in DRAM from getting
136 // clobbered when our caller installs permanent PEI RAM, before we have a
137 // chance of marking its location as reserved or copy it to a freshly
138 // allocated block in the permanent PEI RAM in the platform PEIM.
140 ASSERT (NewSize
>= SIZE_128MB
);
142 (((UINT64
)PcdGet64 (PcdFdBaseAddress
) +
143 (UINT64
)PcdGet32 (PcdFdSize
)) <= NewBase
) ||
144 ((UINT64
)PcdGet64 (PcdFdBaseAddress
) >= (NewBase
+ NewSize
)));
148 ArmPlatformGetPlatformPpiList (
149 OUT UINTN
*PpiListSize
,
150 OUT EFI_PEI_PPI_DESCRIPTOR
**PpiList