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/hw.h" 25 #include "sysemu/sysemu.h" 26 #include "hw/isa/isa.h" 27 #include "hw/nvram/fw_cfg.h" 28 #include "hw/sysbus.h" 29 #include "trace.h" 30 #include "qemu/error-report.h" 31 #include "qemu/config-file.h" 32 33 #define FW_CFG_SIZE 2 34 #define FW_CFG_DATA_SIZE 1 35 #define TYPE_FW_CFG "fw_cfg" 36 #define FW_CFG_NAME "fw_cfg" 37 #define FW_CFG_PATH "/machine/" FW_CFG_NAME 38 #define FW_CFG(obj) OBJECT_CHECK(FWCfgState, (obj), TYPE_FW_CFG) 39 40 typedef struct FWCfgEntry { 41 uint32_t len; 42 uint8_t *data; 43 void *callback_opaque; 44 FWCfgCallback callback; 45 FWCfgReadCallback read_callback; 46 } FWCfgEntry; 47 48 struct FWCfgState { 49 /*< private >*/ 50 SysBusDevice parent_obj; 51 /*< public >*/ 52 53 MemoryRegion ctl_iomem, data_iomem, comb_iomem; 54 uint32_t ctl_iobase, data_iobase; 55 FWCfgEntry entries[2][FW_CFG_MAX_ENTRY]; 56 FWCfgFiles *files; 57 uint16_t cur_entry; 58 uint32_t cur_offset; 59 Notifier machine_ready; 60 }; 61 62 #define JPG_FILE 0 63 #define BMP_FILE 1 64 65 static char *read_splashfile(char *filename, gsize *file_sizep, 66 int *file_typep) 67 { 68 GError *err = NULL; 69 gboolean res; 70 gchar *content; 71 int file_type; 72 unsigned int filehead; 73 int bmp_bpp; 74 75 res = g_file_get_contents(filename, &content, file_sizep, &err); 76 if (res == FALSE) { 77 error_report("failed to read splash file '%s'", filename); 78 g_error_free(err); 79 return NULL; 80 } 81 82 /* check file size */ 83 if (*file_sizep < 30) { 84 goto error; 85 } 86 87 /* check magic ID */ 88 filehead = ((content[0] & 0xff) + (content[1] << 8)) & 0xffff; 89 if (filehead == 0xd8ff) { 90 file_type = JPG_FILE; 91 } else if (filehead == 0x4d42) { 92 file_type = BMP_FILE; 93 } else { 94 goto error; 95 } 96 97 /* check BMP bpp */ 98 if (file_type == BMP_FILE) { 99 bmp_bpp = (content[28] + (content[29] << 8)) & 0xffff; 100 if (bmp_bpp != 24) { 101 goto error; 102 } 103 } 104 105 /* return values */ 106 *file_typep = file_type; 107 108 return content; 109 110 error: 111 error_report("splash file '%s' format not recognized; must be JPEG " 112 "or 24 bit BMP", filename); 113 g_free(content); 114 return NULL; 115 } 116 117 static void fw_cfg_bootsplash(FWCfgState *s) 118 { 119 int boot_splash_time = -1; 120 const char *boot_splash_filename = NULL; 121 char *p; 122 char *filename, *file_data; 123 gsize file_size; 124 int file_type; 125 const char *temp; 126 127 /* get user configuration */ 128 QemuOptsList *plist = qemu_find_opts("boot-opts"); 129 QemuOpts *opts = QTAILQ_FIRST(&plist->head); 130 if (opts != NULL) { 131 temp = qemu_opt_get(opts, "splash"); 132 if (temp != NULL) { 133 boot_splash_filename = temp; 134 } 135 temp = qemu_opt_get(opts, "splash-time"); 136 if (temp != NULL) { 137 p = (char *)temp; 138 boot_splash_time = strtol(p, (char **)&p, 10); 139 } 140 } 141 142 /* insert splash time if user configurated */ 143 if (boot_splash_time >= 0) { 144 /* validate the input */ 145 if (boot_splash_time > 0xffff) { 146 error_report("splash time is big than 65535, force it to 65535."); 147 boot_splash_time = 0xffff; 148 } 149 /* use little endian format */ 150 qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time & 0xff); 151 qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time >> 8) & 0xff); 152 fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2); 153 } 154 155 /* insert splash file if user configurated */ 156 if (boot_splash_filename != NULL) { 157 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename); 158 if (filename == NULL) { 159 error_report("failed to find file '%s'.", boot_splash_filename); 160 return; 161 } 162 163 /* loading file data */ 164 file_data = read_splashfile(filename, &file_size, &file_type); 165 if (file_data == NULL) { 166 g_free(filename); 167 return; 168 } 169 if (boot_splash_filedata != NULL) { 170 g_free(boot_splash_filedata); 171 } 172 boot_splash_filedata = (uint8_t *)file_data; 173 boot_splash_filedata_size = file_size; 174 175 /* insert data */ 176 if (file_type == JPG_FILE) { 177 fw_cfg_add_file(s, "bootsplash.jpg", 178 boot_splash_filedata, boot_splash_filedata_size); 179 } else { 180 fw_cfg_add_file(s, "bootsplash.bmp", 181 boot_splash_filedata, boot_splash_filedata_size); 182 } 183 g_free(filename); 184 } 185 } 186 187 static void fw_cfg_reboot(FWCfgState *s) 188 { 189 int reboot_timeout = -1; 190 char *p; 191 const char *temp; 192 193 /* get user configuration */ 194 QemuOptsList *plist = qemu_find_opts("boot-opts"); 195 QemuOpts *opts = QTAILQ_FIRST(&plist->head); 196 if (opts != NULL) { 197 temp = qemu_opt_get(opts, "reboot-timeout"); 198 if (temp != NULL) { 199 p = (char *)temp; 200 reboot_timeout = strtol(p, (char **)&p, 10); 201 } 202 } 203 /* validate the input */ 204 if (reboot_timeout > 0xffff) { 205 error_report("reboot timeout is larger than 65535, force it to 65535."); 206 reboot_timeout = 0xffff; 207 } 208 fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4), 4); 209 } 210 211 static void fw_cfg_write(FWCfgState *s, uint8_t value) 212 { 213 int arch = !!(s->cur_entry & FW_CFG_ARCH_LOCAL); 214 FWCfgEntry *e = &s->entries[arch][s->cur_entry & FW_CFG_ENTRY_MASK]; 215 216 trace_fw_cfg_write(s, value); 217 218 if (s->cur_entry & FW_CFG_WRITE_CHANNEL && e->callback && 219 s->cur_offset < e->len) { 220 e->data[s->cur_offset++] = value; 221 if (s->cur_offset == e->len) { 222 e->callback(e->callback_opaque, e->data); 223 s->cur_offset = 0; 224 } 225 } 226 } 227 228 static int fw_cfg_select(FWCfgState *s, uint16_t key) 229 { 230 int ret; 231 232 s->cur_offset = 0; 233 if ((key & FW_CFG_ENTRY_MASK) >= FW_CFG_MAX_ENTRY) { 234 s->cur_entry = FW_CFG_INVALID; 235 ret = 0; 236 } else { 237 s->cur_entry = key; 238 ret = 1; 239 } 240 241 trace_fw_cfg_select(s, key, ret); 242 return ret; 243 } 244 245 static 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 if (e->read_callback) { 255 e->read_callback(e->callback_opaque, s->cur_offset); 256 } 257 ret = e->data[s->cur_offset++]; 258 } 259 260 trace_fw_cfg_read(s, ret); 261 return ret; 262 } 263 264 static uint64_t fw_cfg_data_mem_read(void *opaque, hwaddr addr, 265 unsigned size) 266 { 267 return fw_cfg_read(opaque); 268 } 269 270 static void fw_cfg_data_mem_write(void *opaque, hwaddr addr, 271 uint64_t value, unsigned size) 272 { 273 fw_cfg_write(opaque, (uint8_t)value); 274 } 275 276 static void fw_cfg_ctl_mem_write(void *opaque, hwaddr addr, 277 uint64_t value, unsigned size) 278 { 279 fw_cfg_select(opaque, (uint16_t)value); 280 } 281 282 static bool fw_cfg_ctl_mem_valid(void *opaque, hwaddr addr, 283 unsigned size, bool is_write) 284 { 285 return is_write && size == 2; 286 } 287 288 static uint64_t fw_cfg_comb_read(void *opaque, hwaddr addr, 289 unsigned size) 290 { 291 return fw_cfg_read(opaque); 292 } 293 294 static void fw_cfg_comb_write(void *opaque, hwaddr addr, 295 uint64_t value, unsigned size) 296 { 297 switch (size) { 298 case 1: 299 fw_cfg_write(opaque, (uint8_t)value); 300 break; 301 case 2: 302 fw_cfg_select(opaque, (uint16_t)value); 303 break; 304 } 305 } 306 307 static bool fw_cfg_comb_valid(void *opaque, hwaddr addr, 308 unsigned size, bool is_write) 309 { 310 return (size == 1) || (is_write && size == 2); 311 } 312 313 static const MemoryRegionOps fw_cfg_ctl_mem_ops = { 314 .write = fw_cfg_ctl_mem_write, 315 .endianness = DEVICE_NATIVE_ENDIAN, 316 .valid.accepts = fw_cfg_ctl_mem_valid, 317 }; 318 319 static const MemoryRegionOps fw_cfg_data_mem_ops = { 320 .read = fw_cfg_data_mem_read, 321 .write = fw_cfg_data_mem_write, 322 .endianness = DEVICE_NATIVE_ENDIAN, 323 .valid = { 324 .min_access_size = 1, 325 .max_access_size = 1, 326 }, 327 }; 328 329 static const MemoryRegionOps fw_cfg_comb_mem_ops = { 330 .read = fw_cfg_comb_read, 331 .write = fw_cfg_comb_write, 332 .endianness = DEVICE_LITTLE_ENDIAN, 333 .valid.accepts = fw_cfg_comb_valid, 334 }; 335 336 static void fw_cfg_reset(DeviceState *d) 337 { 338 FWCfgState *s = FW_CFG(d); 339 340 fw_cfg_select(s, 0); 341 } 342 343 /* Save restore 32 bit int as uint16_t 344 This is a Big hack, but it is how the old state did it. 345 Or we broke compatibility in the state, or we can't use struct tm 346 */ 347 348 static int get_uint32_as_uint16(QEMUFile *f, void *pv, size_t size) 349 { 350 uint32_t *v = pv; 351 *v = qemu_get_be16(f); 352 return 0; 353 } 354 355 static void put_unused(QEMUFile *f, void *pv, size_t size) 356 { 357 fprintf(stderr, "uint32_as_uint16 is only used for backward compatibility.\n"); 358 fprintf(stderr, "This functions shouldn't be called.\n"); 359 } 360 361 static const VMStateInfo vmstate_hack_uint32_as_uint16 = { 362 .name = "int32_as_uint16", 363 .get = get_uint32_as_uint16, 364 .put = put_unused, 365 }; 366 367 #define VMSTATE_UINT16_HACK(_f, _s, _t) \ 368 VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint32_as_uint16, uint32_t) 369 370 371 static bool is_version_1(void *opaque, int version_id) 372 { 373 return version_id == 1; 374 } 375 376 static const VMStateDescription vmstate_fw_cfg = { 377 .name = "fw_cfg", 378 .version_id = 2, 379 .minimum_version_id = 1, 380 .fields = (VMStateField[]) { 381 VMSTATE_UINT16(cur_entry, FWCfgState), 382 VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1), 383 VMSTATE_UINT32_V(cur_offset, FWCfgState, 2), 384 VMSTATE_END_OF_LIST() 385 } 386 }; 387 388 static void fw_cfg_add_bytes_read_callback(FWCfgState *s, uint16_t key, 389 FWCfgReadCallback callback, 390 void *callback_opaque, 391 void *data, size_t len) 392 { 393 int arch = !!(key & FW_CFG_ARCH_LOCAL); 394 395 key &= FW_CFG_ENTRY_MASK; 396 397 assert(key < FW_CFG_MAX_ENTRY && len < UINT32_MAX); 398 399 s->entries[arch][key].data = data; 400 s->entries[arch][key].len = (uint32_t)len; 401 s->entries[arch][key].read_callback = callback; 402 s->entries[arch][key].callback_opaque = callback_opaque; 403 } 404 405 static void *fw_cfg_modify_bytes_read(FWCfgState *s, uint16_t key, 406 void *data, size_t len) 407 { 408 void *ptr; 409 int arch = !!(key & FW_CFG_ARCH_LOCAL); 410 411 key &= FW_CFG_ENTRY_MASK; 412 413 assert(key < FW_CFG_MAX_ENTRY && len < UINT32_MAX); 414 415 /* return the old data to the function caller, avoid memory leak */ 416 ptr = s->entries[arch][key].data; 417 s->entries[arch][key].data = data; 418 s->entries[arch][key].len = len; 419 s->entries[arch][key].callback_opaque = NULL; 420 s->entries[arch][key].callback = NULL; 421 422 return ptr; 423 } 424 425 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len) 426 { 427 fw_cfg_add_bytes_read_callback(s, key, NULL, NULL, data, len); 428 } 429 430 void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value) 431 { 432 size_t sz = strlen(value) + 1; 433 434 return fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz); 435 } 436 437 void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value) 438 { 439 uint16_t *copy; 440 441 copy = g_malloc(sizeof(value)); 442 *copy = cpu_to_le16(value); 443 fw_cfg_add_bytes(s, key, copy, sizeof(value)); 444 } 445 446 void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value) 447 { 448 uint32_t *copy; 449 450 copy = g_malloc(sizeof(value)); 451 *copy = cpu_to_le32(value); 452 fw_cfg_add_bytes(s, key, copy, sizeof(value)); 453 } 454 455 void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value) 456 { 457 uint64_t *copy; 458 459 copy = g_malloc(sizeof(value)); 460 *copy = cpu_to_le64(value); 461 fw_cfg_add_bytes(s, key, copy, sizeof(value)); 462 } 463 464 void fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback, 465 void *callback_opaque, void *data, size_t len) 466 { 467 int arch = !!(key & FW_CFG_ARCH_LOCAL); 468 469 assert(key & FW_CFG_WRITE_CHANNEL); 470 471 key &= FW_CFG_ENTRY_MASK; 472 473 assert(key < FW_CFG_MAX_ENTRY && len <= UINT32_MAX); 474 475 s->entries[arch][key].data = data; 476 s->entries[arch][key].len = (uint32_t)len; 477 s->entries[arch][key].callback_opaque = callback_opaque; 478 s->entries[arch][key].callback = callback; 479 } 480 481 void fw_cfg_add_file_callback(FWCfgState *s, const char *filename, 482 FWCfgReadCallback callback, void *callback_opaque, 483 void *data, size_t len) 484 { 485 int i, index; 486 size_t dsize; 487 488 if (!s->files) { 489 dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS; 490 s->files = g_malloc0(dsize); 491 fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, s->files, dsize); 492 } 493 494 index = be32_to_cpu(s->files->count); 495 assert(index < FW_CFG_FILE_SLOTS); 496 497 fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index, 498 callback, callback_opaque, data, len); 499 500 pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name), 501 filename); 502 for (i = 0; i < index; i++) { 503 if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) { 504 trace_fw_cfg_add_file_dupe(s, s->files->f[index].name); 505 return; 506 } 507 } 508 509 s->files->f[index].size = cpu_to_be32(len); 510 s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index); 511 trace_fw_cfg_add_file(s, index, s->files->f[index].name, len); 512 513 s->files->count = cpu_to_be32(index+1); 514 } 515 516 void fw_cfg_add_file(FWCfgState *s, const char *filename, 517 void *data, size_t len) 518 { 519 fw_cfg_add_file_callback(s, filename, NULL, NULL, data, len); 520 } 521 522 void *fw_cfg_modify_file(FWCfgState *s, const char *filename, 523 void *data, size_t len) 524 { 525 int i, index; 526 527 assert(s->files); 528 529 index = be32_to_cpu(s->files->count); 530 assert(index < FW_CFG_FILE_SLOTS); 531 532 for (i = 0; i < index; i++) { 533 if (strcmp(filename, s->files->f[i].name) == 0) { 534 return fw_cfg_modify_bytes_read(s, FW_CFG_FILE_FIRST + i, 535 data, len); 536 } 537 } 538 /* add new one */ 539 fw_cfg_add_file_callback(s, filename, NULL, NULL, data, len); 540 return NULL; 541 } 542 543 static void fw_cfg_machine_reset(void *opaque) 544 { 545 void *ptr; 546 size_t len; 547 FWCfgState *s = opaque; 548 char *bootindex = get_boot_devices_list(&len, false); 549 550 ptr = fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len); 551 g_free(ptr); 552 } 553 554 static void fw_cfg_machine_ready(struct Notifier *n, void *data) 555 { 556 FWCfgState *s = container_of(n, FWCfgState, machine_ready); 557 qemu_register_reset(fw_cfg_machine_reset, s); 558 } 559 560 FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, 561 hwaddr ctl_addr, hwaddr data_addr) 562 { 563 DeviceState *dev; 564 SysBusDevice *d; 565 FWCfgState *s; 566 567 dev = qdev_create(NULL, TYPE_FW_CFG); 568 qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port); 569 qdev_prop_set_uint32(dev, "data_iobase", data_port); 570 d = SYS_BUS_DEVICE(dev); 571 572 s = FW_CFG(dev); 573 574 assert(!object_resolve_path(FW_CFG_PATH, NULL)); 575 576 object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s), NULL); 577 578 qdev_init_nofail(dev); 579 580 if (ctl_addr) { 581 sysbus_mmio_map(d, 0, ctl_addr); 582 } 583 if (data_addr) { 584 sysbus_mmio_map(d, 1, data_addr); 585 } 586 fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); 587 fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); 588 fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); 589 fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); 590 fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); 591 fw_cfg_bootsplash(s); 592 fw_cfg_reboot(s); 593 594 s->machine_ready.notify = fw_cfg_machine_ready; 595 qemu_add_machine_init_done_notifier(&s->machine_ready); 596 597 return s; 598 } 599 600 static void fw_cfg_initfn(Object *obj) 601 { 602 SysBusDevice *sbd = SYS_BUS_DEVICE(obj); 603 FWCfgState *s = FW_CFG(obj); 604 605 memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops, s, 606 "fwcfg.ctl", FW_CFG_SIZE); 607 sysbus_init_mmio(sbd, &s->ctl_iomem); 608 memory_region_init_io(&s->data_iomem, OBJECT(s), &fw_cfg_data_mem_ops, s, 609 "fwcfg.data", FW_CFG_DATA_SIZE); 610 sysbus_init_mmio(sbd, &s->data_iomem); 611 /* In case ctl and data overlap: */ 612 memory_region_init_io(&s->comb_iomem, OBJECT(s), &fw_cfg_comb_mem_ops, s, 613 "fwcfg", FW_CFG_SIZE); 614 } 615 616 static void fw_cfg_realize(DeviceState *dev, Error **errp) 617 { 618 FWCfgState *s = FW_CFG(dev); 619 SysBusDevice *sbd = SYS_BUS_DEVICE(dev); 620 621 622 if (s->ctl_iobase + 1 == s->data_iobase) { 623 sysbus_add_io(sbd, s->ctl_iobase, &s->comb_iomem); 624 } else { 625 if (s->ctl_iobase) { 626 sysbus_add_io(sbd, s->ctl_iobase, &s->ctl_iomem); 627 } 628 if (s->data_iobase) { 629 sysbus_add_io(sbd, s->data_iobase, &s->data_iomem); 630 } 631 } 632 } 633 634 static Property fw_cfg_properties[] = { 635 DEFINE_PROP_UINT32("ctl_iobase", FWCfgState, ctl_iobase, -1), 636 DEFINE_PROP_UINT32("data_iobase", FWCfgState, data_iobase, -1), 637 DEFINE_PROP_END_OF_LIST(), 638 }; 639 640 FWCfgState *fw_cfg_find(void) 641 { 642 return FW_CFG(object_resolve_path(FW_CFG_PATH, NULL)); 643 } 644 645 static void fw_cfg_class_init(ObjectClass *klass, void *data) 646 { 647 DeviceClass *dc = DEVICE_CLASS(klass); 648 649 dc->realize = fw_cfg_realize; 650 dc->reset = fw_cfg_reset; 651 dc->vmsd = &vmstate_fw_cfg; 652 dc->props = fw_cfg_properties; 653 } 654 655 static const TypeInfo fw_cfg_info = { 656 .name = TYPE_FW_CFG, 657 .parent = TYPE_SYS_BUS_DEVICE, 658 .instance_size = sizeof(FWCfgState), 659 .instance_init = fw_cfg_initfn, 660 .class_init = fw_cfg_class_init, 661 }; 662 663 static void fw_cfg_register_types(void) 664 { 665 type_register_static(&fw_cfg_info); 666 } 667 668 type_init(fw_cfg_register_types) 669