]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/AcpiPlatformDxe/QemuLoader.h
OvmfPkg/MemEncryptSevLib: find pages of initial SMRAM save state map
[mirror_edk2.git] / OvmfPkg / AcpiPlatformDxe / QemuLoader.h
1 /** @file
2 Command structures for the QEMU FwCfg table loader interface.
3
4 Copyright (C) 2014, Red Hat, Inc.
5
6 This program and the accompanying materials are licensed and made available
7 under the terms and conditions of the BSD License which accompanies this
8 distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
12 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __QEMU_LOADER_H__
17 #define __QEMU_LOADER_H__
18
19 #include <Include/Base.h>
20 #include <Library/QemuFwCfgLib.h>
21
22 //
23 // The types and the documentation reflects the SeaBIOS interface.
24 //
25 #define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE
26
27 typedef enum {
28 QemuLoaderCmdAllocate = 1,
29 QemuLoaderCmdAddPointer,
30 QemuLoaderCmdAddChecksum,
31 QemuLoaderCmdWritePointer,
32 } QEMU_LOADER_COMMAND_TYPE;
33
34 typedef enum {
35 QemuLoaderAllocHigh = 1,
36 QemuLoaderAllocFSeg
37 } QEMU_LOADER_ALLOC_ZONE;
38
39 #pragma pack (1)
40 //
41 // QemuLoaderCmdAllocate: download the fw_cfg file named File, to a buffer
42 // allocated in the zone specified by Zone, aligned at a multiple of Alignment.
43 //
44 typedef struct {
45 UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
46 UINT32 Alignment; // power of two
47 UINT8 Zone; // QEMU_LOADER_ALLOC_ZONE values
48 } QEMU_LOADER_ALLOCATE;
49
50 //
51 // QemuLoaderCmdAddPointer: the bytes at
52 // [PointerOffset..PointerOffset+PointerSize) in the file PointerFile contain a
53 // relative pointer (an offset) into PointeeFile. Increment the relative
54 // pointer's value by the base address of where PointeeFile's contents have
55 // been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile).
56 //
57 typedef struct {
58 UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
59 UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
60 UINT32 PointerOffset;
61 UINT8 PointerSize; // one of 1, 2, 4, 8
62 } QEMU_LOADER_ADD_POINTER;
63
64 //
65 // QemuLoaderCmdAddChecksum: calculate the UINT8 checksum (as per
66 // CalculateChecksum8()) of the range [Start..Start+Length) in File. Store the
67 // UINT8 result at ResultOffset in the same File.
68 //
69 typedef struct {
70 UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
71 UINT32 ResultOffset;
72 UINT32 Start;
73 UINT32 Length;
74 } QEMU_LOADER_ADD_CHECKSUM;
75
76 //
77 // QemuLoaderCmdWritePointer: the bytes at
78 // [PointerOffset..PointerOffset+PointerSize) in the writeable fw_cfg file
79 // PointerFile are to receive the absolute address of PointeeFile, as allocated
80 // and downloaded by the firmware, incremented by the value of PointeeOffset.
81 // Store the sum of (a) the base address of where PointeeFile's contents have
82 // been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile)
83 // and (b) PointeeOffset, to this portion of PointerFile.
84 //
85 // This command is similar to QemuLoaderCmdAddPointer; the difference is that
86 // the "pointer to patch" does not exist in guest-physical address space, only
87 // in "fw_cfg file space". In addition, the "pointer to patch" is not
88 // initialized by QEMU in-place with a possibly nonzero offset value: the
89 // relative offset into PointeeFile comes from the explicit PointeeOffset
90 // field.
91 //
92 typedef struct {
93 UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
94 UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
95 UINT32 PointerOffset;
96 UINT32 PointeeOffset;
97 UINT8 PointerSize; // one of 1, 2, 4, 8
98 } QEMU_LOADER_WRITE_POINTER;
99
100 typedef struct {
101 UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values
102 union {
103 QEMU_LOADER_ALLOCATE Allocate;
104 QEMU_LOADER_ADD_POINTER AddPointer;
105 QEMU_LOADER_ADD_CHECKSUM AddChecksum;
106 QEMU_LOADER_WRITE_POINTER WritePointer;
107 UINT8 Padding[124];
108 } Command;
109 } QEMU_LOADER_ENTRY;
110 #pragma pack ()
111
112 #endif