#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/PcdLib.h>\r
+#include <Library/QemuFwCfgLib.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
\r
EFI_STATUS\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
-\r
- Status = EFI_SUCCESS;\r
+ EFI_STATUS Status;\r
+ FIRMWARE_CONFIG_ITEM FwCfgItem;\r
+ UINTN FwCfgSize;\r
\r
//\r
// If we fail to install any of the necessary protocols below, the OS will be\r
// unbootable anyway (due to lacking hardware description), so tolerate no\r
// errors here.\r
//\r
- // Always make ACPI available on 64-bit systems.\r
- //\r
- if (MAX_UINTN == MAX_UINT64) {\r
+ if (MAX_UINTN == MAX_UINT64 &&\r
+ !PcdGetBool (PcdForceNoAcpi) &&\r
+ !EFI_ERROR (\r
+ QemuFwCfgFindFile (\r
+ "etc/table-loader",\r
+ &FwCfgItem,\r
+ &FwCfgSize\r
+ )\r
+ )) {\r
+ //\r
+ // Only make ACPI available on 64-bit systems, and only if QEMU generates\r
+ // (a subset of) the ACPI tables.\r
+ //\r
Status = gBS->InstallProtocolInterface (\r
&ImageHandle,\r
&gEdkiiPlatformHasAcpiGuid,\r
if (EFI_ERROR (Status)) {\r
goto Failed;\r
}\r
+\r
+ return Status;\r
}\r
\r
//\r
- // Expose the Device Tree unless PcdPureAcpiBoot is set.\r
+ // Expose the Device Tree otherwise.\r
//\r
- if (!FeaturePcdGet (PcdPureAcpiBoot)) {\r
- Status = gBS->InstallProtocolInterface (\r
- &ImageHandle,\r
- &gEdkiiPlatformHasDeviceTreeGuid,\r
- EFI_NATIVE_INTERFACE,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- goto Failed;\r
- }\r
+ Status = gBS->InstallProtocolInterface (\r
+ &ImageHandle,\r
+ &gEdkiiPlatformHasDeviceTreeGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Failed;\r
}\r
\r
return Status;\r