public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: devel@edk2.groups.io
Cc: "Anthony Perard" <anthony.perard@citrix.com>,
	"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
	"Jordan Justen" <jordan.l.justen@intel.com>,
	"Julien Grall" <julien@xen.org>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 14/43] OvmfPkg/XenAcpiPlatformDxe: remove QEMU fw_cfg dependency
Date: Wed, 26 May 2021 22:14:17 +0200	[thread overview]
Message-ID: <20210526201446.12554-15-lersek@redhat.com> (raw)
In-Reply-To: <20210526201446.12554-1-lersek@redhat.com>

The QemuDetected() function wraps QemuFwCfgIsAvailable(); it always fails
on Xen. Because of that, we can eliminate the QemuDetected() call itself
from the Xen ACPI platform driver, and then the rest of "Qemu.c" becomes
useless -- the workhorse function of that source file is
QemuInstallAcpiTable(), which we no longer call.

Remove any dependencies that are no longer needed by the
XenAcpiPlatformDxe driver.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf |   9 -
 OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.h         |  14 -
 OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c         |   9 +-
 OvmfPkg/XenAcpiPlatformDxe/Qemu.c                 | 511 --------------------
 4 files changed, 1 insertion(+), 542 deletions(-)

diff --git a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
index 72132e397dc1..ca8e7e55f788 100644
--- a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
+++ b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
@@ -22,29 +22,23 @@ [Defines]
 #
 
 [Sources]
   AcpiPlatform.c
   AcpiPlatform.h
   EntryPoint.c
-  Qemu.c
   Xen.c
 
 [Packages]
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   OvmfPkg/OvmfPkg.dec
-  UefiCpuPkg/UefiCpuPkg.dec
 
 [LibraryClasses]
   BaseLib
-  BaseMemoryLib
   DebugLib
-  DxeServicesTableLib
-  MemoryAllocationLib
   PcdLib
-  QemuFwCfgLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   XenPlatformLib
 
 [Protocols]
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED
@@ -53,12 +47,9 @@ [Protocols]
 [Guids]
   gRootBridgesConnectedEventGroupGuid
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
-  gUefiOvmfPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel
-  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
 
 [Depex]
   gEfiAcpiTableProtocolGuid
diff --git a/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.h
index d35143a00d01..2959ff0be6cf 100644
--- a/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.h
+++ b/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.h
@@ -18,26 +18,12 @@ InstallAcpiTable (
   IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol,
   IN   VOID                          *AcpiTableBuffer,
   IN   UINTN                         AcpiTableBufferSize,
   OUT  UINTN                         *TableKey
   );
 
-BOOLEAN
-QemuDetected (
-  VOID
-  );
-
-EFI_STATUS
-EFIAPI
-QemuInstallAcpiTable (
-  IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol,
-  IN   VOID                          *AcpiTableBuffer,
-  IN   UINTN                         AcpiTableBufferSize,
-  OUT  UINTN                         *TableKey
-  );
-
 EFI_STATUS
 EFIAPI
 InstallXenTables (
   IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol
   );
 
diff --git a/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c
index 9c8b1e0fcffa..66dcf885859e 100644
--- a/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c
+++ b/OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c
@@ -152,24 +152,17 @@ InstallOvmfFvTables (
   INTN                                 Instance;
   EFI_ACPI_COMMON_HEADER               *CurrentTable;
   UINTN                                TableHandle;
   UINT32                               FvStatus;
   UINTN                                TableSize;
   UINTN                                Size;
-  EFI_ACPI_TABLE_INSTALL_ACPI_TABLE    TableInstallFunction;
 
   Instance     = 0;
   CurrentTable = NULL;
   TableHandle  = 0;
 
-  if (QemuDetected ()) {
-    TableInstallFunction = QemuInstallAcpiTable;
-  } else {
-    TableInstallFunction = InstallAcpiTable;
-  }
-
   //
   // set FwVol (and use an ASSERT() below) to suppress incorrect
   // compiler/analyzer warnings
   //
   FwVol = NULL;
   //
@@ -204,13 +197,13 @@ InstallOvmfFvTables (
       TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length;
       ASSERT (Size >= TableSize);
 
       //
       // Install ACPI table
       //
-      Status = TableInstallFunction (
+      Status = InstallAcpiTable (
                  AcpiTable,
                  CurrentTable,
                  TableSize,
                  &TableHandle
                  );
 
diff --git a/OvmfPkg/XenAcpiPlatformDxe/Qemu.c b/OvmfPkg/XenAcpiPlatformDxe/Qemu.c
deleted file mode 100644
index b4a407c41b71..000000000000
--- a/OvmfPkg/XenAcpiPlatformDxe/Qemu.c
+++ /dev/null
@@ -1,511 +0,0 @@
-/** @file
-  OVMF ACPI QEMU support
-
-  Copyright (C) 2012-2021, Red Hat, Inc.
-  Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <IndustryStandard/Acpi.h>        // EFI_ACPI_1_0_IO_APIC_STRUCTURE
-#include <Library/BaseMemoryLib.h>        // CopyMem()
-#include <Library/DebugLib.h>             // DEBUG()
-#include <Library/DxeServicesTableLib.h>  // gDS
-#include <Library/MemoryAllocationLib.h>  // AllocatePool()
-#include <Library/PcdLib.h>               // PcdGet16()
-#include <Library/QemuFwCfgLib.h>         // QemuFwCfgIsAvailable()
-
-#include "AcpiPlatform.h"
-
-BOOLEAN
-QemuDetected (
-  VOID
-  )
-{
-  if (!QemuFwCfgIsAvailable ()) {
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-
-STATIC
-UINTN
-CountBits16 (
-  UINT16 Mask
-  )
-{
-  //
-  // For all N >= 1, N bits are enough to represent the number of bits set
-  // among N bits. It's true for N == 1. When adding a new bit (N := N+1),
-  // the maximum number of possibly set bits increases by one, while the
-  // representable maximum doubles.
-  //
-  Mask = ((Mask & 0xAAAA) >> 1) + (Mask & 0x5555);
-  Mask = ((Mask & 0xCCCC) >> 2) + (Mask & 0x3333);
-  Mask = ((Mask & 0xF0F0) >> 4) + (Mask & 0x0F0F);
-  Mask = ((Mask & 0xFF00) >> 8) + (Mask & 0x00FF);
-
-  return Mask;
-}
-
-
-STATIC
-EFI_STATUS
-EFIAPI
-QemuInstallAcpiMadtTable (
-  IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol,
-  IN   VOID                          *AcpiTableBuffer,
-  IN   UINTN                         AcpiTableBufferSize,
-  OUT  UINTN                         *TableKey
-  )
-{
-  UINTN                                               CpuCount;
-  UINTN                                               PciLinkIsoCount;
-  UINTN                                               NewBufferSize;
-  EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt;
-  EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE         *LocalApic;
-  EFI_ACPI_1_0_IO_APIC_STRUCTURE                      *IoApic;
-  EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE    *Iso;
-  EFI_ACPI_1_0_LOCAL_APIC_NMI_STRUCTURE               *LocalApicNmi;
-  VOID                                                *Ptr;
-  UINTN                                               Loop;
-  EFI_STATUS                                          Status;
-
-  ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER));
-
-  QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount);
-  CpuCount = QemuFwCfgRead16 ();
-  ASSERT (CpuCount >= 1);
-
-  //
-  // Set Level-tiggered, Active High for these identity mapped IRQs. The bitset
-  // corresponds to the union of all possible interrupt assignments for the LNKA,
-  // LNKB, LNKC, LNKD PCI interrupt lines. See the DSDT.
-  //
-  PciLinkIsoCount = CountBits16 (PcdGet16 (Pcd8259LegacyModeEdgeLevel));
-
-  NewBufferSize = 1                     * sizeof (*Madt) +
-                  CpuCount              * sizeof (*LocalApic) +
-                  1                     * sizeof (*IoApic) +
-                  (1 + PciLinkIsoCount) * sizeof (*Iso) +
-                  1                     * sizeof (*LocalApicNmi);
-
-  Madt = AllocatePool (NewBufferSize);
-  if (Madt == NULL) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-
-  CopyMem (&(Madt->Header), AcpiTableBuffer, sizeof (EFI_ACPI_DESCRIPTION_HEADER));
-  Madt->Header.Length    = (UINT32) NewBufferSize;
-  Madt->LocalApicAddress = PcdGet32 (PcdCpuLocalApicBaseAddress);
-  Madt->Flags            = EFI_ACPI_1_0_PCAT_COMPAT;
-  Ptr = Madt + 1;
-
-  LocalApic = Ptr;
-  for (Loop = 0; Loop < CpuCount; ++Loop) {
-    LocalApic->Type            = EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC;
-    LocalApic->Length          = sizeof (*LocalApic);
-    LocalApic->AcpiProcessorId = (UINT8) Loop;
-    LocalApic->ApicId          = (UINT8) Loop;
-    LocalApic->Flags           = 1; // enabled
-    ++LocalApic;
-  }
-  Ptr = LocalApic;
-
-  IoApic = Ptr;
-  IoApic->Type             = EFI_ACPI_1_0_IO_APIC;
-  IoApic->Length           = sizeof (*IoApic);
-  IoApic->IoApicId         = (UINT8) CpuCount;
-  IoApic->Reserved         = EFI_ACPI_RESERVED_BYTE;
-  IoApic->IoApicAddress    = 0xFEC00000;
-  IoApic->SystemVectorBase = 0x00000000;
-  Ptr = IoApic + 1;
-
-  //
-  // IRQ0 (8254 Timer) => IRQ2 (PIC) Interrupt Source Override Structure
-  //
-  Iso = Ptr;
-  Iso->Type                        = EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE;
-  Iso->Length                      = sizeof (*Iso);
-  Iso->Bus                         = 0x00; // ISA
-  Iso->Source                      = 0x00; // IRQ0
-  Iso->GlobalSystemInterruptVector = 0x00000002;
-  Iso->Flags                       = 0x0000; // Conforms to specs of the bus
-  ++Iso;
-
-  //
-  // Set Level-triggered, Active High for all possible PCI link targets.
-  //
-  for (Loop = 0; Loop < 16; ++Loop) {
-    if ((PcdGet16 (Pcd8259LegacyModeEdgeLevel) & (1 << Loop)) == 0) {
-      continue;
-    }
-    Iso->Type                        = EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE;
-    Iso->Length                      = sizeof (*Iso);
-    Iso->Bus                         = 0x00; // ISA
-    Iso->Source                      = (UINT8) Loop;
-    Iso->GlobalSystemInterruptVector = (UINT32) Loop;
-    Iso->Flags                       = 0x000D; // Level-triggered, Active High
-    ++Iso;
-  }
-  ASSERT (
-    (UINTN) (Iso - (EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *)Ptr) ==
-      1 + PciLinkIsoCount
-    );
-  Ptr = Iso;
-
-  LocalApicNmi = Ptr;
-  LocalApicNmi->Type            = EFI_ACPI_1_0_LOCAL_APIC_NMI;
-  LocalApicNmi->Length          = sizeof (*LocalApicNmi);
-  LocalApicNmi->AcpiProcessorId = 0xFF; // applies to all processors
-  //
-  // polarity and trigger mode of the APIC I/O input signals conform to the
-  // specifications of the bus
-  //
-  LocalApicNmi->Flags           = 0x0000;
-  //
-  // Local APIC interrupt input LINTn to which NMI is connected.
-  //
-  LocalApicNmi->LocalApicInti   = 0x01;
-  Ptr = LocalApicNmi + 1;
-
-  ASSERT ((UINTN) ((UINT8 *)Ptr - (UINT8 *)Madt) == NewBufferSize);
-  Status = InstallAcpiTable (AcpiProtocol, Madt, NewBufferSize, TableKey);
-
-  FreePool (Madt);
-
-  return Status;
-}
-
-
-#pragma pack(1)
-
-typedef struct {
-  UINT64 Base;
-  UINT64 End;
-  UINT64 Length;
-} PCI_WINDOW;
-
-typedef struct {
-  PCI_WINDOW PciWindow32;
-  PCI_WINDOW PciWindow64;
-} FIRMWARE_DATA;
-
-typedef struct {
-  UINT8 BytePrefix;
-  UINT8 ByteValue;
-} AML_BYTE;
-
-typedef struct {
-  UINT8    NameOp;
-  UINT8    RootChar;
-  UINT8    NameChar[4];
-  UINT8    PackageOp;
-  UINT8    PkgLength;
-  UINT8    NumElements;
-  AML_BYTE Pm1aCntSlpTyp;
-  AML_BYTE Pm1bCntSlpTyp;
-  AML_BYTE Reserved[2];
-} SYSTEM_STATE_PACKAGE;
-
-#pragma pack()
-
-
-STATIC
-EFI_STATUS
-EFIAPI
-PopulateFwData(
-  OUT  FIRMWARE_DATA *FwData
-  )
-{
-  EFI_STATUS                      Status;
-  UINTN                           NumDesc;
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR *AllDesc;
-
-  Status = gDS->GetMemorySpaceMap (&NumDesc, &AllDesc);
-  if (Status == EFI_SUCCESS) {
-    UINT64 NonMmio32MaxExclTop;
-    UINT64 Mmio32MinBase;
-    UINT64 Mmio32MaxExclTop;
-    UINTN CurDesc;
-
-    Status = EFI_UNSUPPORTED;
-
-    NonMmio32MaxExclTop = 0;
-    Mmio32MinBase = BASE_4GB;
-    Mmio32MaxExclTop = 0;
-
-    for (CurDesc = 0; CurDesc < NumDesc; ++CurDesc) {
-      CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc;
-      UINT64 ExclTop;
-
-      Desc = &AllDesc[CurDesc];
-      ExclTop = Desc->BaseAddress + Desc->Length;
-
-      if (ExclTop <= (UINT64) PcdGet32 (PcdOvmfFdBaseAddress)) {
-        switch (Desc->GcdMemoryType) {
-          case EfiGcdMemoryTypeNonExistent:
-            break;
-
-          case EfiGcdMemoryTypeReserved:
-          case EfiGcdMemoryTypeSystemMemory:
-            if (NonMmio32MaxExclTop < ExclTop) {
-              NonMmio32MaxExclTop = ExclTop;
-            }
-            break;
-
-          case EfiGcdMemoryTypeMemoryMappedIo:
-            if (Mmio32MinBase > Desc->BaseAddress) {
-              Mmio32MinBase = Desc->BaseAddress;
-            }
-            if (Mmio32MaxExclTop < ExclTop) {
-              Mmio32MaxExclTop = ExclTop;
-            }
-            break;
-
-          default:
-            ASSERT(0);
-        }
-      }
-    }
-
-    if (Mmio32MinBase < NonMmio32MaxExclTop) {
-      Mmio32MinBase = NonMmio32MaxExclTop;
-    }
-
-    if (Mmio32MinBase < Mmio32MaxExclTop) {
-      FwData->PciWindow32.Base   = Mmio32MinBase;
-      FwData->PciWindow32.End    = Mmio32MaxExclTop - 1;
-      FwData->PciWindow32.Length = Mmio32MaxExclTop - Mmio32MinBase;
-
-      FwData->PciWindow64.Base   = 0;
-      FwData->PciWindow64.End    = 0;
-      FwData->PciWindow64.Length = 0;
-
-      Status = EFI_SUCCESS;
-    }
-
-    FreePool (AllDesc);
-  }
-
-  DEBUG ((
-    DEBUG_INFO,
-    "ACPI PciWindow32: Base=0x%08lx End=0x%08lx Length=0x%08lx\n",
-    FwData->PciWindow32.Base,
-    FwData->PciWindow32.End,
-    FwData->PciWindow32.Length
-    ));
-  DEBUG ((
-    DEBUG_INFO,
-    "ACPI PciWindow64: Base=0x%08lx End=0x%08lx Length=0x%08lx\n",
-    FwData->PciWindow64.Base,
-    FwData->PciWindow64.End,
-    FwData->PciWindow64.Length
-    ));
-
-  return Status;
-}
-
-
-STATIC
-VOID
-EFIAPI
-GetSuspendStates (
-  UINTN                *SuspendToRamSize,
-  SYSTEM_STATE_PACKAGE *SuspendToRam,
-  UINTN                *SuspendToDiskSize,
-  SYSTEM_STATE_PACKAGE *SuspendToDisk
-  )
-{
-  STATIC CONST SYSTEM_STATE_PACKAGE Template = {
-    0x08,                   // NameOp
-    '\\',                   // RootChar
-    { '_', 'S', 'x', '_' }, // NameChar[4]
-    0x12,                   // PackageOp
-    0x0A,                   // PkgLength
-    0x04,                   // NumElements
-    { 0x0A, 0x00 },         // Pm1aCntSlpTyp
-    { 0x0A, 0x00 },         // Pm1bCntSlpTyp -- we don't support it
-    {                       // Reserved[2]
-      { 0x0A, 0x00 },
-      { 0x0A, 0x00 }
-    }
-  };
-  RETURN_STATUS                     Status;
-  FIRMWARE_CONFIG_ITEM              FwCfgItem;
-  UINTN                             FwCfgSize;
-  UINT8                             SystemStates[6];
-
-  //
-  // configure defaults
-  //
-  *SuspendToRamSize = sizeof Template;
-  CopyMem (SuspendToRam, &Template, sizeof Template);
-  SuspendToRam->NameChar[2]             = '3'; // S3
-  SuspendToRam->Pm1aCntSlpTyp.ByteValue = 1;   // PIIX4: STR
-
-  *SuspendToDiskSize = sizeof Template;
-  CopyMem (SuspendToDisk, &Template, sizeof Template);
-  SuspendToDisk->NameChar[2]             = '4'; // S4
-  SuspendToDisk->Pm1aCntSlpTyp.ByteValue = 2;   // PIIX4: POSCL
-
-  //
-  // check for overrides
-  //
-  Status = QemuFwCfgFindFile ("etc/system-states", &FwCfgItem, &FwCfgSize);
-  if (Status != RETURN_SUCCESS || FwCfgSize != sizeof SystemStates) {
-    DEBUG ((DEBUG_INFO, "ACPI using S3/S4 defaults\n"));
-    return;
-  }
-  QemuFwCfgSelectItem (FwCfgItem);
-  QemuFwCfgReadBytes (sizeof SystemStates, SystemStates);
-
-  //
-  // Each byte corresponds to a system state. In each byte, the MSB tells us
-  // whether the given state is enabled. If so, the three LSBs specify the
-  // value to be written to the PM control register's SUS_TYP bits.
-  //
-  if (SystemStates[3] & BIT7) {
-    SuspendToRam->Pm1aCntSlpTyp.ByteValue =
-        SystemStates[3] & (BIT2 | BIT1 | BIT0);
-    DEBUG ((DEBUG_INFO, "ACPI S3 value: %d\n",
-            SuspendToRam->Pm1aCntSlpTyp.ByteValue));
-  } else {
-    *SuspendToRamSize = 0;
-    DEBUG ((DEBUG_INFO, "ACPI S3 disabled\n"));
-  }
-
-  if (SystemStates[4] & BIT7) {
-    SuspendToDisk->Pm1aCntSlpTyp.ByteValue =
-        SystemStates[4] & (BIT2 | BIT1 | BIT0);
-    DEBUG ((DEBUG_INFO, "ACPI S4 value: %d\n",
-            SuspendToDisk->Pm1aCntSlpTyp.ByteValue));
-  } else {
-    *SuspendToDiskSize = 0;
-    DEBUG ((DEBUG_INFO, "ACPI S4 disabled\n"));
-  }
-}
-
-
-STATIC
-EFI_STATUS
-EFIAPI
-QemuInstallAcpiSsdtTable (
-  IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol,
-  IN   VOID                          *AcpiTableBuffer,
-  IN   UINTN                         AcpiTableBufferSize,
-  OUT  UINTN                         *TableKey
-  )
-{
-  EFI_STATUS    Status;
-  FIRMWARE_DATA *FwData;
-
-  Status = EFI_OUT_OF_RESOURCES;
-
-  FwData = AllocateReservedPool (sizeof (*FwData));
-  if (FwData != NULL) {
-    UINTN                SuspendToRamSize;
-    SYSTEM_STATE_PACKAGE SuspendToRam;
-    UINTN                SuspendToDiskSize;
-    SYSTEM_STATE_PACKAGE SuspendToDisk;
-    UINTN                SsdtSize;
-    UINT8                *Ssdt;
-
-    GetSuspendStates (&SuspendToRamSize,  &SuspendToRam,
-                      &SuspendToDiskSize, &SuspendToDisk);
-    SsdtSize = AcpiTableBufferSize + 17 + SuspendToRamSize + SuspendToDiskSize;
-    Ssdt = AllocatePool (SsdtSize);
-
-    if (Ssdt != NULL) {
-      Status = PopulateFwData (FwData);
-
-      if (Status == EFI_SUCCESS) {
-        UINT8 *SsdtPtr;
-
-        SsdtPtr = Ssdt;
-
-        CopyMem (SsdtPtr, AcpiTableBuffer, AcpiTableBufferSize);
-        SsdtPtr += AcpiTableBufferSize;
-
-        //
-        // build "OperationRegion(FWDT, SystemMemory, 0x12345678, 0x87654321)"
-        //
-        *(SsdtPtr++) = 0x5B; // ExtOpPrefix
-        *(SsdtPtr++) = 0x80; // OpRegionOp
-        *(SsdtPtr++) = 'F';
-        *(SsdtPtr++) = 'W';
-        *(SsdtPtr++) = 'D';
-        *(SsdtPtr++) = 'T';
-        *(SsdtPtr++) = 0x00; // SystemMemory
-        *(SsdtPtr++) = 0x0C; // DWordPrefix
-
-        //
-        // no virtual addressing yet, take the four least significant bytes
-        //
-        CopyMem(SsdtPtr, &FwData, 4);
-        SsdtPtr += 4;
-
-        *(SsdtPtr++) = 0x0C; // DWordPrefix
-
-        *(UINT32*) SsdtPtr = sizeof (*FwData);
-        SsdtPtr += 4;
-
-        //
-        // add suspend system states
-        //
-        CopyMem (SsdtPtr, &SuspendToRam, SuspendToRamSize);
-        SsdtPtr += SuspendToRamSize;
-        CopyMem (SsdtPtr, &SuspendToDisk, SuspendToDiskSize);
-        SsdtPtr += SuspendToDiskSize;
-
-        ASSERT((UINTN) (SsdtPtr - Ssdt) == SsdtSize);
-        ((EFI_ACPI_DESCRIPTION_HEADER *) Ssdt)->Length = (UINT32) SsdtSize;
-        Status = InstallAcpiTable (AcpiProtocol, Ssdt, SsdtSize, TableKey);
-      }
-
-      FreePool(Ssdt);
-    }
-
-    if (Status != EFI_SUCCESS) {
-      FreePool(FwData);
-    }
-  }
-
-  return Status;
-}
-
-
-EFI_STATUS
-EFIAPI
-QemuInstallAcpiTable (
-  IN   EFI_ACPI_TABLE_PROTOCOL       *AcpiProtocol,
-  IN   VOID                          *AcpiTableBuffer,
-  IN   UINTN                         AcpiTableBufferSize,
-  OUT  UINTN                         *TableKey
-  )
-{
-  EFI_ACPI_DESCRIPTION_HEADER        *Hdr;
-  EFI_ACPI_TABLE_INSTALL_ACPI_TABLE  TableInstallFunction;
-
-  Hdr = (EFI_ACPI_DESCRIPTION_HEADER*) AcpiTableBuffer;
-  switch (Hdr->Signature) {
-  case EFI_ACPI_1_0_APIC_SIGNATURE:
-    TableInstallFunction = QemuInstallAcpiMadtTable;
-    break;
-  case EFI_ACPI_1_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:
-    TableInstallFunction = QemuInstallAcpiSsdtTable;
-    break;
-  default:
-    TableInstallFunction = InstallAcpiTable;
-  }
-
-  return TableInstallFunction (
-           AcpiProtocol,
-           AcpiTableBuffer,
-           AcpiTableBufferSize,
-           TableKey
-           );
-}
-- 
2.19.1.3.g30247aa5d201



  parent reply	other threads:[~2021-05-26 20:29 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 20:14 [PATCH 00/43] OvmfPkg: remove Xen support from OvmfPkg*.dsc, in favor of OvmfXen.dsc Laszlo Ersek
2021-05-26 20:14 ` [PATCH 01/43] OvmfPkg: remove the Xen drivers from the IA32, IA32X64, and X64 platforms Laszlo Ersek
2021-05-27  8:22   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 02/43] OvmfPkg: remove the Xen drivers from the AmdSev platform Laszlo Ersek
2021-05-27  8:22   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 03/43] OvmfPkg: switch IA32, IA32X64, X64 to the fw_cfg-only ACPI platform driver Laszlo Ersek
2021-05-27 10:15   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 04/43] OvmfPkg: switch the AmdSev platform " Laszlo Ersek
2021-05-27 10:15   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 05/43] OvmfPkg/README: bump minimum QEMU version to 1.7.1, machine types to 1.7 Laszlo Ersek
2021-05-27  8:24   ` Philippe Mathieu-Daudé
2021-05-27  8:56     ` Laszlo Ersek
2021-05-26 20:14 ` [PATCH 06/43] OvmfPkg/AcpiPlatformDxe: fix header file warts Laszlo Ersek
2021-05-27  8:24   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 07/43] OvmfPkg/AcpiPlatformDxe: sort #includes and [LibraryClasses] Laszlo Ersek
2021-05-27  8:25   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 08/43] OvmfPkg/AcpiPlatformDxe/QemuLoader.h: remove QemuFwCfgLib class dependency Laszlo Ersek
2021-05-27  8:26   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 09/43] OvmfPkg/AcpiPlatformDxe: move "QemuLoader.h" to IndustryStandard Laszlo Ersek
2021-05-27  8:26   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 10/43] OvmfPkg/AcpiPlatformDxe: consolidate #includes and [LibraryClasses] Laszlo Ersek
2021-05-27  8:41   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 11/43] OvmfPkg/XenAcpiPlatformDxe: create from AcpiPlatformDxe Laszlo Ersek
2021-05-27 10:16   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 12/43] OvmfPkg/AcpiPlatformDxe: remove the "AcpiPlatformDxe.inf" driver Laszlo Ersek
2021-05-27 10:17   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 13/43] OvmfPkg/XenAcpiPlatformDxe: remove the QEMU ACPI linker/loader client Laszlo Ersek
2021-05-27  8:38   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` Laszlo Ersek [this message]
2021-05-27  8:39   ` [PATCH 14/43] OvmfPkg/XenAcpiPlatformDxe: remove QEMU fw_cfg dependency Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 15/43] OvmfPkg/XenAcpiPlatformDxe: remove the InstallAcpiTable() helper function Laszlo Ersek
2021-05-27  9:39   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 16/43] OvmfPkg/XenAcpiPlatformDxe: remove OVMF's built-in ACPI tables Laszlo Ersek
2021-05-27  8:40   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 17/43] OvmfPkg/Bhyve/AcpiPlatformDxe: fix file path typo in comment Laszlo Ersek
2021-05-26 20:40   ` Rebecca Cran
2021-05-27  8:40   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 18/43] OvmfPkg/AcpiTables: remove unused module Laszlo Ersek
2021-05-27  8:27   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 19/43] OvmfPkg/OvmfXen: make "PcdPciDisableBusEnumeration" Fixed-at-Build Laszlo Ersek
2021-05-27  8:42   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 20/43] OvmfPkg/XenAcpiPlatformDxe: remove delayed ACPI table installation Laszlo Ersek
2021-05-27  8:28   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 21/43] OvmfPkg/PlatformPei: remove Xen support Laszlo Ersek
2021-05-27 10:20   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 22/43] OvmfPkg: drop PcdPciDisableBusEnumeration from the IA32, IA32X64, X64 DSCs Laszlo Ersek
2021-05-27  8:29   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 23/43] OvmfPkg: drop PcdPciDisableBusEnumeration from the AmdSev platform Laszlo Ersek
2021-05-27 10:21   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 24/43] OvmfPkg/Bhyve: make "PcdPciDisableBusEnumeration" Fixed-at-Build Laszlo Ersek
2021-05-26 20:41   ` Rebecca Cran
2021-05-27  8:43   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 25/43] OvmfPkg/OvmfXen: remove IncompatiblePciDeviceSupport DXE driver Laszlo Ersek
2021-05-27  8:29   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 26/43] OvmfPkg/Bhyve: " Laszlo Ersek
2021-05-27 10:23   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 27/43] OvmfPkg/IncompatiblePciDeviceSupportDxe: remove PcdPciDisableBusEnumeration Laszlo Ersek
2021-05-27  8:30   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 28/43] OvmfPkg/PciHostBridgeLib: consolidate #includes and INF file sections Laszlo Ersek
2021-05-27  8:31   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 29/43] OvmfPkg/PciHostBridgeLibScan: create from PciHostBridgeLib Laszlo Ersek
2021-05-31 14:52   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 30/43] OvmfPkg/Bhyve: consume PciHostBridgeLibScan Laszlo Ersek
2021-05-26 22:46   ` Rebecca Cran
2021-05-27  8:31   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 31/43] OvmfPkg/OvmfXen: " Laszlo Ersek
2021-05-27  8:31   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 32/43] OvmfPkg/PciHostBridgeLib: remove Bhyve and Xen support Laszlo Ersek
2021-05-27  8:32   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 33/43] OvmfPkg/PciHostBridgeLibScan: remove QEMU (fw_cfg) support Laszlo Ersek
2021-05-27 10:25   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 34/43] OvmfPkg/PciHostBridgeLibScan: remove PcdOvmfHostBridgePciDevId Laszlo Ersek
2021-05-27  8:33   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 35/43] OvmfPkg/PciHostBridgeLibScan: clean up file names and file-top comments Laszlo Ersek
2021-05-27  8:34   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 36/43] OvmfPkg/SmbiosPlatformDxe: clean up #includes and INF Laszlo Ersek
2021-05-27  8:34   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 37/43] OvmfPkg/SmbiosPlatformDxe: return EFI_NOT_FOUND if there is no SMBIOS data Laszlo Ersek
2021-05-27  8:45   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 38/43] OvmfPkg/SmbiosPlatformDxe: locate SMBIOS protocol in InstallAllStructures() Laszlo Ersek
2021-05-27  8:35   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 39/43] OvmfPkg/SmbiosPlatformDxe: split GetXenSmbiosTables() decl. to new header Laszlo Ersek
2021-05-31 14:54   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 40/43] OvmfPkg/SmbiosPlatformDxe: declare InstallAllStructures() in header file Laszlo Ersek
2021-05-31 15:00   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 41/43] OvmfPkg/SmbiosPlatformDxe: create Xen-specific module INF file Laszlo Ersek
2021-05-31 14:56   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 42/43] OvmfPkg/SmbiosPlatformDxe: split Xen entry point from QEMU entry point Laszlo Ersek
2021-05-31 15:03   ` Philippe Mathieu-Daudé
2021-05-26 20:14 ` [PATCH 43/43] OvmfPkg: restrict XenPlatformLib to BdsDxe in the IA32, IA32X64, X64 DSCs Laszlo Ersek
2021-05-31 14:58   ` Philippe Mathieu-Daudé
2021-05-27  7:34 ` [PATCH 00/43] OvmfPkg: remove Xen support from OvmfPkg*.dsc, in favor of OvmfXen.dsc Ard Biesheuvel
2021-05-27  8:55   ` Laszlo Ersek
2021-05-31 15:06     ` Philippe Mathieu-Daudé
2021-06-01  7:41       ` Laszlo Ersek
2021-05-27 13:07 ` Leif Lindholm
2021-05-27 13:09   ` Leif Lindholm
2021-05-27 16:30   ` Laszlo Ersek
2021-06-02  8:36 ` [edk2-devel] " Laszlo Ersek
2021-06-04 14:02   ` Anthony PERARD
2021-06-04 14:19     ` Laszlo Ersek
2021-06-04 16:05     ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210526201446.12554-15-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox