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