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