--- trunk/src/machine.c 2007/10/08 16:18:27 10 +++ trunk/src/machine.c 2007/10/08 16:18:38 12 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: machine.c,v 1.470 2005/06/26 11:36:28 debug Exp $ + * $Id: machine.c,v 1.515 2005/08/16 09:16:26 debug Exp $ * * Emulation of specific machines. * @@ -53,7 +53,6 @@ #include "arcbios.h" #include "bus_pci.h" #include "cpu.h" -#include "cpu_mips.h" #include "device.h" #include "devices.h" #include "diskimage.h" @@ -65,10 +64,16 @@ #include "net.h" #include "symbol.h" +/* For Alpha emulation: */ +#include "alpha_rpb.h" + /* For SGI and ARC emulation: */ #include "sgi_arcbios.h" #include "crimereg.h" +/* For evbmips emulation: */ +#include "maltareg.h" + /* For DECstation emulation: */ #include "dec_prom.h" #include "dec_bootinfo.h" @@ -147,6 +152,9 @@ m->bintrans_enable = 1; m->old_bintrans_enable = 1; #endif + m->arch_pagesize = 4096; /* Should be overriden in + emul.c for other pagesizes. */ + m->dyntrans_alignment_check = 1; m->prom_emulation = 1; m->speed_tricks = 1; m->byte_order_override = NO_BYTE_ORDER_OVERRIDE; @@ -177,11 +185,12 @@ int *type, int *subtype, int *arch) { struct machine_entry *me; - int i, j, k; + int i, j, k, nmatches = 0; *type = MACHINE_NONE; *subtype = 0; + /* Check stype, and optionally ssubtype: */ me = first_machine_entry; while (me != NULL) { for (i=0; in_aliases; i++) @@ -216,12 +225,48 @@ me = me->next; } - fatal("\nSorry, emulation \"%s\"", stype); - if (ssubtype != NULL && ssubtype[0] != '\0') - fatal(" (subtype \"%s\")", ssubtype); - fatal(" is unknown.\n"); - fatal("Use the -H command line option to get a list of available" - " types and subtypes.\n\n"); + /* Not found? Then just check ssubtype: */ + me = first_machine_entry; + while (me != NULL) { + if (me->n_subtypes == 0) { + me = me->next; + continue; + } + + /* Check for subtype: */ + for (j=0; jn_subtypes; j++) + for (k=0; ksubtype[j]->n_aliases; k++) + if (strcasecmp(ssubtype, me->subtype[j]-> + aliases[k]) == 0) { + *type = me->machine_type; + *arch = me->arch; + *subtype = me->subtype[j]-> + machine_subtype; + nmatches ++; + } + + me = me->next; + } + + switch (nmatches) { + case 0: fatal("\nSorry, emulation \"%s\"", stype); + if (ssubtype != NULL && ssubtype[0] != '\0') + fatal(" (subtype \"%s\")", ssubtype); + fatal(" is unknown.\n"); + break; + case 1: return 1; + default:fatal("\nSorry, multiple matches for \"%s\"", stype); + if (ssubtype != NULL && ssubtype[0] != '\0') + fatal(" (subtype \"%s\")", ssubtype); + fatal(".\n"); + } + + *type = MACHINE_NONE; + *subtype = 0; + + fatal("Use the -H command line option to get a list of " + "available types and subtypes.\n\n"); + return 0; } @@ -343,6 +388,35 @@ /* + * add_environment_string_dual(): + * + * Add "dual" environment strings, one for the variable name and one for the + * value, and update pointers afterwards. + */ +void add_environment_string_dual(struct cpu *cpu, + uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2) +{ + uint64_t ptr = *ptrp, addr = *addrp; + + store_32bit_word(cpu, ptr, addr); + ptr += sizeof(uint32_t); + if (addr != 0) { + store_string(cpu, addr, s1); + addr += strlen(s1) + 1; + } + store_32bit_word(cpu, ptr, addr); + ptr += sizeof(uint32_t); + if (addr != 0) { + store_string(cpu, addr, s2); + addr += strlen(s2) + 1; + } + + *ptrp = ptr; + *addrp = addr; +} + + +/* * store_64bit_word(): * * Stores a 64-bit word in emulated RAM. Byte order is taken into account. @@ -1231,29 +1305,83 @@ if (irq_nr < 8) { if (assrt) - m->md_int.malta_data->assert_lo |= mask; + m->md_int.isa_pic_data.pic1->irr |= mask; else - m->md_int.malta_data->assert_lo &= ~mask; + m->md_int.isa_pic_data.pic1->irr &= ~mask; } else if (irq_nr < 16) { if (assrt) - m->md_int.malta_data->assert_hi |= mask; + m->md_int.isa_pic_data.pic2->irr |= mask; else - m->md_int.malta_data->assert_hi &= ~mask; + m->md_int.isa_pic_data.pic2->irr &= ~mask; } /* Any interrupt assertions on PIC2 go to irq 2 on PIC1 */ - if (m->md_int.malta_data->assert_hi & - ~m->md_int.malta_data->disable_hi) - m->md_int.malta_data->assert_lo |= 0x04; + /* (TODO: don't hardcode this here) */ + if (m->md_int.isa_pic_data.pic2->irr & + ~m->md_int.isa_pic_data.pic2->ier) + m->md_int.isa_pic_data.pic1->irr |= 0x04; else - m->md_int.malta_data->assert_lo &= ~0x04; + m->md_int.isa_pic_data.pic1->irr &= ~0x04; /* Now, PIC1: */ - if (m->md_int.malta_data->assert_lo & - ~m->md_int.malta_data->disable_lo) + if (m->md_int.isa_pic_data.pic1->irr & + ~m->md_int.isa_pic_data.pic1->ier) cpu_interrupt(cpu, 2); else cpu_interrupt_ack(cpu, 2); + + /* printf("MALTA: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x " + "ier=0x%02x\n", m->md_int.isa_pic_data.pic1->irr, + m->md_int.isa_pic_data.pic1->ier, + m->md_int.isa_pic_data.pic2->irr, + m->md_int.isa_pic_data.pic2->ier); */ +} + + +/* + * Cobalt interrupts: + * + * (irq_nr = 8 + 16 can be used to just reassert/deassert interrupts.) + */ +void cobalt_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt) +{ + int mask; + + irq_nr -= 8; + mask = 1 << (irq_nr & 7); + + if (irq_nr < 8) { + if (assrt) + m->md_int.isa_pic_data.pic1->irr |= mask; + else + m->md_int.isa_pic_data.pic1->irr &= ~mask; + } else if (irq_nr < 16) { + if (assrt) + m->md_int.isa_pic_data.pic2->irr |= mask; + else + m->md_int.isa_pic_data.pic2->irr &= ~mask; + } + + /* Any interrupt assertions on PIC2 go to irq 2 on PIC1 */ + /* (TODO: don't hardcode this here) */ + if (m->md_int.isa_pic_data.pic2->irr & + ~m->md_int.isa_pic_data.pic2->ier) + m->md_int.isa_pic_data.pic1->irr |= 0x04; + else + m->md_int.isa_pic_data.pic1->irr &= ~0x04; + + /* Now, PIC1: */ + if (m->md_int.isa_pic_data.pic1->irr & + ~m->md_int.isa_pic_data.pic1->ier) + cpu_interrupt(cpu, 6); + else + cpu_interrupt_ack(cpu, 6); + + /* printf("COBALT: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x " + "ier=0x%02x\n", m->md_int.isa_pic_data.pic1->irr, + m->md_int.isa_pic_data.pic1->ier, + m->md_int.isa_pic_data.pic2->irr, + m->md_int.isa_pic_data.pic2->ier); */ } @@ -1319,6 +1447,7 @@ int i, j; struct memory *mem; char tmpstr[1000]; + struct cons_data *cons_data; /* DECstation: */ char *framebuffer_console_name, *serial_console_name; @@ -1391,6 +1520,7 @@ printf("\nNo emulation type specified.\n"); exit(1); +#ifdef ENABLE_MIPS case MACHINE_BAREMIPS: /* * A "bare" MIPS test machine. @@ -1405,19 +1535,38 @@ /* * A MIPS test machine (which happens to work with the * code in my master's thesis). :-) + * + * IRQ map: + * 7 CPU counter + * 6 SMP IPIs + * 5 not used yet + * 4 not used yet + * 3 ethernet + * 2 serial console */ cpu->byte_order = EMUL_BIG_ENDIAN; machine->machine_name = "MIPS test machine"; - machine->main_console_handle = dev_cons_init( - machine, mem, DEV_CONS_ADDRESS, "console", 2); + snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=2", + (long long)DEV_CONS_ADDRESS); + cons_data = device_add(machine, tmpstr); + machine->main_console_handle = cons_data->console_handle; - snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx", + snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx", (long long)DEV_MP_ADDRESS); device_add(machine, tmpstr); - fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC, - 640,480, 640,480, 24, "generic", 1); + fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC, + 640,480, 640,480, 24, "testmips generic"); + + snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx", + (long long)DEV_DISK_ADDRESS); + device_add(machine, tmpstr); + + snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=3", + (long long)DEV_ETHER_ADDRESS); + device_add(machine, tmpstr); + break; case MACHINE_DEC: @@ -1459,7 +1608,7 @@ */ fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START, color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01, - 0,0,0,0,0, color_fb_flag? "VFB02":"VFB01", 1); + 0,0,0,0,0, color_fb_flag? "VFB02":"VFB01"); dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask); dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag); dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576); @@ -1891,7 +2040,7 @@ dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576); dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII); - snprintf(tmpstr, sizeof(tmpstr) - 1, + snprintf(tmpstr, sizeof(tmpstr), "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR); machine->md_int.kn230_csr = device_add(machine, tmpstr); @@ -2130,17 +2279,24 @@ * 4 Tulip 1 * 5 16550 UART (serial console) * 6 VIA southbridge PIC - * 7 PCI + * 7 PCI (Note: Not used. The PCI controller + * interrupts at ISA interrupt 9.) */ -/* dev_XXX_init(cpu, mem, 0x10000000, machine->emulated_hz); */ + + /* ISA interrupt controllers: */ + snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020"); + machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0"); + machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr); + machine->md_interrupt = cobalt_interrupt; + dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4); - machine->main_console_handle = dev_ns16550_init(machine, mem, - 0x1c800000, 5, 1, 1, "serial console"); + machine->main_console_handle = (size_t) + device_add(machine, "ns16550 irq=5 addr=0x1c800000 name2=tty0 in_use=1"); #if 0 - dev_ns16550_init(machine, mem, 0x1f000010, 0, 1, 1, - "other serial console"); + device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0"); #endif /* @@ -2152,8 +2308,10 @@ * pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37 * pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr * tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1 + * + * The PCI controller interrupts at ISA interrupt 9. */ - pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 6, 11); /* 7 for PCI, not 6? */ + pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 8 + 9, 11); /* bus_pci_add(machine, pci_data, mem, 0, 7, 0, pci_dec21143_init, pci_dec21143_rr); */ bus_pci_add(machine, pci_data, mem, 0, 8, 0, NULL, NULL); /* PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860 */ bus_pci_add(machine, pci_data, mem, 0, 9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr); @@ -2164,14 +2322,15 @@ * NetBSD/cobalt expects memsize in a0, but it seems that what * it really wants is the end of memory + 0x80000000. * - * The bootstring should be stored starting 512 bytes before end - * of physical ram. + * The bootstring is stored 512 bytes before the end of + * physical ram. */ - cpu->cd.mips.gpr[MIPS_GPR_A0] = machine->physical_ram_in_mb * 1048576 + 0x80000000; + cpu->cd.mips.gpr[MIPS_GPR_A0] = + machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL; bootstr = "root=/dev/hda1 ro"; /* bootstr = "nfsroot=/usr/cobalt/"; */ - store_string(cpu, 0xffffffff80000000ULL + - machine->physical_ram_in_mb * 1048576 - 512, bootstr); + /* TODO: bootarg, and/or automagic boot device detection */ + store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr); break; case MACHINE_HPCMIPS: @@ -2208,9 +2367,10 @@ hpcmips_fb_bits = 15; hpcmips_fb_encoding = BIFB_D16_0000; - machine->main_console_handle = dev_ns16550_init( - machine, mem, 0xa008680, 0, 4, - machine->use_x11? 0 : 1, "serial console"); /* TODO: irq? */ + /* TODO: irq? */ + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1); + machine->main_console_handle = (size_t)device_add(machine, tmpstr); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131); machine->md_interrupt = vr41xx_interrupt; @@ -2239,9 +2399,10 @@ hpcmips_fb_bits = 16; hpcmips_fb_encoding = BIFB_D16_0000; - machine->main_console_handle = dev_ns16550_init( - machine, mem, 0xa008680, 0, 4, - machine->use_x11? 0 : 1, "serial console"); /* TODO: irq? */ + /* TODO: irq? */ + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1); + machine->main_console_handle = (size_t)device_add(machine, tmpstr); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121); machine->md_interrupt = vr41xx_interrupt; @@ -2389,8 +2550,8 @@ VRIP_INTR_SIU (=9) here? */ { int x; - x = dev_ns16550_init(machine, mem, 0x0c000010, - 8 + VRIP_INTR_SIU, 1, 1, "serial 0"); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x0c000010", 8 + VRIP_INTR_SIU); + x = (size_t)device_add(machine, tmpstr); if (!machine->use_x11) machine->main_console_handle = x; @@ -2413,7 +2574,7 @@ break; case MACHINE_HPCMIPS_IBM_WORKPAD_Z50: /* 131 MHz VR4121 */ - machine->machine_name = "Agenda VR3"; + machine->machine_name = "IBM Workpad Z50"; /* TODO: */ hpcmips_fb_addr = 0xa000000; hpcmips_fb_xsize = 640; @@ -2516,7 +2677,7 @@ dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS, hpcmips_fb_xsize, hpcmips_fb_ysize, hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem, - hpcmips_fb_bits, "HPCmips", 0); + hpcmips_fb_bits, "HPCmips"); /* NetBSD/hpcmips uses framebuffer at physical address 0x8.......: */ @@ -2556,7 +2717,7 @@ machine->md_interrupt = ps2_interrupt; add_symbol_name(&machine->symbol_context, - PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0); + PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0); store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS); store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4); @@ -2901,10 +3062,12 @@ * program dumps something there, but it doesn't look like * readable text. (TODO) */ - machine->main_console_handle = dev_ns16550_init(machine, mem, 0x1f620170, 0, 1, - machine->use_x11? 0 : 1, "serial 0"); /* TODO: irq? */ - dev_ns16550_init(machine, mem, 0x1f620178, 0, 1, - 0, "serial 1"); /* TODO: irq? */ + + /* TODO: irq! */ + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620170 name2=tty0 in_use=%i", machine->use_x11? 0 : 1); + machine->main_console_handle = (size_t)device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620178 name2=tty1 in_use=0"); + device_add(machine, tmpstr); /* MardiGras graphics: */ device_add(machine, "sgi_mardigras addr=0x1c000000"); @@ -2989,13 +3152,12 @@ dev_sgi_ust_init(mem, 0x1f340000); /* ust? */ - j = dev_ns16550_init(machine, mem, 0x1f390000, - (1<<20) + MACE_PERIPH_SERIAL, 0x100, - machine->use_x11? 0 : 1, "serial 0"); /* com0 */ - dev_ns16550_init(machine, mem, 0x1f398000, - (1<<26) + MACE_PERIPH_SERIAL, 0x100, - 0, "serial 1"); /* com1 */ - + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f390000 addr_mult=0x100 in_use=%i name2=tty0", + (1<<20) + MACE_PERIPH_SERIAL, machine->use_x11? 0 : 1); + j = (size_t)device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1", + (1<<26) + MACE_PERIPH_SERIAL, 0); + device_add(machine, tmpstr); #if 0 if (machine->use_x11) machine->main_console_handle = i; @@ -3092,10 +3254,11 @@ device_add(machine, "sn addr=0x80001000 irq=0"); dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1); i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11, 0); - j = dev_ns16550_init(machine, mem, 0x80006000ULL, - 3, 1, machine->use_x11? 0 : 1, "serial 0"); /* com0 */ - dev_ns16550_init(machine, mem, 0x80007000ULL, - 0, 1, 0, "serial 1"); /* com1 */ + + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1); + j = (size_t)device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0); + device_add(machine, tmpstr); if (machine->use_x11) machine->main_console_handle = i; @@ -3115,7 +3278,7 @@ case MACHINE_ARC_NEC_R96: dev_fb_init(machine, mem, 0x100e00000ULL, VFB_GENERIC, 640,480, 1024,480, - 8, "necvdfrb", 1); + 8, "necvdfrb"); break; } break; @@ -3211,11 +3374,10 @@ i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0); - j = dev_ns16550_init(machine, mem, - 0x80006000ULL, 8 + 8, 1, - machine->use_x11? 0 : 1, "serial 0"); - dev_ns16550_init(machine, mem, - 0x80007000ULL, 8 + 9, 1, 0, "serial 1"); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1); + j = (size_t)device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0); + device_add(machine, tmpstr); if (machine->use_x11) machine->main_console_handle = i; @@ -3241,7 +3403,7 @@ /* control at 0x60100000? */ dev_fb_init(machine, mem, 0x60200000ULL, VFB_GENERIC, 1024,768, 1024,768, - 8, "VXL", 1); + 8, "VXL"); break; } @@ -3290,11 +3452,11 @@ i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0); #endif - j = dev_ns16550_init(machine, mem, - 0x80006000ULL, 8 + 8, 1, - machine->use_x11? 0 : 1, "serial 0"); - dev_ns16550_init(machine, mem, - 0x80007000ULL, 8 + 9, 1, 0, "serial 1"); + + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1); + j = (size_t)device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0); + device_add(machine, tmpstr); if (machine->use_x11) machine->main_console_handle = i; @@ -3317,10 +3479,11 @@ strlcat(machine->machine_name, " (Deskstation Tyne)", MACHINE_NAME_MAXBUF); - i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0"); - dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1"); - dev_ns16550_init(machine, mem, 0x9000003e8ULL, 0, 1, 0, "serial 2"); - dev_ns16550_init(machine, mem, 0x9000002e8ULL, 0, 1, 0, "serial 3"); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0 : 1); + i = (size_t)device_add(machine, tmpstr); + device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0 name2=tty1"); + device_add(machine, "ns16550 irq=0 addr=0x9000003e8 in_use=0 name2=tty2"); + device_add(machine, "ns16550 irq=0 addr=0x9000002e8 in_use=0 name2=tty3"); dev_mc146818_init(machine, mem, 0x900000070ULL, 2, MC146818_PC_CMOS, 1); @@ -3676,72 +3839,115 @@ switch (machine->machine_subtype) { case MACHINE_EVBMIPS_MALTA: - machine->machine_name = "MALTA (evbmips)"; + case MACHINE_EVBMIPS_MALTA_BE: + machine->machine_name = "MALTA (evbmips, little endian)"; + cpu->byte_order = EMUL_LITTLE_ENDIAN; - machine->md_int.malta_data = - device_add(machine, "malta addr=0x18000020"); + if (machine->machine_subtype == MACHINE_EVBMIPS_MALTA_BE) { + machine->machine_name = "MALTA (evbmips, big endian)"; + cpu->byte_order = EMUL_BIG_ENDIAN; + } + + /* ISA interrupt controllers: */ + snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020"); + machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0"); + machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr); machine->md_interrupt = malta_interrupt; - dev_mc146818_init(machine, mem, 0x18000070, - 8 + 8, MC146818_PC_CMOS, 1); - machine->main_console_handle = dev_ns16550_init(machine, mem, - 0x180003f8, 8 + 4, 1, 1, "serial console"); + dev_mc146818_init(machine, mem, 0x18000070, 8 + 8, MC146818_PC_CMOS, 1); + + machine->main_console_handle = (size_t) + device_add(machine, "ns16550 irq=12 addr=0x180003f8 name2=tty0"); + device_add(machine, "ns16550 irq=11 addr=0x180002f8 name2=tty1"); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x name2=tty2", MALTA_CBUSUART); + device_add(machine, tmpstr); /* TODO: Irqs */ - pci_data = dev_gt_init(machine, mem, 0x1be00000, - 8+16, 8+16, 120); + pci_data = dev_gt_init(machine, mem, 0x1be00000, 8+9, 8+9, 120); /* TODO: Haha, this is bogus. Just a cut&paste from the Cobalt emulation above. */ - bus_pci_add(machine, pci_data, mem, 0, 9, 0, - pci_vt82c586_isa_init, pci_vt82c586_isa_rr); - bus_pci_add(machine, pci_data, mem, 0, 9, 1, - pci_vt82c586_ide_init, pci_vt82c586_ide_rr); + bus_pci_add(machine, pci_data, mem, 0, 9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr); + bus_pci_add(machine, pci_data, mem, 0, 9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr); device_add(machine, "malta_lcd addr=0x1f000400"); break; case MACHINE_EVBMIPS_PB1000: machine->machine_name = "PB1000 (evbmips)"; + cpu->byte_order = EMUL_BIG_ENDIAN; + machine->md_interrupt = au1x00_interrupt; - machine->md_int.au1x00_ic_data = - dev_au1x00_init(machine, mem); + machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem); + /* TODO */ break; default: fatal("Unimplemented EVBMIPS model.\n"); exit(1); } - /* This is just a test. TODO */ - for (i=0; i<32; i++) - cpu->cd.mips.gpr[i] = - 0x01230000 + (i << 8) + 0x55; - - /* NetBSD/evbmips wants these: (at least for Malta) */ - - /* a0 = argc */ - cpu->cd.mips.gpr[MIPS_GPR_A0] = 2; - - /* a1 = argv */ - cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000; - store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040); - store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200); - - bootstr = strdup(machine->boot_kernel_filename); - bootarg = strdup(machine->boot_string_argument); - store_string(cpu, (int32_t)0x9fc01040, bootstr); - store_string(cpu, (int32_t)0x9fc01200, bootarg); - - /* a2 = (yamon_env_var *)envp */ - cpu->cd.mips.gpr[MIPS_GPR_A2] = 0; - - /* a3 = memsize */ - cpu->cd.mips.gpr[MIPS_GPR_A3] = - machine->physical_ram_in_mb * 1048576; - - /* Yamon emulation vectors at 0x9fc005xx: */ - for (i=0; i<0x100; i+=4) - store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i, - (int64_t)(int32_t)0x9fc00800 + i); + if (machine->prom_emulation) { + /* This is just a test. TODO */ + for (i=0; i<32; i++) + cpu->cd.mips.gpr[i] = + 0x01230000 + (i << 8) + 0x55; + + /* NetBSD/evbmips wants these: (at least for Malta) */ + + /* a0 = argc */ + cpu->cd.mips.gpr[MIPS_GPR_A0] = 2; + + /* a1 = argv */ + cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000; + store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040); + store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200); + store_32bit_word(cpu, (int32_t)0x9fc01008, 0); + + bootstr = strdup(machine->boot_kernel_filename); + bootarg = strdup(machine->boot_string_argument); + store_string(cpu, (int32_t)0x9fc01040, bootstr); + store_string(cpu, (int32_t)0x9fc01200, bootarg); + + /* a2 = (yamon_env_var *)envp */ + cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800; + { + uint64_t env = cpu->cd.mips.gpr[MIPS_GPR_A2]; + uint64_t tmpptr = 0xffffffff9fc01c00ULL; + char tmps[50]; + + snprintf(tmps, sizeof(tmps), "0x%08x", + machine->physical_ram_in_mb * 1048576); + add_environment_string_dual(cpu, + &env, &tmpptr, "memsize", tmps); + + add_environment_string_dual(cpu, + &env, &tmpptr, "yamonrev", "02.06"); + + /* End of env: */ + tmpptr = 0; + add_environment_string_dual(cpu, + &env, &tmpptr, NULL, NULL); + } + + /* a3 = memsize */ + cpu->cd.mips.gpr[MIPS_GPR_A3] = + machine->physical_ram_in_mb * 1048576; + /* Hm. Linux ignores a3. */ + + /* + * TODO: + * Core ID numbers. + * How much of this is not valid for PBxxxx? + * + * See maltareg.h for more info. + */ + store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION), (1 << 10) + 0x26); + + /* Call vectors at 0x9fc005xx: */ + for (i=0; i<0x100; i+=4) + store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i, + (int64_t)(int32_t)0x9fc00800 + i); + } break; case MACHINE_PSP: @@ -3765,7 +3971,7 @@ /* 480 x 272 pixels framebuffer (512 bytes per line) */ fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPCMIPS, - 480,272, 512,1088, -15, "Playstation Portable", 0); + 480,272, 512,1088, -15, "Playstation Portable"); /* * TODO/NOTE: This is ugly, but necessary since GXemul doesn't @@ -3786,7 +3992,9 @@ cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0; break; +#endif /* ENABLE_MIPS */ +#ifdef ENABLE_PPC case MACHINE_BAREPPC: /* * A "bare" PPC machine. @@ -3803,15 +4011,26 @@ machine->machine_name = "PPC test machine"; /* TODO: interrupt for PPC? */ - machine->main_console_handle = dev_cons_init( - machine, mem, DEV_CONS_ADDRESS, "console", 0); + snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0", + (long long)DEV_CONS_ADDRESS); + cons_data = device_add(machine, tmpstr); + machine->main_console_handle = cons_data->console_handle; - snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx", + snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx", (long long)DEV_MP_ADDRESS); device_add(machine, tmpstr); - fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC, - 640,480, 640,480, 24, "generic", 1); + fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC, + 640,480, 640,480, 24, "testppc generic"); + + snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx", + (long long)DEV_DISK_ADDRESS); + device_add(machine, tmpstr); + + snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0", + (long long)DEV_ETHER_ADDRESS); + device_add(machine, tmpstr); + break; case MACHINE_WALNUT: @@ -3831,10 +4050,9 @@ dev_pmppc_init(mem); /* com0 = 0xff600300, com1 = 0xff600400 */ - machine->main_console_handle = dev_ns16550_init(machine, mem, - 0xff600300, 0, 1, 1, "serial 0"); - dev_ns16550_init(machine, mem, - 0xff600400, 0, 1, 0, "serial 1"); + + machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0xff600300 name2=tty0"); + device_add(machine, "ns16550 irq=0 addr=0xff600400 in_use=0 name2=tty1"); break; @@ -3861,16 +4079,13 @@ device_add(machine, "bebox"); - /* Serial, used by NetBSD: */ - machine->main_console_handle = dev_ns16550_init(machine, mem, - 0x800003f8, 0, 1, 1, "serial 0"); - - /* Serial, used by Linux: */ - dev_ns16550_init(machine, mem, 0x800002f8, 0, 1, 0, "serial 1"); - - /* This is used by Linux too: */ - dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL, - machine->machine_name); + machine->main_console_handle = (size_t) + device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0"); + device_add(machine, "ns16550 irq=0 addr=0x800002f8 name2=tty1 in_use=0"); + + if (machine->use_x11) + dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL, + machine->machine_name); store_32bit_word(cpu, 0x3010, machine->physical_ram_in_mb * 1048576); @@ -3897,7 +4112,8 @@ store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20); /* next */ store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */ - store_buf(cpu, cpu->cd.ppc.gpr[6] + 20, "com", 4); + store_buf(cpu, cpu->cd.ppc.gpr[6] + 20, + machine->use_x11? "vga" : "com", 4); store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */ store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */ @@ -3946,8 +4162,7 @@ /* For playing with PMON2000 for PPC: */ machine->machine_name = "DB64360"; - machine->main_console_handle = dev_ns16550_init(machine, mem, - 0x1d000020, 0, 4, 1, "serial console"); + machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0x1d000020"); { int i; @@ -3957,12 +4172,39 @@ } break; +#endif /* ENABLE_PPC */ +#ifdef ENABLE_SPARC case MACHINE_BARESPARC: /* A bare SPARC machine, with no devices. */ machine->machine_name = "\"Bare\" SPARC machine"; break; + case MACHINE_TESTSPARC: + machine->machine_name = "SPARC test machine"; + + snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0", + (long long)DEV_CONS_ADDRESS); + cons_data = device_add(machine, tmpstr); + machine->main_console_handle = cons_data->console_handle; + + snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx", + (long long)DEV_MP_ADDRESS); + device_add(machine, tmpstr); + + fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC, + 640,480, 640,480, 24, "testsparc generic"); + + snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx", + (long long)DEV_DISK_ADDRESS); + device_add(machine, tmpstr); + + snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0", + (long long)DEV_ETHER_ADDRESS); + device_add(machine, tmpstr); + + break; + case MACHINE_ULTRA1: /* * NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/) @@ -3970,42 +4212,110 @@ */ machine->machine_name = "Sun Ultra1"; break; +#endif /* ENABLE_SPARC */ - case MACHINE_BAREURISC: - machine->machine_name = "\"Bare\" URISC machine"; +#ifdef ENABLE_ALPHA + case MACHINE_BAREALPHA: + machine->machine_name = "\"Bare\" Alpha machine"; break; - case MACHINE_TESTURISC: - machine->machine_name = "URISC test machine"; + case MACHINE_TESTALPHA: + machine->machine_name = "Alpha test machine"; - /* TODO */ - /* A special "device" for accessing normal devices - using urisc accesses? */ + snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0", + (long long)DEV_CONS_ADDRESS); + cons_data = device_add(machine, tmpstr); + machine->main_console_handle = cons_data->console_handle; - device_add(machine, "urisc addr=0x12341234"); + snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx", + (long long)DEV_MP_ADDRESS); + device_add(machine, tmpstr); - break; + fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC, + 640,480, 640,480, 24, "testalpha generic"); - case MACHINE_BAREHPPA: - machine->machine_name = "\"Bare\" HPPA machine"; - break; + snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx", + (long long)DEV_DISK_ADDRESS); + device_add(machine, tmpstr); - case MACHINE_TESTHPPA: - machine->machine_name = "HPPA test machine"; + snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0", + (long long)DEV_ETHER_ADDRESS); + device_add(machine, tmpstr); - /* TODO */ break; - case MACHINE_BAREALPHA: - machine->machine_name = "\"Bare\" Alpha machine"; - break; + case MACHINE_ALPHA: + /* TODO: Most of these... They are used by NetBSD/alpha: */ + /* a0 = First free Page Frame Number */ + /* a1 = PFN of current Level 1 page table */ + /* a2 = Bootinfo magic */ + /* a3 = Bootinfo pointer */ + /* a4 = Bootinfo version */ + cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192; + cpu->cd.alpha.r[ALPHA_A1] = 0; + cpu->cd.alpha.r[ALPHA_A2] = 0; + cpu->cd.alpha.r[ALPHA_A3] = 0; + cpu->cd.alpha.r[ALPHA_A4] = 0; + + if (machine->prom_emulation) { + struct rpb rpb; + struct crb crb; + struct ctb ctb; + + /* HWRPB: Hardware Restart Parameter Block */ + memset(&rpb, 0, sizeof(struct rpb)); + store_64bit_word_in_host(cpu, (unsigned char *) + &(rpb.rpb_phys), HWRPB_ADDR); + strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8); + store_64bit_word_in_host(cpu, (unsigned char *) + &(rpb.rpb_size), sizeof(struct rpb)); + store_64bit_word_in_host(cpu, (unsigned char *) + &(rpb.rpb_page_size), 8192); + store_64bit_word_in_host(cpu, (unsigned char *) + &(rpb.rpb_type), machine->machine_subtype); + store_64bit_word_in_host(cpu, (unsigned char *) + &(rpb.rpb_cc_freq), 100000000); + store_64bit_word_in_host(cpu, (unsigned char *) + &(rpb.rpb_ctb_off), CTB_ADDR - HWRPB_ADDR); + store_64bit_word_in_host(cpu, (unsigned char *) + &(rpb.rpb_crb_off), CRB_ADDR - HWRPB_ADDR); + + /* CTB: Console Terminal Block */ + memset(&ctb, 0, sizeof(struct ctb)); + store_64bit_word_in_host(cpu, (unsigned char *) + &(ctb.ctb_term_type), machine->use_x11? + CTB_GRAPHICS : CTB_PRINTERPORT); + + /* CRB: Console Routine Block */ + memset(&crb, 0, sizeof(struct crb)); + store_64bit_word_in_host(cpu, (unsigned char *) + &(crb.crb_v_dispatch), CRB_ADDR - 0x100); + store_64bit_word(cpu, CRB_ADDR - 0x100 + 8, 0x10000); - case MACHINE_TESTALPHA: - machine->machine_name = "Alpha test machine"; + /* + * Place a special "hack" palcode call at 0x10000: + * (Hopefully nothing else will be there.) + */ + store_32bit_word(cpu, 0x10000, 0x3fffffe); + + store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb)); + store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb)); + store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb)); + } + + switch (machine->machine_subtype) { + case ST_DEC_3000_300: + machine->machine_name = "DEC 3000/300"; + break; + default:fatal("Unimplemented Alpha machine type %i\n", + machine->machine_subtype); + exit(1); + } - /* TODO */ break; +#endif /* ENABLE_ALPHA */ +#ifdef ENABLE_ARM case MACHINE_BAREARM: machine->machine_name = "\"Bare\" ARM machine"; break; @@ -4013,13 +4323,101 @@ case MACHINE_TESTARM: machine->machine_name = "ARM test machine"; - machine->main_console_handle = dev_cons_init( - machine, mem, DEV_CONS_ADDRESS, "console", 2); + snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0", + (long long)DEV_CONS_ADDRESS); + cons_data = device_add(machine, tmpstr); + machine->main_console_handle = cons_data->console_handle; + + snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx", + (long long)DEV_MP_ADDRESS); + device_add(machine, tmpstr); + + fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC, + 640,480, 640,480, 24, "testarm generic"); + + snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx", + (long long)DEV_DISK_ADDRESS); + device_add(machine, tmpstr); + + snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0", + (long long)DEV_ETHER_ADDRESS); + device_add(machine, tmpstr); + + /* Place a tiny stub at end of memory, and set the link + register to point to it. This stub halts the machine. */ + cpu->cd.arm.r[ARM_SP] = + machine->physical_ram_in_mb * 1048576 - 4096; + cpu->cd.arm.r[ARM_LR] = cpu->cd.arm.r[ARM_SP] + 32; + store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 0, 0xe3a00201); + store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 4, 0xe5c00010); + store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8, + 0xeafffffe); + break; +#endif /* ENABLE_ARM */ + +#ifdef ENABLE_IA64 + case MACHINE_BAREIA64: + machine->machine_name = "\"Bare\" IA64 machine"; + break; + + case MACHINE_TESTIA64: + machine->machine_name = "IA64 test machine"; + + snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0", + (long long)DEV_CONS_ADDRESS); + cons_data = device_add(machine, tmpstr); + machine->main_console_handle = cons_data->console_handle; + + snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx", + (long long)DEV_MP_ADDRESS); + device_add(machine, tmpstr); + + fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC, + 640,480, 640,480, 24, "testia64 generic"); + + snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx", + (long long)DEV_DISK_ADDRESS); + device_add(machine, tmpstr); + + snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0", + (long long)DEV_ETHER_ADDRESS); + device_add(machine, tmpstr); + + break; +#endif /* ENABLE_IA64 */ + +#ifdef ENABLE_M68K + case MACHINE_BAREM68K: + machine->machine_name = "\"Bare\" M68K machine"; + break; + + case MACHINE_TESTM68K: + machine->machine_name = "M68K test machine"; + + snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0", + (long long)DEV_CONS_ADDRESS); + cons_data = device_add(machine, tmpstr); + machine->main_console_handle = cons_data->console_handle; + + snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx", + (long long)DEV_MP_ADDRESS); + device_add(machine, tmpstr); + + fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC, + 640,480, 640,480, 24, "testm68k generic"); + + snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx", + (long long)DEV_DISK_ADDRESS); + device_add(machine, tmpstr); + + snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0", + (long long)DEV_ETHER_ADDRESS); + device_add(machine, tmpstr); - fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC, - 640,480, 640,480, 24, "generic", 1); break; +#endif /* ENABLE_M68K */ +#ifdef ENABLE_X86 case MACHINE_BAREX86: machine->machine_name = "\"Bare\" x86 machine"; break; @@ -4031,11 +4429,11 @@ machine->machine_name = "Generic x86 PC"; /* Interrupt controllers: */ - snprintf(tmpstr, sizeof(tmpstr) - 1, "8259 addr=0x%llx", + snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx", (long long)(X86_IO_BASE + 0x20)); machine->md.pc.pic1 = device_add(machine, tmpstr); if (machine->machine_subtype != MACHINE_X86_XT) { - snprintf(tmpstr, sizeof(tmpstr) - 1, "8259 addr=0x%llx irq=2", + snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2", (long long)(X86_IO_BASE + 0xa0)); machine->md.pc.pic2 = device_add(machine, tmpstr); } @@ -4043,11 +4441,11 @@ machine->md_interrupt = x86_pc_interrupt; /* Timer: */ - snprintf(tmpstr, sizeof(tmpstr) - 1, "8253 addr=0x%llx irq=0", + snprintf(tmpstr, sizeof(tmpstr), "8253 addr=0x%llx irq=0", (long long)(X86_IO_BASE + 0x40)); device_add(machine, tmpstr); - snprintf(tmpstr, sizeof(tmpstr) - 1, "pccmos addr=0x%llx", + snprintf(tmpstr, sizeof(tmpstr), "pccmos addr=0x%llx", (long long)(X86_IO_BASE + 0x70)); device_add(machine, tmpstr); @@ -4062,7 +4460,7 @@ dev_wdc_init(machine, mem, X86_IO_BASE + 0x170, 15, 2); /* Floppy controller at irq 6 */ - snprintf(tmpstr, sizeof(tmpstr) - 1, "fdc addr=0x%llx irq=6", + snprintf(tmpstr, sizeof(tmpstr), "fdc addr=0x%llx irq=6", (long long)(X86_IO_BASE + 0x3f0)); device_add(machine, tmpstr); @@ -4071,8 +4469,13 @@ /* TODO: parallel port */ /* Serial ports: (TODO: 8250 for PC XT?) */ - dev_ns16550_init(machine, mem, X86_IO_BASE + 0x3f8, 4, 1, 0, "com1"); - dev_ns16550_init(machine, mem, X86_IO_BASE + 0x378, 3, 1, 0, "com2"); + + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%llx name2=com1 in_use=0", + (long long)X86_IO_BASE + 0x3f8); + device_add(machine, tmpstr); + snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x%llx name2=com2 in_use=0", + (long long)X86_IO_BASE + 0x2f8); + device_add(machine, tmpstr); /* VGA + keyboard: */ dev_vga_init(machine, mem, 0xa0000ULL, X86_IO_BASE + 0x3c0, @@ -4091,6 +4494,7 @@ "-------------------------------------" "------------------------------------------\n"); break; +#endif /* ENABLE_X86 */ default: fatal("Unknown emulation type %i\n", machine->machine_type); @@ -4192,12 +4596,11 @@ m->physical_ram_in_mb = 32; } break; - case MACHINE_BEBOX: + case MACHINE_ALPHA: m->physical_ram_in_mb = 64; break; - case MACHINE_BAREURISC: - case MACHINE_TESTURISC: - m->physical_ram_in_mb = 2; + case MACHINE_BEBOX: + m->physical_ram_in_mb = 64; break; case MACHINE_X86: if (m->machine_subtype == MACHINE_X86_XT) @@ -4337,6 +4740,7 @@ case MACHINE_EVBMIPS: switch (m->machine_subtype) { case MACHINE_EVBMIPS_MALTA: + case MACHINE_EVBMIPS_MALTA_BE: m->cpu_name = strdup("5Kc"); break; case MACHINE_EVBMIPS_PB1000: @@ -4396,28 +4800,16 @@ /* SPARC: */ case MACHINE_BARESPARC: - m->cpu_name = strdup("SPARCV9"); - break; + case MACHINE_TESTSPARC: case MACHINE_ULTRA1: - m->cpu_name = strdup("SPARCV9"); - break; - - /* URISC: */ - case MACHINE_BAREURISC: - case MACHINE_TESTURISC: - m->cpu_name = strdup("URISC"); - break; - - /* HPPA: */ - case MACHINE_BAREHPPA: - case MACHINE_TESTHPPA: - m->cpu_name = strdup("HPPA2.0"); + m->cpu_name = strdup("SPARCv9"); break; /* Alpha: */ case MACHINE_BAREALPHA: case MACHINE_TESTALPHA: - m->cpu_name = strdup("EV4"); + case MACHINE_ALPHA: + m->cpu_name = strdup("Alpha"); break; /* ARM: */ @@ -4426,6 +4818,18 @@ m->cpu_name = strdup("ARM"); break; + /* IA64: */ + case MACHINE_BAREIA64: + case MACHINE_TESTIA64: + m->cpu_name = strdup("IA64"); + break; + + /* M68K: */ + case MACHINE_BAREM68K: + case MACHINE_TESTM68K: + m->cpu_name = strdup("68020"); + break; + /* x86: */ case MACHINE_BAREX86: case MACHINE_X86: @@ -4472,12 +4876,14 @@ if (m->single_step_on_bad_addr) debug("single-step on bad addresses\n"); - if (m->bintrans_enable) - debug("bintrans enabled (%i MB cache)\n", - (int) (m->bintrans_size / 1048576)); - else - debug("bintrans disabled, other speedtricks %s\n", - m->speed_tricks? "enabled" : "disabled"); + if (m->arch == ARCH_MIPS) { + if (m->bintrans_enable) + debug("bintrans enabled (%i MB cache)\n", + (int) (m->bintrans_size / 1048576)); + else + debug("bintrans disabled, other speedtricks %s\n", + m->speed_tricks? "enabled" : "disabled"); + } debug("clock: "); if (m->automatic_clock_adjustment) @@ -4664,6 +5070,8 @@ debug("\n"); useremul_list_emuls(); + debug("Userland emulation works for programs with the complexity" + " of Hello World,\nbut not much more.\n"); } @@ -4705,11 +5113,11 @@ me->next = first_machine_entry; first_machine_entry = me; } - /* Test-machine for URISC: */ - me = machine_entry_new("Test-machine for URISC", ARCH_URISC, - MACHINE_TESTURISC, 1, 0); - me->aliases[0] = "testurisc"; - if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) { + /* Test-machine for SPARC: */ + me = machine_entry_new("Test-machine for SPARC", ARCH_SPARC, + MACHINE_TESTSPARC, 1, 0); + me->aliases[0] = "testsparc"; + if (cpu_family_ptr_by_number(ARCH_SPARC) != NULL) { me->next = first_machine_entry; first_machine_entry = me; } @@ -4729,11 +5137,19 @@ me->next = first_machine_entry; first_machine_entry = me; } - /* Test-machine for HPPA: */ - me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA, - MACHINE_TESTHPPA, 1, 0); - me->aliases[0] = "testhppa"; - if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) { + /* Test-machine for M68K: */ + me = machine_entry_new("Test-machine for M68K", ARCH_M68K, + MACHINE_TESTM68K, 1, 0); + me->aliases[0] = "testm68k"; + if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) { + me->next = first_machine_entry; first_machine_entry = me; + } + + /* Test-machine for IA64: */ + me = machine_entry_new("Test-machine for IA64", ARCH_IA64, + MACHINE_TESTIA64, 1, 0); + me->aliases[0] = "testia64"; + if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) { me->next = first_machine_entry; first_machine_entry = me; } @@ -4779,32 +5195,34 @@ } /* SGI: */ - me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 9); + me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 10); me->aliases[0] = "silicon graphics"; me->aliases[1] = "sgi"; - me->subtype[0] = machine_entry_subtype_new("IP19", 19, 1); - me->subtype[0]->aliases[0] = "ip19"; - me->subtype[1] = machine_entry_subtype_new("IP20", 20, 1); - me->subtype[1]->aliases[0] = "ip20"; - me->subtype[2] = machine_entry_subtype_new("IP22", 22, 2); - me->subtype[2]->aliases[0] = "ip22"; - me->subtype[2]->aliases[1] = "indy"; - me->subtype[3] = machine_entry_subtype_new("IP24", 24, 1); - me->subtype[3]->aliases[0] = "ip24"; - me->subtype[4] = machine_entry_subtype_new("IP27", 27, 3); - me->subtype[4]->aliases[0] = "ip27"; - me->subtype[4]->aliases[1] = "origin 200"; - me->subtype[4]->aliases[2] = "origin 2000"; - me->subtype[5] = machine_entry_subtype_new("IP28", 28, 1); - me->subtype[5]->aliases[0] = "ip28"; - me->subtype[6] = machine_entry_subtype_new("IP30", 30, 2); - me->subtype[6]->aliases[0] = "ip30"; - me->subtype[6]->aliases[1] = "octane"; - me->subtype[7] = machine_entry_subtype_new("IP32", 32, 2); - me->subtype[7]->aliases[0] = "ip32"; - me->subtype[7]->aliases[1] = "o2"; - me->subtype[8] = machine_entry_subtype_new("IP35", 35, 1); - me->subtype[8]->aliases[0] = "ip35"; + me->subtype[0] = machine_entry_subtype_new("IP12", 12, 1); + me->subtype[0]->aliases[0] = "ip12"; + me->subtype[1] = machine_entry_subtype_new("IP19", 19, 1); + me->subtype[1]->aliases[0] = "ip19"; + me->subtype[2] = machine_entry_subtype_new("IP20", 20, 1); + me->subtype[2]->aliases[0] = "ip20"; + me->subtype[3] = machine_entry_subtype_new("IP22", 22, 2); + me->subtype[3]->aliases[0] = "ip22"; + me->subtype[3]->aliases[1] = "indy"; + me->subtype[4] = machine_entry_subtype_new("IP24", 24, 1); + me->subtype[4]->aliases[0] = "ip24"; + me->subtype[5] = machine_entry_subtype_new("IP27", 27, 3); + me->subtype[5]->aliases[0] = "ip27"; + me->subtype[5]->aliases[1] = "origin 200"; + me->subtype[5]->aliases[2] = "origin 2000"; + me->subtype[6] = machine_entry_subtype_new("IP28", 28, 1); + me->subtype[6]->aliases[0] = "ip28"; + me->subtype[7] = machine_entry_subtype_new("IP30", 30, 2); + me->subtype[7]->aliases[0] = "ip30"; + me->subtype[7]->aliases[1] = "octane"; + me->subtype[8] = machine_entry_subtype_new("IP32", 32, 2); + me->subtype[8]->aliases[0] = "ip32"; + me->subtype[8]->aliases[1] = "o2"; + me->subtype[9] = machine_entry_subtype_new("IP35", 35, 1); + me->subtype[9]->aliases[0] = "ip35"; if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) { me->next = first_machine_entry; first_machine_entry = me; } @@ -4849,20 +5267,6 @@ me->next = first_machine_entry; first_machine_entry = me; } - /* Evaluation Boards (MALTA etc): */ - me = machine_entry_new("evbmips", ARCH_MIPS, - MACHINE_EVBMIPS, 1, 2); - me->aliases[0] = "evbmips"; - me->subtype[0] = machine_entry_subtype_new("Malta", - MACHINE_EVBMIPS_MALTA, 1); - me->subtype[0]->aliases[0] = "malta"; - me->subtype[1] = machine_entry_subtype_new("PB1000", - MACHINE_EVBMIPS_PB1000, 1); - me->subtype[1]->aliases[0] = "pb1000"; - if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) { - me->next = first_machine_entry; first_machine_entry = me; - } - /* Macintosh (PPC): */ me = machine_entry_new("Macintosh (PPC)", ARCH_PPC, MACHINE_MACPPC, 1, 2); @@ -4878,10 +5282,9 @@ } /* HPCmips: */ - me = machine_entry_new("Handheld MIPS (HPC)", - ARCH_MIPS, MACHINE_HPCMIPS, 2, 8); + me = machine_entry_new("Handheld MIPS (HPCmips)", + ARCH_MIPS, MACHINE_HPCMIPS, 1, 8); me->aliases[0] = "hpcmips"; - me->aliases[1] = "hpc"; me->subtype[0] = machine_entry_subtype_new( "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2); me->subtype[0]->aliases[0] = "be-300"; @@ -4922,14 +5325,6 @@ me->next = first_machine_entry; first_machine_entry = me; } - /* Generic "bare" URISC machine: */ - me = machine_entry_new("Generic \"bare\" URISC machine", ARCH_URISC, - MACHINE_BAREURISC, 1, 0); - me->aliases[0] = "bareurisc"; - if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) { - me->next = first_machine_entry; first_machine_entry = me; - } - /* Generic "bare" SPARC machine: */ me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC, MACHINE_BARESPARC, 1, 0); @@ -4954,11 +5349,19 @@ me->next = first_machine_entry; first_machine_entry = me; } - /* Generic "bare" HPPA machine: */ - me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA, - MACHINE_BAREHPPA, 1, 0); - me->aliases[0] = "barehppa"; - if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) { + /* Generic "bare" M68K machine: */ + me = machine_entry_new("Generic \"bare\" M68K machine", ARCH_M68K, + MACHINE_BAREM68K, 1, 0); + me->aliases[0] = "barem68k"; + if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) { + me->next = first_machine_entry; first_machine_entry = me; + } + + /* Generic "bare" IA64 machine: */ + me = machine_entry_new("Generic \"bare\" IA64 machine", ARCH_IA64, + MACHINE_BAREIA64, 1, 0); + me->aliases[0] = "bareia64"; + if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) { me->next = first_machine_entry; first_machine_entry = me; } @@ -4978,6 +5381,23 @@ me->next = first_machine_entry; first_machine_entry = me; } + /* Evaluation Boards (MALTA etc): */ + me = machine_entry_new("Evaluation boards (evbmips)", ARCH_MIPS, + MACHINE_EVBMIPS, 1, 3); + me->aliases[0] = "evbmips"; + me->subtype[0] = machine_entry_subtype_new("Malta", + MACHINE_EVBMIPS_MALTA, 1); + me->subtype[0]->aliases[0] = "malta"; + me->subtype[1] = machine_entry_subtype_new("Malta (Big-Endian)", + MACHINE_EVBMIPS_MALTA_BE, 1); + me->subtype[1]->aliases[0] = "maltabe"; + me->subtype[2] = machine_entry_subtype_new("PB1000", + MACHINE_EVBMIPS_PB1000, 1); + me->subtype[2]->aliases[0] = "pb1000"; + if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) { + me->next = first_machine_entry; first_machine_entry = me; + } + /* DECstation: */ me = machine_entry_new("DECstation/DECsystem", ARCH_MIPS, MACHINE_DEC, 3, 9); @@ -5109,5 +5529,15 @@ if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) { me->next = first_machine_entry; first_machine_entry = me; } + + /* Alpha: */ + me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 1); + me->aliases[0] = "alpha"; + me->subtype[0] = machine_entry_subtype_new( + "DEC 3000/300", ST_DEC_3000_300, 1); + me->subtype[0]->aliases[0] = "3000/300"; + if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) { + me->next = first_machine_entry; first_machine_entry = me; + } }