]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Command structures for the QEMU FwCfg table loader interface.\r | |
3 | \r | |
4 | Copyright (C) 2014, Red Hat, Inc.\r | |
5 | \r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | **/\r | |
9 | \r | |
10 | #ifndef __QEMU_LOADER_H__\r | |
11 | #define __QEMU_LOADER_H__\r | |
12 | \r | |
13 | #include <Include/Base.h>\r | |
14 | #include <Library/QemuFwCfgLib.h>\r | |
15 | \r | |
16 | //\r | |
17 | // The types and the documentation reflects the SeaBIOS interface.\r | |
18 | //\r | |
19 | #define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE\r | |
20 | \r | |
21 | typedef enum {\r | |
22 | QemuLoaderCmdAllocate = 1,\r | |
23 | QemuLoaderCmdAddPointer,\r | |
24 | QemuLoaderCmdAddChecksum,\r | |
25 | QemuLoaderCmdWritePointer,\r | |
26 | } QEMU_LOADER_COMMAND_TYPE;\r | |
27 | \r | |
28 | typedef enum {\r | |
29 | QemuLoaderAllocHigh = 1,\r | |
30 | QemuLoaderAllocFSeg\r | |
31 | } QEMU_LOADER_ALLOC_ZONE;\r | |
32 | \r | |
33 | #pragma pack (1)\r | |
34 | //\r | |
35 | // QemuLoaderCmdAllocate: download the fw_cfg file named File, to a buffer\r | |
36 | // allocated in the zone specified by Zone, aligned at a multiple of Alignment.\r | |
37 | //\r | |
38 | typedef struct {\r | |
39 | UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated\r | |
40 | UINT32 Alignment; // power of two\r | |
41 | UINT8 Zone; // QEMU_LOADER_ALLOC_ZONE values\r | |
42 | } QEMU_LOADER_ALLOCATE;\r | |
43 | \r | |
44 | //\r | |
45 | // QemuLoaderCmdAddPointer: the bytes at\r | |
46 | // [PointerOffset..PointerOffset+PointerSize) in the file PointerFile contain a\r | |
47 | // relative pointer (an offset) into PointeeFile. Increment the relative\r | |
48 | // pointer's value by the base address of where PointeeFile's contents have\r | |
49 | // been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile).\r | |
50 | //\r | |
51 | typedef struct {\r | |
52 | UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated\r | |
53 | UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated\r | |
54 | UINT32 PointerOffset;\r | |
55 | UINT8 PointerSize; // one of 1, 2, 4, 8\r | |
56 | } QEMU_LOADER_ADD_POINTER;\r | |
57 | \r | |
58 | //\r | |
59 | // QemuLoaderCmdAddChecksum: calculate the UINT8 checksum (as per\r | |
60 | // CalculateChecksum8()) of the range [Start..Start+Length) in File. Store the\r | |
61 | // UINT8 result at ResultOffset in the same File.\r | |
62 | //\r | |
63 | typedef struct {\r | |
64 | UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated\r | |
65 | UINT32 ResultOffset;\r | |
66 | UINT32 Start;\r | |
67 | UINT32 Length;\r | |
68 | } QEMU_LOADER_ADD_CHECKSUM;\r | |
69 | \r | |
70 | //\r | |
71 | // QemuLoaderCmdWritePointer: the bytes at\r | |
72 | // [PointerOffset..PointerOffset+PointerSize) in the writeable fw_cfg file\r | |
73 | // PointerFile are to receive the absolute address of PointeeFile, as allocated\r | |
74 | // and downloaded by the firmware, incremented by the value of PointeeOffset.\r | |
75 | // Store the sum of (a) the base address of where PointeeFile's contents have\r | |
76 | // been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile)\r | |
77 | // and (b) PointeeOffset, to this portion of PointerFile.\r | |
78 | //\r | |
79 | // This command is similar to QemuLoaderCmdAddPointer; the difference is that\r | |
80 | // the "pointer to patch" does not exist in guest-physical address space, only\r | |
81 | // in "fw_cfg file space". In addition, the "pointer to patch" is not\r | |
82 | // initialized by QEMU in-place with a possibly nonzero offset value: the\r | |
83 | // relative offset into PointeeFile comes from the explicit PointeeOffset\r | |
84 | // field.\r | |
85 | //\r | |
86 | typedef struct {\r | |
87 | UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated\r | |
88 | UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated\r | |
89 | UINT32 PointerOffset;\r | |
90 | UINT32 PointeeOffset;\r | |
91 | UINT8 PointerSize; // one of 1, 2, 4, 8\r | |
92 | } QEMU_LOADER_WRITE_POINTER;\r | |
93 | \r | |
94 | typedef struct {\r | |
95 | UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values\r | |
96 | union {\r | |
97 | QEMU_LOADER_ALLOCATE Allocate;\r | |
98 | QEMU_LOADER_ADD_POINTER AddPointer;\r | |
99 | QEMU_LOADER_ADD_CHECKSUM AddChecksum;\r | |
100 | QEMU_LOADER_WRITE_POINTER WritePointer;\r | |
101 | UINT8 Padding[124];\r | |
102 | } Command;\r | |
103 | } QEMU_LOADER_ENTRY;\r | |
104 | #pragma pack ()\r | |
105 | \r | |
106 | #endif\r |