4 #include "exec/hwaddr.h"
5 #include "hw/nvram/fw_cfg_keys.h"
7 typedef struct FWCfgFile
{
8 uint32_t size
; /* file size */
9 uint16_t select
; /* write this to 0x510 to read it */
11 char name
[FW_CFG_MAX_FILE_PATH
];
14 #define FW_CFG_ORDER_OVERRIDE_VGA 70
15 #define FW_CFG_ORDER_OVERRIDE_NIC 80
16 #define FW_CFG_ORDER_OVERRIDE_USER 100
17 #define FW_CFG_ORDER_OVERRIDE_DEVICE 110
19 void fw_cfg_set_order_override(FWCfgState
*fw_cfg
, int order
);
20 void fw_cfg_reset_order_override(FWCfgState
*fw_cfg
);
22 typedef struct FWCfgFiles
{
27 /* Control as first field allows for different structures selected by this
28 * field, which might be useful in the future
30 typedef struct FWCfgDmaAccess
{
34 } QEMU_PACKED FWCfgDmaAccess
;
36 typedef void (*FWCfgReadCallback
)(void *opaque
);
40 * @s: fw_cfg device being modified
41 * @key: selector key value for new fw_cfg item
42 * @data: pointer to start of item data
43 * @len: size of item data
45 * Add a new fw_cfg item, available by selecting the given key, as a raw
46 * "blob" of the given size. The data referenced by the starting pointer
47 * is only linked, NOT copied, into the data structure of the fw_cfg device.
49 void fw_cfg_add_bytes(FWCfgState
*s
, uint16_t key
, void *data
, size_t len
);
53 * @s: fw_cfg device being modified
54 * @key: selector key value for new fw_cfg item
55 * @value: NUL-terminated ascii string
57 * Add a new fw_cfg item, available by selecting the given key. The item
58 * data will consist of a dynamically allocated copy of the provided string,
59 * including its NUL terminator.
61 void fw_cfg_add_string(FWCfgState
*s
, uint16_t key
, const char *value
);
65 * @s: fw_cfg device being modified
66 * @key: selector key value for new fw_cfg item
67 * @value: 16-bit integer
69 * Add a new fw_cfg item, available by selecting the given key. The item
70 * data will consist of a dynamically allocated copy of the given 16-bit
71 * value, converted to little-endian representation.
73 void fw_cfg_add_i16(FWCfgState
*s
, uint16_t key
, uint16_t value
);
77 * @s: fw_cfg device being modified
78 * @key: selector key value for new fw_cfg item
79 * @value: 16-bit integer
81 * Replace the fw_cfg item available by selecting the given key. The new
82 * data will consist of a dynamically allocated copy of the given 16-bit
83 * value, converted to little-endian representation. The data being replaced,
84 * assumed to have been dynamically allocated during an earlier call to
85 * either fw_cfg_add_i16() or fw_cfg_modify_i16(), is freed before returning.
87 void fw_cfg_modify_i16(FWCfgState
*s
, uint16_t key
, uint16_t value
);
91 * @s: fw_cfg device being modified
92 * @key: selector key value for new fw_cfg item
93 * @value: 32-bit integer
95 * Add a new fw_cfg item, available by selecting the given key. The item
96 * data will consist of a dynamically allocated copy of the given 32-bit
97 * value, converted to little-endian representation.
99 void fw_cfg_add_i32(FWCfgState
*s
, uint16_t key
, uint32_t value
);
103 * @s: fw_cfg device being modified
104 * @key: selector key value for new fw_cfg item
105 * @value: 64-bit integer
107 * Add a new fw_cfg item, available by selecting the given key. The item
108 * data will consist of a dynamically allocated copy of the given 64-bit
109 * value, converted to little-endian representation.
111 void fw_cfg_add_i64(FWCfgState
*s
, uint16_t key
, uint64_t value
);
115 * @s: fw_cfg device being modified
116 * @filename: name of new fw_cfg file item
117 * @data: pointer to start of item data
118 * @len: size of item data
120 * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data
121 * referenced by the starting pointer is only linked, NOT copied, into the
122 * data structure of the fw_cfg device.
123 * The next available (unused) selector key starting at FW_CFG_FILE_FIRST
124 * will be used; also, a new entry will be added to the file directory
125 * structure residing at key value FW_CFG_FILE_DIR, containing the item name,
126 * data size, and assigned selector key value.
128 void fw_cfg_add_file(FWCfgState
*s
, const char *filename
, void *data
,
132 * fw_cfg_add_file_callback:
133 * @s: fw_cfg device being modified
134 * @filename: name of new fw_cfg file item
135 * @callback: callback function
136 * @callback_opaque: argument to be passed into callback function
137 * @data: pointer to start of item data
138 * @len: size of item data
140 * Add a new NAMED fw_cfg item as a raw "blob" of the given size. The data
141 * referenced by the starting pointer is only linked, NOT copied, into the
142 * data structure of the fw_cfg device.
143 * The next available (unused) selector key starting at FW_CFG_FILE_FIRST
144 * will be used; also, a new entry will be added to the file directory
145 * structure residing at key value FW_CFG_FILE_DIR, containing the item name,
146 * data size, and assigned selector key value.
147 * Additionally, set a callback function (and argument) to be called each
148 * time this item is selected (by having its selector key either written to
149 * the fw_cfg control register, or passed to QEMU in FWCfgDmaAccess.control
150 * with FW_CFG_DMA_CTL_SELECT).
152 void fw_cfg_add_file_callback(FWCfgState
*s
, const char *filename
,
153 FWCfgReadCallback callback
, void *callback_opaque
,
154 void *data
, size_t len
);
157 * fw_cfg_modify_file:
158 * @s: fw_cfg device being modified
159 * @filename: name of new fw_cfg file item
160 * @data: pointer to start of item data
161 * @len: size of item data
163 * Replace a NAMED fw_cfg item. If an existing item is found, its callback
164 * information will be cleared, and a pointer to its data will be returned
165 * to the caller, so that it may be freed if necessary. If an existing item
166 * is not found, this call defaults to fw_cfg_add_file(), and NULL is
167 * returned to the caller.
168 * In either case, the new item data is only linked, NOT copied, into the
169 * data structure of the fw_cfg device.
171 * Returns: pointer to old item's data, or NULL if old item does not exist.
173 void *fw_cfg_modify_file(FWCfgState
*s
, const char *filename
, void *data
,
176 FWCfgState
*fw_cfg_init_io_dma(uint32_t iobase
, uint32_t dma_iobase
,
177 AddressSpace
*dma_as
);
178 FWCfgState
*fw_cfg_init_io(uint32_t iobase
);
179 FWCfgState
*fw_cfg_init_mem(hwaddr ctl_addr
, hwaddr data_addr
);
180 FWCfgState
*fw_cfg_init_mem_wide(hwaddr ctl_addr
,
181 hwaddr data_addr
, uint32_t data_width
,
182 hwaddr dma_addr
, AddressSpace
*dma_as
);
184 FWCfgState
*fw_cfg_find(void);