]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
ArmVirtPkg: remove PURE_ACPI_BOOT_ENABLE and PcdPureAcpiBoot
[mirror_edk2.git] / ArmVirtPkg / PlatformHasAcpiDtDxe / PlatformHasAcpiDtDxe.c
1 /** @file
2 Decide whether the firmware should expose an ACPI- and/or a Device Tree-based
3 hardware description to the operating system.
4
5 Copyright (c) 2017, Red Hat, Inc.
6
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 **/
15
16 #include <Guid/PlatformHasAcpi.h>
17 #include <Guid/PlatformHasDeviceTree.h>
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/QemuFwCfgLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22
23 EFI_STATUS
24 EFIAPI
25 PlatformHasAcpiDt (
26 IN EFI_HANDLE ImageHandle,
27 IN EFI_SYSTEM_TABLE *SystemTable
28 )
29 {
30 EFI_STATUS Status;
31 FIRMWARE_CONFIG_ITEM FwCfgItem;
32 UINTN FwCfgSize;
33
34 //
35 // If we fail to install any of the necessary protocols below, the OS will be
36 // unbootable anyway (due to lacking hardware description), so tolerate no
37 // errors here.
38 //
39 if (MAX_UINTN == MAX_UINT64 &&
40 !EFI_ERROR (
41 QemuFwCfgFindFile (
42 "etc/table-loader",
43 &FwCfgItem,
44 &FwCfgSize
45 )
46 )) {
47 //
48 // Only make ACPI available on 64-bit systems, and only if QEMU generates
49 // (a subset of) the ACPI tables.
50 //
51 Status = gBS->InstallProtocolInterface (
52 &ImageHandle,
53 &gEdkiiPlatformHasAcpiGuid,
54 EFI_NATIVE_INTERFACE,
55 NULL
56 );
57 if (EFI_ERROR (Status)) {
58 goto Failed;
59 }
60
61 return Status;
62 }
63
64 //
65 // Expose the Device Tree otherwise.
66 //
67 Status = gBS->InstallProtocolInterface (
68 &ImageHandle,
69 &gEdkiiPlatformHasDeviceTreeGuid,
70 EFI_NATIVE_INTERFACE,
71 NULL
72 );
73 if (EFI_ERROR (Status)) {
74 goto Failed;
75 }
76
77 return Status;
78
79 Failed:
80 ASSERT_EFI_ERROR (Status);
81 CpuDeadLoop ();
82 //
83 // Keep compilers happy.
84 //
85 return Status;
86 }