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