Commit f48f656949894aa4d440f4f2a5e5bf7b34106785
1 parent
5f750b2e
Sparc32: convert boot prom to qdev
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Showing
1 changed file
with
67 additions
and
87 deletions
hw/sun4m.c
... | ... | @@ -422,6 +422,64 @@ static void idreg_register_devices(void) |
422 | 422 | |
423 | 423 | device_init(idreg_register_devices); |
424 | 424 | |
425 | +/* Boot PROM (OpenBIOS) */ | |
426 | +static void prom_init(target_phys_addr_t addr, const char *bios_name) | |
427 | +{ | |
428 | + DeviceState *dev; | |
429 | + SysBusDevice *s; | |
430 | + char *filename; | |
431 | + int ret; | |
432 | + | |
433 | + dev = qdev_create(NULL, "openprom"); | |
434 | + qdev_init(dev); | |
435 | + s = sysbus_from_qdev(dev); | |
436 | + | |
437 | + sysbus_mmio_map(s, 0, addr); | |
438 | + | |
439 | + /* load boot prom */ | |
440 | + if (bios_name == NULL) { | |
441 | + bios_name = PROM_FILENAME; | |
442 | + } | |
443 | + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | |
444 | + if (filename) { | |
445 | + ret = load_elf(filename, addr - PROM_VADDR, NULL, NULL, NULL); | |
446 | + if (ret < 0 || ret > PROM_SIZE_MAX) { | |
447 | + ret = load_image_targphys(filename, addr, PROM_SIZE_MAX); | |
448 | + } | |
449 | + qemu_free(filename); | |
450 | + } else { | |
451 | + ret = -1; | |
452 | + } | |
453 | + if (ret < 0 || ret > PROM_SIZE_MAX) { | |
454 | + fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name); | |
455 | + exit(1); | |
456 | + } | |
457 | +} | |
458 | + | |
459 | +static void prom_init1(SysBusDevice *dev) | |
460 | +{ | |
461 | + ram_addr_t prom_offset; | |
462 | + | |
463 | + prom_offset = qemu_ram_alloc(PROM_SIZE_MAX); | |
464 | + sysbus_init_mmio(dev, PROM_SIZE_MAX, prom_offset | IO_MEM_ROM); | |
465 | +} | |
466 | + | |
467 | +static SysBusDeviceInfo prom_info = { | |
468 | + .init = prom_init1, | |
469 | + .qdev.name = "openprom", | |
470 | + .qdev.size = sizeof(SysBusDevice), | |
471 | + .qdev.props = (DevicePropList[]) { | |
472 | + {.name = NULL} | |
473 | + } | |
474 | +}; | |
475 | + | |
476 | +static void prom_register_devices(void) | |
477 | +{ | |
478 | + sysbus_register_withprop(&prom_info); | |
479 | +} | |
480 | + | |
481 | +device_init(prom_register_devices); | |
482 | + | |
425 | 483 | static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, |
426 | 484 | const char *boot_device, |
427 | 485 | const char *kernel_filename, |
... | ... | @@ -437,10 +495,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, |
437 | 495 | qemu_irq *esp_reset, *le_reset; |
438 | 496 | qemu_irq fdc_tc; |
439 | 497 | qemu_irq *cpu_halt; |
440 | - ram_addr_t ram_offset, prom_offset; | |
498 | + ram_addr_t ram_offset; | |
441 | 499 | unsigned long kernel_size; |
442 | - int ret; | |
443 | - char *filename; | |
444 | 500 | BlockDriverState *fd[MAX_FD]; |
445 | 501 | int drive_index; |
446 | 502 | void *fw_cfg; |
... | ... | @@ -482,33 +538,9 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size, |
482 | 538 | ram_offset = qemu_ram_alloc(RAM_size); |
483 | 539 | cpu_register_physical_memory(0, RAM_size, ram_offset); |
484 | 540 | |
485 | - /* load boot prom */ | |
486 | - prom_offset = qemu_ram_alloc(PROM_SIZE_MAX); | |
487 | - cpu_register_physical_memory(hwdef->slavio_base, | |
488 | - (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & | |
489 | - TARGET_PAGE_MASK, | |
490 | - prom_offset | IO_MEM_ROM); | |
491 | - | |
492 | - if (bios_name == NULL) | |
493 | - bios_name = PROM_FILENAME; | |
494 | - filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | |
495 | - if (filename) { | |
496 | - ret = load_elf(filename, hwdef->slavio_base - PROM_VADDR, | |
497 | - NULL, NULL, NULL); | |
498 | - if (ret < 0 || ret > PROM_SIZE_MAX) | |
499 | - ret = load_image_targphys(filename, hwdef->slavio_base, | |
500 | - PROM_SIZE_MAX); | |
501 | - qemu_free(filename); | |
502 | - } else { | |
503 | - ret = -1; | |
504 | - } | |
505 | - if (ret < 0 || ret > PROM_SIZE_MAX) { | |
506 | - fprintf(stderr, "qemu: could not load prom '%s'\n", | |
507 | - bios_name); | |
508 | - exit(1); | |
509 | - } | |
510 | - | |
511 | 541 | /* set up devices */ |
542 | + prom_init(hwdef->slavio_base, bios_name); | |
543 | + | |
512 | 544 | slavio_intctl = slavio_intctl_init(hwdef->intctl_base, |
513 | 545 | hwdef->intctl_base + 0x10000ULL, |
514 | 546 | &hwdef->intbit_to_level[0], |
... | ... | @@ -1227,10 +1259,8 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, |
1227 | 1259 | qemu_irq *cpu_irqs[MAX_CPUS], *sbi_irq, *sbi_cpu_irq, |
1228 | 1260 | espdma_irq, ledma_irq; |
1229 | 1261 | qemu_irq *esp_reset, *le_reset; |
1230 | - ram_addr_t ram_offset, prom_offset; | |
1262 | + ram_addr_t ram_offset; | |
1231 | 1263 | unsigned long kernel_size; |
1232 | - int ret; | |
1233 | - char *filename; | |
1234 | 1264 | void *fw_cfg; |
1235 | 1265 | |
1236 | 1266 | /* init CPUs */ |
... | ... | @@ -1269,33 +1299,9 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size, |
1269 | 1299 | ram_offset = qemu_ram_alloc(RAM_size); |
1270 | 1300 | cpu_register_physical_memory(0, RAM_size, ram_offset); |
1271 | 1301 | |
1272 | - /* load boot prom */ | |
1273 | - prom_offset = qemu_ram_alloc(PROM_SIZE_MAX); | |
1274 | - cpu_register_physical_memory(hwdef->slavio_base, | |
1275 | - (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & | |
1276 | - TARGET_PAGE_MASK, | |
1277 | - prom_offset | IO_MEM_ROM); | |
1278 | - | |
1279 | - if (bios_name == NULL) | |
1280 | - bios_name = PROM_FILENAME; | |
1281 | - filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | |
1282 | - if (filename) { | |
1283 | - ret = load_elf(filename, hwdef->slavio_base - PROM_VADDR, | |
1284 | - NULL, NULL, NULL); | |
1285 | - if (ret < 0 || ret > PROM_SIZE_MAX) | |
1286 | - ret = load_image_targphys(filename, hwdef->slavio_base, | |
1287 | - PROM_SIZE_MAX); | |
1288 | - qemu_free(filename); | |
1289 | - } else { | |
1290 | - ret = -1; | |
1291 | - } | |
1292 | - if (ret < 0 || ret > PROM_SIZE_MAX) { | |
1293 | - fprintf(stderr, "qemu: could not load prom '%s'\n", | |
1294 | - bios_name); | |
1295 | - exit(1); | |
1296 | - } | |
1297 | - | |
1298 | 1302 | /* set up devices */ |
1303 | + prom_init(hwdef->slavio_base, bios_name); | |
1304 | + | |
1299 | 1305 | sbi = sbi_init(hwdef->sbi_base, &sbi_irq, &sbi_cpu_irq, cpu_irqs); |
1300 | 1306 | |
1301 | 1307 | for (i = 0; i < MAX_IOUNITS; i++) |
... | ... | @@ -1448,10 +1454,8 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, |
1448 | 1454 | qemu_irq *cpu_irqs, *slavio_irq, espdma_irq, ledma_irq; |
1449 | 1455 | qemu_irq *esp_reset, *le_reset; |
1450 | 1456 | qemu_irq fdc_tc; |
1451 | - ram_addr_t ram_offset, prom_offset; | |
1457 | + ram_addr_t ram_offset; | |
1452 | 1458 | unsigned long kernel_size; |
1453 | - int ret; | |
1454 | - char *filename; | |
1455 | 1459 | BlockDriverState *fd[MAX_FD]; |
1456 | 1460 | int drive_index; |
1457 | 1461 | void *fw_cfg; |
... | ... | @@ -1483,33 +1487,9 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size, |
1483 | 1487 | ram_offset = qemu_ram_alloc(RAM_size); |
1484 | 1488 | cpu_register_physical_memory(0, RAM_size, ram_offset); |
1485 | 1489 | |
1486 | - /* load boot prom */ | |
1487 | - prom_offset = qemu_ram_alloc(PROM_SIZE_MAX); | |
1488 | - cpu_register_physical_memory(hwdef->slavio_base, | |
1489 | - (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & | |
1490 | - TARGET_PAGE_MASK, | |
1491 | - prom_offset | IO_MEM_ROM); | |
1492 | - | |
1493 | - if (bios_name == NULL) | |
1494 | - bios_name = PROM_FILENAME; | |
1495 | - filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); | |
1496 | - if (filename) { | |
1497 | - ret = load_elf(filename, hwdef->slavio_base - PROM_VADDR, | |
1498 | - NULL, NULL, NULL); | |
1499 | - if (ret < 0 || ret > PROM_SIZE_MAX) | |
1500 | - ret = load_image_targphys(filename, hwdef->slavio_base, | |
1501 | - PROM_SIZE_MAX); | |
1502 | - qemu_free(filename); | |
1503 | - } else { | |
1504 | - ret = -1; | |
1505 | - } | |
1506 | - if (ret < 0 || ret > PROM_SIZE_MAX) { | |
1507 | - fprintf(stderr, "qemu: could not load prom '%s'\n", | |
1508 | - filename); | |
1509 | - exit(1); | |
1510 | - } | |
1511 | - | |
1512 | 1490 | /* set up devices */ |
1491 | + prom_init(hwdef->slavio_base, bios_name); | |
1492 | + | |
1513 | 1493 | slavio_intctl = sun4c_intctl_init(hwdef->intctl_base, |
1514 | 1494 | &slavio_irq, cpu_irqs); |
1515 | 1495 | ... | ... |