/** @file\r
- Sample ACPI Platform Driver\r
+ OVMF ACPI Platform Driver\r
\r
- Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-**/ \r
-\r
-#include <PiDxe.h>\r
+**/\r
\r
-#include <Protocol/AcpiTable.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
+#include "AcpiPlatform.h"\r
\r
-#include <Library/BaseLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/PcdLib.h>\r
+EFI_STATUS\r
+EFIAPI\r
+InstallAcpiTable (\r
+ IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,\r
+ IN VOID *AcpiTableBuffer,\r
+ IN UINTN AcpiTableBufferSize,\r
+ OUT UINTN *TableKey\r
+ )\r
+{\r
+ return AcpiProtocol->InstallAcpiTable (\r
+ AcpiProtocol,\r
+ AcpiTableBuffer,\r
+ AcpiTableBufferSize,\r
+ TableKey\r
+ );\r
+}\r
\r
-#include <IndustryStandard/Acpi.h>\r
\r
/**\r
Locate the first instance of a protocol. If the protocol requested is an\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_ACPI_TABLE_PROTOCOL *AcpiTable;\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;\r
- INTN Instance;\r
- EFI_ACPI_COMMON_HEADER *CurrentTable;\r
- UINTN TableHandle;\r
- UINT32 FvStatus;\r
- UINTN TableSize;\r
- UINTN Size;\r
+ EFI_STATUS Status;\r
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTable;\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;\r
+ INTN Instance;\r
+ EFI_ACPI_COMMON_HEADER *CurrentTable;\r
+ UINTN TableHandle;\r
+ UINT32 FvStatus;\r
+ UINTN TableSize;\r
+ UINTN Size;\r
+ EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction;\r
\r
Instance = 0;\r
CurrentTable = NULL;\r
return EFI_ABORTED;\r
}\r
\r
+ if (QemuDetected ()) {\r
+ TableInstallFunction = QemuInstallAcpiTable;\r
+ } else if (XenDetected ()) {\r
+ TableInstallFunction = XenInstallAcpiTable;\r
+ } else {\r
+ TableInstallFunction = InstallAcpiTable;\r
+ }\r
+\r
//\r
// Locate the firmware volume protocol\r
//\r
//\r
// Install ACPI table\r
//\r
- Status = AcpiTable->InstallAcpiTable (\r
- AcpiTable,\r
- CurrentTable,\r
- TableSize,\r
- &TableHandle\r
- );\r
+ Status = TableInstallFunction (\r
+ AcpiTable,\r
+ CurrentTable,\r
+ TableSize,\r
+ &TableHandle\r
+ );\r
\r
//\r
// Free memory allocated by ReadSection\r
//\r
gBS->FreePool (CurrentTable);\r
\r
- if (EFI_ERROR(Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return EFI_ABORTED;\r
}\r
\r
--- /dev/null
+/** @file\r
+ Sample ACPI Platform Driver\r
+\r
+ Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+\r
+#ifndef _ACPI_PLATFORM_H_INCLUDED_\r
+#define _ACPI_PLATFORM_H_INCLUDED_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/AcpiTable.h>\r
+#include <Protocol/FirmwareVolume2.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+#include <IndustryStandard/Acpi.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InstallAcpiTable (\r
+ IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,\r
+ IN VOID *AcpiTableBuffer,\r
+ IN UINTN AcpiTableBufferSize,\r
+ OUT UINTN *TableKey\r
+ );\r
+\r
+BOOLEAN\r
+QemuDetected (\r
+ VOID\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+QemuInstallAcpiTable (\r
+ IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,\r
+ IN VOID *AcpiTableBuffer,\r
+ IN UINTN AcpiTableBufferSize,\r
+ OUT UINTN *TableKey\r
+ );\r
+\r
+BOOLEAN\r
+XenDetected (\r
+ VOID\r
+ );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+XenInstallAcpiTable (\r
+ IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,\r
+ IN VOID *AcpiTableBuffer,\r
+ IN UINTN AcpiTableBufferSize,\r
+ OUT UINTN *TableKey\r
+ );\r
+\r
+#endif\r
+\r
## @file\r
-# Sample ACPI Platform Driver\r
+# OVMF ACPI Platform Driver\r
#\r
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
# http://opensource.org/licenses/bsd-license.php\r
-# \r
+#\r
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-# \r
+#\r
##\r
\r
[Defines]\r
\r
[Sources]\r
AcpiPlatform.c\r
+ Qemu.c\r
+ Xen.c\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
MdeModulePkg/MdeModulePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
\r
[LibraryClasses]\r
UefiLib\r
DebugLib\r
UefiBootServicesTableLib\r
UefiDriverEntryPoint\r
+ HobLib\r
+ QemuFwCfgLib\r
\r
[Protocols]\r
gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED\r
\r
+[Guids]\r
+ gEfiXenInfoGuid\r
+\r
[Pcd]\r
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile\r
\r
--- /dev/null
+/** @file\r
+ OVMF ACPI QEMU support\r
+\r
+ Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+\r
+#include "AcpiPlatform.h"\r
+#include <Library/QemuFwCfgLib.h>\r
+\r
+\r
+BOOLEAN\r
+QemuDetected (\r
+ VOID\r
+ )\r
+{\r
+ if (!QemuFwCfgIsAvailable ()) {\r
+ return FALSE;\r
+ }\r
+\r
+ return TRUE;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+QemuInstallAcpiTable (\r
+ IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,\r
+ IN VOID *AcpiTableBuffer,\r
+ IN UINTN AcpiTableBufferSize,\r
+ OUT UINTN *TableKey\r
+ )\r
+{\r
+ return InstallAcpiTable(\r
+ AcpiProtocol,\r
+ AcpiTableBuffer,\r
+ AcpiTableBufferSize,\r
+ TableKey\r
+ );\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ OVMF ACPI QEMU support\r
+\r
+ Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/ \r
+\r
+#include "AcpiPlatform.h"\r
+#include <Library/HobLib.h>\r
+#include <Guid/XenInfo.h>\r
+\r
+\r
+BOOLEAN\r
+XenDetected (\r
+ VOID\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+\r
+ //\r
+ // See if a XenInfo HOB is available\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
+ if (GuidHob == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ return TRUE;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+XenInstallAcpiTable (\r
+ IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,\r
+ IN VOID *AcpiTableBuffer,\r
+ IN UINTN AcpiTableBufferSize,\r
+ OUT UINTN *TableKey\r
+ )\r
+{\r
+ return InstallAcpiTable(\r
+ AcpiProtocol,\r
+ AcpiTableBuffer,\r
+ AcpiTableBufferSize,\r
+ TableKey\r
+ );\r
+}\r
+\r