]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmJunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
ArmPlatformPkg/ArmJunoPkg: Added ACPI support
[mirror_edk2.git] / ArmPlatformPkg / ArmJunoPkg / Drivers / ArmJunoDxe / ArmJunoDxe.c
CommitLineData
9f38945f
OM
1/** @file\r
2*\r
3* Copyright (c) 2013-2014, ARM Limited. All rights reserved.\r
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
17\r
05e56470
OM
18// This GUID must match the FILE_GUID in ArmPlatformPkg/ArmJunoPkg/AcpiTables/AcpiTables.inf\r
19STATIC CONST EFI_GUID mJunoAcpiTableFile = { 0xa1dd808e, 0x1e95, 0x4399, { 0xab, 0xc0, 0x65, 0x3c, 0x82, 0xe8, 0x53, 0x0c } };\r
20\r
9f38945f
OM
21EFI_STATUS\r
22EFIAPI\r
23ArmJunoEntryPoint (\r
24 IN EFI_HANDLE ImageHandle,\r
25 IN EFI_SYSTEM_TABLE *SystemTable\r
26 )\r
27{\r
28 EFI_STATUS Status;\r
29 EFI_PHYSICAL_ADDRESS HypBase;\r
30\r
31 Status = PciEmulationEntryPoint ();\r
32 if (EFI_ERROR (Status)) {\r
33 return Status;\r
34 }\r
35\r
36 //\r
37 // If a hypervisor has been declared then we need to make sure its region is protected at runtime\r
38 //\r
39 // Note: This code is only a workaround for our dummy hypervisor (ArmPkg/Extra/AArch64ToAArch32Shim/)\r
40 // that does not set up (yet) the stage 2 translation table to hide its own memory to EL1.\r
41 //\r
42 if (FixedPcdGet32 (PcdHypFvSize) != 0) {\r
43 // Ensure the hypervisor region is strictly contained into a EFI_PAGE_SIZE-aligned region.\r
44 // The memory must be a multiple of EFI_PAGE_SIZE to ensure we do not reserve more memory than the hypervisor itself.\r
45 // A UEFI Runtime region size granularity cannot be smaller than EFI_PAGE_SIZE. If the hypervisor size is not rounded\r
46 // to this size then there is a risk some non-runtime memory could be visible to the OS view.\r
47 if (((FixedPcdGet32 (PcdHypFvSize) & EFI_PAGE_MASK) == 0) && ((FixedPcdGet32 (PcdHypFvBaseAddress) & EFI_PAGE_MASK) == 0)) {\r
48 // The memory needs to be declared because the DXE core marked it as reserved and removed it from the memory space\r
49 // as it contains the Firmware.\r
50 Status = gDS->AddMemorySpace (\r
51 EfiGcdMemoryTypeSystemMemory,\r
52 FixedPcdGet32 (PcdHypFvBaseAddress), FixedPcdGet32 (PcdHypFvSize),\r
53 EFI_MEMORY_WB | EFI_MEMORY_RUNTIME\r
54 );\r
55 if (!EFI_ERROR (Status)) {\r
56 // We allocate the memory to ensure it is marked as runtime memory\r
57 HypBase = FixedPcdGet32 (PcdHypFvBaseAddress);\r
58 Status = gBS->AllocatePages (AllocateAddress, EfiRuntimeServicesCode,\r
59 EFI_SIZE_TO_PAGES (FixedPcdGet32 (PcdHypFvSize)), &HypBase);\r
60 }\r
61 } else {\r
62 // The hypervisor must be contained into a EFI_PAGE_SIZE-aligned region and its size must also be aligned\r
63 // on a EFI_PAGE_SIZE boundary (ie: 4KB).\r
64 Status = EFI_UNSUPPORTED;\r
65 ASSERT_EFI_ERROR (Status);\r
66 }\r
67\r
68 if (EFI_ERROR (Status)) {\r
69 return Status;\r
70 }\r
71 }\r
72\r
73 // Install dynamic Shell command to run baremetal binaries.\r
74 Status = ShellDynCmdRunAxfInstall (ImageHandle);\r
75 if (EFI_ERROR (Status)) {\r
76 DEBUG ((EFI_D_ERROR, "ArmJunoDxe: Failed to install ShellDynCmdRunAxf\n"));\r
77 }\r
78\r
05e56470
OM
79 // Try to install the ACPI Tables\r
80 Status = LocateAndInstallAcpiFromFv (&mJunoAcpiTableFile);\r
81 if (EFI_ERROR (Status)) {\r
82 return Status;\r
83 }\r
84
9f38945f
OM
85 // Try to install the Flat Device Tree (FDT). This function actually installs the\r
86 // UEFI Driver Binding Protocol.\r
87 Status = JunoFdtInstall (ImageHandle);\r
88\r
89 return Status;\r
90}\r