]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
ArmVirtPkg: change qemu default resolution to 1280x800
[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 //
45 // Only make ACPI available on 64-bit systems, and only if QEMU generates
46 // (a subset of) the ACPI tables.
47 //
48 Status = gBS->InstallProtocolInterface (
49 &ImageHandle,
50 &gEdkiiPlatformHasAcpiGuid,
51 EFI_NATIVE_INTERFACE,
52 NULL
53 );
54 if (EFI_ERROR (Status)) {
55 goto Failed;
56 }
57
58 return Status;
59 }
60
61 //
62 // Expose the Device Tree otherwise.
63 //
64 Status = gBS->InstallProtocolInterface (
65 &ImageHandle,
66 &gEdkiiPlatformHasDeviceTreeGuid,
67 EFI_NATIVE_INTERFACE,
68 NULL
69 );
70 if (EFI_ERROR (Status)) {
71 goto Failed;
72 }
73
74 return Status;
75
76 Failed:
77 ASSERT_EFI_ERROR (Status);
78 CpuDeadLoop ();
79 //
80 // Keep compilers happy.
81 //
82 return Status;
83 }