]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/QemuFwCfgLib.h
ArmVirtPkg, OvmfPkg: QemuFwCfgLib: move DMA-related defs to lib class
[mirror_edk2.git] / OvmfPkg / Include / Library / QemuFwCfgLib.h
CommitLineData
f1ec65ba 1/** @file\r
2 QEMU/KVM Firmware Configuration access\r
3\r
29874a8c 4 Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
0dc231c9
LE
5 Copyright (C) 2013, Red Hat, Inc.\r
6\r
f1ec65ba 7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#ifndef __FW_CFG_LIB__\r
18#define __FW_CFG_LIB__\r
19\r
6a904296
LE
20//\r
21// The size, in bytes, of names of firmware configuration files, including at\r
22// least one terminating NUL byte.\r
23//\r
24#define QEMU_FW_CFG_FNAME_SIZE 56\r
25\r
de01f72c
LE
26//\r
27// Macros for the FW_CFG_DMA_ACCESS.Control bitmap (in native encoding).\r
28//\r
29#define FW_CFG_DMA_CTL_ERROR BIT0\r
30#define FW_CFG_DMA_CTL_READ BIT1\r
31#define FW_CFG_DMA_CTL_SKIP BIT2\r
32#define FW_CFG_DMA_CTL_SELECT BIT3\r
33\r
f1ec65ba 34typedef enum {\r
35 QemuFwCfgItemSignature = 0x0000,\r
36 QemuFwCfgItemInterfaceVersion = 0x0001,\r
37 QemuFwCfgItemSystemUuid = 0x0002,\r
38 QemuFwCfgItemRamSize = 0x0003,\r
39 QemuFwCfgItemGraphicsEnabled = 0x0004,\r
40 QemuFwCfgItemSmpCpuCount = 0x0005,\r
41 QemuFwCfgItemMachineId = 0x0006,\r
42 QemuFwCfgItemKernelAddress = 0x0007,\r
43 QemuFwCfgItemKernelSize = 0x0008,\r
44 QemuFwCfgItemKernelCommandLine = 0x0009,\r
45 QemuFwCfgItemInitrdAddress = 0x000a,\r
46 QemuFwCfgItemInitrdSize = 0x000b,\r
47 QemuFwCfgItemBootDevice = 0x000c,\r
48 QemuFwCfgItemNumaData = 0x000d,\r
49 QemuFwCfgItemBootMenu = 0x000e,\r
50 QemuFwCfgItemMaximumCpuCount = 0x000f,\r
51 QemuFwCfgItemKernelEntry = 0x0010,\r
52 QemuFwCfgItemKernelData = 0x0011,\r
53 QemuFwCfgItemInitrdData = 0x0012,\r
54 QemuFwCfgItemCommandLineAddress = 0x0013,\r
55 QemuFwCfgItemCommandLineSize = 0x0014,\r
56 QemuFwCfgItemCommandLineData = 0x0015,\r
57 QemuFwCfgItemKernelSetupAddress = 0x0016,\r
58 QemuFwCfgItemKernelSetupSize = 0x0017,\r
59 QemuFwCfgItemKernelSetupData = 0x0018,\r
0ac9bc9b 60 QemuFwCfgItemFileDir = 0x0019,\r
f1ec65ba 61\r
62 QemuFwCfgItemX86AcpiTables = 0x8000,\r
63 QemuFwCfgItemX86SmbiosTables = 0x8001,\r
64 QemuFwCfgItemX86Irq0Override = 0x8002,\r
65 QemuFwCfgItemX86E820Table = 0x8003,\r
66 QemuFwCfgItemX86HpetData = 0x8004,\r
67\r
68} FIRMWARE_CONFIG_ITEM;\r
69\r
de01f72c
LE
70//\r
71// Communication structure for the DMA access method. All fields are encoded in\r
72// big endian.\r
73//\r
74#pragma pack (1)\r
75typedef struct {\r
76 UINT32 Control;\r
77 UINT32 Length;\r
78 UINT64 Address;\r
79} FW_CFG_DMA_ACCESS;\r
80#pragma pack ()\r
f1ec65ba 81\r
82/**\r
83 Returns a boolean indicating if the firmware configuration interface\r
84 is available or not.\r
85\r
0dc231c9
LE
86 This function may change fw_cfg state.\r
87\r
f1ec65ba 88 @retval TRUE The interface is available\r
89 @retval FALSE The interface is not available\r
90\r
91**/\r
92BOOLEAN\r
93EFIAPI\r
94QemuFwCfgIsAvailable (\r
95 VOID\r
96 );\r
97\r
98\r
99/**\r
100 Selects a firmware configuration item for reading.\r
101\r
102 Following this call, any data read from this item will start from\r
103 the beginning of the configuration item's data.\r
104\r
105 @param[in] QemuFwCfgItem - Firmware Configuration item to read\r
106\r
107**/\r
108VOID\r
109EFIAPI\r
110QemuFwCfgSelectItem (\r
111 IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem\r
112 );\r
113\r
114\r
115/**\r
116 Reads firmware configuration bytes into a buffer\r
117\r
118 If called multiple times, then the data read will\r
119 continue at the offset of the firmware configuration\r
120 item where the previous read ended.\r
121\r
122 @param[in] Size - Size in bytes to read\r
123 @param[in] Buffer - Buffer to store data into\r
124\r
125**/\r
126VOID\r
127EFIAPI\r
128QemuFwCfgReadBytes (\r
129 IN UINTN Size,\r
130 IN VOID *Buffer OPTIONAL\r
131 );\r
132\r
133\r
29874a8c 134/**\r
135 Writes firmware configuration bytes from a buffer\r
136\r
137 If called multiple times, then the data written will\r
138 continue at the offset of the firmware configuration\r
139 item where the previous write ended.\r
140\r
141 @param[in] Size - Size in bytes to write\r
142 @param[in] Buffer - Buffer to read data from\r
143\r
144**/\r
145VOID\r
146EFIAPI\r
147QemuFwCfgWriteBytes (\r
148 IN UINTN Size,\r
149 IN VOID *Buffer\r
150 );\r
151\r
152\r
f1ec65ba 153/**\r
154 Reads a UINT8 firmware configuration value\r
155\r
156 @return Value of Firmware Configuration item read\r
157\r
158**/\r
159UINT8\r
160EFIAPI\r
161QemuFwCfgRead8 (\r
162 VOID\r
163 );\r
164\r
165\r
166/**\r
167 Reads a UINT16 firmware configuration value\r
168\r
169 @return Value of Firmware Configuration item read\r
170\r
171**/\r
172UINT16\r
173EFIAPI\r
174QemuFwCfgRead16 (\r
175 VOID\r
176 );\r
177\r
178\r
179/**\r
180 Reads a UINT32 firmware configuration value\r
181\r
182 @return Value of Firmware Configuration item read\r
183\r
184**/\r
185UINT32\r
186EFIAPI\r
187QemuFwCfgRead32 (\r
188 VOID\r
189 );\r
190\r
191\r
192/**\r
193 Reads a UINT64 firmware configuration value\r
194\r
195 @return Value of Firmware Configuration item read\r
196\r
197**/\r
198UINT64\r
199EFIAPI\r
200QemuFwCfgRead64 (\r
201 VOID\r
202 );\r
203\r
204\r
0ac9bc9b 205/**\r
206 Find the configuration item corresponding to the firmware configuration file.\r
207\r
208 @param[in] Name - Name of file to look up.\r
209 @param[out] Item - Configuration item corresponding to the file, to be passed\r
210 to QemuFwCfgSelectItem ().\r
211 @param[out] Size - Number of bytes in the file.\r
212\r
213 @return RETURN_SUCCESS If file is found.\r
214 RETURN_NOT_FOUND If file is not found.\r
215 RETURN_UNSUPPORTED If firmware configuration is unavailable.\r
216\r
217**/\r
218RETURN_STATUS\r
219EFIAPI\r
220QemuFwCfgFindFile (\r
221 IN CONST CHAR8 *Name,\r
222 OUT FIRMWARE_CONFIG_ITEM *Item,\r
223 OUT UINTN *Size\r
224 );\r
0dc231c9
LE
225\r
226\r
14eb7a5b
LE
227/**\r
228 Determine if S3 support is explicitly enabled.\r
229\r
230 @retval TRUE if S3 support is explicitly enabled.\r
231 FALSE otherwise. This includes unavailability of the firmware\r
232 configuration interface.\r
233**/\r
234BOOLEAN\r
235EFIAPI\r
236QemuFwCfgS3Enabled (\r
237 VOID\r
238 );\r
239\r
f1ec65ba 240#endif\r
241\r