]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
OvmfPkg/Csm/LegacyBiosDxe: Update to make it build for OVMF
[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 SPDX-License-Identifier: BSD-2-Clause-Patent
8 **/
9
10 #include <Guid/PlatformHasAcpi.h>
11 #include <Guid/PlatformHasDeviceTree.h>
12 #include <Library/BaseLib.h>
13 #include <Library/DebugLib.h>
14 #include <Library/PcdLib.h>
15 #include <Library/QemuFwCfgLib.h>
16 #include <Library/UefiBootServicesTableLib.h>
17
18 EFI_STATUS
19 EFIAPI
20 PlatformHasAcpiDt (
21 IN EFI_HANDLE ImageHandle,
22 IN EFI_SYSTEM_TABLE *SystemTable
23 )
24 {
25 EFI_STATUS Status;
26 FIRMWARE_CONFIG_ITEM FwCfgItem;
27 UINTN FwCfgSize;
28
29 //
30 // If we fail to install any of the necessary protocols below, the OS will be
31 // unbootable anyway (due to lacking hardware description), so tolerate no
32 // errors here.
33 //
34 if (MAX_UINTN == MAX_UINT64 &&
35 !PcdGetBool (PcdForceNoAcpi) &&
36 !EFI_ERROR (
37 QemuFwCfgFindFile (
38 "etc/table-loader",
39 &FwCfgItem,
40 &FwCfgSize
41 )
42 )) {
43 //
44 // Only make ACPI available on 64-bit systems, and only if QEMU generates
45 // (a subset of) the ACPI tables.
46 //
47 Status = gBS->InstallProtocolInterface (
48 &ImageHandle,
49 &gEdkiiPlatformHasAcpiGuid,
50 EFI_NATIVE_INTERFACE,
51 NULL
52 );
53 if (EFI_ERROR (Status)) {
54 goto Failed;
55 }
56
57 return Status;
58 }
59
60 //
61 // Expose the Device Tree otherwise.
62 //
63 Status = gBS->InstallProtocolInterface (
64 &ImageHandle,
65 &gEdkiiPlatformHasDeviceTreeGuid,
66 EFI_NATIVE_INTERFACE,
67 NULL
68 );
69 if (EFI_ERROR (Status)) {
70 goto Failed;
71 }
72
73 return Status;
74
75 Failed:
76 ASSERT_EFI_ERROR (Status);
77 CpuDeadLoop ();
78 //
79 // Keep compilers happy.
80 //
81 return Status;
82 }