blueswir1 | 3cce624 | 2008-09-18 18:27:29 +0000 | [diff] [blame] | 1 | #ifndef FW_CFG_H |
| 2 | #define FW_CFG_H |
| 3 | |
Hu Tao | 1dfe505 | 2013-04-26 11:24:43 +0800 | [diff] [blame] | 4 | #include "exec/hwaddr.h" |
Marc-André Lureau | 5be5df7 | 2018-08-17 17:59:10 +0200 | [diff] [blame] | 5 | #include "standard-headers/linux/qemu_fw_cfg.h" |
Mark Cave-Ayland | 39736e1 | 2017-07-14 10:40:08 +0100 | [diff] [blame] | 6 | #include "hw/sysbus.h" |
| 7 | #include "sysemu/dma.h" |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 8 | #include "qom/object.h" |
Mark Cave-Ayland | 39736e1 | 2017-07-14 10:40:08 +0100 | [diff] [blame] | 9 | |
| 10 | #define TYPE_FW_CFG "fw_cfg" |
| 11 | #define TYPE_FW_CFG_IO "fw_cfg_io" |
| 12 | #define TYPE_FW_CFG_MEM "fw_cfg_mem" |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 13 | #define TYPE_FW_CFG_DATA_GENERATOR_INTERFACE "fw_cfg-data-generator" |
Mark Cave-Ayland | 39736e1 | 2017-07-14 10:40:08 +0100 | [diff] [blame] | 14 | |
Eduardo Habkost | 8063396 | 2020-09-16 14:25:19 -0400 | [diff] [blame] | 15 | OBJECT_DECLARE_SIMPLE_TYPE(FWCfgState, FW_CFG) |
| 16 | OBJECT_DECLARE_SIMPLE_TYPE(FWCfgIoState, FW_CFG_IO) |
| 17 | OBJECT_DECLARE_SIMPLE_TYPE(FWCfgMemState, FW_CFG_MEM) |
Hu Tao | 1dfe505 | 2013-04-26 11:24:43 +0800 | [diff] [blame] | 18 | |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 19 | typedef struct FWCfgDataGeneratorClass FWCfgDataGeneratorClass; |
Eduardo Habkost | 8110fa1 | 2020-08-31 17:07:33 -0400 | [diff] [blame] | 20 | DECLARE_CLASS_CHECKERS(FWCfgDataGeneratorClass, FW_CFG_DATA_GENERATOR, |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 21 | TYPE_FW_CFG_DATA_GENERATOR_INTERFACE) |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 22 | |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 23 | struct FWCfgDataGeneratorClass { |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 24 | /*< private >*/ |
| 25 | InterfaceClass parent_class; |
| 26 | /*< public >*/ |
| 27 | |
| 28 | /** |
| 29 | * get_data: |
| 30 | * @obj: the object implementing this interface |
| 31 | * @errp: pointer to a NULL-initialized error object |
| 32 | * |
Philippe Mathieu-Daudé | a3ad583 | 2020-07-21 15:05:51 +0200 | [diff] [blame] | 33 | * Returns: reference to a byte array containing the data on success, |
| 34 | * or NULL on error. |
| 35 | * |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 36 | * The caller should release the reference when no longer |
| 37 | * required. |
| 38 | */ |
| 39 | GByteArray *(*get_data)(Object *obj, Error **errp); |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 40 | }; |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 41 | |
Marc-André Lureau | 5be5df7 | 2018-08-17 17:59:10 +0200 | [diff] [blame] | 42 | typedef struct fw_cfg_file FWCfgFile; |
Gerd Hoffmann | abe147e | 2009-12-18 12:01:10 +0100 | [diff] [blame] | 43 | |
Gerd Hoffmann | bab47d9 | 2016-04-07 09:12:58 -0500 | [diff] [blame] | 44 | #define FW_CFG_ORDER_OVERRIDE_VGA 70 |
| 45 | #define FW_CFG_ORDER_OVERRIDE_NIC 80 |
| 46 | #define FW_CFG_ORDER_OVERRIDE_USER 100 |
| 47 | #define FW_CFG_ORDER_OVERRIDE_DEVICE 110 |
| 48 | |
| 49 | void fw_cfg_set_order_override(FWCfgState *fw_cfg, int order); |
| 50 | void fw_cfg_reset_order_override(FWCfgState *fw_cfg); |
| 51 | |
Gerd Hoffmann | abe147e | 2009-12-18 12:01:10 +0100 | [diff] [blame] | 52 | typedef struct FWCfgFiles { |
| 53 | uint32_t count; |
| 54 | FWCfgFile f[]; |
| 55 | } FWCfgFiles; |
| 56 | |
Marc-André Lureau | 5be5df7 | 2018-08-17 17:59:10 +0200 | [diff] [blame] | 57 | typedef struct fw_cfg_dma_access FWCfgDmaAccess; |
Marc Marí | a4c0d1d | 2015-10-08 17:02:55 +0200 | [diff] [blame] | 58 | |
Marc-André Lureau | 6f6f4ae | 2017-08-07 20:16:11 +0200 | [diff] [blame] | 59 | typedef void (*FWCfgCallback)(void *opaque); |
Marc-André Lureau | 5f9252f | 2017-09-11 18:59:23 +0200 | [diff] [blame] | 60 | typedef void (*FWCfgWriteCallback)(void *opaque, off_t start, size_t len); |
blueswir1 | 3cce624 | 2008-09-18 18:27:29 +0000 | [diff] [blame] | 61 | |
Paolo Bonzini | c71a42b | 2024-05-02 16:57:08 +0200 | [diff] [blame] | 62 | typedef struct FWCfgEntry FWCfgEntry; |
| 63 | |
Mark Cave-Ayland | 39736e1 | 2017-07-14 10:40:08 +0100 | [diff] [blame] | 64 | struct FWCfgState { |
| 65 | /*< private >*/ |
| 66 | SysBusDevice parent_obj; |
| 67 | /*< public >*/ |
| 68 | |
| 69 | uint16_t file_slots; |
| 70 | FWCfgEntry *entries[2]; |
| 71 | int *entry_order; |
| 72 | FWCfgFiles *files; |
| 73 | uint16_t cur_entry; |
| 74 | uint32_t cur_offset; |
| 75 | Notifier machine_ready; |
| 76 | |
| 77 | int fw_cfg_order_override; |
| 78 | |
| 79 | bool dma_enabled; |
| 80 | dma_addr_t dma_addr; |
| 81 | AddressSpace *dma_as; |
| 82 | MemoryRegion dma_iomem; |
Shameer Kolothum | 394f0f7 | 2020-04-03 11:18:26 +0100 | [diff] [blame] | 83 | |
| 84 | /* restore during migration */ |
| 85 | bool acpi_mr_restore; |
| 86 | uint64_t table_mr_size; |
| 87 | uint64_t linker_mr_size; |
| 88 | uint64_t rsdp_mr_size; |
Mark Cave-Ayland | 39736e1 | 2017-07-14 10:40:08 +0100 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | struct FWCfgIoState { |
| 92 | /*< private >*/ |
| 93 | FWCfgState parent_obj; |
| 94 | /*< public >*/ |
| 95 | |
| 96 | MemoryRegion comb_iomem; |
| 97 | }; |
| 98 | |
| 99 | struct FWCfgMemState { |
| 100 | /*< private >*/ |
| 101 | FWCfgState parent_obj; |
| 102 | /*< public >*/ |
| 103 | |
| 104 | MemoryRegion ctl_iomem, data_iomem; |
| 105 | uint32_t data_width; |
| 106 | MemoryRegionOps wide_data_ops; |
| 107 | }; |
| 108 | |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 109 | /** |
| 110 | * fw_cfg_add_bytes: |
| 111 | * @s: fw_cfg device being modified |
| 112 | * @key: selector key value for new fw_cfg item |
| 113 | * @data: pointer to start of item data |
| 114 | * @len: size of item data |
| 115 | * |
| 116 | * Add a new fw_cfg item, available by selecting the given key, as a raw |
| 117 | * "blob" of the given size. The data referenced by the starting pointer |
| 118 | * is only linked, NOT copied, into the data structure of the fw_cfg device. |
| 119 | */ |
Markus Armbruster | 089da57 | 2013-01-16 14:50:28 +0100 | [diff] [blame] | 120 | void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * fw_cfg_add_string: |
| 124 | * @s: fw_cfg device being modified |
| 125 | * @key: selector key value for new fw_cfg item |
| 126 | * @value: NUL-terminated ascii string |
| 127 | * |
| 128 | * Add a new fw_cfg item, available by selecting the given key. The item |
| 129 | * data will consist of a dynamically allocated copy of the provided string, |
| 130 | * including its NUL terminator. |
| 131 | */ |
Markus Armbruster | 44687f7 | 2013-01-16 14:50:24 +0100 | [diff] [blame] | 132 | void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 133 | |
| 134 | /** |
Sergio Lopez | e5f6aa3 | 2019-09-24 11:38:18 +0200 | [diff] [blame] | 135 | * fw_cfg_modify_string: |
| 136 | * @s: fw_cfg device being modified |
| 137 | * @key: selector key value for new fw_cfg item |
| 138 | * @value: NUL-terminated ascii string |
| 139 | * |
| 140 | * Replace the fw_cfg item available by selecting the given key. The new |
| 141 | * data will consist of a dynamically allocated copy of the provided string, |
| 142 | * including its NUL terminator. The data being replaced, assumed to have |
| 143 | * been dynamically allocated during an earlier call to either |
| 144 | * fw_cfg_add_string() or fw_cfg_modify_string(), is freed before returning. |
| 145 | */ |
| 146 | void fw_cfg_modify_string(FWCfgState *s, uint16_t key, const char *value); |
| 147 | |
| 148 | /** |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 149 | * fw_cfg_add_i16: |
| 150 | * @s: fw_cfg device being modified |
| 151 | * @key: selector key value for new fw_cfg item |
| 152 | * @value: 16-bit integer |
| 153 | * |
| 154 | * Add a new fw_cfg item, available by selecting the given key. The item |
| 155 | * data will consist of a dynamically allocated copy of the given 16-bit |
| 156 | * value, converted to little-endian representation. |
| 157 | */ |
Markus Armbruster | 4cad386 | 2013-01-16 14:50:23 +0100 | [diff] [blame] | 158 | void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * fw_cfg_modify_i16: |
| 162 | * @s: fw_cfg device being modified |
| 163 | * @key: selector key value for new fw_cfg item |
| 164 | * @value: 16-bit integer |
| 165 | * |
| 166 | * Replace the fw_cfg item available by selecting the given key. The new |
| 167 | * data will consist of a dynamically allocated copy of the given 16-bit |
| 168 | * value, converted to little-endian representation. The data being replaced, |
| 169 | * assumed to have been dynamically allocated during an earlier call to |
| 170 | * either fw_cfg_add_i16() or fw_cfg_modify_i16(), is freed before returning. |
| 171 | */ |
Gabriel L. Somlo | 1edd34b | 2015-06-08 14:10:44 -0400 | [diff] [blame] | 172 | void fw_cfg_modify_i16(FWCfgState *s, uint16_t key, uint16_t value); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * fw_cfg_add_i32: |
| 176 | * @s: fw_cfg device being modified |
| 177 | * @key: selector key value for new fw_cfg item |
| 178 | * @value: 32-bit integer |
| 179 | * |
| 180 | * Add a new fw_cfg item, available by selecting the given key. The item |
| 181 | * data will consist of a dynamically allocated copy of the given 32-bit |
| 182 | * value, converted to little-endian representation. |
| 183 | */ |
Markus Armbruster | 4cad386 | 2013-01-16 14:50:23 +0100 | [diff] [blame] | 184 | void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 185 | |
| 186 | /** |
Sergio Lopez | e5f6aa3 | 2019-09-24 11:38:18 +0200 | [diff] [blame] | 187 | * fw_cfg_modify_i32: |
| 188 | * @s: fw_cfg device being modified |
| 189 | * @key: selector key value for new fw_cfg item |
| 190 | * @value: 32-bit integer |
| 191 | * |
| 192 | * Replace the fw_cfg item available by selecting the given key. The new |
| 193 | * data will consist of a dynamically allocated copy of the given 32-bit |
| 194 | * value, converted to little-endian representation. The data being replaced, |
| 195 | * assumed to have been dynamically allocated during an earlier call to |
| 196 | * either fw_cfg_add_i32() or fw_cfg_modify_i32(), is freed before returning. |
| 197 | */ |
| 198 | void fw_cfg_modify_i32(FWCfgState *s, uint16_t key, uint32_t value); |
| 199 | |
| 200 | /** |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 201 | * fw_cfg_add_i64: |
| 202 | * @s: fw_cfg device being modified |
| 203 | * @key: selector key value for new fw_cfg item |
| 204 | * @value: 64-bit integer |
| 205 | * |
| 206 | * Add a new fw_cfg item, available by selecting the given key. The item |
| 207 | * data will consist of a dynamically allocated copy of the given 64-bit |
| 208 | * value, converted to little-endian representation. |
| 209 | */ |
Markus Armbruster | 4cad386 | 2013-01-16 14:50:23 +0100 | [diff] [blame] | 210 | void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 211 | |
| 212 | /** |
Sergio Lopez | e5f6aa3 | 2019-09-24 11:38:18 +0200 | [diff] [blame] | 213 | * fw_cfg_modify_i64: |
| 214 | * @s: fw_cfg device being modified |
| 215 | * @key: selector key value for new fw_cfg item |
| 216 | * @value: 64-bit integer |
| 217 | * |
| 218 | * Replace the fw_cfg item available by selecting the given key. The new |
| 219 | * data will consist of a dynamically allocated copy of the given 64-bit |
| 220 | * value, converted to little-endian representation. The data being replaced, |
| 221 | * assumed to have been dynamically allocated during an earlier call to |
| 222 | * either fw_cfg_add_i64() or fw_cfg_modify_i64(), is freed before returning. |
| 223 | */ |
| 224 | void fw_cfg_modify_i64(FWCfgState *s, uint16_t key, uint64_t value); |
| 225 | |
| 226 | /** |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 227 | * fw_cfg_add_file: |
| 228 | * @s: fw_cfg device being modified |
| 229 | * @filename: name of new fw_cfg file item |
| 230 | * @data: pointer to start of item data |
| 231 | * @len: size of item data |
| 232 | * |
| 233 | * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data |
| 234 | * referenced by the starting pointer is only linked, NOT copied, into the |
| 235 | * data structure of the fw_cfg device. |
| 236 | * The next available (unused) selector key starting at FW_CFG_FILE_FIRST |
| 237 | * will be used; also, a new entry will be added to the file directory |
| 238 | * structure residing at key value FW_CFG_FILE_DIR, containing the item name, |
| 239 | * data size, and assigned selector key value. |
| 240 | */ |
Markus Armbruster | 089da57 | 2013-01-16 14:50:28 +0100 | [diff] [blame] | 241 | void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data, |
| 242 | size_t len); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 243 | |
| 244 | /** |
| 245 | * fw_cfg_add_file_callback: |
| 246 | * @s: fw_cfg device being modified |
| 247 | * @filename: name of new fw_cfg file item |
Marc-André Lureau | 6f6f4ae | 2017-08-07 20:16:11 +0200 | [diff] [blame] | 248 | * @select_cb: callback function when selecting |
Marc-André Lureau | 5f9252f | 2017-09-11 18:59:23 +0200 | [diff] [blame] | 249 | * @write_cb: callback function after a write |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 250 | * @callback_opaque: argument to be passed into callback function |
| 251 | * @data: pointer to start of item data |
| 252 | * @len: size of item data |
Michael S. Tsirkin | baf2d5b | 2017-01-12 19:24:14 +0100 | [diff] [blame] | 253 | * @read_only: is file read only |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 254 | * |
| 255 | * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data |
| 256 | * referenced by the starting pointer is only linked, NOT copied, into the |
| 257 | * data structure of the fw_cfg device. |
| 258 | * The next available (unused) selector key starting at FW_CFG_FILE_FIRST |
| 259 | * will be used; also, a new entry will be added to the file directory |
| 260 | * structure residing at key value FW_CFG_FILE_DIR, containing the item name, |
| 261 | * data size, and assigned selector key value. |
| 262 | * Additionally, set a callback function (and argument) to be called each |
Gabriel L. Somlo | 3bef7e8 | 2015-11-05 09:32:48 -0500 | [diff] [blame] | 263 | * time this item is selected (by having its selector key either written to |
| 264 | * the fw_cfg control register, or passed to QEMU in FWCfgDmaAccess.control |
| 265 | * with FW_CFG_DMA_CTL_SELECT). |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 266 | */ |
Michael S. Tsirkin | d87072c | 2013-09-01 17:56:20 +0300 | [diff] [blame] | 267 | void fw_cfg_add_file_callback(FWCfgState *s, const char *filename, |
Marc-André Lureau | 6f6f4ae | 2017-08-07 20:16:11 +0200 | [diff] [blame] | 268 | FWCfgCallback select_cb, |
Marc-André Lureau | 5f9252f | 2017-09-11 18:59:23 +0200 | [diff] [blame] | 269 | FWCfgWriteCallback write_cb, |
Marc-André Lureau | 6f6f4ae | 2017-08-07 20:16:11 +0200 | [diff] [blame] | 270 | void *callback_opaque, |
Michael S. Tsirkin | baf2d5b | 2017-01-12 19:24:14 +0100 | [diff] [blame] | 271 | void *data, size_t len, bool read_only); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 272 | |
| 273 | /** |
| 274 | * fw_cfg_modify_file: |
| 275 | * @s: fw_cfg device being modified |
| 276 | * @filename: name of new fw_cfg file item |
| 277 | * @data: pointer to start of item data |
| 278 | * @len: size of item data |
| 279 | * |
| 280 | * Replace a NAMED fw_cfg item. If an existing item is found, its callback |
| 281 | * information will be cleared, and a pointer to its data will be returned |
| 282 | * to the caller, so that it may be freed if necessary. If an existing item |
| 283 | * is not found, this call defaults to fw_cfg_add_file(), and NULL is |
| 284 | * returned to the caller. |
| 285 | * In either case, the new item data is only linked, NOT copied, into the |
| 286 | * data structure of the fw_cfg device. |
| 287 | * |
| 288 | * Returns: pointer to old item's data, or NULL if old item does not exist. |
| 289 | */ |
Gonglei | bdbb5b1 | 2014-10-07 16:00:08 +0800 | [diff] [blame] | 290 | void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, |
| 291 | size_t len); |
Gabriel L. Somlo | 9c4a5c5 | 2015-11-05 09:32:47 -0500 | [diff] [blame] | 292 | |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 293 | /** |
| 294 | * fw_cfg_add_from_generator: |
| 295 | * @s: fw_cfg device being modified |
| 296 | * @filename: name of new fw_cfg file item |
| 297 | * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface |
| 298 | * @errp: pointer to a NULL initialized error object |
| 299 | * |
| 300 | * Add a new NAMED fw_cfg item with the content generated from the |
| 301 | * @gen_id object. The data generated by the @gen_id object is copied |
| 302 | * into the data structure of the fw_cfg device. |
| 303 | * The next available (unused) selector key starting at FW_CFG_FILE_FIRST |
| 304 | * will be used; also, a new entry will be added to the file directory |
| 305 | * structure residing at key value FW_CFG_FILE_DIR, containing the item name, |
| 306 | * data size, and assigned selector key value. |
Philippe Mathieu-Daudé | 0771951 | 2020-07-20 14:20:15 +0200 | [diff] [blame] | 307 | * |
| 308 | * Returns: %true on success, %false on error. |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 309 | */ |
Philippe Mathieu-Daudé | 0771951 | 2020-07-20 14:20:15 +0200 | [diff] [blame] | 310 | bool fw_cfg_add_from_generator(FWCfgState *s, const char *filename, |
Philippe Mathieu-Daudé | 3203148 | 2020-05-14 15:15:38 +0200 | [diff] [blame] | 311 | const char *gen_id, Error **errp); |
| 312 | |
Jiahui Cen | 0abd388 | 2020-11-19 09:48:34 +0800 | [diff] [blame] | 313 | /** |
| 314 | * fw_cfg_add_extra_pci_roots: |
| 315 | * @bus: main pci root bus to be scanned from |
| 316 | * @s: fw_cfg device being modified |
| 317 | * |
| 318 | * Add a new fw_cfg item... |
| 319 | */ |
| 320 | void fw_cfg_add_extra_pci_roots(PCIBus *bus, FWCfgState *s); |
| 321 | |
Marc Marí | a4c0d1d | 2015-10-08 17:02:55 +0200 | [diff] [blame] | 322 | FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, |
| 323 | AddressSpace *dma_as); |
Laszlo Ersek | 5712db6 | 2014-12-22 13:11:35 +0100 | [diff] [blame] | 324 | FWCfgState *fw_cfg_init_io(uint32_t iobase); |
| 325 | FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr); |
Marc Marí | a4c0d1d | 2015-10-08 17:02:55 +0200 | [diff] [blame] | 326 | FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, |
| 327 | hwaddr data_addr, uint32_t data_width, |
| 328 | hwaddr dma_addr, AddressSpace *dma_as); |
blueswir1 | 3cce624 | 2008-09-18 18:27:29 +0000 | [diff] [blame] | 329 | |
Michael S. Tsirkin | 600c60b | 2013-05-30 16:07:58 +0300 | [diff] [blame] | 330 | FWCfgState *fw_cfg_find(void); |
Marc Marí | b2a575a | 2016-05-23 19:11:33 +0100 | [diff] [blame] | 331 | bool fw_cfg_dma_enabled(void *opaque); |
Michael S. Tsirkin | 600c60b | 2013-05-30 16:07:58 +0300 | [diff] [blame] | 332 | |
Philippe Mathieu-Daudé | b15c0f7 | 2019-04-22 15:49:41 +0200 | [diff] [blame] | 333 | /** |
| 334 | * fw_cfg_arch_key_name: |
| 335 | * |
| 336 | * @key: The uint16 selector key. |
| 337 | * |
| 338 | * The key is architecture-specific (the FW_CFG_ARCH_LOCAL mask is expected |
| 339 | * to be set in the key). |
| 340 | * |
| 341 | * Returns: The stringified architecture-specific name if the selector |
| 342 | * refers to a well-known numerically defined item, or NULL on |
| 343 | * key lookup failure. |
| 344 | */ |
| 345 | const char *fw_cfg_arch_key_name(uint16_t key); |
| 346 | |
Sunil V L | 785a738 | 2022-10-04 14:53:49 +0530 | [diff] [blame] | 347 | /** |
| 348 | * load_image_to_fw_cfg() - Load an image file into an fw_cfg entry identified |
| 349 | * by key. |
| 350 | * @fw_cfg: The firmware config instance to store the data in. |
| 351 | * @size_key: The firmware config key to store the size of the loaded |
| 352 | * data under, with fw_cfg_add_i32(). |
| 353 | * @data_key: The firmware config key to store the loaded data under, |
| 354 | * with fw_cfg_add_bytes(). |
| 355 | * @image_name: The name of the image file to load. If it is NULL, the |
| 356 | * function returns without doing anything. |
| 357 | * @try_decompress: Whether the image should be decompressed (gunzipped) before |
| 358 | * adding it to fw_cfg. If decompression fails, the image is |
| 359 | * loaded as-is. |
| 360 | * |
| 361 | * In case of failure, the function prints an error message to stderr and the |
| 362 | * process exits with status 1. |
| 363 | */ |
| 364 | void load_image_to_fw_cfg(FWCfgState *fw_cfg, uint16_t size_key, |
| 365 | uint16_t data_key, const char *image_name, |
| 366 | bool try_decompress); |
| 367 | |
blueswir1 | 3cce624 | 2008-09-18 18:27:29 +0000 | [diff] [blame] | 368 | #endif |