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