From 747b1ef72543c321c386198641a29de7f8537520 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 26 May 2021 22:14:12 +0200 Subject: OvmfPkg/AcpiPlatformDxe: move "QemuLoader.h" to IndustryStandard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turn the "QemuLoader.h" header into a public (IndustryStandard) one. The QEMU ACPI linker-loader interface is stable between QEMU and multiple guest firmwares. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Philippe Mathieu-Daudé Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2122 Signed-off-by: Laszlo Ersek Message-Id: <20210526201446.12554-10-lersek@redhat.com> Reviewed-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daudé --- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 1 - OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c | 2 +- .../AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf | 1 - OvmfPkg/AcpiPlatformDxe/QemuLoader.h | 106 --------------------- OvmfPkg/Include/IndustryStandard/QemuLoader.h | 106 +++++++++++++++++++++ 5 files changed, 107 insertions(+), 109 deletions(-) delete mode 100644 OvmfPkg/AcpiPlatformDxe/QemuLoader.h create mode 100644 OvmfPkg/Include/IndustryStandard/QemuLoader.h diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf index 4522d7f611..3daeb2ee42 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -28,7 +28,6 @@ PciDecoding.c Qemu.c QemuFwCfgAcpi.c - QemuLoader.h Xen.c [Packages] diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c index c07b84a213..621e69410d 100644 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c +++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c @@ -9,6 +9,7 @@ **/ #include +#include #include #include #include @@ -18,7 +19,6 @@ #include #include "AcpiPlatform.h" -#include "QemuLoader.h" // // The user structure for the ordered collection that will track the fw_cfg diff --git a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf index cc24f35bd8..48c8269a8b 100644 --- a/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf +++ b/OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf @@ -27,7 +27,6 @@ PciDecoding.c QemuFwCfgAcpi.c QemuFwCfgAcpiPlatform.c - QemuLoader.h [Packages] MdeModulePkg/MdeModulePkg.dec diff --git a/OvmfPkg/AcpiPlatformDxe/QemuLoader.h b/OvmfPkg/AcpiPlatformDxe/QemuLoader.h deleted file mode 100644 index 5782a23c43..0000000000 --- a/OvmfPkg/AcpiPlatformDxe/QemuLoader.h +++ /dev/null @@ -1,106 +0,0 @@ -/** @file - Command structures for the QEMU FwCfg table loader interface. - - Copyright (C) 2014, Red Hat, Inc. - - SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef QEMU_LOADER_H_ -#define QEMU_LOADER_H_ - -#include -#include - -// -// The types and the documentation reflects the SeaBIOS interface. -// -#define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE - -typedef enum { - QemuLoaderCmdAllocate = 1, - QemuLoaderCmdAddPointer, - QemuLoaderCmdAddChecksum, - QemuLoaderCmdWritePointer, -} QEMU_LOADER_COMMAND_TYPE; - -typedef enum { - QemuLoaderAllocHigh = 1, - QemuLoaderAllocFSeg -} QEMU_LOADER_ALLOC_ZONE; - -#pragma pack (1) -// -// QemuLoaderCmdAllocate: download the fw_cfg file named File, to a buffer -// allocated in the zone specified by Zone, aligned at a multiple of Alignment. -// -typedef struct { - UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 Alignment; // power of two - UINT8 Zone; // QEMU_LOADER_ALLOC_ZONE values -} QEMU_LOADER_ALLOCATE; - -// -// QemuLoaderCmdAddPointer: the bytes at -// [PointerOffset..PointerOffset+PointerSize) in the file PointerFile contain a -// relative pointer (an offset) into PointeeFile. Increment the relative -// pointer's value by the base address of where PointeeFile's contents have -// been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile). -// -typedef struct { - UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 PointerOffset; - UINT8 PointerSize; // one of 1, 2, 4, 8 -} QEMU_LOADER_ADD_POINTER; - -// -// QemuLoaderCmdAddChecksum: calculate the UINT8 checksum (as per -// CalculateChecksum8()) of the range [Start..Start+Length) in File. Store the -// UINT8 result at ResultOffset in the same File. -// -typedef struct { - UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 ResultOffset; - UINT32 Start; - UINT32 Length; -} QEMU_LOADER_ADD_CHECKSUM; - -// -// QemuLoaderCmdWritePointer: the bytes at -// [PointerOffset..PointerOffset+PointerSize) in the writeable fw_cfg file -// PointerFile are to receive the absolute address of PointeeFile, as allocated -// and downloaded by the firmware, incremented by the value of PointeeOffset. -// Store the sum of (a) the base address of where PointeeFile's contents have -// been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile) -// and (b) PointeeOffset, to this portion of PointerFile. -// -// This command is similar to QemuLoaderCmdAddPointer; the difference is that -// the "pointer to patch" does not exist in guest-physical address space, only -// in "fw_cfg file space". In addition, the "pointer to patch" is not -// initialized by QEMU in-place with a possibly nonzero offset value: the -// relative offset into PointeeFile comes from the explicit PointeeOffset -// field. -// -typedef struct { - UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated - UINT32 PointerOffset; - UINT32 PointeeOffset; - UINT8 PointerSize; // one of 1, 2, 4, 8 -} QEMU_LOADER_WRITE_POINTER; - -typedef struct { - UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values - union { - QEMU_LOADER_ALLOCATE Allocate; - QEMU_LOADER_ADD_POINTER AddPointer; - QEMU_LOADER_ADD_CHECKSUM AddChecksum; - QEMU_LOADER_WRITE_POINTER WritePointer; - UINT8 Padding[124]; - } Command; -} QEMU_LOADER_ENTRY; -#pragma pack () - -#endif diff --git a/OvmfPkg/Include/IndustryStandard/QemuLoader.h b/OvmfPkg/Include/IndustryStandard/QemuLoader.h new file mode 100644 index 0000000000..5782a23c43 --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/QemuLoader.h @@ -0,0 +1,106 @@ +/** @file + Command structures for the QEMU FwCfg table loader interface. + + Copyright (C) 2014, Red Hat, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef QEMU_LOADER_H_ +#define QEMU_LOADER_H_ + +#include +#include + +// +// The types and the documentation reflects the SeaBIOS interface. +// +#define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE + +typedef enum { + QemuLoaderCmdAllocate = 1, + QemuLoaderCmdAddPointer, + QemuLoaderCmdAddChecksum, + QemuLoaderCmdWritePointer, +} QEMU_LOADER_COMMAND_TYPE; + +typedef enum { + QemuLoaderAllocHigh = 1, + QemuLoaderAllocFSeg +} QEMU_LOADER_ALLOC_ZONE; + +#pragma pack (1) +// +// QemuLoaderCmdAllocate: download the fw_cfg file named File, to a buffer +// allocated in the zone specified by Zone, aligned at a multiple of Alignment. +// +typedef struct { + UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated + UINT32 Alignment; // power of two + UINT8 Zone; // QEMU_LOADER_ALLOC_ZONE values +} QEMU_LOADER_ALLOCATE; + +// +// QemuLoaderCmdAddPointer: the bytes at +// [PointerOffset..PointerOffset+PointerSize) in the file PointerFile contain a +// relative pointer (an offset) into PointeeFile. Increment the relative +// pointer's value by the base address of where PointeeFile's contents have +// been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile). +// +typedef struct { + UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated + UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated + UINT32 PointerOffset; + UINT8 PointerSize; // one of 1, 2, 4, 8 +} QEMU_LOADER_ADD_POINTER; + +// +// QemuLoaderCmdAddChecksum: calculate the UINT8 checksum (as per +// CalculateChecksum8()) of the range [Start..Start+Length) in File. Store the +// UINT8 result at ResultOffset in the same File. +// +typedef struct { + UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated + UINT32 ResultOffset; + UINT32 Start; + UINT32 Length; +} QEMU_LOADER_ADD_CHECKSUM; + +// +// QemuLoaderCmdWritePointer: the bytes at +// [PointerOffset..PointerOffset+PointerSize) in the writeable fw_cfg file +// PointerFile are to receive the absolute address of PointeeFile, as allocated +// and downloaded by the firmware, incremented by the value of PointeeOffset. +// Store the sum of (a) the base address of where PointeeFile's contents have +// been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile) +// and (b) PointeeOffset, to this portion of PointerFile. +// +// This command is similar to QemuLoaderCmdAddPointer; the difference is that +// the "pointer to patch" does not exist in guest-physical address space, only +// in "fw_cfg file space". In addition, the "pointer to patch" is not +// initialized by QEMU in-place with a possibly nonzero offset value: the +// relative offset into PointeeFile comes from the explicit PointeeOffset +// field. +// +typedef struct { + UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated + UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated + UINT32 PointerOffset; + UINT32 PointeeOffset; + UINT8 PointerSize; // one of 1, 2, 4, 8 +} QEMU_LOADER_WRITE_POINTER; + +typedef struct { + UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values + union { + QEMU_LOADER_ALLOCATE Allocate; + QEMU_LOADER_ADD_POINTER AddPointer; + QEMU_LOADER_ADD_CHECKSUM AddChecksum; + QEMU_LOADER_WRITE_POINTER WritePointer; + UINT8 Padding[124]; + } Command; +} QEMU_LOADER_ENTRY; +#pragma pack () + +#endif -- cgit v1.2.3