|
9 | 9 | #define TYPE_FW_CFG "fw_cfg"
|
10 | 10 | #define TYPE_FW_CFG_IO "fw_cfg_io"
|
11 | 11 | #define TYPE_FW_CFG_MEM "fw_cfg_mem"
|
| 12 | +#define TYPE_FW_CFG_DATA_GENERATOR_INTERFACE "fw_cfg-data-generator" |
12 | 13 |
|
13 | 14 | #define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG)
|
14 | 15 | #define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO)
|
15 | 16 | #define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM)
|
16 | 17 |
|
| 18 | +#define FW_CFG_DATA_GENERATOR_CLASS(class) \ |
| 19 | + OBJECT_CLASS_CHECK(FWCfgDataGeneratorClass, (class), \ |
| 20 | + TYPE_FW_CFG_DATA_GENERATOR_INTERFACE) |
| 21 | +#define FW_CFG_DATA_GENERATOR_GET_CLASS(obj) \ |
| 22 | + OBJECT_GET_CLASS(FWCfgDataGeneratorClass, (obj), \ |
| 23 | + TYPE_FW_CFG_DATA_GENERATOR_INTERFACE) |
| 24 | + |
| 25 | +typedef struct FWCfgDataGeneratorClass { |
| 26 | + /*< private >*/ |
| 27 | + InterfaceClass parent_class; |
| 28 | + /*< public >*/ |
| 29 | + |
| 30 | + /** |
| 31 | + * get_data: |
| 32 | + * @obj: the object implementing this interface |
| 33 | + * @errp: pointer to a NULL-initialized error object |
| 34 | + * |
| 35 | + * Returns: reference to a byte array containing the data. |
| 36 | + * The caller should release the reference when no longer |
| 37 | + * required. |
| 38 | + */ |
| 39 | + GByteArray *(*get_data)(Object *obj, Error **errp); |
| 40 | +} FWCfgDataGeneratorClass; |
| 41 | + |
17 | 42 | typedef struct fw_cfg_file FWCfgFile;
|
18 | 43 |
|
19 | 44 | #define FW_CFG_ORDER_OVERRIDE_VGA 70
|
@@ -263,6 +288,24 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
|
263 | 288 | void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data,
|
264 | 289 | size_t len);
|
265 | 290 |
|
| 291 | +/** |
| 292 | + * fw_cfg_add_from_generator: |
| 293 | + * @s: fw_cfg device being modified |
| 294 | + * @filename: name of new fw_cfg file item |
| 295 | + * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface |
| 296 | + * @errp: pointer to a NULL initialized error object |
| 297 | + * |
| 298 | + * Add a new NAMED fw_cfg item with the content generated from the |
| 299 | + * @gen_id object. The data generated by the @gen_id object is copied |
| 300 | + * into the data structure of the fw_cfg device. |
| 301 | + * The next available (unused) selector key starting at FW_CFG_FILE_FIRST |
| 302 | + * will be used; also, a new entry will be added to the file directory |
| 303 | + * structure residing at key value FW_CFG_FILE_DIR, containing the item name, |
| 304 | + * data size, and assigned selector key value. |
| 305 | + */ |
| 306 | +void fw_cfg_add_from_generator(FWCfgState *s, const char *filename, |
| 307 | + const char *gen_id, Error **errp); |
| 308 | + |
266 | 309 | FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
|
267 | 310 | AddressSpace *dma_as);
|
268 | 311 | FWCfgState *fw_cfg_init_io(uint32_t iobase);
|
|
0 commit comments