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. In OVMF we
|
---|
24 | // use a minimal subset of it.
|
---|
25 | //
|
---|
26 | #define QEMU_LOADER_FNAME_SIZE QEMU_FW_CFG_FNAME_SIZE
|
---|
27 |
|
---|
28 | //
|
---|
29 | // We only look at the Allocate command, and only to get FwCfg filenames.
|
---|
30 | //
|
---|
31 | typedef enum {
|
---|
32 | QemuLoaderCmdAllocate = 1,
|
---|
33 | QemuLoaderCmdAddPointer,
|
---|
34 | QemuLoaderCmdAddChecksum
|
---|
35 | } QEMU_LOADER_COMMAND_TYPE;
|
---|
36 |
|
---|
37 | typedef enum {
|
---|
38 | QemuLoaderAllocHigh = 1,
|
---|
39 | QemuLoaderAllocFSeg
|
---|
40 | } QEMU_LOADER_ALLOC_ZONE;
|
---|
41 |
|
---|
42 | #pragma pack (1)
|
---|
43 | //
|
---|
44 | // QemuLoaderCmdAllocate: download the fw_cfg file named File, to a buffer
|
---|
45 | // allocated in the zone specified by Zone, aligned at a multiple of Alignment.
|
---|
46 | //
|
---|
47 | typedef struct {
|
---|
48 | UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
49 | UINT32 Alignment; // power of two
|
---|
50 | UINT8 Zone; // QEMU_LOADER_ALLOC_ZONE values
|
---|
51 | } QEMU_LOADER_ALLOCATE;
|
---|
52 |
|
---|
53 | //
|
---|
54 | // QemuLoaderCmdAddPointer: the bytes at
|
---|
55 | // [PointerOffset..PointerOffset+PointerSize) in the file PointerFile contain a
|
---|
56 | // relative pointer (an offset) into PointeeFile. Increment the relative
|
---|
57 | // pointer's value by the base address of where PointeeFile's contents have
|
---|
58 | // been placed (when QemuLoaderCmdAllocate has been executed for PointeeFile).
|
---|
59 | //
|
---|
60 | typedef struct {
|
---|
61 | UINT8 PointerFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
62 | UINT8 PointeeFile[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
63 | UINT32 PointerOffset;
|
---|
64 | UINT8 PointerSize; // one of 1, 2, 4, 8
|
---|
65 | } QEMU_LOADER_ADD_POINTER;
|
---|
66 |
|
---|
67 | //
|
---|
68 | // QemuLoaderCmdAddChecksum: calculate the UINT8 checksum (as per
|
---|
69 | // CalculateChecksum8()) of the range [Start..Start+Length) in File. Store the
|
---|
70 | // UINT8 result at ResultOffset in the same File.
|
---|
71 | //
|
---|
72 | typedef struct {
|
---|
73 | UINT8 File[QEMU_LOADER_FNAME_SIZE]; // NUL-terminated
|
---|
74 | UINT32 ResultOffset;
|
---|
75 | UINT32 Start;
|
---|
76 | UINT32 Length;
|
---|
77 | } QEMU_LOADER_ADD_CHECKSUM;
|
---|
78 |
|
---|
79 | typedef struct {
|
---|
80 | UINT32 Type; // QEMU_LOADER_COMMAND_TYPE values
|
---|
81 | union {
|
---|
82 | QEMU_LOADER_ALLOCATE Allocate;
|
---|
83 | QEMU_LOADER_ADD_POINTER AddPointer;
|
---|
84 | QEMU_LOADER_ADD_CHECKSUM AddChecksum;
|
---|
85 | UINT8 Padding[124];
|
---|
86 | } Command;
|
---|
87 | } QEMU_LOADER_ENTRY;
|
---|
88 | #pragma pack ()
|
---|
89 |
|
---|
90 | #endif
|
---|