xref: /qemu/include/hw/nvram/fw_cfg.h (revision 3203148917d035b09f71986ac2eaa19a352d6d9d)
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"
739736e18SMark Cave-Ayland #include "sysemu/dma.h"
839736e18SMark Cave-Ayland 
939736e18SMark Cave-Ayland #define TYPE_FW_CFG     "fw_cfg"
1039736e18SMark Cave-Ayland #define TYPE_FW_CFG_IO  "fw_cfg_io"
1139736e18SMark Cave-Ayland #define TYPE_FW_CFG_MEM "fw_cfg_mem"
12*32031489SPhilippe Mathieu-Daudé #define TYPE_FW_CFG_DATA_GENERATOR_INTERFACE "fw_cfg-data-generator"
1339736e18SMark Cave-Ayland 
1439736e18SMark Cave-Ayland #define FW_CFG(obj)     OBJECT_CHECK(FWCfgState,    (obj), TYPE_FW_CFG)
1539736e18SMark Cave-Ayland #define FW_CFG_IO(obj)  OBJECT_CHECK(FWCfgIoState,  (obj), TYPE_FW_CFG_IO)
1639736e18SMark Cave-Ayland #define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM)
171dfe5057SHu Tao 
18*32031489SPhilippe Mathieu-Daudé #define FW_CFG_DATA_GENERATOR_CLASS(class) \
19*32031489SPhilippe Mathieu-Daudé     OBJECT_CLASS_CHECK(FWCfgDataGeneratorClass, (class), \
20*32031489SPhilippe Mathieu-Daudé                        TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)
21*32031489SPhilippe Mathieu-Daudé #define FW_CFG_DATA_GENERATOR_GET_CLASS(obj) \
22*32031489SPhilippe Mathieu-Daudé     OBJECT_GET_CLASS(FWCfgDataGeneratorClass, (obj), \
23*32031489SPhilippe Mathieu-Daudé                      TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)
24*32031489SPhilippe Mathieu-Daudé 
25*32031489SPhilippe Mathieu-Daudé typedef struct FWCfgDataGeneratorClass {
26*32031489SPhilippe Mathieu-Daudé     /*< private >*/
27*32031489SPhilippe Mathieu-Daudé     InterfaceClass parent_class;
28*32031489SPhilippe Mathieu-Daudé     /*< public >*/
29*32031489SPhilippe Mathieu-Daudé 
30*32031489SPhilippe Mathieu-Daudé     /**
31*32031489SPhilippe Mathieu-Daudé      * get_data:
32*32031489SPhilippe Mathieu-Daudé      * @obj: the object implementing this interface
33*32031489SPhilippe Mathieu-Daudé      * @errp: pointer to a NULL-initialized error object
34*32031489SPhilippe Mathieu-Daudé      *
35*32031489SPhilippe Mathieu-Daudé      * Returns: reference to a byte array containing the data.
36*32031489SPhilippe Mathieu-Daudé      * The caller should release the reference when no longer
37*32031489SPhilippe Mathieu-Daudé      * required.
38*32031489SPhilippe Mathieu-Daudé      */
39*32031489SPhilippe Mathieu-Daudé     GByteArray *(*get_data)(Object *obj, Error **errp);
40*32031489SPhilippe Mathieu-Daudé } FWCfgDataGeneratorClass;
41*32031489SPhilippe Mathieu-Daudé 
425be5df72SMarc-André Lureau typedef struct fw_cfg_file FWCfgFile;
43abe147e0SGerd Hoffmann 
44bab47d9aSGerd Hoffmann #define FW_CFG_ORDER_OVERRIDE_VGA    70
45bab47d9aSGerd Hoffmann #define FW_CFG_ORDER_OVERRIDE_NIC    80
46bab47d9aSGerd Hoffmann #define FW_CFG_ORDER_OVERRIDE_USER   100
47bab47d9aSGerd Hoffmann #define FW_CFG_ORDER_OVERRIDE_DEVICE 110
48bab47d9aSGerd Hoffmann 
49bab47d9aSGerd Hoffmann void fw_cfg_set_order_override(FWCfgState *fw_cfg, int order);
50bab47d9aSGerd Hoffmann void fw_cfg_reset_order_override(FWCfgState *fw_cfg);
51bab47d9aSGerd Hoffmann 
52abe147e0SGerd Hoffmann typedef struct FWCfgFiles {
53abe147e0SGerd Hoffmann     uint32_t  count;
54abe147e0SGerd Hoffmann     FWCfgFile f[];
55abe147e0SGerd Hoffmann } FWCfgFiles;
56abe147e0SGerd Hoffmann 
575be5df72SMarc-André Lureau typedef struct fw_cfg_dma_access FWCfgDmaAccess;
58a4c0d1deSMarc Marí 
596f6f4aecSMarc-André Lureau typedef void (*FWCfgCallback)(void *opaque);
605f9252f7SMarc-André Lureau typedef void (*FWCfgWriteCallback)(void *opaque, off_t start, size_t len);
613cce6243Sblueswir1 
6239736e18SMark Cave-Ayland struct FWCfgState {
6339736e18SMark Cave-Ayland     /*< private >*/
6439736e18SMark Cave-Ayland     SysBusDevice parent_obj;
6539736e18SMark Cave-Ayland     /*< public >*/
6639736e18SMark Cave-Ayland 
6739736e18SMark Cave-Ayland     uint16_t file_slots;
6839736e18SMark Cave-Ayland     FWCfgEntry *entries[2];
6939736e18SMark Cave-Ayland     int *entry_order;
7039736e18SMark Cave-Ayland     FWCfgFiles *files;
7139736e18SMark Cave-Ayland     uint16_t cur_entry;
7239736e18SMark Cave-Ayland     uint32_t cur_offset;
7339736e18SMark Cave-Ayland     Notifier machine_ready;
7439736e18SMark Cave-Ayland 
7539736e18SMark Cave-Ayland     int fw_cfg_order_override;
7639736e18SMark Cave-Ayland 
7739736e18SMark Cave-Ayland     bool dma_enabled;
7839736e18SMark Cave-Ayland     dma_addr_t dma_addr;
7939736e18SMark Cave-Ayland     AddressSpace *dma_as;
8039736e18SMark Cave-Ayland     MemoryRegion dma_iomem;
81394f0f72SShameer Kolothum 
82394f0f72SShameer Kolothum     /* restore during migration */
83394f0f72SShameer Kolothum     bool acpi_mr_restore;
84394f0f72SShameer Kolothum     uint64_t table_mr_size;
85394f0f72SShameer Kolothum     uint64_t linker_mr_size;
86394f0f72SShameer Kolothum     uint64_t rsdp_mr_size;
8739736e18SMark Cave-Ayland };
8839736e18SMark Cave-Ayland 
8939736e18SMark Cave-Ayland struct FWCfgIoState {
9039736e18SMark Cave-Ayland     /*< private >*/
9139736e18SMark Cave-Ayland     FWCfgState parent_obj;
9239736e18SMark Cave-Ayland     /*< public >*/
9339736e18SMark Cave-Ayland 
9439736e18SMark Cave-Ayland     MemoryRegion comb_iomem;
9539736e18SMark Cave-Ayland };
9639736e18SMark Cave-Ayland 
9739736e18SMark Cave-Ayland struct FWCfgMemState {
9839736e18SMark Cave-Ayland     /*< private >*/
9939736e18SMark Cave-Ayland     FWCfgState parent_obj;
10039736e18SMark Cave-Ayland     /*< public >*/
10139736e18SMark Cave-Ayland 
10239736e18SMark Cave-Ayland     MemoryRegion ctl_iomem, data_iomem;
10339736e18SMark Cave-Ayland     uint32_t data_width;
10439736e18SMark Cave-Ayland     MemoryRegionOps wide_data_ops;
10539736e18SMark Cave-Ayland };
10639736e18SMark Cave-Ayland 
1079c4a5c55SGabriel L. Somlo /**
1089c4a5c55SGabriel L. Somlo  * fw_cfg_add_bytes:
1099c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
1109c4a5c55SGabriel L. Somlo  * @key: selector key value for new fw_cfg item
1119c4a5c55SGabriel L. Somlo  * @data: pointer to start of item data
1129c4a5c55SGabriel L. Somlo  * @len: size of item data
1139c4a5c55SGabriel L. Somlo  *
1149c4a5c55SGabriel L. Somlo  * Add a new fw_cfg item, available by selecting the given key, as a raw
1159c4a5c55SGabriel L. Somlo  * "blob" of the given size. The data referenced by the starting pointer
1169c4a5c55SGabriel L. Somlo  * is only linked, NOT copied, into the data structure of the fw_cfg device.
1179c4a5c55SGabriel L. Somlo  */
118089da572SMarkus Armbruster void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
1199c4a5c55SGabriel L. Somlo 
1209c4a5c55SGabriel L. Somlo /**
1219c4a5c55SGabriel L. Somlo  * fw_cfg_add_string:
1229c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
1239c4a5c55SGabriel L. Somlo  * @key: selector key value for new fw_cfg item
1249c4a5c55SGabriel L. Somlo  * @value: NUL-terminated ascii string
1259c4a5c55SGabriel L. Somlo  *
1269c4a5c55SGabriel L. Somlo  * Add a new fw_cfg item, available by selecting the given key. The item
1279c4a5c55SGabriel L. Somlo  * data will consist of a dynamically allocated copy of the provided string,
1289c4a5c55SGabriel L. Somlo  * including its NUL terminator.
1299c4a5c55SGabriel L. Somlo  */
13044687f75SMarkus Armbruster void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value);
1319c4a5c55SGabriel L. Somlo 
1329c4a5c55SGabriel L. Somlo /**
133e5f6aa31SSergio Lopez  * fw_cfg_modify_string:
134e5f6aa31SSergio Lopez  * @s: fw_cfg device being modified
135e5f6aa31SSergio Lopez  * @key: selector key value for new fw_cfg item
136e5f6aa31SSergio Lopez  * @value: NUL-terminated ascii string
137e5f6aa31SSergio Lopez  *
138e5f6aa31SSergio Lopez  * Replace the fw_cfg item available by selecting the given key. The new
139e5f6aa31SSergio Lopez  * data will consist of a dynamically allocated copy of the provided string,
140e5f6aa31SSergio Lopez  * including its NUL terminator. The data being replaced, assumed to have
141e5f6aa31SSergio Lopez  * been dynamically allocated during an earlier call to either
142e5f6aa31SSergio Lopez  * fw_cfg_add_string() or fw_cfg_modify_string(), is freed before returning.
143e5f6aa31SSergio Lopez  */
144e5f6aa31SSergio Lopez void fw_cfg_modify_string(FWCfgState *s, uint16_t key, const char *value);
145e5f6aa31SSergio Lopez 
146e5f6aa31SSergio Lopez /**
1479c4a5c55SGabriel L. Somlo  * fw_cfg_add_i16:
1489c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
1499c4a5c55SGabriel L. Somlo  * @key: selector key value for new fw_cfg item
1509c4a5c55SGabriel L. Somlo  * @value: 16-bit integer
1519c4a5c55SGabriel L. Somlo  *
1529c4a5c55SGabriel L. Somlo  * Add a new fw_cfg item, available by selecting the given key. The item
1539c4a5c55SGabriel L. Somlo  * data will consist of a dynamically allocated copy of the given 16-bit
1549c4a5c55SGabriel L. Somlo  * value, converted to little-endian representation.
1559c4a5c55SGabriel L. Somlo  */
1564cad3867SMarkus Armbruster void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value);
1579c4a5c55SGabriel L. Somlo 
1589c4a5c55SGabriel L. Somlo /**
1599c4a5c55SGabriel L. Somlo  * fw_cfg_modify_i16:
1609c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
1619c4a5c55SGabriel L. Somlo  * @key: selector key value for new fw_cfg item
1629c4a5c55SGabriel L. Somlo  * @value: 16-bit integer
1639c4a5c55SGabriel L. Somlo  *
1649c4a5c55SGabriel L. Somlo  * Replace the fw_cfg item available by selecting the given key. The new
1659c4a5c55SGabriel L. Somlo  * data will consist of a dynamically allocated copy of the given 16-bit
1669c4a5c55SGabriel L. Somlo  * value, converted to little-endian representation. The data being replaced,
1679c4a5c55SGabriel L. Somlo  * assumed to have been dynamically allocated during an earlier call to
1689c4a5c55SGabriel L. Somlo  * either fw_cfg_add_i16() or fw_cfg_modify_i16(), is freed before returning.
1699c4a5c55SGabriel L. Somlo  */
1701edd34b6SGabriel L. Somlo void fw_cfg_modify_i16(FWCfgState *s, uint16_t key, uint16_t value);
1719c4a5c55SGabriel L. Somlo 
1729c4a5c55SGabriel L. Somlo /**
1739c4a5c55SGabriel L. Somlo  * fw_cfg_add_i32:
1749c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
1759c4a5c55SGabriel L. Somlo  * @key: selector key value for new fw_cfg item
1769c4a5c55SGabriel L. Somlo  * @value: 32-bit integer
1779c4a5c55SGabriel L. Somlo  *
1789c4a5c55SGabriel L. Somlo  * Add a new fw_cfg item, available by selecting the given key. The item
1799c4a5c55SGabriel L. Somlo  * data will consist of a dynamically allocated copy of the given 32-bit
1809c4a5c55SGabriel L. Somlo  * value, converted to little-endian representation.
1819c4a5c55SGabriel L. Somlo  */
1824cad3867SMarkus Armbruster void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value);
1839c4a5c55SGabriel L. Somlo 
1849c4a5c55SGabriel L. Somlo /**
185e5f6aa31SSergio Lopez  * fw_cfg_modify_i32:
186e5f6aa31SSergio Lopez  * @s: fw_cfg device being modified
187e5f6aa31SSergio Lopez  * @key: selector key value for new fw_cfg item
188e5f6aa31SSergio Lopez  * @value: 32-bit integer
189e5f6aa31SSergio Lopez  *
190e5f6aa31SSergio Lopez  * Replace the fw_cfg item available by selecting the given key. The new
191e5f6aa31SSergio Lopez  * data will consist of a dynamically allocated copy of the given 32-bit
192e5f6aa31SSergio Lopez  * value, converted to little-endian representation. The data being replaced,
193e5f6aa31SSergio Lopez  * assumed to have been dynamically allocated during an earlier call to
194e5f6aa31SSergio Lopez  * either fw_cfg_add_i32() or fw_cfg_modify_i32(), is freed before returning.
195e5f6aa31SSergio Lopez  */
196e5f6aa31SSergio Lopez void fw_cfg_modify_i32(FWCfgState *s, uint16_t key, uint32_t value);
197e5f6aa31SSergio Lopez 
198e5f6aa31SSergio Lopez /**
1999c4a5c55SGabriel L. Somlo  * fw_cfg_add_i64:
2009c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
2019c4a5c55SGabriel L. Somlo  * @key: selector key value for new fw_cfg item
2029c4a5c55SGabriel L. Somlo  * @value: 64-bit integer
2039c4a5c55SGabriel L. Somlo  *
2049c4a5c55SGabriel L. Somlo  * Add a new fw_cfg item, available by selecting the given key. The item
2059c4a5c55SGabriel L. Somlo  * data will consist of a dynamically allocated copy of the given 64-bit
2069c4a5c55SGabriel L. Somlo  * value, converted to little-endian representation.
2079c4a5c55SGabriel L. Somlo  */
2084cad3867SMarkus Armbruster void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);
2099c4a5c55SGabriel L. Somlo 
2109c4a5c55SGabriel L. Somlo /**
211e5f6aa31SSergio Lopez  * fw_cfg_modify_i64:
212e5f6aa31SSergio Lopez  * @s: fw_cfg device being modified
213e5f6aa31SSergio Lopez  * @key: selector key value for new fw_cfg item
214e5f6aa31SSergio Lopez  * @value: 64-bit integer
215e5f6aa31SSergio Lopez  *
216e5f6aa31SSergio Lopez  * Replace the fw_cfg item available by selecting the given key. The new
217e5f6aa31SSergio Lopez  * data will consist of a dynamically allocated copy of the given 64-bit
218e5f6aa31SSergio Lopez  * value, converted to little-endian representation. The data being replaced,
219e5f6aa31SSergio Lopez  * assumed to have been dynamically allocated during an earlier call to
220e5f6aa31SSergio Lopez  * either fw_cfg_add_i64() or fw_cfg_modify_i64(), is freed before returning.
221e5f6aa31SSergio Lopez  */
222e5f6aa31SSergio Lopez void fw_cfg_modify_i64(FWCfgState *s, uint16_t key, uint64_t value);
223e5f6aa31SSergio Lopez 
224e5f6aa31SSergio Lopez /**
2259c4a5c55SGabriel L. Somlo  * fw_cfg_add_file:
2269c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
2279c4a5c55SGabriel L. Somlo  * @filename: name of new fw_cfg file item
2289c4a5c55SGabriel L. Somlo  * @data: pointer to start of item data
2299c4a5c55SGabriel L. Somlo  * @len: size of item data
2309c4a5c55SGabriel L. Somlo  *
2319c4a5c55SGabriel L. Somlo  * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data
2329c4a5c55SGabriel L. Somlo  * referenced by the starting pointer is only linked, NOT copied, into the
2339c4a5c55SGabriel L. Somlo  * data structure of the fw_cfg device.
2349c4a5c55SGabriel L. Somlo  * The next available (unused) selector key starting at FW_CFG_FILE_FIRST
2359c4a5c55SGabriel L. Somlo  * will be used; also, a new entry will be added to the file directory
2369c4a5c55SGabriel L. Somlo  * structure residing at key value FW_CFG_FILE_DIR, containing the item name,
2379c4a5c55SGabriel L. Somlo  * data size, and assigned selector key value.
2389c4a5c55SGabriel L. Somlo  */
239089da572SMarkus Armbruster void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
240089da572SMarkus Armbruster                      size_t len);
2419c4a5c55SGabriel L. Somlo 
2429c4a5c55SGabriel L. Somlo /**
2439c4a5c55SGabriel L. Somlo  * fw_cfg_add_file_callback:
2449c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
2459c4a5c55SGabriel L. Somlo  * @filename: name of new fw_cfg file item
2466f6f4aecSMarc-André Lureau  * @select_cb: callback function when selecting
2475f9252f7SMarc-André Lureau  * @write_cb: callback function after a write
2489c4a5c55SGabriel L. Somlo  * @callback_opaque: argument to be passed into callback function
2499c4a5c55SGabriel L. Somlo  * @data: pointer to start of item data
2509c4a5c55SGabriel L. Somlo  * @len: size of item data
251baf2d5bfSMichael S. Tsirkin  * @read_only: is file read only
2529c4a5c55SGabriel L. Somlo  *
2539c4a5c55SGabriel L. Somlo  * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data
2549c4a5c55SGabriel L. Somlo  * referenced by the starting pointer is only linked, NOT copied, into the
2559c4a5c55SGabriel L. Somlo  * data structure of the fw_cfg device.
2569c4a5c55SGabriel L. Somlo  * The next available (unused) selector key starting at FW_CFG_FILE_FIRST
2579c4a5c55SGabriel L. Somlo  * will be used; also, a new entry will be added to the file directory
2589c4a5c55SGabriel L. Somlo  * structure residing at key value FW_CFG_FILE_DIR, containing the item name,
2599c4a5c55SGabriel L. Somlo  * data size, and assigned selector key value.
2609c4a5c55SGabriel L. Somlo  * Additionally, set a callback function (and argument) to be called each
2613bef7e8aSGabriel L. Somlo  * time this item is selected (by having its selector key either written to
2623bef7e8aSGabriel L. Somlo  * the fw_cfg control register, or passed to QEMU in FWCfgDmaAccess.control
2633bef7e8aSGabriel L. Somlo  * with FW_CFG_DMA_CTL_SELECT).
2649c4a5c55SGabriel L. Somlo  */
265d87072ceSMichael S. Tsirkin void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
2666f6f4aecSMarc-André Lureau                               FWCfgCallback select_cb,
2675f9252f7SMarc-André Lureau                               FWCfgWriteCallback write_cb,
2686f6f4aecSMarc-André Lureau                               void *callback_opaque,
269baf2d5bfSMichael S. Tsirkin                               void *data, size_t len, bool read_only);
2709c4a5c55SGabriel L. Somlo 
2719c4a5c55SGabriel L. Somlo /**
2729c4a5c55SGabriel L. Somlo  * fw_cfg_modify_file:
2739c4a5c55SGabriel L. Somlo  * @s: fw_cfg device being modified
2749c4a5c55SGabriel L. Somlo  * @filename: name of new fw_cfg file item
2759c4a5c55SGabriel L. Somlo  * @data: pointer to start of item data
2769c4a5c55SGabriel L. Somlo  * @len: size of item data
2779c4a5c55SGabriel L. Somlo  *
2789c4a5c55SGabriel L. Somlo  * Replace a NAMED fw_cfg item. If an existing item is found, its callback
2799c4a5c55SGabriel L. Somlo  * information will be cleared, and a pointer to its data will be returned
2809c4a5c55SGabriel L. Somlo  * to the caller, so that it may be freed if necessary. If an existing item
2819c4a5c55SGabriel L. Somlo  * is not found, this call defaults to fw_cfg_add_file(), and NULL is
2829c4a5c55SGabriel L. Somlo  * returned to the caller.
2839c4a5c55SGabriel L. Somlo  * In either case, the new item data is only linked, NOT copied, into the
2849c4a5c55SGabriel L. Somlo  * data structure of the fw_cfg device.
2859c4a5c55SGabriel L. Somlo  *
2869c4a5c55SGabriel L. Somlo  * Returns: pointer to old item's data, or NULL if old item does not exist.
2879c4a5c55SGabriel L. Somlo  */
288bdbb5b17SGonglei void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data,
289bdbb5b17SGonglei                          size_t len);
2909c4a5c55SGabriel L. Somlo 
291*32031489SPhilippe Mathieu-Daudé /**
292*32031489SPhilippe Mathieu-Daudé  * fw_cfg_add_from_generator:
293*32031489SPhilippe Mathieu-Daudé  * @s: fw_cfg device being modified
294*32031489SPhilippe Mathieu-Daudé  * @filename: name of new fw_cfg file item
295*32031489SPhilippe Mathieu-Daudé  * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface
296*32031489SPhilippe Mathieu-Daudé  * @errp: pointer to a NULL initialized error object
297*32031489SPhilippe Mathieu-Daudé  *
298*32031489SPhilippe Mathieu-Daudé  * Add a new NAMED fw_cfg item with the content generated from the
299*32031489SPhilippe Mathieu-Daudé  * @gen_id object. The data generated by the @gen_id object is copied
300*32031489SPhilippe Mathieu-Daudé  * into the data structure of the fw_cfg device.
301*32031489SPhilippe Mathieu-Daudé  * The next available (unused) selector key starting at FW_CFG_FILE_FIRST
302*32031489SPhilippe Mathieu-Daudé  * will be used; also, a new entry will be added to the file directory
303*32031489SPhilippe Mathieu-Daudé  * structure residing at key value FW_CFG_FILE_DIR, containing the item name,
304*32031489SPhilippe Mathieu-Daudé  * data size, and assigned selector key value.
305*32031489SPhilippe Mathieu-Daudé  */
306*32031489SPhilippe Mathieu-Daudé void fw_cfg_add_from_generator(FWCfgState *s, const char *filename,
307*32031489SPhilippe Mathieu-Daudé                                const char *gen_id, Error **errp);
308*32031489SPhilippe Mathieu-Daudé 
309a4c0d1deSMarc Marí FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
310a4c0d1deSMarc Marí                                 AddressSpace *dma_as);
3115712db6aSLaszlo Ersek FWCfgState *fw_cfg_init_io(uint32_t iobase);
3125712db6aSLaszlo Ersek FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr);
313a4c0d1deSMarc Marí FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,
314a4c0d1deSMarc Marí                                  hwaddr data_addr, uint32_t data_width,
315a4c0d1deSMarc Marí                                  hwaddr dma_addr, AddressSpace *dma_as);
3163cce6243Sblueswir1 
317600c60b7SMichael S. Tsirkin FWCfgState *fw_cfg_find(void);
318b2a575a1SMarc Marí bool fw_cfg_dma_enabled(void *opaque);
319600c60b7SMichael S. Tsirkin 
320b15c0f7dSPhilippe Mathieu-Daudé /**
321b15c0f7dSPhilippe Mathieu-Daudé  * fw_cfg_arch_key_name:
322b15c0f7dSPhilippe Mathieu-Daudé  *
323b15c0f7dSPhilippe Mathieu-Daudé  * @key: The uint16 selector key.
324b15c0f7dSPhilippe Mathieu-Daudé  *
325b15c0f7dSPhilippe Mathieu-Daudé  * The key is architecture-specific (the FW_CFG_ARCH_LOCAL mask is expected
326b15c0f7dSPhilippe Mathieu-Daudé  * to be set in the key).
327b15c0f7dSPhilippe Mathieu-Daudé  *
328b15c0f7dSPhilippe Mathieu-Daudé  * Returns: The stringified architecture-specific name if the selector
329b15c0f7dSPhilippe Mathieu-Daudé  *          refers to a well-known numerically defined item, or NULL on
330b15c0f7dSPhilippe Mathieu-Daudé  *          key lookup failure.
331b15c0f7dSPhilippe Mathieu-Daudé  */
332b15c0f7dSPhilippe Mathieu-Daudé const char *fw_cfg_arch_key_name(uint16_t key);
333b15c0f7dSPhilippe Mathieu-Daudé 
3343cce6243Sblueswir1 #endif
335