X-Git-Url: http://git.maemo.org/git/?p=qemu;a=blobdiff_plain;f=hw%2Fsun4u.c;fp=hw%2Fsun4u.c;h=7d020182fe9db297c2676ef14b34fc14540669b9;hp=8f9e56bb713c52d1f02a6d5ee57fc7e80265803a;hb=a03c3bde4e288e790eccfb8cd45abd8ecbf467dc;hpb=e2ffa1bf065fa199f27d661d495573e9d6059bf1 diff --git a/hw/sun4u.c b/hw/sun4u.c index 8f9e56b..7d02018 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -36,10 +36,10 @@ //#define DEBUG_IRQ #ifdef DEBUG_IRQ -#define DPRINTF(fmt, args...) \ - do { printf("CPUIRQ: " fmt , ##args); } while (0) +#define DPRINTF(fmt, ...) \ + do { printf("CPUIRQ: " fmt , ## __VA_ARGS__); } while (0) #else -#define DPRINTF(fmt, args...) +#define DPRINTF(fmt, ...) #endif #define KERNEL_LOAD_ADDR 0x00404000 @@ -326,14 +326,14 @@ pci_ebus_init(PCIBus *bus, int devfn) ebus_mmio_mapfunc); } -static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, +static void sun4uv_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, const struct hwdef *hwdef) { CPUState *env; - char buf[1024]; + char *filename; m48t59_t *nvram; int ret, linux_boot; unsigned int i; @@ -374,7 +374,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, reset_info = qemu_mallocz(sizeof(ResetData)); reset_info->env = env; reset_info->reset_addr = hwdef->prom_addr + 0x40ULL; - qemu_register_reset(main_cpu_reset, reset_info); + qemu_register_reset(main_cpu_reset, 0, reset_info); main_cpu_reset(reset_info); // Override warm reset address with cold start address env->pc = hwdef->prom_addr + 0x20ULL; @@ -392,17 +392,23 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, if (bios_name == NULL) bios_name = PROM_FILENAME; - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); - ret = load_elf(buf, hwdef->prom_addr - PROM_VADDR, NULL, NULL, NULL); - if (ret < 0) { - ret = load_image_targphys(buf, hwdef->prom_addr, - (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & - TARGET_PAGE_MASK); + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (filename) { + ret = load_elf(filename, hwdef->prom_addr - PROM_VADDR, + NULL, NULL, NULL); if (ret < 0) { - fprintf(stderr, "qemu: could not load prom '%s'\n", - buf); - exit(1); + ret = load_image_targphys(filename, hwdef->prom_addr, + (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & + TARGET_PAGE_MASK); } + qemu_free(filename); + } else { + ret = -1; + } + if (ret < 0) { + fprintf(stderr, "qemu: could not load prom '%s'\n", + bios_name); + exit(1); } kernel_size = 0; @@ -447,7 +453,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size, pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, NULL, &pci_bus2, &pci_bus3); isa_mem_base = VGA_BASE; - pci_vga_init(pci_bus, vga_ram_size, 0, 0); + pci_vga_init(pci_bus, 0, 0); // XXX Should be pci_bus3 pci_ebus_init(pci_bus, -1); @@ -560,52 +566,62 @@ static const struct hwdef hwdefs[] = { }; /* Sun4u hardware initialisation */ -static void sun4u_init(ram_addr_t RAM_size, int vga_ram_size, +static void sun4u_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { - sun4uv_init(RAM_size, vga_ram_size, boot_devices, kernel_filename, + sun4uv_init(RAM_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, &hwdefs[0]); } /* Sun4v hardware initialisation */ -static void sun4v_init(ram_addr_t RAM_size, int vga_ram_size, +static void sun4v_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { - sun4uv_init(RAM_size, vga_ram_size, boot_devices, kernel_filename, + sun4uv_init(RAM_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, &hwdefs[1]); } /* Niagara hardware initialisation */ -static void niagara_init(ram_addr_t RAM_size, int vga_ram_size, +static void niagara_init(ram_addr_t RAM_size, const char *boot_devices, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { - sun4uv_init(RAM_size, vga_ram_size, boot_devices, kernel_filename, + sun4uv_init(RAM_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, &hwdefs[2]); } -QEMUMachine sun4u_machine = { +static QEMUMachine sun4u_machine = { .name = "sun4u", .desc = "Sun4u platform", .init = sun4u_init, .max_cpus = 1, // XXX for now + .is_default = 1, }; -QEMUMachine sun4v_machine = { +static QEMUMachine sun4v_machine = { .name = "sun4v", .desc = "Sun4v platform", .init = sun4v_init, .max_cpus = 1, // XXX for now }; -QEMUMachine niagara_machine = { +static QEMUMachine niagara_machine = { .name = "Niagara", .desc = "Sun4v platform, Niagara", .init = niagara_init, .max_cpus = 1, // XXX for now }; + +static void sun4u_machine_init(void) +{ + qemu_register_machine(&sun4u_machine); + qemu_register_machine(&sun4v_machine); + qemu_register_machine(&niagara_machine); +} + +machine_init(sun4u_machine_init);