]>
Commit | Line | Data |
---|---|---|
9f38945f OM |
1 | /** @file\r |
2 | *\r | |
21a76332 | 3 | * Copyright (c) 2013-2015, ARM Limited. All rights reserved.\r |
9f38945f OM |
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 "ArmJunoDxeInternal.h"\r | |
16 | #include <Library/ArmShellCmdLib.h>\r | |
21a76332 | 17 | #include <Library/AcpiLib.h>\r |
9f38945f | 18 | \r |
05e56470 OM |
19 | // This GUID must match the FILE_GUID in ArmPlatformPkg/ArmJunoPkg/AcpiTables/AcpiTables.inf\r |
20 | STATIC CONST EFI_GUID mJunoAcpiTableFile = { 0xa1dd808e, 0x1e95, 0x4399, { 0xab, 0xc0, 0x65, 0x3c, 0x82, 0xe8, 0x53, 0x0c } };\r | |
21 | \r | |
9f38945f OM |
22 | EFI_STATUS\r |
23 | EFIAPI\r | |
24 | ArmJunoEntryPoint (\r | |
25 | IN EFI_HANDLE ImageHandle,\r | |
26 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
27 | )\r | |
28 | {\r | |
7aec2926 RC |
29 | EFI_STATUS Status;\r |
30 | EFI_PHYSICAL_ADDRESS HypBase;\r | |
31 | CHAR16 *TextDevicePath;\r | |
32 | UINTN TextDevicePathSize;\r | |
33 | VOID *Buffer;\r | |
34 | UINT32 Midr;\r | |
35 | UINT32 CpuType;\r | |
36 | UINT32 CpuRev;\r | |
9f38945f OM |
37 | \r |
38 | Status = PciEmulationEntryPoint ();\r | |
39 | if (EFI_ERROR (Status)) {\r | |
40 | return Status;\r | |
41 | }\r | |
42 | \r | |
43 | //\r | |
44 | // If a hypervisor has been declared then we need to make sure its region is protected at runtime\r | |
45 | //\r | |
46 | // Note: This code is only a workaround for our dummy hypervisor (ArmPkg/Extra/AArch64ToAArch32Shim/)\r | |
47 | // that does not set up (yet) the stage 2 translation table to hide its own memory to EL1.\r | |
48 | //\r | |
49 | if (FixedPcdGet32 (PcdHypFvSize) != 0) {\r | |
50 | // Ensure the hypervisor region is strictly contained into a EFI_PAGE_SIZE-aligned region.\r | |
51 | // The memory must be a multiple of EFI_PAGE_SIZE to ensure we do not reserve more memory than the hypervisor itself.\r | |
52 | // A UEFI Runtime region size granularity cannot be smaller than EFI_PAGE_SIZE. If the hypervisor size is not rounded\r | |
53 | // to this size then there is a risk some non-runtime memory could be visible to the OS view.\r | |
54 | if (((FixedPcdGet32 (PcdHypFvSize) & EFI_PAGE_MASK) == 0) && ((FixedPcdGet32 (PcdHypFvBaseAddress) & EFI_PAGE_MASK) == 0)) {\r | |
55 | // The memory needs to be declared because the DXE core marked it as reserved and removed it from the memory space\r | |
56 | // as it contains the Firmware.\r | |
57 | Status = gDS->AddMemorySpace (\r | |
58 | EfiGcdMemoryTypeSystemMemory,\r | |
59 | FixedPcdGet32 (PcdHypFvBaseAddress), FixedPcdGet32 (PcdHypFvSize),\r | |
60 | EFI_MEMORY_WB | EFI_MEMORY_RUNTIME\r | |
61 | );\r | |
62 | if (!EFI_ERROR (Status)) {\r | |
63 | // We allocate the memory to ensure it is marked as runtime memory\r | |
64 | HypBase = FixedPcdGet32 (PcdHypFvBaseAddress);\r | |
65 | Status = gBS->AllocatePages (AllocateAddress, EfiRuntimeServicesCode,\r | |
66 | EFI_SIZE_TO_PAGES (FixedPcdGet32 (PcdHypFvSize)), &HypBase);\r | |
67 | }\r | |
68 | } else {\r | |
69 | // The hypervisor must be contained into a EFI_PAGE_SIZE-aligned region and its size must also be aligned\r | |
70 | // on a EFI_PAGE_SIZE boundary (ie: 4KB).\r | |
71 | Status = EFI_UNSUPPORTED;\r | |
72 | ASSERT_EFI_ERROR (Status);\r | |
73 | }\r | |
74 | \r | |
75 | if (EFI_ERROR (Status)) {\r | |
76 | return Status;\r | |
77 | }\r | |
78 | }\r | |
79 | \r | |
80 | // Install dynamic Shell command to run baremetal binaries.\r | |
81 | Status = ShellDynCmdRunAxfInstall (ImageHandle);\r | |
82 | if (EFI_ERROR (Status)) {\r | |
83 | DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n"));\r | |
84 | }\r | |
85 | \r | |
7aec2926 RC |
86 | //\r |
87 | // Set up the device path to the FDT.\r | |
88 | // We detect whether we are running on a Juno r0 or Juno r1 board at\r | |
89 | // runtime by checking the value of the MIDR register.\r | |
90 | //\r | |
91 | \r | |
92 | Midr = ArmReadMidr ();\r | |
93 | CpuType = (Midr >> ARM_CPU_TYPE_SHIFT) & ARM_CPU_TYPE_MASK;\r | |
94 | CpuRev = Midr & ARM_CPU_REV_MASK;\r | |
95 | TextDevicePath = NULL;\r | |
96 | \r | |
97 | switch (CpuType) {\r | |
98 | case ARM_CPU_TYPE_A53:\r | |
99 | if (CpuRev == ARM_CPU_REV (0, 0)) {\r | |
1ccc0fd7 | 100 | TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdJunoR0FdtDevicePath);\r |
7aec2926 | 101 | } else if (CpuRev == ARM_CPU_REV (0, 3)) {\r |
1ccc0fd7 | 102 | TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdJunoR1A57x2FdtDevicePath);\r |
7aec2926 RC |
103 | }\r |
104 | break;\r | |
105 | \r | |
106 | case ARM_CPU_TYPE_A57:\r | |
107 | if (CpuRev == ARM_CPU_REV (0, 0)) {\r | |
1ccc0fd7 | 108 | TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdJunoR0FdtDevicePath);\r |
7aec2926 | 109 | } else if (CpuRev == ARM_CPU_REV (1, 1)) {\r |
1ccc0fd7 | 110 | TextDevicePath = (CHAR16*)FixedPcdGetPtr (PcdJunoR1A57x2FdtDevicePath);\r |
7aec2926 RC |
111 | }\r |
112 | }\r | |
113 | \r | |
114 | if (TextDevicePath != NULL) {\r | |
115 | TextDevicePathSize = StrSize (TextDevicePath);\r | |
116 | Buffer = PcdSetPtr (PcdFdtDevicePaths, &TextDevicePathSize, TextDevicePath);\r | |
117 | Status = (Buffer != NULL) ? EFI_SUCCESS : EFI_BUFFER_TOO_SMALL;\r | |
118 | } else {\r | |
119 | Status = EFI_NOT_FOUND;\r | |
120 | }\r | |
121 | \r | |
05e56470 | 122 | if (EFI_ERROR (Status)) {\r |
7aec2926 RC |
123 | DEBUG (\r |
124 | (EFI_D_ERROR,\r | |
125 | "ArmJunoDxe: Setting of FDT device path in PcdFdtDevicePaths failed - %r\n", Status)\r | |
126 | );\r | |
05e56470 OM |
127 | return Status;\r |
128 | }\r | |
21a76332 | 129 | \r |
7aec2926 RC |
130 | // Try to install the ACPI Tables\r |
131 | Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile);\r | |
132 | \r | |
9f38945f OM |
133 | return Status;\r |
134 | }\r |