]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/QemuFwCfgLib.h
OvmfPkg/QemuFwCfgLib: generalize InternalQemuFwCfgDmaBytes() to SKIP op
[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
be0eaf42
LE
26//\r
27// If the following bit is set in the UINT32 fw_cfg revision / feature bitmap\r
28// -- read from key 0x0001 with the basic IO Port or MMIO method --, then the\r
29// DMA interface is available.\r
30//\r
31#define FW_CFG_F_DMA BIT1\r
32\r
de01f72c
LE
33//\r
34// Macros for the FW_CFG_DMA_ACCESS.Control bitmap (in native encoding).\r
35//\r
36#define FW_CFG_DMA_CTL_ERROR BIT0\r
37#define FW_CFG_DMA_CTL_READ BIT1\r
38#define FW_CFG_DMA_CTL_SKIP BIT2\r
39#define FW_CFG_DMA_CTL_SELECT BIT3\r
be0eaf42 40#define FW_CFG_DMA_CTL_WRITE BIT4\r
de01f72c 41\r
f1ec65ba 42typedef enum {\r
43 QemuFwCfgItemSignature = 0x0000,\r
44 QemuFwCfgItemInterfaceVersion = 0x0001,\r
45 QemuFwCfgItemSystemUuid = 0x0002,\r
46 QemuFwCfgItemRamSize = 0x0003,\r
47 QemuFwCfgItemGraphicsEnabled = 0x0004,\r
48 QemuFwCfgItemSmpCpuCount = 0x0005,\r
49 QemuFwCfgItemMachineId = 0x0006,\r
50 QemuFwCfgItemKernelAddress = 0x0007,\r
51 QemuFwCfgItemKernelSize = 0x0008,\r
52 QemuFwCfgItemKernelCommandLine = 0x0009,\r
53 QemuFwCfgItemInitrdAddress = 0x000a,\r
54 QemuFwCfgItemInitrdSize = 0x000b,\r
55 QemuFwCfgItemBootDevice = 0x000c,\r
56 QemuFwCfgItemNumaData = 0x000d,\r
57 QemuFwCfgItemBootMenu = 0x000e,\r
58 QemuFwCfgItemMaximumCpuCount = 0x000f,\r
59 QemuFwCfgItemKernelEntry = 0x0010,\r
60 QemuFwCfgItemKernelData = 0x0011,\r
61 QemuFwCfgItemInitrdData = 0x0012,\r
62 QemuFwCfgItemCommandLineAddress = 0x0013,\r
63 QemuFwCfgItemCommandLineSize = 0x0014,\r
64 QemuFwCfgItemCommandLineData = 0x0015,\r
65 QemuFwCfgItemKernelSetupAddress = 0x0016,\r
66 QemuFwCfgItemKernelSetupSize = 0x0017,\r
67 QemuFwCfgItemKernelSetupData = 0x0018,\r
0ac9bc9b 68 QemuFwCfgItemFileDir = 0x0019,\r
f1ec65ba 69\r
70 QemuFwCfgItemX86AcpiTables = 0x8000,\r
71 QemuFwCfgItemX86SmbiosTables = 0x8001,\r
72 QemuFwCfgItemX86Irq0Override = 0x8002,\r
73 QemuFwCfgItemX86E820Table = 0x8003,\r
74 QemuFwCfgItemX86HpetData = 0x8004,\r
75\r
76} FIRMWARE_CONFIG_ITEM;\r
77\r
de01f72c
LE
78//\r
79// Communication structure for the DMA access method. All fields are encoded in\r
80// big endian.\r
81//\r
82#pragma pack (1)\r
83typedef struct {\r
84 UINT32 Control;\r
85 UINT32 Length;\r
86 UINT64 Address;\r
87} FW_CFG_DMA_ACCESS;\r
88#pragma pack ()\r
f1ec65ba 89\r
90/**\r
91 Returns a boolean indicating if the firmware configuration interface\r
92 is available or not.\r
93\r
0dc231c9
LE
94 This function may change fw_cfg state.\r
95\r
f1ec65ba 96 @retval TRUE The interface is available\r
97 @retval FALSE The interface is not available\r
98\r
99**/\r
100BOOLEAN\r
101EFIAPI\r
102QemuFwCfgIsAvailable (\r
103 VOID\r
104 );\r
105\r
106\r
107/**\r
108 Selects a firmware configuration item for reading.\r
109\r
110 Following this call, any data read from this item will start from\r
111 the beginning of the configuration item's data.\r
112\r
113 @param[in] QemuFwCfgItem - Firmware Configuration item to read\r
114\r
115**/\r
116VOID\r
117EFIAPI\r
118QemuFwCfgSelectItem (\r
119 IN FIRMWARE_CONFIG_ITEM QemuFwCfgItem\r
120 );\r
121\r
122\r
123/**\r
124 Reads firmware configuration bytes into a buffer\r
125\r
126 If called multiple times, then the data read will\r
127 continue at the offset of the firmware configuration\r
128 item where the previous read ended.\r
129\r
130 @param[in] Size - Size in bytes to read\r
131 @param[in] Buffer - Buffer to store data into\r
132\r
133**/\r
134VOID\r
135EFIAPI\r
136QemuFwCfgReadBytes (\r
137 IN UINTN Size,\r
138 IN VOID *Buffer OPTIONAL\r
139 );\r
140\r
141\r
29874a8c 142/**\r
143 Writes firmware configuration bytes from a buffer\r
144\r
145 If called multiple times, then the data written will\r
146 continue at the offset of the firmware configuration\r
147 item where the previous write ended.\r
148\r
149 @param[in] Size - Size in bytes to write\r
150 @param[in] Buffer - Buffer to read data from\r
151\r
152**/\r
153VOID\r
154EFIAPI\r
155QemuFwCfgWriteBytes (\r
156 IN UINTN Size,\r
157 IN VOID *Buffer\r
158 );\r
159\r
160\r
f1ec65ba 161/**\r
162 Reads a UINT8 firmware configuration value\r
163\r
164 @return Value of Firmware Configuration item read\r
165\r
166**/\r
167UINT8\r
168EFIAPI\r
169QemuFwCfgRead8 (\r
170 VOID\r
171 );\r
172\r
173\r
174/**\r
175 Reads a UINT16 firmware configuration value\r
176\r
177 @return Value of Firmware Configuration item read\r
178\r
179**/\r
180UINT16\r
181EFIAPI\r
182QemuFwCfgRead16 (\r
183 VOID\r
184 );\r
185\r
186\r
187/**\r
188 Reads a UINT32 firmware configuration value\r
189\r
190 @return Value of Firmware Configuration item read\r
191\r
192**/\r
193UINT32\r
194EFIAPI\r
195QemuFwCfgRead32 (\r
196 VOID\r
197 );\r
198\r
199\r
200/**\r
201 Reads a UINT64 firmware configuration value\r
202\r
203 @return Value of Firmware Configuration item read\r
204\r
205**/\r
206UINT64\r
207EFIAPI\r
208QemuFwCfgRead64 (\r
209 VOID\r
210 );\r
211\r
212\r
0ac9bc9b 213/**\r
214 Find the configuration item corresponding to the firmware configuration file.\r
215\r
216 @param[in] Name - Name of file to look up.\r
217 @param[out] Item - Configuration item corresponding to the file, to be passed\r
218 to QemuFwCfgSelectItem ().\r
219 @param[out] Size - Number of bytes in the file.\r
220\r
221 @return RETURN_SUCCESS If file is found.\r
222 RETURN_NOT_FOUND If file is not found.\r
223 RETURN_UNSUPPORTED If firmware configuration is unavailable.\r
224\r
225**/\r
226RETURN_STATUS\r
227EFIAPI\r
228QemuFwCfgFindFile (\r
229 IN CONST CHAR8 *Name,\r
230 OUT FIRMWARE_CONFIG_ITEM *Item,\r
231 OUT UINTN *Size\r
232 );\r
0dc231c9
LE
233\r
234\r
14eb7a5b
LE
235/**\r
236 Determine if S3 support is explicitly enabled.\r
237\r
238 @retval TRUE if S3 support is explicitly enabled.\r
239 FALSE otherwise. This includes unavailability of the firmware\r
240 configuration interface.\r
241**/\r
242BOOLEAN\r
243EFIAPI\r
244QemuFwCfgS3Enabled (\r
245 VOID\r
246 );\r
247\r
f1ec65ba 248#endif\r
249\r