audk/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h

96 lines
2.1 KiB
C
Raw Normal View History

/** @file
Sample ACPI Platform Driver
Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
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.
OvmfPkg: AcpiPlatformDxe: download ACPI tables from QEMU Recent qemu versions compose all ACPI tables on the host side, according to the target hardware configuration, and make the tables available to any guest firmware over fw_cfg. See version compatibility information below. The feature moves the burden of keeping ACPI tables up-to-date from boot firmware to qemu (which is the source of hardware configuration anyway). This patch adds client code for this feature. Benefits of the qemu-provided ACPI tables include PCI hotplug for example. Qemu provides the following three fw_cfg files: - etc/acpi/rsdp - etc/acpi/tables - etc/table-loader "etc/acpi/rsdp" and "etc/acpi/tables" are similar, they are only kept separate because they have different allocation requirements in SeaBIOS. Both of these fw_cfg files contain preformatted ACPI payload. "etc/acpi/rsdp" contains only the RSDP table, while "etc/acpi/tables" contains all other tables, concatenated. The tables in these two fw_cfg files are filled in by qemu, but two kinds of fields are left incomplete in each table: pointers to other tables, and checksums (which depend on the pointers). Qemu initializes each pointer with a relative offset into the fw_cfg file that contains the pointed-to ACPI table. The final pointer values depend on where the fw_cfg files, holding the pointed-to ACPI tables, will be placed in memory by the guest. That is, the pointer fields need to be "relocated" (incremented) by the base addresses of where "/etc/acpi/rsdp" and "/etc/acpi/tables" will be placed in guest memory. This is where the third file, "/etc/table-loader" comes in the picture. It is a linker/loader script that has several command types: One command type instructs the guest to download the other two files. Another command type instructs the guest to increment ("absolutize") a pointer field (having a relative initial value) in the pointing ACPI table, present in some fw_cfg file, with the dynamic base address of the same (or another) fw_cfg file, holding the pointed-to ACPI table. The third command type instructs the guest to compute checksums over ranges and to store them. In edk2, EFI_ACPI_TABLE_PROTOCOL knows about table relationships -- it handles linkage automatically when a table is installed. The protocol takes care of checksumming too. RSDP is installed automatically. Hence we only need to care about the "etc/acpi/tables" fw_cfg file, determining the boundaries of each ACPI table inside it, and installing those tables. Qemu compatibility information: --------------+---------------------+------------------------------------- qemu version | qemu machine type | effects of the patch --------------+---------------------+------------------------------------- up to 1.6.x | any pc-i440fx | None. OVMF's built-in ACPI tables | | are used. --------------+---------------------+------------------------------------- any | up to pc-i440fx-1.6 | None. OVMF's built-in ACPI tables | | are used. --------------+---------------------+------------------------------------- 1.7.0 | pc-i440fx-1.7 | Potential guest OS crash, dependent | (default for 1.7.0) | on guest RAM size. | | | | DO NOT RUN OVMF on the (1.7.0, | | pc-i440fx-1.7) qemu / machine type | | combination. --------------+---------------------+------------------------------------- 1.7.1 | pc-i440fx-1.7 | OVMF downloads valid ACPI tables | (default for 1.7.1) | from qemu and passes them to the | | guest OS. --------------+---------------------+------------------------------------- 2.0.0-rc0 | pc-i440fx-1.7 or | OVMF downloads valid ACPI tables | later | from qemu and passes them to the | | guest OS. -------------+---------------------+------------------------------------- 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://svn.code.sf.net/p/edk2/code/trunk/edk2@15420 6f19259b-4bc3-4df7-8a09-765794883524
2014-03-31 22:36:06 +02:00
**/
#ifndef _ACPI_PLATFORM_H_INCLUDED_
#define _ACPI_PLATFORM_H_INCLUDED_
#include <PiDxe.h>
#include <Protocol/AcpiTable.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/PciIo.h>
#include <Library/BaseLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <IndustryStandard/Acpi.h>
typedef struct {
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 PciAttributes;
} ORIGINAL_ATTRIBUTES;
EFI_STATUS
EFIAPI
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
);
BOOLEAN
XenDetected (
VOID
);
EFI_STATUS
EFIAPI
InstallXenTables (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
);
OvmfPkg: AcpiPlatformDxe: download ACPI tables from QEMU Recent qemu versions compose all ACPI tables on the host side, according to the target hardware configuration, and make the tables available to any guest firmware over fw_cfg. See version compatibility information below. The feature moves the burden of keeping ACPI tables up-to-date from boot firmware to qemu (which is the source of hardware configuration anyway). This patch adds client code for this feature. Benefits of the qemu-provided ACPI tables include PCI hotplug for example. Qemu provides the following three fw_cfg files: - etc/acpi/rsdp - etc/acpi/tables - etc/table-loader "etc/acpi/rsdp" and "etc/acpi/tables" are similar, they are only kept separate because they have different allocation requirements in SeaBIOS. Both of these fw_cfg files contain preformatted ACPI payload. "etc/acpi/rsdp" contains only the RSDP table, while "etc/acpi/tables" contains all other tables, concatenated. The tables in these two fw_cfg files are filled in by qemu, but two kinds of fields are left incomplete in each table: pointers to other tables, and checksums (which depend on the pointers). Qemu initializes each pointer with a relative offset into the fw_cfg file that contains the pointed-to ACPI table. The final pointer values depend on where the fw_cfg files, holding the pointed-to ACPI tables, will be placed in memory by the guest. That is, the pointer fields need to be "relocated" (incremented) by the base addresses of where "/etc/acpi/rsdp" and "/etc/acpi/tables" will be placed in guest memory. This is where the third file, "/etc/table-loader" comes in the picture. It is a linker/loader script that has several command types: One command type instructs the guest to download the other two files. Another command type instructs the guest to increment ("absolutize") a pointer field (having a relative initial value) in the pointing ACPI table, present in some fw_cfg file, with the dynamic base address of the same (or another) fw_cfg file, holding the pointed-to ACPI table. The third command type instructs the guest to compute checksums over ranges and to store them. In edk2, EFI_ACPI_TABLE_PROTOCOL knows about table relationships -- it handles linkage automatically when a table is installed. The protocol takes care of checksumming too. RSDP is installed automatically. Hence we only need to care about the "etc/acpi/tables" fw_cfg file, determining the boundaries of each ACPI table inside it, and installing those tables. Qemu compatibility information: --------------+---------------------+------------------------------------- qemu version | qemu machine type | effects of the patch --------------+---------------------+------------------------------------- up to 1.6.x | any pc-i440fx | None. OVMF's built-in ACPI tables | | are used. --------------+---------------------+------------------------------------- any | up to pc-i440fx-1.6 | None. OVMF's built-in ACPI tables | | are used. --------------+---------------------+------------------------------------- 1.7.0 | pc-i440fx-1.7 | Potential guest OS crash, dependent | (default for 1.7.0) | on guest RAM size. | | | | DO NOT RUN OVMF on the (1.7.0, | | pc-i440fx-1.7) qemu / machine type | | combination. --------------+---------------------+------------------------------------- 1.7.1 | pc-i440fx-1.7 | OVMF downloads valid ACPI tables | (default for 1.7.1) | from qemu and passes them to the | | guest OS. --------------+---------------------+------------------------------------- 2.0.0-rc0 | pc-i440fx-1.7 or | OVMF downloads valid ACPI tables | later | from qemu and passes them to the | | guest OS. -------------+---------------------+------------------------------------- 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://svn.code.sf.net/p/edk2/code/trunk/edk2@15420 6f19259b-4bc3-4df7-8a09-765794883524
2014-03-31 22:36:06 +02:00
EFI_STATUS
EFIAPI
InstallQemuFwCfgTables (
OvmfPkg: AcpiPlatformDxe: download ACPI tables from QEMU Recent qemu versions compose all ACPI tables on the host side, according to the target hardware configuration, and make the tables available to any guest firmware over fw_cfg. See version compatibility information below. The feature moves the burden of keeping ACPI tables up-to-date from boot firmware to qemu (which is the source of hardware configuration anyway). This patch adds client code for this feature. Benefits of the qemu-provided ACPI tables include PCI hotplug for example. Qemu provides the following three fw_cfg files: - etc/acpi/rsdp - etc/acpi/tables - etc/table-loader "etc/acpi/rsdp" and "etc/acpi/tables" are similar, they are only kept separate because they have different allocation requirements in SeaBIOS. Both of these fw_cfg files contain preformatted ACPI payload. "etc/acpi/rsdp" contains only the RSDP table, while "etc/acpi/tables" contains all other tables, concatenated. The tables in these two fw_cfg files are filled in by qemu, but two kinds of fields are left incomplete in each table: pointers to other tables, and checksums (which depend on the pointers). Qemu initializes each pointer with a relative offset into the fw_cfg file that contains the pointed-to ACPI table. The final pointer values depend on where the fw_cfg files, holding the pointed-to ACPI tables, will be placed in memory by the guest. That is, the pointer fields need to be "relocated" (incremented) by the base addresses of where "/etc/acpi/rsdp" and "/etc/acpi/tables" will be placed in guest memory. This is where the third file, "/etc/table-loader" comes in the picture. It is a linker/loader script that has several command types: One command type instructs the guest to download the other two files. Another command type instructs the guest to increment ("absolutize") a pointer field (having a relative initial value) in the pointing ACPI table, present in some fw_cfg file, with the dynamic base address of the same (or another) fw_cfg file, holding the pointed-to ACPI table. The third command type instructs the guest to compute checksums over ranges and to store them. In edk2, EFI_ACPI_TABLE_PROTOCOL knows about table relationships -- it handles linkage automatically when a table is installed. The protocol takes care of checksumming too. RSDP is installed automatically. Hence we only need to care about the "etc/acpi/tables" fw_cfg file, determining the boundaries of each ACPI table inside it, and installing those tables. Qemu compatibility information: --------------+---------------------+------------------------------------- qemu version | qemu machine type | effects of the patch --------------+---------------------+------------------------------------- up to 1.6.x | any pc-i440fx | None. OVMF's built-in ACPI tables | | are used. --------------+---------------------+------------------------------------- any | up to pc-i440fx-1.6 | None. OVMF's built-in ACPI tables | | are used. --------------+---------------------+------------------------------------- 1.7.0 | pc-i440fx-1.7 | Potential guest OS crash, dependent | (default for 1.7.0) | on guest RAM size. | | | | DO NOT RUN OVMF on the (1.7.0, | | pc-i440fx-1.7) qemu / machine type | | combination. --------------+---------------------+------------------------------------- 1.7.1 | pc-i440fx-1.7 | OVMF downloads valid ACPI tables | (default for 1.7.1) | from qemu and passes them to the | | guest OS. --------------+---------------------+------------------------------------- 2.0.0-rc0 | pc-i440fx-1.7 or | OVMF downloads valid ACPI tables | later | from qemu and passes them to the | | guest OS. -------------+---------------------+------------------------------------- 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://svn.code.sf.net/p/edk2/code/trunk/edk2@15420 6f19259b-4bc3-4df7-8a09-765794883524
2014-03-31 22:36:06 +02:00
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
);
EFI_STATUS
EFIAPI
InstallAcpiTables (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
);
VOID
EnablePciDecoding (
OUT ORIGINAL_ATTRIBUTES **OriginalAttributes,
OUT UINTN *Count
);
VOID
RestorePciDecoding (
IN ORIGINAL_ATTRIBUTES *OriginalAttributes,
IN UINTN Count
);
#endif