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