static void pic_irq_request(void *opaque, int level)
{
if (level)
- cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
+ cpu_interrupt(first_cpu, CPU_INTERRUPT_HARD);
else
- cpu_reset_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
+ cpu_reset_interrupt(first_cpu, CPU_INTERRUPT_HARD);
}
/* PCI intack register */
uint8_t syscontrol;
uint8_t fake_io[2];
int contiguous_map;
+ int endian;
} sysctrl_t;
enum {
/* Special port 92 */
/* Check soft reset asked */
if (val & 0x01) {
- // cpu_interrupt(cpu_single_env, CPU_INTERRUPT_RESET);
+ // cpu_interrupt(first_cpu, CPU_INTERRUPT_RESET);
}
/* Check LE mode */
if (val & 0x02) {
- printf("Little Endian mode isn't supported (yet ?)\n");
- abort();
+ sysctrl->endian = 1;
+ } else {
+ sysctrl->endian = 0;
}
break;
case 0x0800:
break;
case 0x0814:
/* L2 invalidate register */
- // tlb_flush(cpu_single_env, 1);
+ // tlb_flush(first_cpu, 1);
break;
case 0x081C:
/* system control register */
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename)
{
+ CPUState *env;
char buf[1024];
+ SetIRQFunc *set_irq;
m48t59_t *nvram;
int PPC_io_memory;
- int ret, linux_boot, i, nb_nics1;
+ int linux_boot, i, nb_nics1, bios_size;
unsigned long bios_offset;
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
+ ppc_def_t *def;
PCIBus *pci_bus;
sysctrl = qemu_mallocz(sizeof(sysctrl_t));
return;
linux_boot = (kernel_filename != NULL);
+
+ /* init CPUs */
+
+ env = cpu_init();
+ register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
+
+ /* Register CPU as a 604 */
+ /* XXX: CPU model (or PVR) should be provided on command line */
+ // ppc_find_by_name("604r", &def);
+ // ppc_find_by_name("604e", &def);
+ ppc_find_by_name("604", &def);
+ if (def == NULL) {
+ cpu_abort(env, "Unable to find PowerPC CPU definition\n");
+ }
+ cpu_ppc_register(env, def);
+ /* Set time-base frequency to 100 Mhz */
+ cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
/* allocate RAM */
cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
/* allocate and load BIOS */
bios_offset = ram_size + vga_ram_size;
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
- ret = load_image(buf, phys_ram_base + bios_offset);
- if (ret != BIOS_SIZE) {
+ bios_size = load_image(buf, phys_ram_base + bios_offset);
+ if (bios_size < 0 || bios_size > BIOS_SIZE) {
fprintf(stderr, "qemu: could not load PPC PREP bios '%s'\n", buf);
exit(1);
}
- cpu_register_physical_memory((uint32_t)(-BIOS_SIZE),
- BIOS_SIZE, bios_offset | IO_MEM_ROM);
- cpu_single_env->nip = 0xfffffffc;
+ bios_size = (bios_size + 0xfff) & ~0xfff;
+ cpu_register_physical_memory((uint32_t)(-bios_size),
+ bios_size, bios_offset | IO_MEM_ROM);
if (linux_boot) {
kernel_base = KERNEL_LOAD_ADDR;
initrd_size = 0;
}
- /* Register CPU as a 604 */
- cpu_ppc_register(cpu_single_env, 0x00040000);
- /* Set time-base frequency to 100 Mhz */
- cpu_ppc_tb_init(cpu_single_env, 100UL * 1000UL * 1000UL);
-
isa_mem_base = 0xc0000000;
pci_bus = pci_prep_init();
// pci_bus = i440fx_init();
/* init basic PC hardware */
vga_initialize(pci_bus, ds, phys_ram_base + ram_size, ram_size,
- vga_ram_size);
+ vga_ram_size, 0, 0);
rtc_init(0x70, 8);
// openpic = openpic_init(0x00000000, 0xF0000000, 1);
- isa_pic = pic_init(pic_irq_request, cpu_single_env);
+ isa_pic = pic_init(pic_irq_request, first_cpu);
// pit = pit_init(0x40, 0);
- serial_init(0x3f8, 4, serial_hds[0]);
+ serial_init(&pic_set_irq_new, isa_pic, 0x3f8, 4, serial_hds[0]);
nb_nics1 = nb_nics;
if (nb_nics1 > NE2000_NB_MAX)
nb_nics1 = NE2000_NB_MAX;
cpu_register_physical_memory(0xFEFF0000, 0x1000, PPC_io_memory);
#endif
- nvram = m48t59_init(8, 0, 0x0074, NVRAM_SIZE);
+ nvram = m48t59_init(8, 0, 0x0074, NVRAM_SIZE, 59);
if (nvram == NULL)
return;
sysctrl->nvram = nvram;