]>
Commit | Line | Data |
---|---|---|
2558bfe3 LE |
1 | /** @file\r |
2 | Decide whether the firmware should expose an ACPI- and/or a Device Tree-based\r | |
3 | hardware description to the operating system.\r | |
4 | \r | |
5 | Copyright (c) 2017, Red Hat, Inc.\r | |
6 | \r | |
9792fb0e | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
2558bfe3 LE |
8 | **/\r |
9 | \r | |
10 | #include <Guid/PlatformHasAcpi.h>\r | |
11 | #include <Guid/PlatformHasDeviceTree.h>\r | |
12 | #include <Library/BaseLib.h>\r | |
13 | #include <Library/DebugLib.h>\r | |
7e5f1b67 | 14 | #include <Library/PcdLib.h>\r |
110316a9 | 15 | #include <Library/QemuFwCfgLib.h>\r |
2558bfe3 LE |
16 | #include <Library/UefiBootServicesTableLib.h>\r |
17 | \r | |
18 | EFI_STATUS\r | |
19 | EFIAPI\r | |
20 | PlatformHasAcpiDt (\r | |
21 | IN EFI_HANDLE ImageHandle,\r | |
22 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
23 | )\r | |
24 | {\r | |
110316a9 LE |
25 | EFI_STATUS Status;\r |
26 | FIRMWARE_CONFIG_ITEM FwCfgItem;\r | |
27 | UINTN FwCfgSize;\r | |
2558bfe3 LE |
28 | \r |
29 | //\r | |
30 | // If we fail to install any of the necessary protocols below, the OS will be\r | |
31 | // unbootable anyway (due to lacking hardware description), so tolerate no\r | |
32 | // errors here.\r | |
33 | //\r | |
110316a9 | 34 | if (MAX_UINTN == MAX_UINT64 &&\r |
7e5f1b67 | 35 | !PcdGetBool (PcdForceNoAcpi) &&\r |
110316a9 LE |
36 | !EFI_ERROR (\r |
37 | QemuFwCfgFindFile (\r | |
38 | "etc/table-loader",\r | |
39 | &FwCfgItem,\r | |
40 | &FwCfgSize\r | |
41 | )\r | |
42 | )) {\r | |
43 | //\r | |
44 | // Only make ACPI available on 64-bit systems, and only if QEMU generates\r | |
45 | // (a subset of) the ACPI tables.\r | |
46 | //\r | |
2558bfe3 LE |
47 | Status = gBS->InstallProtocolInterface (\r |
48 | &ImageHandle,\r | |
49 | &gEdkiiPlatformHasAcpiGuid,\r | |
50 | EFI_NATIVE_INTERFACE,\r | |
51 | NULL\r | |
52 | );\r | |
53 | if (EFI_ERROR (Status)) {\r | |
54 | goto Failed;\r | |
55 | }\r | |
110316a9 LE |
56 | \r |
57 | return Status;\r | |
2558bfe3 LE |
58 | }\r |
59 | \r | |
60 | //\r | |
110316a9 | 61 | // Expose the Device Tree otherwise.\r |
2558bfe3 | 62 | //\r |
110316a9 LE |
63 | Status = gBS->InstallProtocolInterface (\r |
64 | &ImageHandle,\r | |
65 | &gEdkiiPlatformHasDeviceTreeGuid,\r | |
66 | EFI_NATIVE_INTERFACE,\r | |
67 | NULL\r | |
68 | );\r | |
69 | if (EFI_ERROR (Status)) {\r | |
70 | goto Failed;\r | |
2558bfe3 LE |
71 | }\r |
72 | \r | |
73 | return Status;\r | |
74 | \r | |
75 | Failed:\r | |
76 | ASSERT_EFI_ERROR (Status);\r | |
77 | CpuDeadLoop ();\r | |
78 | //\r | |
79 | // Keep compilers happy.\r | |
80 | //\r | |
81 | return Status;\r | |
82 | }\r |