2 Command structures for the QEMU FwCfg table loader interface.
4 Copyright (C) 2014, Red Hat, Inc.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __QEMU_LOADER_H__
11 #define __QEMU_LOADER_H__
13 #include <Include/Base.h>
14 #include <Library/QemuFwCfgLib.h>
17 // The types and the documentation reflects the SeaBIOS interface.
19 #define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE
22 QemuLoaderCmdAllocate
= 1,
23 QemuLoaderCmdAddPointer
,
24 QemuLoaderCmdAddChecksum
,
25 QemuLoaderCmdWritePointer
,
26 } QEMU_LOADER_COMMAND_TYPE
;
29 QemuLoaderAllocHigh
= 1,
31 } QEMU_LOADER_ALLOC_ZONE
;
35 // QemuLoaderCmdAllocate: download the fw_cfg file named File, to a buffer
36 // allocated in the zone specified by Zone, aligned at a multiple of Alignment.
39 UINT8 File
[QEMU_LOADER_FNAME_SIZE
]; // NUL-terminated
40 UINT32 Alignment
; // power of two
41 UINT8 Zone
; // QEMU_LOADER_ALLOC_ZONE values
42 } QEMU_LOADER_ALLOCATE
;
45 // QemuLoaderCmdAddPointer: the bytes at
46 // [PointerOffset..PointerOffset+PointerSize) in the file PointerFile contain a
47 // relative pointer (an offset) into PointeeFile. Increment the relative
48 // pointer's value by the base address of where PointeeFile's contents have
49 // been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile).
52 UINT8 PointerFile
[QEMU_LOADER_FNAME_SIZE
]; // NUL-terminated
53 UINT8 PointeeFile
[QEMU_LOADER_FNAME_SIZE
]; // NUL-terminated
55 UINT8 PointerSize
; // one of 1, 2, 4, 8
56 } QEMU_LOADER_ADD_POINTER
;
59 // QemuLoaderCmdAddChecksum: calculate the UINT8 checksum (as per
60 // CalculateChecksum8()) of the range [Start..Start+Length) in File. Store the
61 // UINT8 result at ResultOffset in the same File.
64 UINT8 File
[QEMU_LOADER_FNAME_SIZE
]; // NUL-terminated
68 } QEMU_LOADER_ADD_CHECKSUM
;
71 // QemuLoaderCmdWritePointer: the bytes at
72 // [PointerOffset..PointerOffset+PointerSize) in the writeable fw_cfg file
73 // PointerFile are to receive the absolute address of PointeeFile, as allocated
74 // and downloaded by the firmware, incremented by the value of PointeeOffset.
75 // Store the sum of (a) the base address of where PointeeFile's contents have
76 // been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile)
77 // and (b) PointeeOffset, to this portion of PointerFile.
79 // This command is similar to QemuLoaderCmdAddPointer; the difference is that
80 // the "pointer to patch" does not exist in guest-physical address space, only
81 // in "fw_cfg file space". In addition, the "pointer to patch" is not
82 // initialized by QEMU in-place with a possibly nonzero offset value: the
83 // relative offset into PointeeFile comes from the explicit PointeeOffset
87 UINT8 PointerFile
[QEMU_LOADER_FNAME_SIZE
]; // NUL-terminated
88 UINT8 PointeeFile
[QEMU_LOADER_FNAME_SIZE
]; // NUL-terminated
91 UINT8 PointerSize
; // one of 1, 2, 4, 8
92 } QEMU_LOADER_WRITE_POINTER
;
95 UINT32 Type
; // QEMU_LOADER_COMMAND_TYPE values
97 QEMU_LOADER_ALLOCATE Allocate
;
98 QEMU_LOADER_ADD_POINTER AddPointer
;
99 QEMU_LOADER_ADD_CHECKSUM AddChecksum
;
100 QEMU_LOADER_WRITE_POINTER WritePointer
;