]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/AcpiPlatformDxe: Detect QEMU & Xen
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 30 May 2012 23:15:27 +0000 (23:15 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 30 May 2012 23:15:27 +0000 (23:15 +0000)
Detect QEMU & Xen, and allow each to choose how to publish
the individual ACPI tables.

Currently both paths simply publish the tables unmodified.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13385 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c
OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h [new file with mode: 0644]
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
OvmfPkg/AcpiPlatformDxe/Qemu.c [new file with mode: 0644]
OvmfPkg/AcpiPlatformDxe/Xen.c [new file with mode: 0644]

index 44bdd94fa8db68b16caced77f4165429ef4bd9cb..0b05942f71cd34f05e48fa2cbc31483357304511 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -171,15 +179,16 @@ AcpiPlatformEntryPoint (
   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
@@ -193,6 +202,14 @@ AcpiPlatformEntryPoint (
     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
@@ -231,19 +248,19 @@ AcpiPlatformEntryPoint (
       //\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
diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h
new file mode 100644 (file)
index 0000000..cb7393c
--- /dev/null
@@ -0,0 +1,68 @@
+/** @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
index 1034a0ae1f67082c03ad51ce0ec7efaee7ad246f..57cdf3e28dac3585596135e69d9c631150189154 100644 (file)
@@ -1,15 +1,15 @@
 ## @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
diff --git a/OvmfPkg/AcpiPlatformDxe/Qemu.c b/OvmfPkg/AcpiPlatformDxe/Qemu.c
new file mode 100644 (file)
index 0000000..f4e3269
--- /dev/null
@@ -0,0 +1,48 @@
+/** @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
diff --git a/OvmfPkg/AcpiPlatformDxe/Xen.c b/OvmfPkg/AcpiPlatformDxe/Xen.c
new file mode 100644 (file)
index 0000000..4f4faee
--- /dev/null
@@ -0,0 +1,55 @@
+/** @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