2 * QEMU Firmware configuration device emulation
4 * Copyright (c) 2008 Gleb Natapov
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
25 #include "sysemu/sysemu.h"
26 #include "hw/isa/isa.h"
27 #include "hw/nvram/fw_cfg.h"
28 #include "hw/sysbus.h"
30 #include "qemu/error-report.h"
31 #include "qemu/config-file.h"
34 #define FW_CFG_NAME "fw_cfg"
35 #define FW_CFG_PATH "/machine/" FW_CFG_NAME
37 #define TYPE_FW_CFG "fw_cfg"
38 #define TYPE_FW_CFG_IO "fw_cfg_io"
39 #define TYPE_FW_CFG_MEM "fw_cfg_mem"
41 #define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG)
42 #define FW_CFG_IO(obj) OBJECT_CHECK(FWCfgIoState, (obj), TYPE_FW_CFG_IO)
43 #define FW_CFG_MEM(obj) OBJECT_CHECK(FWCfgMemState, (obj), TYPE_FW_CFG_MEM)
45 typedef struct FWCfgEntry
{
48 void *callback_opaque
;
49 FWCfgCallback callback
;
50 FWCfgReadCallback read_callback
;
55 SysBusDevice parent_obj
;
58 FWCfgEntry entries
[2][FW_CFG_MAX_ENTRY
];
62 Notifier machine_ready
;
67 FWCfgState parent_obj
;
70 MemoryRegion comb_iomem
;
74 struct FWCfgMemState
{
76 FWCfgState parent_obj
;
79 MemoryRegion ctl_iomem
, data_iomem
;
81 MemoryRegionOps wide_data_ops
;
87 static char *read_splashfile(char *filename
, gsize
*file_sizep
,
94 unsigned int filehead
;
97 res
= g_file_get_contents(filename
, &content
, file_sizep
, &err
);
99 error_report("failed to read splash file '%s'", filename
);
104 /* check file size */
105 if (*file_sizep
< 30) {
110 filehead
= ((content
[0] & 0xff) + (content
[1] << 8)) & 0xffff;
111 if (filehead
== 0xd8ff) {
112 file_type
= JPG_FILE
;
113 } else if (filehead
== 0x4d42) {
114 file_type
= BMP_FILE
;
120 if (file_type
== BMP_FILE
) {
121 bmp_bpp
= (content
[28] + (content
[29] << 8)) & 0xffff;
128 *file_typep
= file_type
;
133 error_report("splash file '%s' format not recognized; must be JPEG "
134 "or 24 bit BMP", filename
);
139 static void fw_cfg_bootsplash(FWCfgState
*s
)
141 int boot_splash_time
= -1;
142 const char *boot_splash_filename
= NULL
;
144 char *filename
, *file_data
;
149 /* get user configuration */
150 QemuOptsList
*plist
= qemu_find_opts("boot-opts");
151 QemuOpts
*opts
= QTAILQ_FIRST(&plist
->head
);
153 temp
= qemu_opt_get(opts
, "splash");
155 boot_splash_filename
= temp
;
157 temp
= qemu_opt_get(opts
, "splash-time");
160 boot_splash_time
= strtol(p
, (char **)&p
, 10);
164 /* insert splash time if user configurated */
165 if (boot_splash_time
>= 0) {
166 /* validate the input */
167 if (boot_splash_time
> 0xffff) {
168 error_report("splash time is big than 65535, force it to 65535.");
169 boot_splash_time
= 0xffff;
171 /* use little endian format */
172 qemu_extra_params_fw
[0] = (uint8_t)(boot_splash_time
& 0xff);
173 qemu_extra_params_fw
[1] = (uint8_t)((boot_splash_time
>> 8) & 0xff);
174 fw_cfg_add_file(s
, "etc/boot-menu-wait", qemu_extra_params_fw
, 2);
177 /* insert splash file if user configurated */
178 if (boot_splash_filename
!= NULL
) {
179 filename
= qemu_find_file(QEMU_FILE_TYPE_BIOS
, boot_splash_filename
);
180 if (filename
== NULL
) {
181 error_report("failed to find file '%s'.", boot_splash_filename
);
185 /* loading file data */
186 file_data
= read_splashfile(filename
, &file_size
, &file_type
);
187 if (file_data
== NULL
) {
191 if (boot_splash_filedata
!= NULL
) {
192 g_free(boot_splash_filedata
);
194 boot_splash_filedata
= (uint8_t *)file_data
;
195 boot_splash_filedata_size
= file_size
;
198 if (file_type
== JPG_FILE
) {
199 fw_cfg_add_file(s
, "bootsplash.jpg",
200 boot_splash_filedata
, boot_splash_filedata_size
);
202 fw_cfg_add_file(s
, "bootsplash.bmp",
203 boot_splash_filedata
, boot_splash_filedata_size
);
209 static void fw_cfg_reboot(FWCfgState
*s
)
211 int reboot_timeout
= -1;
215 /* get user configuration */
216 QemuOptsList
*plist
= qemu_find_opts("boot-opts");
217 QemuOpts
*opts
= QTAILQ_FIRST(&plist
->head
);
219 temp
= qemu_opt_get(opts
, "reboot-timeout");
222 reboot_timeout
= strtol(p
, (char **)&p
, 10);
225 /* validate the input */
226 if (reboot_timeout
> 0xffff) {
227 error_report("reboot timeout is larger than 65535, force it to 65535.");
228 reboot_timeout
= 0xffff;
230 fw_cfg_add_file(s
, "etc/boot-fail-wait", g_memdup(&reboot_timeout
, 4), 4);
233 static void fw_cfg_write(FWCfgState
*s
, uint8_t value
)
235 int arch
= !!(s
->cur_entry
& FW_CFG_ARCH_LOCAL
);
236 FWCfgEntry
*e
= &s
->entries
[arch
][s
->cur_entry
& FW_CFG_ENTRY_MASK
];
238 trace_fw_cfg_write(s
, value
);
240 if (s
->cur_entry
& FW_CFG_WRITE_CHANNEL
&& e
->callback
&&
241 s
->cur_offset
< e
->len
) {
242 e
->data
[s
->cur_offset
++] = value
;
243 if (s
->cur_offset
== e
->len
) {
244 e
->callback(e
->callback_opaque
, e
->data
);
250 static int fw_cfg_select(FWCfgState
*s
, uint16_t key
)
255 if ((key
& FW_CFG_ENTRY_MASK
) >= FW_CFG_MAX_ENTRY
) {
256 s
->cur_entry
= FW_CFG_INVALID
;
263 trace_fw_cfg_select(s
, key
, ret
);
267 static uint8_t fw_cfg_read(FWCfgState
*s
)
269 int arch
= !!(s
->cur_entry
& FW_CFG_ARCH_LOCAL
);
270 FWCfgEntry
*e
= &s
->entries
[arch
][s
->cur_entry
& FW_CFG_ENTRY_MASK
];
273 if (s
->cur_entry
== FW_CFG_INVALID
|| !e
->data
|| s
->cur_offset
>= e
->len
)
276 if (e
->read_callback
) {
277 e
->read_callback(e
->callback_opaque
, s
->cur_offset
);
279 ret
= e
->data
[s
->cur_offset
++];
282 trace_fw_cfg_read(s
, ret
);
286 static uint64_t fw_cfg_data_mem_read(void *opaque
, hwaddr addr
,
289 FWCfgState
*s
= opaque
;
293 for (i
= 0; i
< size
; ++i
) {
294 value
= (value
<< 8) | fw_cfg_read(s
);
299 static void fw_cfg_data_mem_write(void *opaque
, hwaddr addr
,
300 uint64_t value
, unsigned size
)
302 FWCfgState
*s
= opaque
;
306 fw_cfg_write(s
, value
>> (8 * --i
));
310 static bool fw_cfg_data_mem_valid(void *opaque
, hwaddr addr
,
311 unsigned size
, bool is_write
)
316 static void fw_cfg_ctl_mem_write(void *opaque
, hwaddr addr
,
317 uint64_t value
, unsigned size
)
319 fw_cfg_select(opaque
, (uint16_t)value
);
322 static bool fw_cfg_ctl_mem_valid(void *opaque
, hwaddr addr
,
323 unsigned size
, bool is_write
)
325 return is_write
&& size
== 2;
328 static uint64_t fw_cfg_comb_read(void *opaque
, hwaddr addr
,
331 return fw_cfg_read(opaque
);
334 static void fw_cfg_comb_write(void *opaque
, hwaddr addr
,
335 uint64_t value
, unsigned size
)
339 fw_cfg_write(opaque
, (uint8_t)value
);
342 fw_cfg_select(opaque
, (uint16_t)value
);
347 static bool fw_cfg_comb_valid(void *opaque
, hwaddr addr
,
348 unsigned size
, bool is_write
)
350 return (size
== 1) || (is_write
&& size
== 2);
353 static const MemoryRegionOps fw_cfg_ctl_mem_ops
= {
354 .write
= fw_cfg_ctl_mem_write
,
355 .endianness
= DEVICE_BIG_ENDIAN
,
356 .valid
.accepts
= fw_cfg_ctl_mem_valid
,
359 static const MemoryRegionOps fw_cfg_data_mem_ops
= {
360 .read
= fw_cfg_data_mem_read
,
361 .write
= fw_cfg_data_mem_write
,
362 .endianness
= DEVICE_BIG_ENDIAN
,
364 .min_access_size
= 1,
365 .max_access_size
= 1,
366 .accepts
= fw_cfg_data_mem_valid
,
370 static const MemoryRegionOps fw_cfg_comb_mem_ops
= {
371 .read
= fw_cfg_comb_read
,
372 .write
= fw_cfg_comb_write
,
373 .endianness
= DEVICE_LITTLE_ENDIAN
,
374 .valid
.accepts
= fw_cfg_comb_valid
,
377 static void fw_cfg_reset(DeviceState
*d
)
379 FWCfgState
*s
= FW_CFG(d
);
384 /* Save restore 32 bit int as uint16_t
385 This is a Big hack, but it is how the old state did it.
386 Or we broke compatibility in the state, or we can't use struct tm
389 static int get_uint32_as_uint16(QEMUFile
*f
, void *pv
, size_t size
)
392 *v
= qemu_get_be16(f
);
396 static void put_unused(QEMUFile
*f
, void *pv
, size_t size
)
398 fprintf(stderr
, "uint32_as_uint16 is only used for backward compatibility.\n");
399 fprintf(stderr
, "This functions shouldn't be called.\n");
402 static const VMStateInfo vmstate_hack_uint32_as_uint16
= {
403 .name
= "int32_as_uint16",
404 .get
= get_uint32_as_uint16
,
408 #define VMSTATE_UINT16_HACK(_f, _s, _t) \
409 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint32_as_uint16, uint32_t)
412 static bool is_version_1(void *opaque
, int version_id
)
414 return version_id
== 1;
417 static const VMStateDescription vmstate_fw_cfg
= {
420 .minimum_version_id
= 1,
421 .fields
= (VMStateField
[]) {
422 VMSTATE_UINT16(cur_entry
, FWCfgState
),
423 VMSTATE_UINT16_HACK(cur_offset
, FWCfgState
, is_version_1
),
424 VMSTATE_UINT32_V(cur_offset
, FWCfgState
, 2),
425 VMSTATE_END_OF_LIST()
429 static void fw_cfg_add_bytes_read_callback(FWCfgState
*s
, uint16_t key
,
430 FWCfgReadCallback callback
,
431 void *callback_opaque
,
432 void *data
, size_t len
)
434 int arch
= !!(key
& FW_CFG_ARCH_LOCAL
);
436 key
&= FW_CFG_ENTRY_MASK
;
438 assert(key
< FW_CFG_MAX_ENTRY
&& len
< UINT32_MAX
);
440 s
->entries
[arch
][key
].data
= data
;
441 s
->entries
[arch
][key
].len
= (uint32_t)len
;
442 s
->entries
[arch
][key
].read_callback
= callback
;
443 s
->entries
[arch
][key
].callback_opaque
= callback_opaque
;
446 static void *fw_cfg_modify_bytes_read(FWCfgState
*s
, uint16_t key
,
447 void *data
, size_t len
)
450 int arch
= !!(key
& FW_CFG_ARCH_LOCAL
);
452 key
&= FW_CFG_ENTRY_MASK
;
454 assert(key
< FW_CFG_MAX_ENTRY
&& len
< UINT32_MAX
);
456 /* return the old data to the function caller, avoid memory leak */
457 ptr
= s
->entries
[arch
][key
].data
;
458 s
->entries
[arch
][key
].data
= data
;
459 s
->entries
[arch
][key
].len
= len
;
460 s
->entries
[arch
][key
].callback_opaque
= NULL
;
461 s
->entries
[arch
][key
].callback
= NULL
;
466 void fw_cfg_add_bytes(FWCfgState
*s
, uint16_t key
, void *data
, size_t len
)
468 fw_cfg_add_bytes_read_callback(s
, key
, NULL
, NULL
, data
, len
);
471 void fw_cfg_add_string(FWCfgState
*s
, uint16_t key
, const char *value
)
473 size_t sz
= strlen(value
) + 1;
475 fw_cfg_add_bytes(s
, key
, g_memdup(value
, sz
), sz
);
478 void fw_cfg_add_i16(FWCfgState
*s
, uint16_t key
, uint16_t value
)
482 copy
= g_malloc(sizeof(value
));
483 *copy
= cpu_to_le16(value
);
484 fw_cfg_add_bytes(s
, key
, copy
, sizeof(value
));
487 void fw_cfg_add_i32(FWCfgState
*s
, uint16_t key
, uint32_t value
)
491 copy
= g_malloc(sizeof(value
));
492 *copy
= cpu_to_le32(value
);
493 fw_cfg_add_bytes(s
, key
, copy
, sizeof(value
));
496 void fw_cfg_add_i64(FWCfgState
*s
, uint16_t key
, uint64_t value
)
500 copy
= g_malloc(sizeof(value
));
501 *copy
= cpu_to_le64(value
);
502 fw_cfg_add_bytes(s
, key
, copy
, sizeof(value
));
505 void fw_cfg_add_callback(FWCfgState
*s
, uint16_t key
, FWCfgCallback callback
,
506 void *callback_opaque
, void *data
, size_t len
)
508 int arch
= !!(key
& FW_CFG_ARCH_LOCAL
);
510 assert(key
& FW_CFG_WRITE_CHANNEL
);
512 key
&= FW_CFG_ENTRY_MASK
;
514 assert(key
< FW_CFG_MAX_ENTRY
&& len
<= UINT32_MAX
);
516 s
->entries
[arch
][key
].data
= data
;
517 s
->entries
[arch
][key
].len
= (uint32_t)len
;
518 s
->entries
[arch
][key
].callback_opaque
= callback_opaque
;
519 s
->entries
[arch
][key
].callback
= callback
;
522 void fw_cfg_add_file_callback(FWCfgState
*s
, const char *filename
,
523 FWCfgReadCallback callback
, void *callback_opaque
,
524 void *data
, size_t len
)
530 dsize
= sizeof(uint32_t) + sizeof(FWCfgFile
) * FW_CFG_FILE_SLOTS
;
531 s
->files
= g_malloc0(dsize
);
532 fw_cfg_add_bytes(s
, FW_CFG_FILE_DIR
, s
->files
, dsize
);
535 index
= be32_to_cpu(s
->files
->count
);
536 assert(index
< FW_CFG_FILE_SLOTS
);
538 fw_cfg_add_bytes_read_callback(s
, FW_CFG_FILE_FIRST
+ index
,
539 callback
, callback_opaque
, data
, len
);
541 pstrcpy(s
->files
->f
[index
].name
, sizeof(s
->files
->f
[index
].name
),
543 for (i
= 0; i
< index
; i
++) {
544 if (strcmp(s
->files
->f
[index
].name
, s
->files
->f
[i
].name
) == 0) {
545 trace_fw_cfg_add_file_dupe(s
, s
->files
->f
[index
].name
);
550 s
->files
->f
[index
].size
= cpu_to_be32(len
);
551 s
->files
->f
[index
].select
= cpu_to_be16(FW_CFG_FILE_FIRST
+ index
);
552 trace_fw_cfg_add_file(s
, index
, s
->files
->f
[index
].name
, len
);
554 s
->files
->count
= cpu_to_be32(index
+1);
557 void fw_cfg_add_file(FWCfgState
*s
, const char *filename
,
558 void *data
, size_t len
)
560 fw_cfg_add_file_callback(s
, filename
, NULL
, NULL
, data
, len
);
563 void *fw_cfg_modify_file(FWCfgState
*s
, const char *filename
,
564 void *data
, size_t len
)
571 index
= be32_to_cpu(s
->files
->count
);
572 assert(index
< FW_CFG_FILE_SLOTS
);
574 for (i
= 0; i
< index
; i
++) {
575 if (strcmp(filename
, s
->files
->f
[i
].name
) == 0) {
576 ptr
= fw_cfg_modify_bytes_read(s
, FW_CFG_FILE_FIRST
+ i
,
578 s
->files
->f
[i
].size
= cpu_to_be32(len
);
583 fw_cfg_add_file_callback(s
, filename
, NULL
, NULL
, data
, len
);
587 static void fw_cfg_machine_reset(void *opaque
)
591 FWCfgState
*s
= opaque
;
592 char *bootindex
= get_boot_devices_list(&len
, false);
594 ptr
= fw_cfg_modify_file(s
, "bootorder", (uint8_t *)bootindex
, len
);
598 static void fw_cfg_machine_ready(struct Notifier
*n
, void *data
)
600 FWCfgState
*s
= container_of(n
, FWCfgState
, machine_ready
);
601 qemu_register_reset(fw_cfg_machine_reset
, s
);
606 static void fw_cfg_init1(DeviceState
*dev
)
608 FWCfgState
*s
= FW_CFG(dev
);
610 assert(!object_resolve_path(FW_CFG_PATH
, NULL
));
612 object_property_add_child(qdev_get_machine(), FW_CFG_NAME
, OBJECT(s
), NULL
);
614 qdev_init_nofail(dev
);
616 fw_cfg_add_bytes(s
, FW_CFG_SIGNATURE
, (char *)"QEMU", 4);
617 fw_cfg_add_i32(s
, FW_CFG_ID
, 1);
618 fw_cfg_add_bytes(s
, FW_CFG_UUID
, qemu_uuid
, 16);
619 fw_cfg_add_i16(s
, FW_CFG_NOGRAPHIC
, (uint16_t)(display_type
== DT_NOGRAPHIC
));
620 fw_cfg_add_i16(s
, FW_CFG_NB_CPUS
, (uint16_t)smp_cpus
);
621 fw_cfg_add_i16(s
, FW_CFG_BOOT_MENU
, (uint16_t)boot_menu
);
622 fw_cfg_bootsplash(s
);
625 s
->machine_ready
.notify
= fw_cfg_machine_ready
;
626 qemu_add_machine_init_done_notifier(&s
->machine_ready
);
629 FWCfgState
*fw_cfg_init_io(uint32_t iobase
)
633 dev
= qdev_create(NULL
, TYPE_FW_CFG_IO
);
634 qdev_prop_set_uint32(dev
, "iobase", iobase
);
640 FWCfgState
*fw_cfg_init_mem_wide(hwaddr ctl_addr
, hwaddr data_addr
,
646 dev
= qdev_create(NULL
, TYPE_FW_CFG_MEM
);
647 qdev_prop_set_uint32(dev
, "data_width", data_width
);
651 sbd
= SYS_BUS_DEVICE(dev
);
652 sysbus_mmio_map(sbd
, 0, ctl_addr
);
653 sysbus_mmio_map(sbd
, 1, data_addr
);
658 FWCfgState
*fw_cfg_init_mem(hwaddr ctl_addr
, hwaddr data_addr
)
660 return fw_cfg_init_mem_wide(ctl_addr
, data_addr
,
661 fw_cfg_data_mem_ops
.valid
.max_access_size
);
665 FWCfgState
*fw_cfg_find(void)
667 return FW_CFG(object_resolve_path(FW_CFG_PATH
, NULL
));
670 static void fw_cfg_class_init(ObjectClass
*klass
, void *data
)
672 DeviceClass
*dc
= DEVICE_CLASS(klass
);
674 dc
->reset
= fw_cfg_reset
;
675 dc
->vmsd
= &vmstate_fw_cfg
;
678 static const TypeInfo fw_cfg_info
= {
680 .parent
= TYPE_SYS_BUS_DEVICE
,
681 .instance_size
= sizeof(FWCfgState
),
682 .class_init
= fw_cfg_class_init
,
686 static Property fw_cfg_io_properties
[] = {
687 DEFINE_PROP_UINT32("iobase", FWCfgIoState
, iobase
, -1),
688 DEFINE_PROP_END_OF_LIST(),
691 static void fw_cfg_io_realize(DeviceState
*dev
, Error
**errp
)
693 FWCfgIoState
*s
= FW_CFG_IO(dev
);
694 SysBusDevice
*sbd
= SYS_BUS_DEVICE(dev
);
696 memory_region_init_io(&s
->comb_iomem
, OBJECT(s
), &fw_cfg_comb_mem_ops
,
697 FW_CFG(s
), "fwcfg", FW_CFG_SIZE
);
698 sysbus_add_io(sbd
, s
->iobase
, &s
->comb_iomem
);
701 static void fw_cfg_io_class_init(ObjectClass
*klass
, void *data
)
703 DeviceClass
*dc
= DEVICE_CLASS(klass
);
705 dc
->realize
= fw_cfg_io_realize
;
706 dc
->props
= fw_cfg_io_properties
;
709 static const TypeInfo fw_cfg_io_info
= {
710 .name
= TYPE_FW_CFG_IO
,
711 .parent
= TYPE_FW_CFG
,
712 .instance_size
= sizeof(FWCfgIoState
),
713 .class_init
= fw_cfg_io_class_init
,
717 static Property fw_cfg_mem_properties
[] = {
718 DEFINE_PROP_UINT32("data_width", FWCfgMemState
, data_width
, -1),
719 DEFINE_PROP_END_OF_LIST(),
722 static void fw_cfg_mem_realize(DeviceState
*dev
, Error
**errp
)
724 FWCfgMemState
*s
= FW_CFG_MEM(dev
);
725 SysBusDevice
*sbd
= SYS_BUS_DEVICE(dev
);
726 const MemoryRegionOps
*data_ops
= &fw_cfg_data_mem_ops
;
728 memory_region_init_io(&s
->ctl_iomem
, OBJECT(s
), &fw_cfg_ctl_mem_ops
,
729 FW_CFG(s
), "fwcfg.ctl", FW_CFG_SIZE
);
730 sysbus_init_mmio(sbd
, &s
->ctl_iomem
);
732 if (s
->data_width
> data_ops
->valid
.max_access_size
) {
733 /* memberwise copy because the "old_mmio" member is const */
734 s
->wide_data_ops
.read
= data_ops
->read
;
735 s
->wide_data_ops
.write
= data_ops
->write
;
736 s
->wide_data_ops
.endianness
= data_ops
->endianness
;
737 s
->wide_data_ops
.valid
= data_ops
->valid
;
738 s
->wide_data_ops
.impl
= data_ops
->impl
;
740 s
->wide_data_ops
.valid
.max_access_size
= s
->data_width
;
741 s
->wide_data_ops
.impl
.max_access_size
= s
->data_width
;
742 data_ops
= &s
->wide_data_ops
;
744 memory_region_init_io(&s
->data_iomem
, OBJECT(s
), data_ops
, FW_CFG(s
),
745 "fwcfg.data", data_ops
->valid
.max_access_size
);
746 sysbus_init_mmio(sbd
, &s
->data_iomem
);
749 static void fw_cfg_mem_class_init(ObjectClass
*klass
, void *data
)
751 DeviceClass
*dc
= DEVICE_CLASS(klass
);
753 dc
->realize
= fw_cfg_mem_realize
;
754 dc
->props
= fw_cfg_mem_properties
;
757 static const TypeInfo fw_cfg_mem_info
= {
758 .name
= TYPE_FW_CFG_MEM
,
759 .parent
= TYPE_FW_CFG
,
760 .instance_size
= sizeof(FWCfgMemState
),
761 .class_init
= fw_cfg_mem_class_init
,
765 static void fw_cfg_register_types(void)
767 type_register_static(&fw_cfg_info
);
768 type_register_static(&fw_cfg_io_info
);
769 type_register_static(&fw_cfg_mem_info
);
772 type_init(fw_cfg_register_types
)