1 | /** @file
|
---|
2 | Command structures for the QEMU FwCfg table loader interface.
|
---|
3 |
|
---|
4 | Copyright (C) 2014, Red Hat, Inc.
|
---|
5 |
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #ifndef __QEMU_LOADER_H__
|
---|
11 | #define __QEMU_LOADER_H__
|
---|
12 |
|
---|
13 | #include <Include/Base.h>
|
---|
14 | #include <Library/QemuFwCfgLib.h>
|
---|
15 |
|
---|
16 | //
|
---|
17 | // The types and the documentation reflects the SeaBIOS interface.
|
---|
18 | //
|
---|
19 | #define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE
|
---|
20 |
|
---|
21 | typedef enum {
|
---|
22 | QemuLoaderCmdAllocate = 1,
|
---|
23 | QemuLoaderCmdAddPointer,
|
---|
24 | QemuLoaderCmdAddChecksum,
|
---|
25 | QemuLoaderCmdWritePointer,
|
---|
26 | } QEMU_LOADER_COMMAND_TYPE;
|
---|
27 |
|
---|
28 | typedef enum {
|
---|
29 | QemuLoaderAllocHigh = 1,
|
---|
30 | QemuLoaderAllocFSeg
|
---|
31 | } QEMU_LOADER_ALLOC_ZONE;
|
---|
32 |
|
---|
33 | #pragma pack (1)
|
---|
34 | //
|
---|
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.
|
---|
37 | //
|
---|
38 | typedef struct {
|
---|
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;
|
---|
43 |
|
---|
44 | //
|
---|
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).
|
---|
50 | //
|
---|
51 | typedef struct {
|
---|
52 | UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
53 | UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
54 | UINT32 PointerOffset;
|
---|
55 | UINT8 PointerSize; // one of 1, 2, 4, 8
|
---|
56 | } QEMU_LOADER_ADD_POINTER;
|
---|
57 |
|
---|
58 | //
|
---|
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.
|
---|
62 | //
|
---|
63 | typedef struct {
|
---|
64 | UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
65 | UINT32 ResultOffset;
|
---|
66 | UINT32 Start;
|
---|
67 | UINT32 Length;
|
---|
68 | } QEMU_LOADER_ADD_CHECKSUM;
|
---|
69 |
|
---|
70 | //
|
---|
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.
|
---|
78 | //
|
---|
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
|
---|
84 | // field.
|
---|
85 | //
|
---|
86 | typedef struct {
|
---|
87 | UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
88 | UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
89 | UINT32 PointerOffset;
|
---|
90 | UINT32 PointeeOffset;
|
---|
91 | UINT8 PointerSize; // one of 1, 2, 4, 8
|
---|
92 | } QEMU_LOADER_WRITE_POINTER;
|
---|
93 |
|
---|
94 | typedef struct {
|
---|
95 | UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values
|
---|
96 | union {
|
---|
97 | QEMU_LOADER_ALLOCATE Allocate;
|
---|
98 | QEMU_LOADER_ADD_POINTER AddPointer;
|
---|
99 | QEMU_LOADER_ADD_CHECKSUM AddChecksum;
|
---|
100 | QEMU_LOADER_WRITE_POINTER WritePointer;
|
---|
101 | UINT8 Padding[124];
|
---|
102 | } Command;
|
---|
103 | } QEMU_LOADER_ENTRY;
|
---|
104 | #pragma pack ()
|
---|
105 |
|
---|
106 | #endif
|
---|