--- trunk/src/machine.c 2007/10/08 16:18:00 4 +++ trunk/src/machine.c 2007/10/08 16:18:11 6 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: machine.c,v 1.420 2005/04/17 00:15:24 debug Exp $ + * $Id: machine.c,v 1.452 2005/06/02 17:11:34 debug Exp $ * * Emulation of specific machines. * @@ -67,7 +67,6 @@ /* For SGI and ARC emulation: */ #include "sgi_arcbios.h" -#include "arcbios_other.h" #include "crimereg.h" /* For DECstation emulation: */ @@ -107,6 +106,11 @@ struct machine_entry_subtype **subtype; }; + +/* See main.c: */ +extern int quiet_mode; + + /* This is initialized by machine_init(): */ static struct machine_entry *first_machine_entry = NULL; @@ -195,22 +199,23 @@ return 1; } - fatal("unknown subtype '%s' for emulation" + fatal("Unknown subtype '%s' for emulation" " '%s'\n", ssubtype, stype); + if (!ssubtype[0]) + fatal("(Maybe you forgot the -e" + " command line option?)\n"); exit(1); } me = me->next; } - fatal("machine_name_to_type(): unknown emulation type '%s' (", stype); - if (ssubtype == NULL) - fatal("no subtype)\n"); - else - fatal("subtype '%s')\n", ssubtype); - + 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"); + " types and subtypes.\n\n"); return 0; } @@ -415,26 +420,23 @@ */ void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len) { + int psize = 1024; /* 1024 256 64 16 4 1 */ + if ((addr >> 32) == 0) addr = (int64_t)(int32_t)addr; - if ((addr & 7) == 0 && (((size_t)s) & 7) == 0) { - while (len >= 8) { - cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)s, - 8, MEM_WRITE, CACHE_DATA); - addr += 8; - s += 8; - len -= 8; - } - } - if ((addr & 3) == 0 && (((size_t)s) & 3) == 0) { - while (len >= 4) { - cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)s, - 4, MEM_WRITE, CACHE_DATA); - addr += 4; - s += 4; - len -= 4; + while (len != 0) { + if ((addr & (psize-1)) == 0) { + while (len >= psize) { + cpu->memory_rw(cpu, cpu->mem, addr, + (unsigned char *)s, psize, MEM_WRITE, + CACHE_DATA); + addr += psize; + s += psize; + len -= psize; + } } + psize >>= 2; } while (len-- != 0) @@ -594,13 +596,13 @@ if (assrt) { /* OR in the irq_nr into the CSR: */ - m->kn02_csr->csr[0] |= irq_nr; + m->md_int.kn02_csr->csr[0] |= irq_nr; } else { /* AND out the irq_nr from the CSR: */ - m->kn02_csr->csr[0] &= ~irq_nr; + m->md_int.kn02_csr->csr[0] &= ~irq_nr; } - current = m->kn02_csr->csr[0] & m->kn02_csr->csr[2]; + current = m->md_int.kn02_csr->csr[0] & m->md_int.kn02_csr->csr[2]; if (current == 0) cpu_interrupt_ack(cpu, 2); else @@ -619,12 +621,12 @@ /* debug("kmin_interrupt(): irq_nr=%i assrt=%i\n", irq_nr, assrt); */ if (assrt) - m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr; + m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr; else - m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr; + m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr; - if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] - & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10]) + if (m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] + & m->md_int.dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10]) cpu_interrupt(cpu, KMIN_INT_TC3); else cpu_interrupt_ack(cpu, KMIN_INT_TC3); @@ -640,12 +642,12 @@ /* debug("kn03_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt); */ if (assrt) - m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr; + m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr; else - m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr; + m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr; - if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] - & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10]) + if (m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] + & m->md_int.dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10]) cpu_interrupt(cpu, KN03_INT_ASIC); else cpu_interrupt_ack(cpu, KN03_INT_ASIC); @@ -662,14 +664,14 @@ debug("maxine_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt); if (assrt) - m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) + m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr; else - m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) + m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr; - if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] - & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) + if (m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] + & m->md_int.dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10]) cpu_interrupt(cpu, XINE_INT_TC3); else @@ -684,7 +686,7 @@ { int r2 = 0; - m->kn230_csr->csr |= irq_nr; + m->md_int.kn230_csr->csr |= irq_nr; switch (irq_nr) { case KN230_CSR_INTR_SII: @@ -702,24 +704,24 @@ if (assrt) { /* OR in the irq_nr mask into the CSR: */ - m->kn230_csr->csr |= irq_nr; + m->md_int.kn230_csr->csr |= irq_nr; /* Assert MIPS interrupt 2 or 3: */ cpu_interrupt(cpu, r2); } else { /* AND out the irq_nr mask from the CSR: */ - m->kn230_csr->csr &= ~irq_nr; + m->md_int.kn230_csr->csr &= ~irq_nr; /* If the CSR interrupt bits are all zero, clear the bit in the cause register as well. */ if (r2 == 2) { /* irq 2: */ - if ((m->kn230_csr->csr & (KN230_CSR_INTR_DZ0 + if ((m->md_int.kn230_csr->csr & (KN230_CSR_INTR_DZ0 | KN230_CSR_INTR_OPT0 | KN230_CSR_INTR_OPT1)) == 0) cpu_interrupt_ack(cpu, r2); } else { /* irq 3: */ - if ((m->kn230_csr->csr & (KN230_CSR_INTR_SII | + if ((m->md_int.kn230_csr->csr & (KN230_CSR_INTR_SII | KN230_CSR_INTR_LANCE)) == 0) cpu_interrupt_ack(cpu, r2); } @@ -753,34 +755,35 @@ if (isa) { if (assrt) - m->jazz_data->isa_int_asserted |= irq; + m->md_int.jazz_data->isa_int_asserted |= irq; else - m->jazz_data->isa_int_asserted &= ~irq; + m->md_int.jazz_data->isa_int_asserted &= ~irq; } else { if (assrt) - m->jazz_data->int_asserted |= irq; + m->md_int.jazz_data->int_asserted |= irq; else - m->jazz_data->int_asserted &= ~irq; + m->md_int.jazz_data->int_asserted &= ~irq; } - /* debug(" %08x %08x\n", m->jazz_data->int_asserted, - m->jazz_data->int_enable_mask); */ - /* debug(" %08x %08x\n", m->jazz_data->isa_int_asserted, - m->jazz_data->isa_int_enable_mask); */ + /* debug(" %08x %08x\n", m->md_int.jazz_data->int_asserted, + m->md_int.jazz_data->int_enable_mask); */ + /* debug(" %08x %08x\n", m->md_int.jazz_data->isa_int_asserted, + m->md_int.jazz_data->isa_int_enable_mask); */ - if (m->jazz_data->int_asserted /* & m->jazz_data->int_enable_mask */ - & ~0x8000 ) + if (m->md_int.jazz_data->int_asserted + /* & m->md_int.jazz_data->int_enable_mask */ & ~0x8000 ) cpu_interrupt(cpu, 3); else cpu_interrupt_ack(cpu, 3); - if (m->jazz_data->isa_int_asserted & m->jazz_data->isa_int_enable_mask) + if (m->md_int.jazz_data->isa_int_asserted & + m->md_int.jazz_data->isa_int_enable_mask) cpu_interrupt(cpu, 4); else cpu_interrupt_ack(cpu, 4); /* TODO: this "15" (0x8000) is the timer... fix this? */ - if (m->jazz_data->int_asserted & 0x8000) + if (m->md_int.jazz_data->int_asserted & 0x8000) cpu_interrupt(cpu, 6); else cpu_interrupt_ack(cpu, 6); @@ -805,9 +808,9 @@ giu_irq = irq_nr - 32; if (assrt) - m->vr41xx_data->giuint |= (1 << giu_irq); + m->md_int.vr41xx_data->giuint |= (1 << giu_irq); else - m->vr41xx_data->giuint &= ~(1 << giu_irq); + m->md_int.vr41xx_data->giuint &= ~(1 << giu_irq); } /* TODO: This is wrong. What about GIU bit 8? */ @@ -815,7 +818,8 @@ if (irq_nr != 8) { /* If any GIU bit is asserted, then assert the main GIU interrupt: */ - if (m->vr41xx_data->giuint & m->vr41xx_data->giumask) + if (m->md_int.vr41xx_data->giuint & + m->md_int.vr41xx_data->giumask) vr41xx_interrupt(m, cpu, 8 + 8, 1); else vr41xx_interrupt(m, cpu, 8 + 8, 0); @@ -826,25 +830,25 @@ if (irq_nr < 16) { if (assrt) - m->vr41xx_data->sysint1 |= (1 << irq_nr); + m->md_int.vr41xx_data->sysint1 |= (1 << irq_nr); else - m->vr41xx_data->sysint1 &= ~(1 << irq_nr); + m->md_int.vr41xx_data->sysint1 &= ~(1 << irq_nr); } else if (irq_nr < 32) { irq_nr -= 16; if (assrt) - m->vr41xx_data->sysint2 |= (1 << irq_nr); + m->md_int.vr41xx_data->sysint2 |= (1 << irq_nr); else - m->vr41xx_data->sysint2 &= ~(1 << irq_nr); + m->md_int.vr41xx_data->sysint2 &= ~(1 << irq_nr); } /* TODO: Which hardware interrupt pin? */ /* debug(" sysint1=%04x mask=%04x, sysint2=%04x mask=%04x\n", - m->vr41xx_data->sysint1, m->vr41xx_data->msysint1, - m->vr41xx_data->sysint2, m->vr41xx_data->msysint2); */ + m->md_int.vr41xx_data->sysint1, m->md_int.vr41xx_data->msysint1, + m->md_int.vr41xx_data->sysint2, m->md_int.vr41xx_data->msysint2); */ - if ((m->vr41xx_data->sysint1 & m->vr41xx_data->msysint1) | - (m->vr41xx_data->sysint2 & m->vr41xx_data->msysint2)) + if ((m->md_int.vr41xx_data->sysint1 & m->md_int.vr41xx_data->msysint1) | + (m->md_int.vr41xx_data->sysint2 & m->md_int.vr41xx_data->msysint2)) cpu_interrupt(cpu, 2); else cpu_interrupt_ack(cpu, 2); @@ -878,11 +882,11 @@ } if (assrt) - m->ps2_data->sbus_smflg |= msk; + m->md_int.ps2_data->sbus_smflg |= msk; else - m->ps2_data->sbus_smflg &= ~msk; + m->md_int.ps2_data->sbus_smflg &= ~msk; - if (m->ps2_data->sbus_smflg != 0) + if (m->md_int.ps2_data->sbus_smflg != 0) cpu_interrupt(cpu, 8 + 1); else cpu_interrupt_ack(cpu, 8 + 1); @@ -892,25 +896,27 @@ if (assrt) { /* OR into the INTR: */ if (irq_nr < 16) - m->ps2_data->intr |= (1 << irq_nr); + m->md_int.ps2_data->intr |= (1 << irq_nr); else - m->ps2_data->dmac_reg[0x601] |= (1 << (irq_nr-16)); + m->md_int.ps2_data->dmac_reg[0x601] |= + (1 << (irq_nr-16)); } else { /* AND out of the INTR: */ if (irq_nr < 16) - m->ps2_data->intr &= ~(1 << irq_nr); + m->md_int.ps2_data->intr &= ~(1 << irq_nr); else - m->ps2_data->dmac_reg[0x601] &= ~(1 << (irq_nr-16)); + m->md_int.ps2_data->dmac_reg[0x601] &= + ~(1 << (irq_nr-16)); } /* TODO: Hm? How about the mask? */ - if (m->ps2_data->intr /* & m->ps2_data->imask */ ) + if (m->md_int.ps2_data->intr /* & m->md_int.ps2_data->imask */ ) cpu_interrupt(cpu, 2); else cpu_interrupt_ack(cpu, 2); /* TODO: mask? */ - if (m->ps2_data->dmac_reg[0x601] & 0xffff) + if (m->md_int.ps2_data->dmac_reg[0x601] & 0xffff) cpu_interrupt(cpu, 3); else cpu_interrupt_ack(cpu, 3); @@ -942,36 +948,36 @@ int ms = irq_nr / 64; uint32_t new = 1 << ms; if (assrt) - m->sgi_ip22_data->reg[4] |= new; + m->md_int.sgi_ip22_data->reg[4] |= new; else - m->sgi_ip22_data->reg[4] &= ~new; + m->md_int.sgi_ip22_data->reg[4] &= ~new; /* TODO: is this enough? */ irq_nr &= 63; } if (irq_nr < 32) { if (assrt) - m->sgi_ip22_data->reg[0] |= newmask; + m->md_int.sgi_ip22_data->reg[0] |= newmask; else - m->sgi_ip22_data->reg[0] &= ~newmask; + m->md_int.sgi_ip22_data->reg[0] &= ~newmask; } else { if (assrt) - m->sgi_ip22_data->reg[2] |= newmask; + m->md_int.sgi_ip22_data->reg[2] |= newmask; else - m->sgi_ip22_data->reg[2] &= ~newmask; + m->md_int.sgi_ip22_data->reg[2] &= ~newmask; } /* Read stat and mask for local0: */ - stat = m->sgi_ip22_data->reg[0]; - mask = m->sgi_ip22_data->reg[1]; + stat = m->md_int.sgi_ip22_data->reg[0]; + mask = m->md_int.sgi_ip22_data->reg[1]; if ((stat & mask) == 0) cpu_interrupt_ack(cpu, 2); else cpu_interrupt(cpu, 2); /* Read stat and mask for local1: */ - stat = m->sgi_ip22_data->reg[2]; - mask = m->sgi_ip22_data->reg[3]; + stat = m->md_int.sgi_ip22_data->reg[2]; + mask = m->md_int.sgi_ip22_data->reg[3]; if ((stat & mask) == 0) cpu_interrupt_ack(cpu, 3); else @@ -1003,9 +1009,9 @@ newmask = (int64_t)1 << irq_nr; if (assrt) - m->sgi_ip30_data->isr |= newmask; + m->md_int.sgi_ip30_data->isr |= newmask; else - m->sgi_ip30_data->isr &= ~newmask; + m->md_int.sgi_ip30_data->isr &= ~newmask; just_assert_and_such: @@ -1015,8 +1021,8 @@ cpu_interrupt_ack(cpu, 5); cpu_interrupt_ack(cpu, 6); - stat = m->sgi_ip30_data->isr; - mask = m->sgi_ip30_data->imask0; + stat = m->md_int.sgi_ip30_data->isr; + mask = m->md_int.sgi_ip30_data->imask0; if ((stat & mask) & 0x000000000000ffffULL) cpu_interrupt(cpu, 2); @@ -1069,7 +1075,7 @@ */ if (irq_nr & MACE_PERIPH_SERIAL) { /* Read current MACE interrupt bits: */ - memcpy(x, m->mace_data->reg + mace_addr, sizeof(uint32_t)); + memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr, sizeof(uint32_t)); mace_interrupts = 0; for (i=0; i> (i*8); - memcpy(m->mace_data->reg + mace_addr, x, sizeof(uint32_t)); + memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint32_t)); irq_nr = MACE_PERIPH_SERIAL; if (mace_interrupts == 0) @@ -1097,7 +1103,7 @@ /* Hopefully _MISC and _SERIAL will not be both on at the same time. */ if (irq_nr & MACE_PERIPH_MISC) { /* Read current MACE interrupt bits: */ - memcpy(x, m->mace_data->reg + mace_addr, sizeof(uint32_t)); + memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr, sizeof(uint32_t)); mace_interrupts = 0; for (i=0; i> (i*8); - memcpy(m->mace_data->reg + mace_addr, x, sizeof(uint32_t)); + memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint32_t)); irq_nr = MACE_PERIPH_MISC; if (mace_interrupts == 0) @@ -1123,7 +1129,7 @@ } /* Read CRIME_INTSTAT: */ - memcpy(x, m->crime_data->reg + crime_addr, sizeof(uint64_t)); + memcpy(x, m->md_int.ip32.crime_data->reg + crime_addr, sizeof(uint64_t)); crime_interrupts = 0; for (i=0; i<8; i++) { /* SGI is big-endian... */ @@ -1139,10 +1145,10 @@ /* Write back CRIME_INTSTAT: */ for (i=0; i<8; i++) x[7-i] = crime_interrupts >> (i*8); - memcpy(m->crime_data->reg + crime_addr, x, sizeof(uint64_t)); + memcpy(m->md_int.ip32.crime_data->reg + crime_addr, x, sizeof(uint64_t)); /* Read CRIME_INTMASK: */ - memcpy(x, m->crime_data->reg + CRIME_INTMASK, sizeof(uint64_t)); + memcpy(x, m->md_int.ip32.crime_data->reg + CRIME_INTMASK, sizeof(uint64_t)); crime_interrupts_mask = 0; for (i=0; i<8; i++) { crime_interrupts_mask <<= 8; @@ -1187,15 +1193,15 @@ ms = 1 << (irq_nr & 31); if (assrt) - m->au1x00_ic_data->request0_int |= ms; + m->md_int.au1x00_ic_data->request0_int |= ms; else - m->au1x00_ic_data->request0_int &= ~ms; + m->md_int.au1x00_ic_data->request0_int &= ~ms; /* TODO: Controller 1 */ } - if ((m->au1x00_ic_data->request0_int & - m->au1x00_ic_data->mask) != 0) + if ((m->md_int.au1x00_ic_data->request0_int & + m->md_int.au1x00_ic_data->mask) != 0) cpu_interrupt(cpu, 2); else cpu_interrupt_ack(cpu, 2); @@ -1206,6 +1212,49 @@ } +/* + * x86 (PC) interrupts: + * + * (irq_nr = 16 can be used to just reassert/deassert interrupts.) + */ +void x86_pc_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt) +{ + int mask = 1 << (irq_nr & 7); + + if (irq_nr < 8) { + if (assrt) + m->md.pc.pic1->irr |= mask; + else + m->md.pc.pic1->irr &= ~mask; + } else if (irq_nr < 16) { + if (m->md.pc.pic2 == NULL) { + fatal("x86_pc_interrupt(): pic2 used (irq_nr = %i), " + "but we are emulating an XT?\n", irq_nr); + return; + } + if (assrt) + m->md.pc.pic2->irr |= mask; + else + m->md.pc.pic2->irr &= ~mask; + } + + if (m->md.pc.pic2 != NULL) { + /* Any interrupt assertions on PIC2 go to irq 2 on PIC1 */ + /* (TODO: don't hardcode this here) */ + if (m->md.pc.pic2->irr & ~m->md.pc.pic2->ier) + m->md.pc.pic1->irr |= 0x04; + else + m->md.pc.pic1->irr &= ~0x04; + } + + /* Now, PIC1: */ + if (m->md.pc.pic1->irr & ~m->md.pc.pic1->ier) + cpu->cd.x86.interrupt_asserted = 1; + else + cpu->cd.x86.interrupt_asserted = 0; +} + + /**************************************************************************** * * * Machine dependant Initialization routines * @@ -1248,21 +1297,14 @@ int hpcmips_fb_ysize_mem = 0; /* ARCBIOS stuff: */ - struct arcbios_spb arcbios_spb; - struct arcbios_spb_64 arcbios_spb_64; - struct arcbios_sysid arcbios_sysid; - struct arcbios_dsp_stat arcbios_dsp_stat; - uint64_t mem_base, mem_count; - uint64_t system = 0; uint64_t sgi_ram_offset = 0; - uint64_t arc_reserved; int arc_wordlen = sizeof(uint32_t); - char *short_machine_name = NULL; char *eaddr_string = "eaddr=10:20:30:40:50:60"; /* nonsense */ unsigned char macaddr[6]; /* Generic bootstring stuff: */ - int bootdev_id = diskimage_bootdev(machine); + int bootdev_type = 0; + int bootdev_id; char *bootstr = NULL; char *bootarg = NULL; char *init_bootpath; @@ -1277,6 +1319,8 @@ struct cpu *cpu = machine->cpus[machine->bootstrap_cpu]; + bootdev_id = diskimage_bootdev(machine, &bootdev_type); + mem = cpu->mem; machine->machine_name = NULL; @@ -1460,7 +1504,7 @@ dev_mc146818_init(machine, mem, KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1); - machine->kn02_csr = + machine->md_int.kn02_csr = dev_kn02_init(cpu, mem, KN02_SYS_CSR); framebuffer_console_name = "osconsole=0,7"; @@ -1494,7 +1538,7 @@ * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1c300000) slot 12 * dma for asc0 (0x1c380000) slot 14 */ - machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0); + machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0); dev_le_init(machine, mem, 0x1c0c0000, 0, 0, KMIN_INTR_LANCE +8, 4*65536); dev_scc_init(machine, mem, 0x1c100000, KMIN_INTR_SCC_0 +8, machine->use_x11, 0, 1); dev_scc_init(machine, mem, 0x1c180000, KMIN_INTR_SCC_1 +8, machine->use_x11, 1, 1); @@ -1560,14 +1604,14 @@ * mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000) * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000) */ - machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1f800000, 0); + machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1f800000, 0); dev_le_init(machine, mem, KN03_SYS_LANCE, 0, 0, KN03_INTR_LANCE +8, 4*65536); - machine->dec_ioasic_data->dma_func[3] = dev_scc_dma_func; - machine->dec_ioasic_data->dma_func_extra[2] = dev_scc_init(machine, mem, KN03_SYS_SCC_0, KN03_INTR_SCC_0 +8, machine->use_x11, 0, 1); - machine->dec_ioasic_data->dma_func[2] = dev_scc_dma_func; - machine->dec_ioasic_data->dma_func_extra[3] = dev_scc_init(machine, mem, KN03_SYS_SCC_1, KN03_INTR_SCC_1 +8, machine->use_x11, 1, 1); + machine->md_int.dec_ioasic_data->dma_func[3] = dev_scc_dma_func; + machine->md_int.dec_ioasic_data->dma_func_extra[2] = dev_scc_init(machine, mem, KN03_SYS_SCC_0, KN03_INTR_SCC_0 +8, machine->use_x11, 0, 1); + machine->md_int.dec_ioasic_data->dma_func[2] = dev_scc_dma_func; + machine->md_int.dec_ioasic_data->dma_func_extra[3] = dev_scc_init(machine, mem, KN03_SYS_SCC_1, KN03_INTR_SCC_1 +8, machine->use_x11, 1, 1); dev_mc146818_init(machine, mem, KN03_SYS_CLOCK, KN03_INT_RTC, MC146818_DEC, 1); dev_asc_init(machine, mem, KN03_SYS_SCSI, @@ -1626,9 +1670,9 @@ * Clock uses interrupt 3 (shared with XMI?). */ - machine->dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000); + machine->md_int.dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000); dev_decbi_init(mem, 0x10000000); - dev_ssc_init(machine, mem, 0x10140000, 2, machine->use_x11, &machine->dec5800_csr->csr); + dev_ssc_init(machine, mem, 0x10140000, 2, machine->use_x11, &machine->md_int.dec5800_csr->csr); dev_decxmi_init(mem, 0x11800000); dev_deccca_init(mem, DEC_DECCCA_BASEADDR); @@ -1697,7 +1741,7 @@ * asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1c300000) * xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer (0xa000000) */ - machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0); + machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0); /* TURBOchannel slots (0 and 1): */ dev_turbochannel_init(machine, mem, 0, @@ -1804,7 +1848,7 @@ snprintf(tmpstr, sizeof(tmpstr) - 1, "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR); - machine->kn230_csr = device_add(machine, tmpstr); + machine->md_int.kn230_csr = device_add(machine, tmpstr); serial_console_name = "osconsole=0"; break; @@ -1895,7 +1939,8 @@ } else { /* disk boot: */ bootpath[0] = '0' + boot_scsi_boardnumber; - if (diskimage_is_a_tape(machine, bootdev_id)) + if (diskimage_is_a_tape(machine, bootdev_id, + bootdev_type)) bootpath[2] = 't'; bootpath[4] = '0' + bootdev_id; } @@ -2031,9 +2076,15 @@ */ /* dev_XXX_init(cpu, mem, 0x10000000, machine->emulated_hz); */ 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"); +#if 0 + dev_ns16550_init(machine, mem, 0x1f000010, 0, 1, 1, + "other serial console"); +#endif + /* * According to NetBSD/cobalt: * @@ -2102,7 +2153,7 @@ machine->main_console_handle = dev_ns16550_init( machine, mem, 0xa008680, 0, 4, machine->use_x11? 0 : 1, "serial console"); /* TODO: irq? */ - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4131); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131); machine->md_interrupt = vr41xx_interrupt; store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu, @@ -2133,7 +2184,7 @@ machine->main_console_handle = dev_ns16550_init( machine, mem, 0xa008680, 0, 4, machine->use_x11? 0 : 1, "serial console"); /* TODO: irq? */ - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121); machine->md_interrupt = vr41xx_interrupt; store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu, @@ -2161,7 +2212,7 @@ hpcmips_fb_bits = 16; hpcmips_fb_encoding = BIFB_D16_0000; - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121); machine->md_interrupt = vr41xx_interrupt; store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu, @@ -2189,7 +2240,7 @@ hpcmips_fb_bits = 16; hpcmips_fb_encoding = BIFB_D16_0000; - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121); machine->md_interrupt = vr41xx_interrupt; store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu, @@ -2217,7 +2268,7 @@ hpcmips_fb_bits = 16; hpcmips_fb_encoding = BIFB_D16_0000; - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121); machine->md_interrupt = vr41xx_interrupt; store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu, @@ -2245,7 +2296,7 @@ hpcmips_fb_bits = 16; hpcmips_fb_encoding = BIFB_D16_0000; - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121); machine->md_interrupt = vr41xx_interrupt; store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu, @@ -2273,7 +2324,7 @@ hpcmips_fb_bits = 4; hpcmips_fb_encoding = BIFB_D4_M2L_F; - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4181); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4181); machine->md_interrupt = vr41xx_interrupt; /* TODO: Hm... irq 17 according to linux, but @@ -2314,7 +2365,7 @@ hpcmips_fb_bits = 16; hpcmips_fb_encoding = BIFB_D16_0000; - machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121); + machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121); machine->md_interrupt = vr41xx_interrupt; store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu, @@ -2337,7 +2388,7 @@ if (machine->use_x11) machine->main_console_handle = - machine->vr41xx_data->kiu_console_handle; + machine->md_int.vr41xx_data->kiu_console_handle; /* NetBSD/hpcmips and possibly others expects the following: */ @@ -2437,7 +2488,7 @@ * ohci0: OHCI version 1.0 */ - machine->ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000); + machine->md_int.ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000); device_add(machine, "ps2_gs addr=0x12000000"); device_add(machine, "ps2_ether addr=0x14001000"); dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0); /* TODO: how much? */ @@ -2453,7 +2504,8 @@ /* Set the Harddisk controller present flag, if either disk 0 or 1 is present: */ - if (diskimage_exist(machine, 0) || diskimage_exist(machine, 1)) { + if (diskimage_exist(machine, 0, DISKIMAGE_IDE) || + diskimage_exist(machine, 1, DISKIMAGE_IDE)) { store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100); dev_ps2_spd_init(machine, mem, 0x14000000); } @@ -2515,21 +2567,11 @@ fprintf(stderr, "out of memory\n"); exit(1); } - short_machine_name = malloc(500); - if (short_machine_name == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } if (machine->machine_type == MACHINE_SGI) { cpu->byte_order = EMUL_BIG_ENDIAN; - sprintf(short_machine_name, "SGI-IP%i", machine->machine_subtype); sprintf(machine->machine_name, "SGI-IP%i", machine->machine_subtype); - /* Super-special case for IP24: */ - if (machine->machine_subtype == 24) - sprintf(short_machine_name, "SGI-IP22"); - sgi_ram_offset = 1048576 * machine->memory_offset_in_mb; /* Special cases for IP20,22,24,26 memory offset: */ @@ -2546,7 +2588,6 @@ } } else { cpu->byte_order = EMUL_LITTLE_ENDIAN; - sprintf(short_machine_name, "ARC"); sprintf(machine->machine_name, "ARC"); } @@ -2602,7 +2643,7 @@ */ /* int0 at mainbus0 addr 0x1fb801c0 */ - machine->sgi_ip20_data = dev_sgi_ip20_init(cpu, mem, DEV_SGI_IP20_BASE); + machine->md_int.sgi_ip20_data = dev_sgi_ip20_init(cpu, mem, DEV_SGI_IP20_BASE); /* imc0 at mainbus0 addr 0x1fa00000: revision 0: TODO (or in dev_sgi_ip20?) */ @@ -2638,10 +2679,10 @@ case 24: if (machine->machine_subtype == 22) { strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Full-house)"); - machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0); + machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0); } else { strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Guiness)"); - machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1); + machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1); } /* @@ -2684,7 +2725,7 @@ /* Not supported by NetBSD 1.6.2, but by 2.0_BETA: */ j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242, - 0, 0, machine->use_x11); /* TODO: irq numbers */ + 0, 0, machine->use_x11, 0); /* TODO: irq numbers */ if (machine->use_x11) machine->main_console_handle = j; @@ -2765,7 +2806,7 @@ arc_wordlen = sizeof(uint64_t); strcat(machine->machine_name, " (Octane)"); - machine->sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000); + machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000); machine->md_interrupt = sgi_ip30_interrupt; dev_ram_init(mem, 0xa0000000ULL, @@ -2808,7 +2849,7 @@ dev_ram_init(mem, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000); dev_ram_init(mem, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000); - machine->crime_data = dev_crime_init(machine, mem, 0x14000000, 2, machine->use_x11); /* crime0 */ + machine->md_int.ip32.crime_data = dev_crime_init(machine, mem, 0x14000000, 2, machine->use_x11); /* crime0 */ dev_sgi_mte_init(mem, 0x15000000); /* mte ??? memory thing */ dev_sgi_gbe_init(machine, mem, 0x16000000); /* gbe? framebuffer? */ @@ -2835,7 +2876,7 @@ * 1f3a0000 mcclock0 */ - machine->mace_data = dev_mace_init(mem, 0x1f310000, 2); + machine->md_int.ip32.mace_data = dev_mace_init(mem, 0x1f310000, 2); machine->md_interrupt = sgi_ip32_interrupt; /* @@ -2854,7 +2895,7 @@ i = dev_pckbc_init(machine, mem, 0x1f320000, PCKBC_8242, 0x200 + MACE_PERIPH_MISC, - 0x800 + MACE_PERIPH_MISC, machine->use_x11); + 0x800 + MACE_PERIPH_MISC, machine->use_x11, 0); /* keyb+mouse (mace irq numbers) */ net_generate_unique_mac(machine, macaddr); @@ -2896,9 +2937,19 @@ pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE); /* macepci0 */ /* bus_pci_add(machine, pci_data, mem, 0, 0, 0, pci_ne2000_init, pci_ne2000_rr); TODO */ -#if 1 - bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr); -#endif + + /* TODO: make this nicer */ + if (diskimage_exist(machine, 0, DISKIMAGE_SCSI) || + diskimage_exist(machine, 1, DISKIMAGE_SCSI) || + diskimage_exist(machine, 2, DISKIMAGE_SCSI) || + diskimage_exist(machine, 3, DISKIMAGE_SCSI) || + diskimage_exist(machine, 4, DISKIMAGE_SCSI) || + diskimage_exist(machine, 5, DISKIMAGE_SCSI) || + diskimage_exist(machine, 6, DISKIMAGE_SCSI) || + diskimage_exist(machine, 7, DISKIMAGE_SCSI)) + bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr); + + /* TODO: second ahc */ /* bus_pci_add(machine, pci_data, mem, 0, 2, 0, pci_ahc_init, pci_ahc_rr); */ break; @@ -2955,7 +3006,7 @@ 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); + 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, @@ -3064,18 +3115,33 @@ exit(1); } - machine->jazz_data = device_add(machine, + machine->md_int.jazz_data = device_add(machine, "jazz addr=0x80000000"); machine->md_interrupt = jazz_interrupt; + 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"); + + if (machine->use_x11) + machine->main_console_handle = i; + else + machine->main_console_handle = j; + switch (machine->machine_subtype) { case MACHINE_ARC_JAZZ_PICA: - dev_vga_init(machine, mem, - 0x400b8000ULL, 0x600003c0ULL, - ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name); - arcbios_console_init(cpu, 0x400b8000ULL, - 0x600003c0ULL, ARC_CONSOLE_MAX_X, - ARC_CONSOLE_MAX_Y); + if (machine->use_x11) { + dev_vga_init(machine, mem, + 0x400a0000ULL, 0x600003c0ULL, + machine->machine_name); + arcbios_console_init(machine, + 0x400b8000ULL, 0x600003c0ULL); + } break; case MACHINE_ARC_JAZZ_MAGNUM: /* PROM mirror? */ @@ -3095,27 +3161,14 @@ dev_asc_init(machine, mem, 0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA, - dev_jazz_dma_controller, machine->jazz_data); + dev_jazz_dma_controller, + machine->md_int.jazz_data); device_add(machine, "fdc addr=0x80003000, irq=0"); dev_mc146818_init(machine, mem, 0x80004000ULL, 2, MC146818_ARC_JAZZ, 1); - i = dev_pckbc_init(machine, mem, 0x80005000ULL, - PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11); - - 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"); - - if (machine->use_x11) - machine->main_console_handle = i; - else - machine->main_console_handle = j; - #if 0 Not yet. dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0); @@ -3135,7 +3188,7 @@ strcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)"); - machine->jazz_data = device_add(machine, + machine->md_int.jazz_data = device_add(machine, "jazz addr=0x80000000"); machine->md_interrupt = jazz_interrupt; @@ -3145,7 +3198,7 @@ i = 0; /* TODO: Yuck! */ #if 0 i = dev_pckbc_init(machine, mem, 0x80005000ULL, - PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11); + PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0); #endif j = dev_ns16550_init(machine, mem, 0x80006000ULL, 8 + 8, 1, @@ -3173,13 +3226,6 @@ strcat(machine->machine_name, " (Deskstation Tyne)"); - dev_vga_init(machine, mem, 0x1000b8000ULL, 0x9000003c0ULL, - ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name); - - arcbios_console_init(cpu, 0x1000b8000ULL, - 0x9000003c0ULL, ARC_CONSOLE_MAX_X, - ARC_CONSOLE_MAX_Y); - 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"); @@ -3194,13 +3240,20 @@ #endif /* PC kbd */ j = dev_pckbc_init(machine, mem, 0x900000060ULL, - PCKBC_8042, 0, 0, machine->use_x11); + PCKBC_8042, 0, 0, machine->use_x11, 0); if (machine->use_x11) machine->main_console_handle = j; else machine->main_console_handle = i; + if (machine->use_x11) { + dev_vga_init(machine, mem, 0x1000a0000ULL, + 0x9000003c0ULL, machine->machine_name); + + arcbios_console_init(machine, + 0x1000b8000ULL, 0x9000003c0ULL); + } break; default: @@ -3210,732 +3263,24 @@ } } - - if (!machine->prom_emulation) - goto no_arc_prom_emulation; /* TODO: ugly */ - - /* * This is important: :-) * - * TODO: There should not be any use of - * ARCBIOS before this statement. - */ - if (arc_wordlen == sizeof(uint64_t)) - arcbios_set_64bit_mode(1); - - if (machine->physical_ram_in_mb < 16) - fprintf(stderr, "WARNING! The ARC platform specification doesn't allow less than 16 MB of RAM. Continuing anyway.\n"); - - arcbios_set_default_exception_handler(cpu); - - memset(&arcbios_sysid, 0, sizeof(arcbios_sysid)); - if (machine->machine_type == MACHINE_SGI) { - /* Vendor ID, max 8 chars: */ - strncpy(arcbios_sysid.VendorId, "SGI", 3); - switch (machine->machine_subtype) { - case 22: - strncpy(arcbios_sysid.ProductId, - "87654321", 8); /* some kind of ID? */ - break; - case 32: - strncpy(arcbios_sysid.ProductId, "8", 1); - /* 6 or 8 (?) */ - break; - default: - snprintf(arcbios_sysid.ProductId, 8, "IP%i", - machine->machine_subtype); - } - } else { - switch (machine->machine_subtype) { - case MACHINE_ARC_NEC_RD94: - strncpy(arcbios_sysid.VendorId, "NEC W&S", 8); /* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "RD94", 4); /* NOTE: max 8 chars */ - break; - case MACHINE_ARC_NEC_R94: - strncpy(arcbios_sysid.VendorId, "NEC W&S", 8); /* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */ - break; - case MACHINE_ARC_NEC_R96: - strncpy(arcbios_sysid.VendorId, "MIPS DUO", 8); /* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "blahblah", 8); /* NOTE: max 8 chars */ - break; - case MACHINE_ARC_NEC_R98: - strncpy(arcbios_sysid.VendorId, "NEC W&S", 8); /* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "R98", 4); /* NOTE: max 8 chars */ - break; - case MACHINE_ARC_JAZZ_PICA: - strncpy(arcbios_sysid.VendorId, "MIPS MAG", 8);/* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */ - break; - case MACHINE_ARC_JAZZ_MAGNUM: - strncpy(arcbios_sysid.VendorId, "MIPS MAG", 8);/* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */ - break; - case MACHINE_ARC_JAZZ_M700: - strncpy(arcbios_sysid.VendorId, "OLI00000", 8);/* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */ - break; - case MACHINE_ARC_DESKTECH_TYNE: - strncpy(arcbios_sysid.VendorId, "DESKTECH", 8);/* NOTE: max 8 chars */ - strncpy(arcbios_sysid.ProductId, "ijkl", 4); /* NOTE: max 8 chars */ - break; - default: - fatal("error in machine.c sysid\n"); - exit(1); - } - } - store_buf(cpu, SGI_SYSID_ADDR, (char *)&arcbios_sysid, sizeof(arcbios_sysid)); - - arcbios_get_dsp_stat(cpu, &arcbios_dsp_stat); - store_buf(cpu, ARC_DSPSTAT_ADDR, (char *)&arcbios_dsp_stat, sizeof(arcbios_dsp_stat)); - - /* - * The first 12 MBs of RAM are simply reserved... this simplifies things a lot. - * If there's more than 512MB of RAM, it has to be split in two, according to - * the ARC spec. This code creates a number of chunks of at most 512MB each. - * - * NOTE: The region of physical address space between 0x10000000 and 0x1fffffff - * (256 - 512 MB) is usually occupied by memory mapped devices, so that portion is "lost". + * TODO: There should not be any use of ARCBIOS before this + * point. */ - arc_reserved = 0x2000; - if (machine->machine_type == MACHINE_SGI) - arc_reserved = 0x4000; - - arcbios_add_memory_descriptor(cpu, 0, arc_reserved, ARCBIOS_MEM_FirmwarePermanent); - arcbios_add_memory_descriptor(cpu, sgi_ram_offset + arc_reserved, 0x60000-arc_reserved, ARCBIOS_MEM_FirmwareTemporary); - - mem_base = 12; - mem_base += sgi_ram_offset / 1048576; - - while (mem_base < machine->physical_ram_in_mb + sgi_ram_offset/1048576) { - mem_count = machine->physical_ram_in_mb + sgi_ram_offset/1048576 - - mem_base; - - /* Skip the 256-512MB region (for devices) */ - if (mem_base < 256 && mem_base + mem_count > 256) { - mem_count = 256-mem_base; - } - - /* At most 512MB per descriptor (at least the first 512MB - must be separated this way, according to the ARC spec) */ - if (mem_count > 512) - mem_count = 512; - - arcbios_add_memory_descriptor(cpu, mem_base * 1048576, - mem_count * 1048576, ARCBIOS_MEM_FreeMemory); - - mem_base += mem_count; - - /* Skip the devices: */ - if (mem_base == 256) - mem_base = 512; - } - - - /* - * Components: (this is an example of what a system could look like) - * - * [System] - * [CPU] (one for each cpu) - * [FPU] (one for each cpu) - * [CPU Caches] - * [Memory] - * [Ethernet] - * [Serial] - * [SCSI] - * [Disk] - * - * Here's a good list of what hardware is in different IP-models: - * http://www.linux-mips.org/archives/linux-mips/2001-03/msg00101.html - */ - - if (machine->machine_name == NULL) - fatal("ERROR: machine_name == NULL\n"); - if (short_machine_name == NULL) - fatal("ERROR: short_machine_name == NULL\n"); - - switch (machine->machine_type) { - case MACHINE_SGI: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, short_machine_name, 0 /* ROOT */ , NULL, 0); - break; - default: - /* ARC: */ - switch (machine->machine_subtype) { - case MACHINE_ARC_NEC_RD94: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "NEC-RD94", 0 /* ROOT */ , NULL, 0); - break; - case MACHINE_ARC_NEC_R94: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "NEC-R94", 0 /* ROOT */ , NULL, 0); - break; - case MACHINE_ARC_NEC_R96: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "NEC-R96", 0 /* ROOT */ , NULL, 0); - break; - case MACHINE_ARC_NEC_R98: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "NEC-R98", 0 /* ROOT */ , NULL, 0); - break; - case MACHINE_ARC_JAZZ_PICA: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "PICA-61", 0 /* ROOT */ , NULL, 0); - break; - case MACHINE_ARC_JAZZ_MAGNUM: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "Microsoft-Jazz", 0 /* ROOT */ , NULL, 0); - break; - case MACHINE_ARC_JAZZ_M700: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "Microsoft-Jazz", 0 /* ROOT */ , NULL, 0); - break; - case MACHINE_ARC_DESKTECH_TYNE: - system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC, - 0, 1, 2, 0, 0xffffffff, "DESKTECH-TYNE", 0 /* ROOT */ , NULL, 0); - break; - default: - fatal("Unimplemented ARC machine type %i\n", - machine->machine_subtype); - exit(1); - } - } - - - /* - * Common stuff for both SGI and ARC: - */ - debug("ARC system @ 0x%llx\n", (long long)system); - - for (i=0; incpus; i++) { - uint64_t cpuaddr, fpu=0, picache, pdcache, sdcache=0; - int cache_size, cache_line_size; - unsigned int jj; - char arc_cpu_name[100]; - char arc_fpc_name[105]; - - snprintf(arc_cpu_name, sizeof(arc_cpu_name), - "MIPS-%s", machine->cpu_name); - - if (machine->machine_type == MACHINE_ARC && - machine->machine_subtype == MACHINE_ARC_NEC_R96) - snprintf(arc_cpu_name, sizeof(arc_cpu_name), - "MIPS-%s - Pr 4/5.0, Fp 5/0", - machine->cpu_name); - - arc_cpu_name[sizeof(arc_cpu_name)-1] = 0; - for (jj=0; jj= 'a' && arc_cpu_name[jj] <= 'z') - arc_cpu_name[jj] += ('A' - 'a'); - - strcpy(arc_fpc_name, arc_cpu_name); - strcat(arc_fpc_name, "FPC"); - - cpuaddr = arcbios_addchild_manual(cpu, COMPONENT_CLASS_ProcessorClass, COMPONENT_TYPE_CPU, - 0, 1, 2, i, 0xffffffff, arc_cpu_name, system, NULL, 0); - - /* - * TODO: This was in the ARC specs, but it isn't - * really used by ARC implementations? - * At least SGI-IP32 uses it. - */ - if (machine->machine_type == MACHINE_SGI) - fpu = arcbios_addchild_manual(cpu, COMPONENT_CLASS_ProcessorClass, COMPONENT_TYPE_FPU, - 0, 1, 2, 0, 0xffffffff, arc_fpc_name, cpuaddr, NULL, 0); - - cache_size = DEFAULT_PCACHE_SIZE - 12; - if (machine->cache_picache) - cache_size = machine->cache_picache - 12; - if (cache_size < 0) - cache_size = 0; - - cache_line_size = DEFAULT_PCACHE_LINESIZE; - if (machine->cache_picache_linesize) - cache_line_size = machine->cache_picache_linesize; - if (cache_line_size < 0) - cache_line_size = 0; - - picache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass, - COMPONENT_TYPE_PrimaryICache, 0, 1, 2, - /* - * Key bits: 0xXXYYZZZZ - * XX is refill-size. - * Cache line size is 1 << YY, - * Cache size is 4KB << ZZZZ. - */ - 0x01000000 + (cache_line_size << 16) + cache_size, - /* 32 bytes per line, default = 32 KB total */ - 0xffffffff, NULL, cpuaddr, NULL, 0); - - cache_size = DEFAULT_PCACHE_SIZE - 12; - if (machine->cache_pdcache) - cache_size = machine->cache_pdcache - 12; - if (cache_size < 0) - cache_size = 0; - - cache_line_size = DEFAULT_PCACHE_LINESIZE; - if (machine->cache_pdcache_linesize) - cache_line_size = machine->cache_pdcache_linesize; - if (cache_line_size < 0) - cache_line_size = 0; - - pdcache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass, - COMPONENT_TYPE_PrimaryDCache, 0, 1, 2, - /* - * Key bits: 0xYYZZZZ - * Cache line size is 1 << YY, - * Cache size is 4KB << ZZZZ. - */ - 0x01000000 + (cache_line_size << 16) + cache_size, - /* 32 bytes per line, default = 32 KB total */ - 0xffffffff, NULL, cpuaddr, NULL, 0); - - if (machine->cache_secondary >= 12) { - cache_size = machine->cache_secondary - 12; - - cache_line_size = 6; /* 64 bytes default */ - if (machine->cache_secondary_linesize) - cache_line_size = machine->cache_secondary_linesize; - if (cache_line_size < 0) - cache_line_size = 0; - - sdcache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass, - COMPONENT_TYPE_SecondaryDCache, 0, 1, 2, - /* - * Key bits: 0xYYZZZZ - * Cache line size is 1 << YY, - * Cache size is 4KB << ZZZZ. - */ - 0x01000000 + (cache_line_size << 16) + cache_size, - /* 64 bytes per line, default = 1 MB total */ - 0xffffffff, NULL, cpuaddr, NULL, 0); - } - - debug("ARC cpu%i @ 0x%llx", i, (long long)cpuaddr); - - if (fpu != 0) - debug(" (fpu @ 0x%llx)\n", (long long)fpu); - else - debug("\n"); - - debug(" picache @ 0x%llx, pdcache @ 0x%llx\n", - (long long)picache, (long long)pdcache); - - if (machine->cache_secondary >= 12) - debug(" sdcache @ 0x%llx\n", - (long long)sdcache); - - if (machine->machine_type == MACHINE_SGI) { - /* TODO: Memory amount (and base address?)! */ - uint64_t memory = arcbios_addchild_manual(cpu, COMPONENT_CLASS_MemoryClass, - COMPONENT_TYPE_MemoryUnit, - 0, 1, 2, 0, 0xffffffff, "memory", cpuaddr, NULL, 0); - debug(" memory @ 0x%llx\n", (long long)memory); - } - } - + if (machine->prom_emulation) + arcbios_init(machine, arc_wordlen == sizeof(uint64_t), + sgi_ram_offset); + else + goto no_arc_prom_emulation; /* TODO: ugly */ /* - * Other components, and default TLB entries: - * * TODO: How to build the component tree intermixed with * the rest of device initialization? */ - if (machine->machine_type == MACHINE_SGI) { - /* TODO: On which models is this required? */ - mips_coproc_tlb_set_entry(cpu, 0, 1048576*16, - 0xc000000000000000ULL, - 0x0, 1048576*16, - 1, 1, 1, 1, 1, 0, 2, 2); - } - - if (machine->machine_type == MACHINE_ARC && - ( machine->machine_subtype == MACHINE_ARC_NEC_RD94 || - machine->machine_subtype == MACHINE_ARC_NEC_R94 || - machine->machine_subtype == MACHINE_ARC_NEC_R96 )) { - uint64_t jazzbus, eisa, other; - - jazzbus = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_AdapterClass, - COMPONENT_TYPE_MultiFunctionAdapter, - 0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus", - system, NULL, 0); - - switch (machine->machine_subtype) { - case MACHINE_ARC_NEC_RD94: - case MACHINE_ARC_NEC_R94: - if (machine->use_x11) - arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_DisplayController, - 0, 1, 2, 0, 0x0, "10110004", - system, NULL, 0); - break; - case MACHINE_ARC_NEC_R96: - if (machine->use_x11) { - uint64_t x; - x = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_DisplayController, - COMPONENT_FLAG_ConsoleOut | - COMPONENT_FLAG_Output, - 1, 2, 0, 0x0, "necvdfrb", - jazzbus, NULL, 0); - arcbios_addchild_manual(cpu, - COMPONENT_CLASS_PeripheralClass, - COMPONENT_TYPE_MonitorPeripheral, - COMPONENT_FLAG_ConsoleOut | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "640x480", - x, NULL, 0); - } - - /* TODO: R[D]94 too? */ - eisa = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_AdapterClass, - COMPONENT_TYPE_EISAAdapter, - 0, 1, 2, 0, 0xffffffff, "EISA", - system, NULL, 0); - - other = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_OtherController, - 0, 1, 2, 0, 0xffffffff, "NEC1C01", - eisa, NULL, 0); - - break; - } - } - - if (machine->machine_type == MACHINE_ARC && - (machine->machine_subtype == MACHINE_ARC_JAZZ_PICA - || machine->machine_subtype == MACHINE_ARC_JAZZ_MAGNUM)) { - uint64_t jazzbus, ali_s3, vxl; - uint64_t diskcontroller, floppy, kbdctl, kbd; - uint64_t ptrctl, ptr, paral, audio; - uint64_t eisa, scsi; - /* uint64_t serial1, serial2; */ - - jazzbus = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_AdapterClass, - COMPONENT_TYPE_MultiFunctionAdapter, - 0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus", - system, NULL, 0); - - /* - * DisplayController, needed by NetBSD: - * TODO: NetBSD still doesn't use it :( - */ - switch (machine->machine_subtype) { - case MACHINE_ARC_JAZZ_PICA: - /* Default TLB entries on PICA-61: */ - - /* 7: 256K, asid: 0x0, v: 0xe1000000, - p0: 0xfff00000(2.VG), p1: 0x0(0..G) */ - mips_coproc_tlb_set_entry(cpu, 7, 262144, - 0xffffffffe1000000ULL, - 0x0fff00000ULL, 0, - 1, 0, 0, 0, 1, 0, 2, 0); - - /* 8: 64K, asid: 0x0, v: 0xe0000000, - p0: 0x80000000(2DVG), p1: 0x0(0..G) */ - mips_coproc_tlb_set_entry(cpu, 8, 65536, - 0xffffffffe0000000ULL, - 0x080000000ULL, 0, - 1, 0, 1, 0, 1, 0, 2, 0); - - /* 9: 64K, asid: 0x0, v: 0xe00e0000, - p0: 0x800e0000(2DVG), p1: 0x800f0000(2DVG) */ - mips_coproc_tlb_set_entry(cpu, 9, 65536, - (uint64_t)0xffffffffe00e0000ULL, - (uint64_t)0x0800e0000ULL, - (uint64_t)0x0800f0000ULL, - 1, 1, 1, 1, 1, 0, 2, 2); - - /* 10: 4K, asid: 0x0, v: 0xe0100000, - p0: 0xf0000000(2DVG), p1: 0x0(0..G) */ - mips_coproc_tlb_set_entry(cpu, 10, 4096, - (uint64_t)0xffffffffe0100000ULL, - (uint64_t)0x0f0000000ULL, 0, - 1, 0, 1, 0, 1, 0, 2, 0); - - /* 11: 1M, asid: 0x0, v: 0xe0200000, - p0: 0x60000000(2DVG), p1: 0x60100000(2DVG) */ - mips_coproc_tlb_set_entry(cpu, 11, 1048576, - 0xffffffffe0200000ULL, - 0x060000000ULL, 0x060100000ULL, - 1, 1, 1, 1, 1, 0, 2, 2); - - /* 12: 1M, asid: 0x0, v: 0xe0400000, - p0: 0x60200000(2DVG), p1: 0x60300000(2DVG) */ - mips_coproc_tlb_set_entry(cpu, 12, 1048576, - 0xffffffffe0400000ULL, - 0x060200000ULL, 0x060300000ULL, - 1, 1, 1, 1, 1, 0, 2, 2); - - /* 13: 4M, asid: 0x0, v: 0xe0800000, - p0: 0x40000000(2DVG), p1: 0x40400000(2DVG) */ - mips_coproc_tlb_set_entry(cpu, 13, 1048576*4, - 0xffffffffe0800000ULL, - 0x040000000ULL, 0x040400000ULL, - 1, 1, 1, 1, 1, 0, 2, 2); - - /* 14: 16M, asid: 0x0, v: 0xe2000000, - p0: 0x90000000(2DVG), p1: 0x91000000(2DVG) */ - mips_coproc_tlb_set_entry(cpu, 14, 1048576*16, - 0xffffffffe2000000ULL, - 0x090000000ULL, 0x091000000ULL, - 1, 1, 1, 1, 1, 0, 2, 2); - - if (machine->use_x11) { - ali_s3 = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_DisplayController, - COMPONENT_FLAG_ConsoleOut | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "ALI_S3", - jazzbus, NULL, 0); - - arcbios_addchild_manual(cpu, - COMPONENT_CLASS_PeripheralClass, - COMPONENT_TYPE_MonitorPeripheral, - COMPONENT_FLAG_ConsoleOut | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "1024x768", - ali_s3, NULL, 0); - } - break; - case MACHINE_ARC_JAZZ_MAGNUM: - if (machine->use_x11) { - vxl = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_DisplayController, - COMPONENT_FLAG_ConsoleOut | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "VXL", - jazzbus, NULL, 0); - - arcbios_addchild_manual(cpu, - COMPONENT_CLASS_PeripheralClass, - COMPONENT_TYPE_MonitorPeripheral, - COMPONENT_FLAG_ConsoleOut | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "1024x768", - vxl, NULL, 0); - } - break; - } - - diskcontroller = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_DiskController, - COMPONENT_FLAG_Input | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "I82077", - jazzbus, NULL, 0); - - floppy = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_PeripheralClass, - COMPONENT_TYPE_FloppyDiskPeripheral, - COMPONENT_FLAG_Removable | - COMPONENT_FLAG_Input | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, NULL, - diskcontroller, NULL, 0); - - kbdctl = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_KeyboardController, - COMPONENT_FLAG_ConsoleIn | - COMPONENT_FLAG_Input, - 1, 2, 0, 0xffffffff, "I8742", - jazzbus, NULL, 0); - - kbd = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_PeripheralClass, - COMPONENT_TYPE_KeyboardPeripheral, - COMPONENT_FLAG_ConsoleIn | - COMPONENT_FLAG_Input, - 1, 2, 0, 0xffffffff, "PCAT_ENHANCED", - kbdctl, NULL, 0); - - ptrctl = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_PointerController, - COMPONENT_FLAG_Input, - 1, 2, 0, 0xffffffff, "I8742", - jazzbus, NULL, 0); - - ptr = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_PeripheralClass, - COMPONENT_TYPE_PointerPeripheral, - COMPONENT_FLAG_Input, - 1, 2, 0, 0xffffffff, "PS2 MOUSE", - ptrctl, NULL, 0); - -/* These cause Windows NT to bug out. */ -#if 0 - serial1 = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_SerialController, - COMPONENT_FLAG_Input | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "COM1", - jazzbus, NULL, 0); - - serial2 = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_SerialController, - COMPONENT_FLAG_Input | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "COM1", - jazzbus, NULL, 0); -#endif - - paral = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_ParallelController, - COMPONENT_FLAG_Input | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "LPT1", - jazzbus, NULL, 0); - - audio = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_ControllerClass, - COMPONENT_TYPE_AudioController, - COMPONENT_FLAG_Input | - COMPONENT_FLAG_Output, - 1, 2, 0, 0xffffffff, "MAGNUM", - jazzbus, NULL, 0); - - eisa = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_AdapterClass, - COMPONENT_TYPE_EISAAdapter, - 0, 1, 2, 0, 0xffffffff, "EISA", - system, NULL, 0); - -{ -unsigned char config[78]; -memset(config, 0, sizeof(config)); - -/* config data version: 1, revision: 2, count: 4 */ -config[0] = 0x01; config[1] = 0x00; -config[2] = 0x02; config[3] = 0x00; -config[4] = 0x04; config[5] = 0x00; config[6] = 0x00; config[7] = 0x00; - -/* - type: Interrupt - share_disposition: DeviceExclusive, flags: LevelSensitive - level: 4, vector: 22, reserved1: 0 -*/ -config[8] = arc_CmResourceTypeInterrupt; -config[9] = arc_CmResourceShareDeviceExclusive; -config[10] = arc_CmResourceInterruptLevelSensitive; -config[12] = 4; -config[16] = 22; -config[20] = 0; - -/* - type: Memory - share_disposition: DeviceExclusive, flags: ReadWrite - start: 0x 0 80002000, length: 0x1000 -*/ -config[24] = arc_CmResourceTypeMemory; -config[25] = arc_CmResourceShareDeviceExclusive; -config[26] = arc_CmResourceMemoryReadWrite; -config[28] = 0x00; config[29] = 0x20; config[30] = 0x00; config[31] = 0x80; - config[32] = 0x00; config[33] = 0x00; config[34] = 0x00; config[35] = 0x00; -config[36] = 0x00; config[37] = 0x10; config[38] = 0x00; config[39] = 0x00; - -/* - type: DMA - share_disposition: DeviceExclusive, flags: 0x0 - channel: 0, port: 0, reserved1: 0 -*/ -config[40] = arc_CmResourceTypeDMA; -config[41] = arc_CmResourceShareDeviceExclusive; -/* 42..43 = flags, 44,45,46,47 = channel, 48,49,50,51 = port, 52,53,54,55 = reserved */ - -/* type: DeviceSpecific - share_disposition: DeviceExclusive, flags: 0x0 - datasize: 6, reserved1: 0, reserved2: 0 - data: [0x1:0x0:0x2:0x0:0x7:0x30] -*/ -config[56] = arc_CmResourceTypeDeviceSpecific; -config[57] = arc_CmResourceShareDeviceExclusive; -/* 58,59 = flags 60,61,62,63 = data size, 64..71 = reserved */ -config[60] = 6; -/* 72..77 = the data */ -config[72] = 0x01; -config[73] = 0x00; -config[74] = 0x02; -config[75] = 0x00; -config[76] = 0x07; -config[77] = 0x30; - scsi = arcbios_addchild_manual(cpu, - COMPONENT_CLASS_AdapterClass, - COMPONENT_TYPE_SCSIAdapter, - 0, 1, 2, 0, 0xffffffff, "ESP216", - system, config, sizeof(config)); - - arcbios_register_scsicontroller(scsi); -} - - } - - - add_symbol_name(&machine->symbol_context, - ARC_FIRMWARE_ENTRIES, 0x10000, "[ARCBIOS entry]", 0); - - switch (arc_wordlen) { - case sizeof(uint64_t): - for (i=0; i<100; i++) - store_64bit_word(cpu, ARC_FIRMWARE_VECTORS + i*8, - ARC_FIRMWARE_ENTRIES + i*8); - for (i=0; i<100; i++) - store_64bit_word(cpu, ARC_PRIVATE_VECTORS + i*8, - ARC_PRIVATE_ENTRIES + i*8); - break; - default: - for (i=0; i<100; i++) - store_32bit_word(cpu, ARC_FIRMWARE_VECTORS + i*4, - ARC_FIRMWARE_ENTRIES + i*4); - for (i=0; i<100; i++) - store_32bit_word(cpu, ARC_PRIVATE_VECTORS + i*4, - ARC_PRIVATE_ENTRIES + i*4); - } - - switch (arc_wordlen) { - case sizeof(uint64_t): - /* - * ARCS64 SPD (TODO: This is just a guess) - */ - memset(&arcbios_spb_64, 0, sizeof(arcbios_spb_64)); - store_64bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.SPBSignature, ARCBIOS_SPB_SIGNATURE); - store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.Version, 64); - store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.Revision, 0); - store_64bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.FirmwareVector, ARC_FIRMWARE_VECTORS); - store_buf(cpu, SGI_SPB_ADDR, (char *)&arcbios_spb_64, sizeof(arcbios_spb_64)); - break; - default: /* 32-bit */ - /* - * ARCBIOS SPB: (For ARC and 32-bit SGI modes) - */ - memset(&arcbios_spb, 0, sizeof(arcbios_spb)); - store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.SPBSignature, ARCBIOS_SPB_SIGNATURE); - store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.SPBLength, sizeof(arcbios_spb)); - store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.Version, 1); - store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.Revision, machine->machine_type == MACHINE_SGI? 10 : 2); - store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.FirmwareVector, ARC_FIRMWARE_VECTORS); - store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.FirmwareVectorLength, 100 * 4); /* ? */ - store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.PrivateVector, ARC_PRIVATE_VECTORS); - store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.PrivateVectorLength, 100 * 4); /* ? */ - store_buf(cpu, SGI_SPB_ADDR, (char *)&arcbios_spb, sizeof(arcbios_spb)); - } - /* * Boot string in ARC format: * @@ -3960,12 +3305,14 @@ strcat(init_bootpath, "pci(0)"); } - if (diskimage_is_a_cdrom(machine, bootdev_id)) - snprintf(init_bootpath + strlen(init_bootpath), 400, - "scsi(0)cdrom(%i)fdisk(0)", bootdev_id); + if (diskimage_is_a_cdrom(machine, bootdev_id, + bootdev_type)) + snprintf(init_bootpath + strlen(init_bootpath), + 400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id); else - snprintf(init_bootpath + strlen(init_bootpath), 400, - "scsi(0)disk(%i)rdisk(0)partition(1)", bootdev_id); + snprintf(init_bootpath + strlen(init_bootpath), + 400,"scsi(0)disk(%i)rdisk(0)partition(1)", + bootdev_id); } if (machine->machine_type == MACHINE_ARC) @@ -3983,7 +3330,8 @@ cpu->cd.mips.gpr[MIPS_GPR_A0] = 0; /* note: argc is increased later */ /* TODO: not needed? */ - cpu->cd.mips.gpr[MIPS_GPR_SP] = machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080; + cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t) + (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080); /* Set up argc/argv: */ addr = ARC_ENV_STRINGS; @@ -4136,7 +3484,7 @@ /* First of all, the MeshCube has an Au1500 in it: */ machine->md_interrupt = au1x00_interrupt; - machine->au1x00_ic_data = dev_au1x00_init(machine, mem); + machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem); /* * TODO: Which non-Au1500 devices, and at what addresses? @@ -4184,46 +3532,6 @@ device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0"); break; - case MACHINE_WRT54G: - machine->machine_name = "Linksys WRT54G"; - - if (machine->use_x11) - fprintf(stderr, "WARNING! Linksys WRT54G with -X is meaningless. Continuing anyway.\n"); - - /* 200 MHz default */ - if (machine->emulated_hz == 0) - machine->emulated_hz = 200000000; - - /* - * Linux should be loaded at 0x80001000. - * RAM: 16 or 32 MB, Flash RAM: 4 or 8 MB. - * http://www.bumpclub.ee/~jaanus/wrt54g/vana/minicom.cap: - * - * Starting program at 0x80001000 - * CPU revision is: 00029007 - * Primary instruction cache 8kb, linesize 16 bytes (2 ways) - * Primary data cache 4kb, linesize 16 bytes (2 ways) - * memory: 01000000 @ 00000000 (usable) - * Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs init=/etc/preinit noinitrd console=ttyS0,115200 - * CPU: BCM4712 rev 1 at 200 MHz - * Calibrating delay loop... 199.47 BogoMIPS - * ttyS00 at 0xb8000300 (irq = 3) is a 16550A - * ttyS01 at 0xb8000400 (irq = 0) is a 16550A - * Flash device: 0x400000 at 0x1c000000 - * .. - */ - - /* TODO: What should the initial register contents be? */ -#if 1 -{ -int i; -for (i=0; i<32; i++) - cpu->cd.mips.gpr[i] = 0x01230000 + (i << 8) + 0x55; -} -#endif - - break; - case MACHINE_SONYNEWS: /* * There are several models, according to @@ -4343,7 +3651,7 @@ dev_ns16550_init(machine, mem, 0x800002f8, 0, 1, 0, "serial 1"); /* This is used by Linux too: */ - dev_vga_init(machine, mem, 0xc00b8000ULL, 0x800003c0ULL, 80, 25, + dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL, machine->machine_name); store_32bit_word(cpu, 0x3010, @@ -4480,38 +3788,86 @@ /* TODO */ break; + case MACHINE_BAREARM: + machine->machine_name = "\"Bare\" ARM machine"; + break; + + case MACHINE_TESTARM: + machine->machine_name = "ARM test machine"; + + /* TODO */ + break; + case MACHINE_BAREX86: machine->machine_name = "\"Bare\" x86 machine"; break; case MACHINE_X86: - machine->machine_name = "Generic x86 PC"; + if (machine->machine_subtype == MACHINE_X86_XT) + machine->machine_name = "PC XT"; + else + machine->machine_name = "Generic x86 PC"; - if (!machine->use_x11) - fprintf(stderr, "WARNING! You are emulating a PC " - "without -X. You will miss any output going\n" - "to the screen!\n\n"); + /* Interrupt controllers: */ + snprintf(tmpstr, sizeof(tmpstr) - 1, "8259 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", + (long long)(X86_IO_BASE + 0xa0)); + machine->md.pc.pic2 = device_add(machine, tmpstr); + } + + machine->md_interrupt = x86_pc_interrupt; + + /* Timer: */ + snprintf(tmpstr, sizeof(tmpstr) - 1, "8253 addr=0x%llx irq=0", + (long long)(X86_IO_BASE + 0x40)); + device_add(machine, tmpstr); - /* - * Initialize all 16-bit interrupt vectors to point to - * somewhere within the PC BIOS area (0xf000:0x8yyy): - */ - for (i=0; i<256; i++) { - store_16bit_word(cpu, i*4, 0x8000 + i); - store_16bit_word(cpu, i*4 + 2, 0xf000); - } + snprintf(tmpstr, sizeof(tmpstr) - 1, "pccmos addr=0x%llx", + (long long)(X86_IO_BASE + 0x70)); + device_add(machine, tmpstr); - dev_vga_init(machine, mem, 0xb8000ULL, 0x1000003c0ULL, 80, 25, - "Generic x86 PC"); + /* TODO: IRQ when emulating a PC XT? */ - dev_wdc_init(machine, mem, 0x1000001f0ULL, 14, 0); + /* IDE controllers: */ + if (diskimage_exist(machine, 0, DISKIMAGE_IDE) || + diskimage_exist(machine, 1, DISKIMAGE_IDE)) + dev_wdc_init(machine, mem, X86_IO_BASE + 0x1f0, 14, 0); + if (diskimage_exist(machine, 2, DISKIMAGE_IDE) || + diskimage_exist(machine, 3, DISKIMAGE_IDE)) + 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", + (long long)(X86_IO_BASE + 0x3f0)); + device_add(machine, tmpstr); - /* TODO: disable the "enable" flag when a keyboard has - been added: */ - machine->main_console_handle = dev_ns16550_init(machine, mem, - 0x1000003f8ULL, 4, 1, 1, "com1"); - dev_ns16550_init(machine, mem, 0x100000378ULL, 3, 1, 0, "com2"); + /* TODO: sound blaster (eventually) at irq 7? */ + + /* 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"); + + /* VGA + keyboard: */ + dev_vga_init(machine, mem, 0xa0000ULL, X86_IO_BASE + 0x3c0, + "Generic x86 PC"); + machine->main_console_handle = dev_pckbc_init(machine, + mem, X86_IO_BASE + 0x60, PCKBC_8042, 1, 12, 1, 1); + if (machine->prom_emulation) + pc_bios_init(cpu); + + if (!machine->use_x11 && !quiet_mode) + fprintf(stderr, "-------------------------------------" + "------------------------------------------\n" + "\n WARNING! You are emulating a PC without -X. " + "You will miss graphical output!\n\n" + "-------------------------------------" + "------------------------------------------\n"); break; default: @@ -4581,9 +3937,6 @@ case MACHINE_NETGEAR: m->physical_ram_in_mb = 16; break; - case MACHINE_WRT54G: - m->physical_ram_in_mb = 32; - break; case MACHINE_ARC: switch (m->machine_subtype) { case MACHINE_ARC_JAZZ_PICA: @@ -4612,12 +3965,15 @@ case MACHINE_TESTURISC: m->physical_ram_in_mb = 2; break; + case MACHINE_X86: + if (m->machine_subtype == MACHINE_X86_XT) + m->physical_ram_in_mb = 1; + break; } } - /* Special hack for WRT54G and hpcmips machines: */ - if (m->machine_type == MACHINE_WRT54G || - m->machine_type == MACHINE_HPCMIPS) { + /* Special hack for hpcmips machines: */ + if (m->machine_type == MACHINE_HPCMIPS) { m->dbe_on_nonexistant_memaccess = 0; } @@ -4713,9 +4069,6 @@ case MACHINE_NETGEAR: m->cpu_name = strdup("RC32334"); break; - case MACHINE_WRT54G: - m->cpu_name = strdup("BCM4712"); - break; case MACHINE_ARC: switch (m->machine_subtype) { case MACHINE_ARC_JAZZ_PICA: @@ -4818,10 +4171,19 @@ m->cpu_name = strdup("EV4"); break; + /* ARM: */ + case MACHINE_BAREARM: + case MACHINE_TESTARM: + m->cpu_name = strdup("ARM"); + break; + /* x86: */ case MACHINE_BAREX86: case MACHINE_X86: - m->cpu_name = strdup("PENTIUM"); + if (m->machine_subtype == MACHINE_X86_XT) + m->cpu_name = strdup("8086"); + else + m->cpu_name = strdup("AMD64"); break; } @@ -5072,10 +4434,15 @@ */ /* X86 machine: */ - me = machine_entry_new("x86 (generic PC-style machine)", ARCH_X86, - MACHINE_X86, 2, 0); + me = machine_entry_new("x86-based PC", ARCH_X86, + MACHINE_X86, 2, 2); me->aliases[0] = "pc"; me->aliases[1] = "x86"; + me->subtype[0] = machine_entry_subtype_new("Generic PC", + MACHINE_X86_GENERIC, 1); + me->subtype[0]->aliases[0] = "generic"; + me->subtype[1] = machine_entry_subtype_new("PC XT", MACHINE_X86_XT, 1); + me->subtype[1]->aliases[0] = "xt"; if (cpu_family_ptr_by_number(ARCH_X86) != NULL) { me->next = first_machine_entry; first_machine_entry = me; } @@ -5121,6 +4488,14 @@ me->next = first_machine_entry; first_machine_entry = me; } + /* Test-machine for ARM: */ + me = machine_entry_new("Test-machine for ARM", ARCH_ARM, + MACHINE_TESTARM, 1, 0); + me->aliases[0] = "testarm"; + if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) { + me->next = first_machine_entry; first_machine_entry = me; + } + /* Test-machine for Alpha: */ me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA, MACHINE_TESTALPHA, 1, 0); @@ -5231,15 +4606,6 @@ me->next = first_machine_entry; first_machine_entry = me; } - /* Linksys: */ - me = machine_entry_new("Linksys WRT54G", ARCH_MIPS, - MACHINE_WRT54G, 2, 0); - me->aliases[0] = "linksys"; - me->aliases[1] = "wrt54g"; - if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) { - me->next = first_machine_entry; first_machine_entry = me; - } - /* HPCmips: */ me = machine_entry_new("Handheld MIPS (HPC)", ARCH_MIPS, MACHINE_HPCMIPS, 2, 8); @@ -5325,6 +4691,14 @@ me->next = first_machine_entry; first_machine_entry = me; } + /* Generic "bare" ARM machine: */ + me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM, + MACHINE_BAREARM, 1, 0); + me->aliases[0] = "barearm"; + if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) { + me->next = first_machine_entry; first_machine_entry = me; + } + /* Generic "bare" Alpha machine: */ me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA, MACHINE_BAREALPHA, 1, 0);