]> git.proxmox.com Git - qemu.git/blame - hw/fw_cfg.c
fix live migration
[qemu.git] / hw / fw_cfg.c
CommitLineData
3cce6243
BS
1/*
2 * QEMU Firmware configuration device emulation
3 *
4 * Copyright (c) 2008 Gleb Natapov
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#include "hw.h"
084a197a 25#include "sysemu.h"
3cce6243
BS
26#include "isa.h"
27#include "fw_cfg.h"
3a5c16fc 28#include "sysbus.h"
3d3b8303 29#include "qemu-error.h"
3cce6243
BS
30
31/* debug firmware config */
32//#define DEBUG_FW_CFG
33
34#ifdef DEBUG_FW_CFG
001faf32
BS
35#define FW_CFG_DPRINTF(fmt, ...) \
36 do { printf("FW_CFG: " fmt , ## __VA_ARGS__); } while (0)
3cce6243 37#else
001faf32 38#define FW_CFG_DPRINTF(fmt, ...)
3cce6243
BS
39#endif
40
41#define FW_CFG_SIZE 2
561e1827 42#define FW_CFG_DATA_SIZE 1
3cce6243 43
b96ae2da 44typedef struct FWCfgEntry {
ff06108b 45 uint32_t len;
3cce6243
BS
46 uint8_t *data;
47 void *callback_opaque;
48 FWCfgCallback callback;
49} FWCfgEntry;
50
b96ae2da 51struct FWCfgState {
3a5c16fc 52 SysBusDevice busdev;
561e1827 53 MemoryRegion ctl_iomem, data_iomem, comb_iomem;
3a5c16fc 54 uint32_t ctl_iobase, data_iobase;
3cce6243 55 FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
abe147e0 56 FWCfgFiles *files;
3cce6243 57 uint16_t cur_entry;
ff06108b 58 uint32_t cur_offset;
962630f2 59 Notifier machine_ready;
c2b5bda4 60};
3cce6243 61
3d3b8303 62#define JPG_FILE 0
63#define BMP_FILE 1
64
9477c87e 65static char *read_splashfile(char *filename, int *file_sizep, int *file_typep)
3d3b8303 66{
9477c87e
PB
67 GError *err = NULL;
68 gboolean res;
69 gchar *content;
3d3b8303 70 int file_type = -1;
9477c87e 71 unsigned int filehead = 0;
3d3b8303 72 int bmp_bpp;
73
9477c87e
PB
74 res = g_file_get_contents(filename, &content, (gsize *)file_sizep, &err);
75 if (res == FALSE) {
76 error_report("failed to read splash file '%s'", filename);
77 g_error_free(err);
78 return NULL;
3d3b8303 79 }
9477c87e 80
3d3b8303 81 /* check file size */
9477c87e
PB
82 if (*file_sizep < 30) {
83 goto error;
3d3b8303 84 }
9477c87e 85
3d3b8303 86 /* check magic ID */
9477c87e
PB
87 filehead = ((content[0] & 0xff) + (content[1] << 8)) & 0xffff;
88 if (filehead == 0xd8ff) {
3d3b8303 89 file_type = JPG_FILE;
9477c87e
PB
90 } else if (filehead == 0x4d42) {
91 file_type = BMP_FILE;
3d3b8303 92 } else {
9477c87e 93 goto error;
3d3b8303 94 }
9477c87e 95
3d3b8303 96 /* check BMP bpp */
97 if (file_type == BMP_FILE) {
9477c87e 98 bmp_bpp = (content[28] + (content[29] << 8)) & 0xffff;
3d3b8303 99 if (bmp_bpp != 24) {
9477c87e 100 goto error;
3d3b8303 101 }
102 }
9477c87e 103
3d3b8303 104 /* return values */
3d3b8303 105 *file_typep = file_type;
9477c87e
PB
106
107 return content;
108
109error:
110 error_report("splash file '%s' format not recognized; must be JPEG "
111 "or 24 bit BMP", filename);
112 g_free(content);
113 return NULL;
3d3b8303 114}
115
116static void fw_cfg_bootsplash(FWCfgState *s)
117{
118 int boot_splash_time = -1;
119 const char *boot_splash_filename = NULL;
120 char *p;
9477c87e 121 char *filename, *file_data;
3d3b8303 122 int file_size;
123 int file_type = -1;
124 const char *temp;
125
126 /* get user configuration */
127 QemuOptsList *plist = qemu_find_opts("boot-opts");
128 QemuOpts *opts = QTAILQ_FIRST(&plist->head);
129 if (opts != NULL) {
130 temp = qemu_opt_get(opts, "splash");
131 if (temp != NULL) {
132 boot_splash_filename = temp;
133 }
134 temp = qemu_opt_get(opts, "splash-time");
135 if (temp != NULL) {
136 p = (char *)temp;
137 boot_splash_time = strtol(p, (char **)&p, 10);
138 }
139 }
140
141 /* insert splash time if user configurated */
142 if (boot_splash_time >= 0) {
143 /* validate the input */
144 if (boot_splash_time > 0xffff) {
145 error_report("splash time is big than 65535, force it to 65535.");
146 boot_splash_time = 0xffff;
147 }
148 /* use little endian format */
149 qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time & 0xff);
150 qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time >> 8) & 0xff);
151 fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
152 }
153
154 /* insert splash file if user configurated */
155 if (boot_splash_filename != NULL) {
156 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename);
157 if (filename == NULL) {
158 error_report("failed to find file '%s'.", boot_splash_filename);
159 return;
160 }
9477c87e
PB
161
162 /* loading file data */
163 file_data = read_splashfile(filename, &file_size, &file_type);
164 if (file_data == NULL) {
7267c094 165 g_free(filename);
3d3b8303 166 return;
167 }
3d3b8303 168 if (boot_splash_filedata != NULL) {
7267c094 169 g_free(boot_splash_filedata);
3d3b8303 170 }
9477c87e 171 boot_splash_filedata = (uint8_t *)file_data;
3d3b8303 172 boot_splash_filedata_size = file_size;
9477c87e 173
3d3b8303 174 /* insert data */
175 if (file_type == JPG_FILE) {
176 fw_cfg_add_file(s, "bootsplash.jpg",
177 boot_splash_filedata, boot_splash_filedata_size);
178 } else {
179 fw_cfg_add_file(s, "bootsplash.bmp",
180 boot_splash_filedata, boot_splash_filedata_size);
181 }
7267c094 182 g_free(filename);
3d3b8303 183 }
184}
185
ac05f349
AK
186static void fw_cfg_reboot(FWCfgState *s)
187{
188 int reboot_timeout = -1;
189 char *p;
190 const char *temp;
191
192 /* get user configuration */
193 QemuOptsList *plist = qemu_find_opts("boot-opts");
194 QemuOpts *opts = QTAILQ_FIRST(&plist->head);
195 if (opts != NULL) {
196 temp = qemu_opt_get(opts, "reboot-timeout");
197 if (temp != NULL) {
198 p = (char *)temp;
199 reboot_timeout = strtol(p, (char **)&p, 10);
200 }
201 }
202 /* validate the input */
203 if (reboot_timeout > 0xffff) {
204 error_report("reboot timeout is larger than 65535, force it to 65535.");
205 reboot_timeout = 0xffff;
206 }
207 fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4), 4);
208}
209
3cce6243
BS
210static void fw_cfg_write(FWCfgState *s, uint8_t value)
211{
212 int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
213 FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
214
215 FW_CFG_DPRINTF("write %d\n", value);
216
962d4b28
BS
217 if (s->cur_entry & FW_CFG_WRITE_CHANNEL && e->callback &&
218 s->cur_offset < e->len) {
3cce6243
BS
219 e->data[s->cur_offset++] = value;
220 if (s->cur_offset == e->len) {
221 e->callback(e->callback_opaque, e->data);
222 s->cur_offset = 0;
223 }
224 }
225}
226
227static int fw_cfg_select(FWCfgState *s, uint16_t key)
228{
229 int ret;
230
231 s->cur_offset = 0;
232 if ((key & FW_CFG_ENTRY_MASK) >= FW_CFG_MAX_ENTRY) {
233 s->cur_entry = FW_CFG_INVALID;
234 ret = 0;
235 } else {
236 s->cur_entry = key;
237 ret = 1;
238 }
239
240 FW_CFG_DPRINTF("select key %d (%sfound)\n", key, ret ? "" : "not ");
241
242 return ret;
243}
244
245static uint8_t fw_cfg_read(FWCfgState *s)
246{
247 int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL);
248 FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK];
249 uint8_t ret;
250
251 if (s->cur_entry == FW_CFG_INVALID || !e->data || s->cur_offset >= e->len)
252 ret = 0;
253 else
254 ret = e->data[s->cur_offset++];
255
256 FW_CFG_DPRINTF("read %d\n", ret);
257
258 return ret;
259}
260
a8170e5e 261static uint64_t fw_cfg_data_mem_read(void *opaque, hwaddr addr,
561e1827 262 unsigned size)
3cce6243
BS
263{
264 return fw_cfg_read(opaque);
265}
266
a8170e5e 267static void fw_cfg_data_mem_write(void *opaque, hwaddr addr,
561e1827 268 uint64_t value, unsigned size)
3cce6243 269{
7442511c 270 fw_cfg_write(opaque, (uint8_t)value);
3cce6243
BS
271}
272
a8170e5e 273static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr,
561e1827 274 uint64_t value, unsigned size)
3cce6243
BS
275{
276 fw_cfg_select(opaque, (uint16_t)value);
277}
278
a8170e5e 279static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr,
561e1827 280 unsigned size, bool is_write)
3cce6243 281{
561e1827 282 return is_write && size == 2;
3cce6243
BS
283}
284
a8170e5e 285static uint64_t fw_cfg_comb_read(void *opaque, hwaddr addr,
561e1827 286 unsigned size)
3cce6243 287{
561e1827 288 return fw_cfg_read(opaque);
3cce6243
BS
289}
290
a8170e5e 291static void fw_cfg_comb_write(void *opaque, hwaddr addr,
561e1827 292 uint64_t value, unsigned size)
3cce6243 293{
561e1827
AK
294 switch (size) {
295 case 1:
296 fw_cfg_write(opaque, (uint8_t)value);
297 break;
298 case 2:
299 fw_cfg_select(opaque, (uint16_t)value);
300 break;
301 }
3cce6243
BS
302}
303
a8170e5e 304static bool fw_cfg_comb_valid(void *opaque, hwaddr addr,
561e1827
AK
305 unsigned size, bool is_write)
306{
307 return (size == 1) || (is_write && size == 2);
308}
3cce6243 309
561e1827
AK
310static const MemoryRegionOps fw_cfg_ctl_mem_ops = {
311 .write = fw_cfg_ctl_mem_write,
312 .endianness = DEVICE_NATIVE_ENDIAN,
313 .valid.accepts = fw_cfg_ctl_mem_valid,
3cce6243
BS
314};
315
561e1827
AK
316static const MemoryRegionOps fw_cfg_data_mem_ops = {
317 .read = fw_cfg_data_mem_read,
318 .write = fw_cfg_data_mem_write,
319 .endianness = DEVICE_NATIVE_ENDIAN,
320 .valid = {
321 .min_access_size = 1,
322 .max_access_size = 1,
323 },
3cce6243
BS
324};
325
561e1827
AK
326static const MemoryRegionOps fw_cfg_comb_mem_ops = {
327 .read = fw_cfg_comb_read,
328 .write = fw_cfg_comb_write,
329 .endianness = DEVICE_NATIVE_ENDIAN,
330 .valid.accepts = fw_cfg_comb_valid,
3cce6243
BS
331};
332
3a5c16fc 333static void fw_cfg_reset(DeviceState *d)
3cce6243 334{
3a5c16fc 335 FWCfgState *s = DO_UPCAST(FWCfgState, busdev.qdev, d);
3cce6243
BS
336
337 fw_cfg_select(s, 0);
338}
339
ff06108b
JQ
340/* Save restore 32 bit int as uint16_t
341 This is a Big hack, but it is how the old state did it.
342 Or we broke compatibility in the state, or we can't use struct tm
343 */
344
345static int get_uint32_as_uint16(QEMUFile *f, void *pv, size_t size)
346{
347 uint32_t *v = pv;
348 *v = qemu_get_be16(f);
349 return 0;
350}
351
352static void put_unused(QEMUFile *f, void *pv, size_t size)
353{
66c80e75 354 fprintf(stderr, "uint32_as_uint16 is only used for backward compatibility.\n");
ff06108b
JQ
355 fprintf(stderr, "This functions shouldn't be called.\n");
356}
357
d05ac8fa 358static const VMStateInfo vmstate_hack_uint32_as_uint16 = {
ff06108b
JQ
359 .name = "int32_as_uint16",
360 .get = get_uint32_as_uint16,
361 .put = put_unused,
362};
363
364#define VMSTATE_UINT16_HACK(_f, _s, _t) \
365 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint32_as_uint16, uint32_t)
366
367
368static bool is_version_1(void *opaque, int version_id)
369{
370 return version_id == 1;
371}
372
7d2edd40
JQ
373static const VMStateDescription vmstate_fw_cfg = {
374 .name = "fw_cfg",
ff06108b 375 .version_id = 2,
7d2edd40
JQ
376 .minimum_version_id = 1,
377 .minimum_version_id_old = 1,
378 .fields = (VMStateField []) {
379 VMSTATE_UINT16(cur_entry, FWCfgState),
ff06108b
JQ
380 VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1),
381 VMSTATE_UINT32_V(cur_offset, FWCfgState, 2),
7d2edd40
JQ
382 VMSTATE_END_OF_LIST()
383 }
384};
3cce6243 385
c2b5bda4 386int fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)
3cce6243 387{
3cce6243
BS
388 int arch = !!(key & FW_CFG_ARCH_LOCAL);
389
390 key &= FW_CFG_ENTRY_MASK;
391
392 if (key >= FW_CFG_MAX_ENTRY)
393 return 0;
394
395 s->entries[arch][key].data = data;
396 s->entries[arch][key].len = len;
397
398 return 1;
399}
400
c2b5bda4 401int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
3cce6243
BS
402{
403 uint16_t *copy;
404
7267c094 405 copy = g_malloc(sizeof(value));
3cce6243 406 *copy = cpu_to_le16(value);
c2b5bda4 407 return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
3cce6243
BS
408}
409
c2b5bda4 410int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value)
3cce6243
BS
411{
412 uint32_t *copy;
413
7267c094 414 copy = g_malloc(sizeof(value));
3cce6243 415 *copy = cpu_to_le32(value);
c2b5bda4 416 return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
3cce6243
BS
417}
418
c2b5bda4 419int fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
3cce6243
BS
420{
421 uint64_t *copy;
422
7267c094 423 copy = g_malloc(sizeof(value));
3cce6243 424 *copy = cpu_to_le64(value);
c2b5bda4 425 return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value));
3cce6243
BS
426}
427
c2b5bda4 428int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
3cce6243
BS
429 void *callback_opaque, uint8_t *data, size_t len)
430{
3cce6243
BS
431 int arch = !!(key & FW_CFG_ARCH_LOCAL);
432
85df0de4
BS
433 if (!(key & FW_CFG_WRITE_CHANNEL))
434 return 0;
435
3cce6243
BS
436 key &= FW_CFG_ENTRY_MASK;
437
85df0de4 438 if (key >= FW_CFG_MAX_ENTRY || len > 65535)
3cce6243
BS
439 return 0;
440
441 s->entries[arch][key].data = data;
442 s->entries[arch][key].len = len;
443 s->entries[arch][key].callback_opaque = callback_opaque;
444 s->entries[arch][key].callback = callback;
445
446 return 1;
447}
448
de1f34cb
GN
449int fw_cfg_add_file(FWCfgState *s, const char *filename, uint8_t *data,
450 uint32_t len)
abe147e0 451{
de9352bc 452 int i, index;
abe147e0
GH
453
454 if (!s->files) {
455 int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS;
7267c094 456 s->files = g_malloc0(dsize);
abe147e0
GH
457 fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize);
458 }
459
460 index = be32_to_cpu(s->files->count);
461 if (index == FW_CFG_FILE_SLOTS) {
462 fprintf(stderr, "fw_cfg: out of file slots\n");
463 return 0;
464 }
465
466 fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len);
467
de1f34cb
GN
468 pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name),
469 filename);
de9352bc
GH
470 for (i = 0; i < index; i++) {
471 if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
472 FW_CFG_DPRINTF("%s: skip duplicate: %s\n", __FUNCTION__,
473 s->files->f[index].name);
474 return 1;
475 }
abe147e0 476 }
de9352bc 477
abe147e0
GH
478 s->files->f[index].size = cpu_to_be32(len);
479 s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
480 FW_CFG_DPRINTF("%s: #%d: %s (%d bytes)\n", __FUNCTION__,
481 index, s->files->f[index].name, len);
482
483 s->files->count = cpu_to_be32(index+1);
484 return 1;
485}
486
9e8dd451 487static void fw_cfg_machine_ready(struct Notifier *n, void *data)
962630f2
GN
488{
489 uint32_t len;
490 FWCfgState *s = container_of(n, FWCfgState, machine_ready);
491 char *bootindex = get_boot_devices_list(&len);
492
493 fw_cfg_add_file(s, "bootorder", (uint8_t*)bootindex, len);
494}
495
c2b5bda4 496FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
a8170e5e 497 hwaddr ctl_addr, hwaddr data_addr)
3cce6243 498{
3a5c16fc
BS
499 DeviceState *dev;
500 SysBusDevice *d;
3cce6243 501 FWCfgState *s;
3cce6243 502
3a5c16fc
BS
503 dev = qdev_create(NULL, "fw_cfg");
504 qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port);
505 qdev_prop_set_uint32(dev, "data_iobase", data_port);
506 qdev_init_nofail(dev);
507 d = sysbus_from_qdev(dev);
508
509 s = DO_UPCAST(FWCfgState, busdev.qdev, dev);
3cce6243 510
3cce6243 511 if (ctl_addr) {
3a5c16fc 512 sysbus_mmio_map(d, 0, ctl_addr);
3cce6243
BS
513 }
514 if (data_addr) {
3a5c16fc 515 sysbus_mmio_map(d, 1, data_addr);
3cce6243
BS
516 }
517 fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (uint8_t *)"QEMU", 4);
084a197a 518 fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16);
993fbfdb 519 fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC));
905fdcb5 520 fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
6be68d7e 521 fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus);
95387491 522 fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
3d3b8303 523 fw_cfg_bootsplash(s);
ac05f349 524 fw_cfg_reboot(s);
962630f2
GN
525
526 s->machine_ready.notify = fw_cfg_machine_ready;
527 qemu_add_machine_init_done_notifier(&s->machine_ready);
528
3cce6243
BS
529 return s;
530}
3a5c16fc
BS
531
532static int fw_cfg_init1(SysBusDevice *dev)
533{
534 FWCfgState *s = FROM_SYSBUS(FWCfgState, dev);
3a5c16fc 535
561e1827
AK
536 memory_region_init_io(&s->ctl_iomem, &fw_cfg_ctl_mem_ops, s,
537 "fwcfg.ctl", FW_CFG_SIZE);
750ecd44 538 sysbus_init_mmio(dev, &s->ctl_iomem);
561e1827
AK
539 memory_region_init_io(&s->data_iomem, &fw_cfg_data_mem_ops, s,
540 "fwcfg.data", FW_CFG_DATA_SIZE);
750ecd44 541 sysbus_init_mmio(dev, &s->data_iomem);
561e1827
AK
542 /* In case ctl and data overlap: */
543 memory_region_init_io(&s->comb_iomem, &fw_cfg_comb_mem_ops, s,
544 "fwcfg", FW_CFG_SIZE);
545
546 if (s->ctl_iobase + 1 == s->data_iobase) {
547 sysbus_add_io(dev, s->ctl_iobase, &s->comb_iomem);
548 } else {
549 if (s->ctl_iobase) {
550 sysbus_add_io(dev, s->ctl_iobase, &s->ctl_iomem);
551 }
552 if (s->data_iobase) {
553 sysbus_add_io(dev, s->data_iobase, &s->data_iomem);
554 }
3a5c16fc
BS
555 }
556 return 0;
557}
558
999e12bb
AL
559static Property fw_cfg_properties[] = {
560 DEFINE_PROP_HEX32("ctl_iobase", FWCfgState, ctl_iobase, -1),
561 DEFINE_PROP_HEX32("data_iobase", FWCfgState, data_iobase, -1),
562 DEFINE_PROP_END_OF_LIST(),
563};
564
565static void fw_cfg_class_init(ObjectClass *klass, void *data)
566{
39bffca2 567 DeviceClass *dc = DEVICE_CLASS(klass);
999e12bb
AL
568 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
569
570 k->init = fw_cfg_init1;
39bffca2
AL
571 dc->no_user = 1;
572 dc->reset = fw_cfg_reset;
573 dc->vmsd = &vmstate_fw_cfg;
574 dc->props = fw_cfg_properties;
999e12bb
AL
575}
576
39bffca2
AL
577static TypeInfo fw_cfg_info = {
578 .name = "fw_cfg",
579 .parent = TYPE_SYS_BUS_DEVICE,
580 .instance_size = sizeof(FWCfgState),
581 .class_init = fw_cfg_class_init,
3a5c16fc
BS
582};
583
83f7d43a 584static void fw_cfg_register_types(void)
3a5c16fc 585{
39bffca2 586 type_register_static(&fw_cfg_info);
3a5c16fc
BS
587}
588
83f7d43a 589type_init(fw_cfg_register_types)