mirror of https://github.com/acidanthera/audk.git
OvmfPkg: install an SSDT with a dynamic OperationRegion called FWDT
"FWDT" ("firmware data") is allocated as EfiReservedMemoryType, with AllocateReservedPool(). <MdePkg/Include/Library/MemoryAllocationLib.h> doesn't seem to provide direct access to EfiACPIReclaimMemory, but at this point the former seems sufficient. Based on SeaBIOS commit 2062f2ba by Gerd Hoffmann <kraxel@redhat.com>. v3: - coding style fixes: - BDAT -> FWDT - __packed -> #pragma pack(1) - BFLD -> FIRMWARE_DATA, PCI_WINDOW - Bfld -> FwData - Ssdt.asl: changed license to 2-clause BSDL, paraphrasing Dsdt.asl Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13573 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
cb678aa85e
commit
253a2ea73f
|
@ -10,7 +10,7 @@
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "AcpiPlatform.h"
|
#include "AcpiPlatform.h"
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
@ -98,6 +98,107 @@ QemuInstallAcpiMadtTable (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINT64 Base;
|
||||||
|
UINT64 End;
|
||||||
|
UINT64 Length;
|
||||||
|
} PCI_WINDOW;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
PCI_WINDOW PciWindow32;
|
||||||
|
PCI_WINDOW PciWindow64;
|
||||||
|
} FIRMWARE_DATA;
|
||||||
|
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
PopulateFwData(
|
||||||
|
OUT FIRMWARE_DATA *FwData
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 SsdtSize;
|
||||||
|
UINT8 *Ssdt;
|
||||||
|
|
||||||
|
SsdtSize = AcpiTableBufferSize + 17;
|
||||||
|
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;
|
||||||
|
|
||||||
|
ASSERT(SsdtPtr - Ssdt == SsdtSize);
|
||||||
|
((EFI_ACPI_DESCRIPTION_HEADER *) Ssdt)->Length = SsdtSize;
|
||||||
|
Status = InstallAcpiTable (AcpiProtocol, Ssdt, SsdtSize, TableKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
FreePool(Ssdt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Status != EFI_SUCCESS) {
|
||||||
|
FreePool(FwData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
QemuInstallAcpiTable (
|
QemuInstallAcpiTable (
|
||||||
|
@ -115,6 +216,9 @@ QemuInstallAcpiTable (
|
||||||
case EFI_ACPI_1_0_APIC_SIGNATURE:
|
case EFI_ACPI_1_0_APIC_SIGNATURE:
|
||||||
TableInstallFunction = QemuInstallAcpiMadtTable;
|
TableInstallFunction = QemuInstallAcpiMadtTable;
|
||||||
break;
|
break;
|
||||||
|
case EFI_ACPI_1_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:
|
||||||
|
TableInstallFunction = QemuInstallAcpiSsdtTable;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
TableInstallFunction = InstallAcpiTable;
|
TableInstallFunction = InstallAcpiTable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
Facp.aslc
|
Facp.aslc
|
||||||
Facs.aslc
|
Facs.aslc
|
||||||
Dsdt.asl
|
Dsdt.asl
|
||||||
|
Ssdt.asl
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
/** @file
|
||||||
|
Placeholder for runtime-generated objects.
|
||||||
|
|
||||||
|
This empty table provides only a header for dynamic copying and extension,
|
||||||
|
and a trigger for QemuInstallAcpiSsdtTable().
|
||||||
|
|
||||||
|
Copyright (C) 2012 Red Hat, Inc.
|
||||||
|
|
||||||
|
This program and the accompanying materials are licensed and made available
|
||||||
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
|
distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
|
||||||
|
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
**/
|
||||||
|
|
||||||
|
DefinitionBlock ("Ssdt.aml", "SSDT", 1, "REDHAT", "OVMF ", 1) {
|
||||||
|
}
|
Loading…
Reference in New Issue