13cce6243Sblueswir1 #ifndef FW_CFG_H 23cce6243Sblueswir1 #define FW_CFG_H 33cce6243Sblueswir1 41dfe5057SHu Tao #include "exec/hwaddr.h" 55be5df72SMarc-André Lureau #include "standard-headers/linux/qemu_fw_cfg.h" 639736e18SMark Cave-Ayland #include "hw/sysbus.h" 7*32cad1ffSPhilippe Mathieu-Daudé #include "system/dma.h" 8db1015e9SEduardo Habkost #include "qom/object.h" 939736e18SMark Cave-Ayland 1039736e18SMark Cave-Ayland #define TYPE_FW_CFG "fw_cfg" 1139736e18SMark Cave-Ayland #define TYPE_FW_CFG_IO "fw_cfg_io" 1239736e18SMark Cave-Ayland #define TYPE_FW_CFG_MEM "fw_cfg_mem" 1332031489SPhilippe Mathieu-Daudé #define TYPE_FW_CFG_DATA_GENERATOR_INTERFACE "fw_cfg-data-generator" 1439736e18SMark Cave-Ayland 158063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(FWCfgState, FW_CFG) 168063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(FWCfgIoState, FW_CFG_IO) 178063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(FWCfgMemState, FW_CFG_MEM) 181dfe5057SHu Tao 19db1015e9SEduardo Habkost typedef struct FWCfgDataGeneratorClass FWCfgDataGeneratorClass; 208110fa1dSEduardo Habkost DECLARE_CLASS_CHECKERS(FWCfgDataGeneratorClass, FW_CFG_DATA_GENERATOR, 2132031489SPhilippe Mathieu-Daudé TYPE_FW_CFG_DATA_GENERATOR_INTERFACE) 2232031489SPhilippe Mathieu-Daudé 23db1015e9SEduardo Habkost struct FWCfgDataGeneratorClass { 2432031489SPhilippe Mathieu-Daudé /*< private >*/ 2532031489SPhilippe Mathieu-Daudé InterfaceClass parent_class; 2632031489SPhilippe Mathieu-Daudé /*< public >*/ 2732031489SPhilippe Mathieu-Daudé 2832031489SPhilippe Mathieu-Daudé /** 2932031489SPhilippe Mathieu-Daudé * get_data: 3032031489SPhilippe Mathieu-Daudé * @obj: the object implementing this interface 3132031489SPhilippe Mathieu-Daudé * @errp: pointer to a NULL-initialized error object 3232031489SPhilippe Mathieu-Daudé * 334016adc7SPhilippe Mathieu-Daudé * Returns: A byte array containing data to add, or NULL without 344016adc7SPhilippe Mathieu-Daudé * @errp set if no data is required, or NULL with @errp 354016adc7SPhilippe Mathieu-Daudé * set on failure. 36a3ad5834SPhilippe Mathieu-Daudé * 3732031489SPhilippe Mathieu-Daudé * The caller should release the reference when no longer 3832031489SPhilippe Mathieu-Daudé * required. 3932031489SPhilippe Mathieu-Daudé */ 4032031489SPhilippe Mathieu-Daudé GByteArray *(*get_data)(Object *obj, Error **errp); 41db1015e9SEduardo Habkost }; 4232031489SPhilippe Mathieu-Daudé 435be5df72SMarc-André Lureau typedef struct fw_cfg_file FWCfgFile; 44abe147e0SGerd Hoffmann 45abe147e0SGerd Hoffmann typedef struct FWCfgFiles { 46abe147e0SGerd Hoffmann uint32_t count; 47abe147e0SGerd Hoffmann FWCfgFile f[]; 48abe147e0SGerd Hoffmann } FWCfgFiles; 49abe147e0SGerd Hoffmann 505be5df72SMarc-André Lureau typedef struct fw_cfg_dma_access FWCfgDmaAccess; 51a4c0d1deSMarc Marí 526f6f4aecSMarc-André Lureau typedef void (*FWCfgCallback)(void *opaque); 535f9252f7SMarc-André Lureau typedef void (*FWCfgWriteCallback)(void *opaque, off_t start, size_t len); 543cce6243Sblueswir1 55c71a42b5SPaolo Bonzini typedef struct FWCfgEntry FWCfgEntry; 56c71a42b5SPaolo Bonzini 5739736e18SMark Cave-Ayland struct FWCfgState { 5839736e18SMark Cave-Ayland /*< private >*/ 5939736e18SMark Cave-Ayland SysBusDevice parent_obj; 6039736e18SMark Cave-Ayland /*< public >*/ 6139736e18SMark Cave-Ayland 6239736e18SMark Cave-Ayland uint16_t file_slots; 6339736e18SMark Cave-Ayland FWCfgEntry *entries[2]; 6439736e18SMark Cave-Ayland int *entry_order; 6539736e18SMark Cave-Ayland FWCfgFiles *files; 6639736e18SMark Cave-Ayland uint16_t cur_entry; 6739736e18SMark Cave-Ayland uint32_t cur_offset; 6839736e18SMark Cave-Ayland Notifier machine_ready; 6939736e18SMark Cave-Ayland 7039736e18SMark Cave-Ayland bool dma_enabled; 7139736e18SMark Cave-Ayland dma_addr_t dma_addr; 7239736e18SMark Cave-Ayland AddressSpace *dma_as; 7339736e18SMark Cave-Ayland MemoryRegion dma_iomem; 74394f0f72SShameer Kolothum 75394f0f72SShameer Kolothum /* restore during migration */ 76394f0f72SShameer Kolothum bool acpi_mr_restore; 77394f0f72SShameer Kolothum uint64_t table_mr_size; 78394f0f72SShameer Kolothum uint64_t linker_mr_size; 79394f0f72SShameer Kolothum uint64_t rsdp_mr_size; 8039736e18SMark Cave-Ayland }; 8139736e18SMark Cave-Ayland 8239736e18SMark Cave-Ayland struct FWCfgIoState { 8339736e18SMark Cave-Ayland /*< private >*/ 8439736e18SMark Cave-Ayland FWCfgState parent_obj; 8539736e18SMark Cave-Ayland /*< public >*/ 8639736e18SMark Cave-Ayland 8739736e18SMark Cave-Ayland MemoryRegion comb_iomem; 8839736e18SMark Cave-Ayland }; 8939736e18SMark Cave-Ayland 9039736e18SMark Cave-Ayland struct FWCfgMemState { 9139736e18SMark Cave-Ayland /*< private >*/ 9239736e18SMark Cave-Ayland FWCfgState parent_obj; 9339736e18SMark Cave-Ayland /*< public >*/ 9439736e18SMark Cave-Ayland 9539736e18SMark Cave-Ayland MemoryRegion ctl_iomem, data_iomem; 9639736e18SMark Cave-Ayland uint32_t data_width; 9739736e18SMark Cave-Ayland MemoryRegionOps wide_data_ops; 9839736e18SMark Cave-Ayland }; 9939736e18SMark Cave-Ayland 1009c4a5c55SGabriel L. Somlo /** 1019c4a5c55SGabriel L. Somlo * fw_cfg_add_bytes: 1029c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 1039c4a5c55SGabriel L. Somlo * @key: selector key value for new fw_cfg item 1049c4a5c55SGabriel L. Somlo * @data: pointer to start of item data 1059c4a5c55SGabriel L. Somlo * @len: size of item data 1069c4a5c55SGabriel L. Somlo * 1079c4a5c55SGabriel L. Somlo * Add a new fw_cfg item, available by selecting the given key, as a raw 1089c4a5c55SGabriel L. Somlo * "blob" of the given size. The data referenced by the starting pointer 1099c4a5c55SGabriel L. Somlo * is only linked, NOT copied, into the data structure of the fw_cfg device. 1109c4a5c55SGabriel L. Somlo */ 111089da572SMarkus Armbruster void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len); 1129c4a5c55SGabriel L. Somlo 1139c4a5c55SGabriel L. Somlo /** 1149c4a5c55SGabriel L. Somlo * fw_cfg_add_string: 1159c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 1169c4a5c55SGabriel L. Somlo * @key: selector key value for new fw_cfg item 1179c4a5c55SGabriel L. Somlo * @value: NUL-terminated ascii string 1189c4a5c55SGabriel L. Somlo * 1199c4a5c55SGabriel L. Somlo * Add a new fw_cfg item, available by selecting the given key. The item 1209c4a5c55SGabriel L. Somlo * data will consist of a dynamically allocated copy of the provided string, 1219c4a5c55SGabriel L. Somlo * including its NUL terminator. 1229c4a5c55SGabriel L. Somlo */ 12344687f75SMarkus Armbruster void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value); 1249c4a5c55SGabriel L. Somlo 1259c4a5c55SGabriel L. Somlo /** 126e5f6aa31SSergio Lopez * fw_cfg_modify_string: 127e5f6aa31SSergio Lopez * @s: fw_cfg device being modified 128e5f6aa31SSergio Lopez * @key: selector key value for new fw_cfg item 129e5f6aa31SSergio Lopez * @value: NUL-terminated ascii string 130e5f6aa31SSergio Lopez * 131e5f6aa31SSergio Lopez * Replace the fw_cfg item available by selecting the given key. The new 132e5f6aa31SSergio Lopez * data will consist of a dynamically allocated copy of the provided string, 133e5f6aa31SSergio Lopez * including its NUL terminator. The data being replaced, assumed to have 134e5f6aa31SSergio Lopez * been dynamically allocated during an earlier call to either 135e5f6aa31SSergio Lopez * fw_cfg_add_string() or fw_cfg_modify_string(), is freed before returning. 136e5f6aa31SSergio Lopez */ 137e5f6aa31SSergio Lopez void fw_cfg_modify_string(FWCfgState *s, uint16_t key, const char *value); 138e5f6aa31SSergio Lopez 139e5f6aa31SSergio Lopez /** 1409c4a5c55SGabriel L. Somlo * fw_cfg_add_i16: 1419c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 1429c4a5c55SGabriel L. Somlo * @key: selector key value for new fw_cfg item 1439c4a5c55SGabriel L. Somlo * @value: 16-bit integer 1449c4a5c55SGabriel L. Somlo * 1459c4a5c55SGabriel L. Somlo * Add a new fw_cfg item, available by selecting the given key. The item 1469c4a5c55SGabriel L. Somlo * data will consist of a dynamically allocated copy of the given 16-bit 1479c4a5c55SGabriel L. Somlo * value, converted to little-endian representation. 1489c4a5c55SGabriel L. Somlo */ 1494cad3867SMarkus Armbruster void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value); 1509c4a5c55SGabriel L. Somlo 1519c4a5c55SGabriel L. Somlo /** 1529c4a5c55SGabriel L. Somlo * fw_cfg_modify_i16: 1539c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 1549c4a5c55SGabriel L. Somlo * @key: selector key value for new fw_cfg item 1559c4a5c55SGabriel L. Somlo * @value: 16-bit integer 1569c4a5c55SGabriel L. Somlo * 1579c4a5c55SGabriel L. Somlo * Replace the fw_cfg item available by selecting the given key. The new 1589c4a5c55SGabriel L. Somlo * data will consist of a dynamically allocated copy of the given 16-bit 1599c4a5c55SGabriel L. Somlo * value, converted to little-endian representation. The data being replaced, 1609c4a5c55SGabriel L. Somlo * assumed to have been dynamically allocated during an earlier call to 1619c4a5c55SGabriel L. Somlo * either fw_cfg_add_i16() or fw_cfg_modify_i16(), is freed before returning. 1629c4a5c55SGabriel L. Somlo */ 1631edd34b6SGabriel L. Somlo void fw_cfg_modify_i16(FWCfgState *s, uint16_t key, uint16_t value); 1649c4a5c55SGabriel L. Somlo 1659c4a5c55SGabriel L. Somlo /** 1669c4a5c55SGabriel L. Somlo * fw_cfg_add_i32: 1679c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 1689c4a5c55SGabriel L. Somlo * @key: selector key value for new fw_cfg item 1699c4a5c55SGabriel L. Somlo * @value: 32-bit integer 1709c4a5c55SGabriel L. Somlo * 1719c4a5c55SGabriel L. Somlo * Add a new fw_cfg item, available by selecting the given key. The item 1729c4a5c55SGabriel L. Somlo * data will consist of a dynamically allocated copy of the given 32-bit 1739c4a5c55SGabriel L. Somlo * value, converted to little-endian representation. 1749c4a5c55SGabriel L. Somlo */ 1754cad3867SMarkus Armbruster void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value); 1769c4a5c55SGabriel L. Somlo 1779c4a5c55SGabriel L. Somlo /** 178e5f6aa31SSergio Lopez * fw_cfg_modify_i32: 179e5f6aa31SSergio Lopez * @s: fw_cfg device being modified 180e5f6aa31SSergio Lopez * @key: selector key value for new fw_cfg item 181e5f6aa31SSergio Lopez * @value: 32-bit integer 182e5f6aa31SSergio Lopez * 183e5f6aa31SSergio Lopez * Replace the fw_cfg item available by selecting the given key. The new 184e5f6aa31SSergio Lopez * data will consist of a dynamically allocated copy of the given 32-bit 185e5f6aa31SSergio Lopez * value, converted to little-endian representation. The data being replaced, 186e5f6aa31SSergio Lopez * assumed to have been dynamically allocated during an earlier call to 187e5f6aa31SSergio Lopez * either fw_cfg_add_i32() or fw_cfg_modify_i32(), is freed before returning. 188e5f6aa31SSergio Lopez */ 189e5f6aa31SSergio Lopez void fw_cfg_modify_i32(FWCfgState *s, uint16_t key, uint32_t value); 190e5f6aa31SSergio Lopez 191e5f6aa31SSergio Lopez /** 1929c4a5c55SGabriel L. Somlo * fw_cfg_add_i64: 1939c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 1949c4a5c55SGabriel L. Somlo * @key: selector key value for new fw_cfg item 1959c4a5c55SGabriel L. Somlo * @value: 64-bit integer 1969c4a5c55SGabriel L. Somlo * 1979c4a5c55SGabriel L. Somlo * Add a new fw_cfg item, available by selecting the given key. The item 1989c4a5c55SGabriel L. Somlo * data will consist of a dynamically allocated copy of the given 64-bit 1999c4a5c55SGabriel L. Somlo * value, converted to little-endian representation. 2009c4a5c55SGabriel L. Somlo */ 2014cad3867SMarkus Armbruster void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value); 2029c4a5c55SGabriel L. Somlo 2039c4a5c55SGabriel L. Somlo /** 204e5f6aa31SSergio Lopez * fw_cfg_modify_i64: 205e5f6aa31SSergio Lopez * @s: fw_cfg device being modified 206e5f6aa31SSergio Lopez * @key: selector key value for new fw_cfg item 207e5f6aa31SSergio Lopez * @value: 64-bit integer 208e5f6aa31SSergio Lopez * 209e5f6aa31SSergio Lopez * Replace the fw_cfg item available by selecting the given key. The new 210e5f6aa31SSergio Lopez * data will consist of a dynamically allocated copy of the given 64-bit 211e5f6aa31SSergio Lopez * value, converted to little-endian representation. The data being replaced, 212e5f6aa31SSergio Lopez * assumed to have been dynamically allocated during an earlier call to 213e5f6aa31SSergio Lopez * either fw_cfg_add_i64() or fw_cfg_modify_i64(), is freed before returning. 214e5f6aa31SSergio Lopez */ 215e5f6aa31SSergio Lopez void fw_cfg_modify_i64(FWCfgState *s, uint16_t key, uint64_t value); 216e5f6aa31SSergio Lopez 217e5f6aa31SSergio Lopez /** 2189c4a5c55SGabriel L. Somlo * fw_cfg_add_file: 2199c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 2209c4a5c55SGabriel L. Somlo * @filename: name of new fw_cfg file item 2219c4a5c55SGabriel L. Somlo * @data: pointer to start of item data 2229c4a5c55SGabriel L. Somlo * @len: size of item data 2239c4a5c55SGabriel L. Somlo * 2249c4a5c55SGabriel L. Somlo * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data 2259c4a5c55SGabriel L. Somlo * referenced by the starting pointer is only linked, NOT copied, into the 2269c4a5c55SGabriel L. Somlo * data structure of the fw_cfg device. 2279c4a5c55SGabriel L. Somlo * The next available (unused) selector key starting at FW_CFG_FILE_FIRST 2289c4a5c55SGabriel L. Somlo * will be used; also, a new entry will be added to the file directory 2299c4a5c55SGabriel L. Somlo * structure residing at key value FW_CFG_FILE_DIR, containing the item name, 2309c4a5c55SGabriel L. Somlo * data size, and assigned selector key value. 2319c4a5c55SGabriel L. Somlo */ 232089da572SMarkus Armbruster void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data, 233089da572SMarkus Armbruster size_t len); 2349c4a5c55SGabriel L. Somlo 2359c4a5c55SGabriel L. Somlo /** 2369c4a5c55SGabriel L. Somlo * fw_cfg_add_file_callback: 2379c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 2389c4a5c55SGabriel L. Somlo * @filename: name of new fw_cfg file item 2396f6f4aecSMarc-André Lureau * @select_cb: callback function when selecting 2405f9252f7SMarc-André Lureau * @write_cb: callback function after a write 2419c4a5c55SGabriel L. Somlo * @callback_opaque: argument to be passed into callback function 2429c4a5c55SGabriel L. Somlo * @data: pointer to start of item data 2439c4a5c55SGabriel L. Somlo * @len: size of item data 244baf2d5bfSMichael S. Tsirkin * @read_only: is file read only 2459c4a5c55SGabriel L. Somlo * 2469c4a5c55SGabriel L. Somlo * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data 2479c4a5c55SGabriel L. Somlo * referenced by the starting pointer is only linked, NOT copied, into the 2489c4a5c55SGabriel L. Somlo * data structure of the fw_cfg device. 2499c4a5c55SGabriel L. Somlo * The next available (unused) selector key starting at FW_CFG_FILE_FIRST 2509c4a5c55SGabriel L. Somlo * will be used; also, a new entry will be added to the file directory 2519c4a5c55SGabriel L. Somlo * structure residing at key value FW_CFG_FILE_DIR, containing the item name, 2529c4a5c55SGabriel L. Somlo * data size, and assigned selector key value. 2539c4a5c55SGabriel L. Somlo * Additionally, set a callback function (and argument) to be called each 2543bef7e8aSGabriel L. Somlo * time this item is selected (by having its selector key either written to 2553bef7e8aSGabriel L. Somlo * the fw_cfg control register, or passed to QEMU in FWCfgDmaAccess.control 2563bef7e8aSGabriel L. Somlo * with FW_CFG_DMA_CTL_SELECT). 2579c4a5c55SGabriel L. Somlo */ 258d87072ceSMichael S. Tsirkin void fw_cfg_add_file_callback(FWCfgState *s, const char *filename, 2596f6f4aecSMarc-André Lureau FWCfgCallback select_cb, 2605f9252f7SMarc-André Lureau FWCfgWriteCallback write_cb, 2616f6f4aecSMarc-André Lureau void *callback_opaque, 262baf2d5bfSMichael S. Tsirkin void *data, size_t len, bool read_only); 2639c4a5c55SGabriel L. Somlo 2649c4a5c55SGabriel L. Somlo /** 2659c4a5c55SGabriel L. Somlo * fw_cfg_modify_file: 2669c4a5c55SGabriel L. Somlo * @s: fw_cfg device being modified 2679c4a5c55SGabriel L. Somlo * @filename: name of new fw_cfg file item 2689c4a5c55SGabriel L. Somlo * @data: pointer to start of item data 2699c4a5c55SGabriel L. Somlo * @len: size of item data 2709c4a5c55SGabriel L. Somlo * 2719c4a5c55SGabriel L. Somlo * Replace a NAMED fw_cfg item. If an existing item is found, its callback 2729c4a5c55SGabriel L. Somlo * information will be cleared, and a pointer to its data will be returned 2739c4a5c55SGabriel L. Somlo * to the caller, so that it may be freed if necessary. If an existing item 2749c4a5c55SGabriel L. Somlo * is not found, this call defaults to fw_cfg_add_file(), and NULL is 2759c4a5c55SGabriel L. Somlo * returned to the caller. 2769c4a5c55SGabriel L. Somlo * In either case, the new item data is only linked, NOT copied, into the 2779c4a5c55SGabriel L. Somlo * data structure of the fw_cfg device. 2789c4a5c55SGabriel L. Somlo * 2799c4a5c55SGabriel L. Somlo * Returns: pointer to old item's data, or NULL if old item does not exist. 2809c4a5c55SGabriel L. Somlo */ 281bdbb5b17SGonglei void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, 282bdbb5b17SGonglei size_t len); 2839c4a5c55SGabriel L. Somlo 28432031489SPhilippe Mathieu-Daudé /** 285e20a4425SPhilippe Mathieu-Daudé * fw_cfg_add_file_from_generator: 28632031489SPhilippe Mathieu-Daudé * @s: fw_cfg device being modified 28732031489SPhilippe Mathieu-Daudé * @filename: name of new fw_cfg file item 28851680269SPhilippe Mathieu-Daudé * @part: name of object implementing FW_CFG_DATA_GENERATOR interface 28951680269SPhilippe Mathieu-Daudé * @parent: the object in which to resolve the @part 29032031489SPhilippe Mathieu-Daudé * @errp: pointer to a NULL initialized error object 29132031489SPhilippe Mathieu-Daudé * 2924016adc7SPhilippe Mathieu-Daudé * If the @part object generates content, add a new NAMED fw_cfg item with it. 2934016adc7SPhilippe Mathieu-Daudé * The data generated by the @part object is copied into the data structure of 2944016adc7SPhilippe Mathieu-Daudé * the fw_cfg device. 29532031489SPhilippe Mathieu-Daudé * The next available (unused) selector key starting at FW_CFG_FILE_FIRST 29632031489SPhilippe Mathieu-Daudé * will be used; also, a new entry will be added to the file directory 29732031489SPhilippe Mathieu-Daudé * structure residing at key value FW_CFG_FILE_DIR, containing the item name, 29832031489SPhilippe Mathieu-Daudé * data size, and assigned selector key value. 29907719518SPhilippe Mathieu-Daudé * 3004016adc7SPhilippe Mathieu-Daudé * If the @part object does not generate content, no fw_cfg item is added. 3014016adc7SPhilippe Mathieu-Daudé * 30207719518SPhilippe Mathieu-Daudé * Returns: %true on success, %false on error. 30332031489SPhilippe Mathieu-Daudé */ 30451680269SPhilippe Mathieu-Daudé bool fw_cfg_add_file_from_generator(FWCfgState *s, 30551680269SPhilippe Mathieu-Daudé Object *parent, const char *part, 30651680269SPhilippe Mathieu-Daudé const char *filename, Error **errp); 30732031489SPhilippe Mathieu-Daudé 308a4c0d1deSMarc Marí FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, 309a4c0d1deSMarc Marí AddressSpace *dma_as); 3105712db6aSLaszlo Ersek FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr); 311a4c0d1deSMarc Marí FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, 312a4c0d1deSMarc Marí hwaddr data_addr, uint32_t data_width, 313a4c0d1deSMarc Marí hwaddr dma_addr, AddressSpace *dma_as); 3143cce6243Sblueswir1 315600c60b7SMichael S. Tsirkin FWCfgState *fw_cfg_find(void); 316b2a575a1SMarc Marí bool fw_cfg_dma_enabled(void *opaque); 317600c60b7SMichael S. Tsirkin 318b15c0f7dSPhilippe Mathieu-Daudé /** 319b15c0f7dSPhilippe Mathieu-Daudé * fw_cfg_arch_key_name: 320b15c0f7dSPhilippe Mathieu-Daudé * 321b15c0f7dSPhilippe Mathieu-Daudé * @key: The uint16 selector key. 322b15c0f7dSPhilippe Mathieu-Daudé * 323b15c0f7dSPhilippe Mathieu-Daudé * The key is architecture-specific (the FW_CFG_ARCH_LOCAL mask is expected 324b15c0f7dSPhilippe Mathieu-Daudé * to be set in the key). 325b15c0f7dSPhilippe Mathieu-Daudé * 326b15c0f7dSPhilippe Mathieu-Daudé * Returns: The stringified architecture-specific name if the selector 327b15c0f7dSPhilippe Mathieu-Daudé * refers to a well-known numerically defined item, or NULL on 328b15c0f7dSPhilippe Mathieu-Daudé * key lookup failure. 329b15c0f7dSPhilippe Mathieu-Daudé */ 330b15c0f7dSPhilippe Mathieu-Daudé const char *fw_cfg_arch_key_name(uint16_t key); 331b15c0f7dSPhilippe Mathieu-Daudé 332785a7383SSunil V L /** 333785a7383SSunil V L * load_image_to_fw_cfg() - Load an image file into an fw_cfg entry identified 334785a7383SSunil V L * by key. 335785a7383SSunil V L * @fw_cfg: The firmware config instance to store the data in. 336785a7383SSunil V L * @size_key: The firmware config key to store the size of the loaded 337785a7383SSunil V L * data under, with fw_cfg_add_i32(). 338785a7383SSunil V L * @data_key: The firmware config key to store the loaded data under, 339785a7383SSunil V L * with fw_cfg_add_bytes(). 340785a7383SSunil V L * @image_name: The name of the image file to load. If it is NULL, the 341785a7383SSunil V L * function returns without doing anything. 342785a7383SSunil V L * @try_decompress: Whether the image should be decompressed (gunzipped) before 343785a7383SSunil V L * adding it to fw_cfg. If decompression fails, the image is 344785a7383SSunil V L * loaded as-is. 345785a7383SSunil V L * 346785a7383SSunil V L * In case of failure, the function prints an error message to stderr and the 347785a7383SSunil V L * process exits with status 1. 348785a7383SSunil V L */ 349785a7383SSunil V L void load_image_to_fw_cfg(FWCfgState *fw_cfg, uint16_t size_key, 350785a7383SSunil V L uint16_t data_key, const char *image_name, 351785a7383SSunil V L bool try_decompress); 352785a7383SSunil V L 3533cce6243Sblueswir1 #endif 354