/[gxemul]/trunk/src/machine.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/machine.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 12 by dpavlin, Mon Oct 8 16:18:38 2007 UTC revision 18 by dpavlin, Mon Oct 8 16:19:11 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: machine.c,v 1.515 2005/08/16 09:16:26 debug Exp $   *  $Id: machine.c,v 1.577 2005/10/27 14:01:12 debug Exp $
29   *   *
30   *  Emulation of specific machines.   *  Emulation of specific machines.
31   *   *
# Line 67  Line 67 
67  /*  For Alpha emulation:  */  /*  For Alpha emulation:  */
68  #include "alpha_rpb.h"  #include "alpha_rpb.h"
69    
70    /*  For CATS emulation:  */
71    #include "cyclone_boot.h"
72    
73  /*  For SGI and ARC emulation:  */  /*  For SGI and ARC emulation:  */
74  #include "sgi_arcbios.h"  #include "sgi_arcbios.h"
75  #include "crimereg.h"  #include "crimereg.h"
# Line 456  int store_64bit_word(struct cpu *cpu, ui Line 459  int store_64bit_word(struct cpu *cpu, ui
459  int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)  int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
460  {  {
461          unsigned char data[4];          unsigned char data[4];
462          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
463                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
464          data[0] = (data32 >> 24) & 255;          data[0] = (data32 >> 24) & 255;
465          data[1] = (data32 >> 16) & 255;          data[1] = (data32 >> 16) & 255;
# Line 481  int store_32bit_word(struct cpu *cpu, ui Line 484  int store_32bit_word(struct cpu *cpu, ui
484  int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16)  int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16)
485  {  {
486          unsigned char data[2];          unsigned char data[2];
487          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
488                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
489          data[0] = (data16 >> 8) & 255;          data[0] = (data16 >> 8) & 255;
490          data[1] = (data16) & 255;          data[1] = (data16) & 255;
# Line 502  void store_buf(struct cpu *cpu, uint64_t Line 505  void store_buf(struct cpu *cpu, uint64_t
505  {  {
506          int psize = 1024;       /*  1024 256 64 16 4 1  */          int psize = 1024;       /*  1024 256 64 16 4 1  */
507    
508          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
509                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
510    
511          while (len != 0) {          while (len != 0) {
# Line 555  uint32_t load_32bit_word(struct cpu *cpu Line 558  uint32_t load_32bit_word(struct cpu *cpu
558  {  {
559          unsigned char data[4];          unsigned char data[4];
560    
561          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
562                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
563          cpu->memory_rw(cpu, cpu->mem,          cpu->memory_rw(cpu, cpu->mem,
564              addr, data, sizeof(data), MEM_READ, CACHE_DATA);              addr, data, sizeof(data), MEM_READ, CACHE_DATA);
# Line 579  uint16_t load_16bit_word(struct cpu *cpu Line 582  uint16_t load_16bit_word(struct cpu *cpu
582  {  {
583          unsigned char data[2];          unsigned char data[2];
584    
585          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
586                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
587          cpu->memory_rw(cpu, cpu->mem,          cpu->memory_rw(cpu, cpu->mem,
588              addr, data, sizeof(data), MEM_READ, CACHE_DATA);              addr, data, sizeof(data), MEM_READ, CACHE_DATA);
# Line 1305  void malta_interrupt(struct machine *m, Line 1308  void malta_interrupt(struct machine *m,
1308    
1309          if (irq_nr < 8) {          if (irq_nr < 8) {
1310                  if (assrt)                  if (assrt)
1311                          m->md_int.isa_pic_data.pic1->irr |= mask;                          m->isa_pic_data.pic1->irr |= mask;
1312                  else                  else
1313                          m->md_int.isa_pic_data.pic1->irr &= ~mask;                          m->isa_pic_data.pic1->irr &= ~mask;
1314          } else if (irq_nr < 16) {          } else if (irq_nr < 16) {
1315                  if (assrt)                  if (assrt)
1316                          m->md_int.isa_pic_data.pic2->irr |= mask;                          m->isa_pic_data.pic2->irr |= mask;
1317                  else                  else
1318                          m->md_int.isa_pic_data.pic2->irr &= ~mask;                          m->isa_pic_data.pic2->irr &= ~mask;
1319          }          }
1320    
1321          /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */          /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1322          /*  (TODO: don't hardcode this here)  */          /*  (TODO: don't hardcode this here)  */
1323          if (m->md_int.isa_pic_data.pic2->irr &          if (m->isa_pic_data.pic2->irr &
1324              ~m->md_int.isa_pic_data.pic2->ier)              ~m->isa_pic_data.pic2->ier)
1325                  m->md_int.isa_pic_data.pic1->irr |= 0x04;                  m->isa_pic_data.pic1->irr |= 0x04;
1326          else          else
1327                  m->md_int.isa_pic_data.pic1->irr &= ~0x04;                  m->isa_pic_data.pic1->irr &= ~0x04;
1328    
1329          /*  Now, PIC1:  */          /*  Now, PIC1:  */
1330          if (m->md_int.isa_pic_data.pic1->irr &          if (m->isa_pic_data.pic1->irr &
1331              ~m->md_int.isa_pic_data.pic1->ier)              ~m->isa_pic_data.pic1->ier)
1332                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1333          else          else
1334                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
1335    
1336          /*  printf("MALTA: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "          /*  printf("MALTA: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "
1337              "ier=0x%02x\n", m->md_int.isa_pic_data.pic1->irr,              "ier=0x%02x\n", m->isa_pic_data.pic1->irr,
1338              m->md_int.isa_pic_data.pic1->ier,              m->isa_pic_data.pic1->ier,
1339              m->md_int.isa_pic_data.pic2->irr,              m->isa_pic_data.pic2->irr,
1340              m->md_int.isa_pic_data.pic2->ier);  */              m->isa_pic_data.pic2->ier);  */
1341  }  }
1342    
1343    
# Line 1352  void cobalt_interrupt(struct machine *m, Line 1355  void cobalt_interrupt(struct machine *m,
1355    
1356          if (irq_nr < 8) {          if (irq_nr < 8) {
1357                  if (assrt)                  if (assrt)
1358                          m->md_int.isa_pic_data.pic1->irr |= mask;                          m->isa_pic_data.pic1->irr |= mask;
1359                  else                  else
1360                          m->md_int.isa_pic_data.pic1->irr &= ~mask;                          m->isa_pic_data.pic1->irr &= ~mask;
1361          } else if (irq_nr < 16) {          } else if (irq_nr < 16) {
1362                  if (assrt)                  if (assrt)
1363                          m->md_int.isa_pic_data.pic2->irr |= mask;                          m->isa_pic_data.pic2->irr |= mask;
1364                  else                  else
1365                          m->md_int.isa_pic_data.pic2->irr &= ~mask;                          m->isa_pic_data.pic2->irr &= ~mask;
1366          }          }
1367    
1368          /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */          /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1369          /*  (TODO: don't hardcode this here)  */          /*  (TODO: don't hardcode this here)  */
1370          if (m->md_int.isa_pic_data.pic2->irr &          if (m->isa_pic_data.pic2->irr &
1371              ~m->md_int.isa_pic_data.pic2->ier)              ~m->isa_pic_data.pic2->ier)
1372                  m->md_int.isa_pic_data.pic1->irr |= 0x04;                  m->isa_pic_data.pic1->irr |= 0x04;
1373          else          else
1374                  m->md_int.isa_pic_data.pic1->irr &= ~0x04;                  m->isa_pic_data.pic1->irr &= ~0x04;
1375    
1376          /*  Now, PIC1:  */          /*  Now, PIC1:  */
1377          if (m->md_int.isa_pic_data.pic1->irr &          if (m->isa_pic_data.pic1->irr &
1378              ~m->md_int.isa_pic_data.pic1->ier)              ~m->isa_pic_data.pic1->ier)
1379                  cpu_interrupt(cpu, 6);                  cpu_interrupt(cpu, 6);
1380          else          else
1381                  cpu_interrupt_ack(cpu, 6);                  cpu_interrupt_ack(cpu, 6);
1382    
1383          /*  printf("COBALT: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "          /*  printf("COBALT: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "
1384              "ier=0x%02x\n", m->md_int.isa_pic_data.pic1->irr,              "ier=0x%02x\n", m->isa_pic_data.pic1->irr,
1385              m->md_int.isa_pic_data.pic1->ier,              m->isa_pic_data.pic1->ier,
1386              m->md_int.isa_pic_data.pic2->irr,              m->isa_pic_data.pic2->irr,
1387              m->md_int.isa_pic_data.pic2->ier);  */              m->isa_pic_data.pic2->ier);  */
1388  }  }
1389    
1390    
# Line 1396  void x86_pc_interrupt(struct machine *m, Line 1399  void x86_pc_interrupt(struct machine *m,
1399    
1400          if (irq_nr < 8) {          if (irq_nr < 8) {
1401                  if (assrt)                  if (assrt)
1402                          m->md.pc.pic1->irr |= mask;                          m->isa_pic_data.pic1->irr |= mask;
1403                  else                  else
1404                          m->md.pc.pic1->irr &= ~mask;                          m->isa_pic_data.pic1->irr &= ~mask;
1405          } else if (irq_nr < 16) {          } else if (irq_nr < 16) {
1406                  if (m->md.pc.pic2 == NULL) {                  if (m->isa_pic_data.pic2 == NULL) {
1407                          fatal("x86_pc_interrupt(): pic2 used (irq_nr = %i), "                          fatal("x86_pc_interrupt(): pic2 used (irq_nr = %i), "
1408                              "but we are emulating an XT?\n", irq_nr);                              "but we are emulating an XT?\n", irq_nr);
1409                          return;                          return;
1410                  }                  }
1411                  if (assrt)                  if (assrt)
1412                          m->md.pc.pic2->irr |= mask;                          m->isa_pic_data.pic2->irr |= mask;
1413                  else                  else
1414                          m->md.pc.pic2->irr &= ~mask;                          m->isa_pic_data.pic2->irr &= ~mask;
1415          }          }
1416    
1417          if (m->md.pc.pic2 != NULL) {          if (m->isa_pic_data.pic2 != NULL) {
1418                  /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */                  /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1419                  /*  (TODO: don't hardcode this here)  */                  /*  (TODO: don't hardcode this here)  */
1420                  if (m->md.pc.pic2->irr & ~m->md.pc.pic2->ier)                  if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1421                          m->md.pc.pic1->irr |= 0x04;                          m->isa_pic_data.pic1->irr |= 0x04;
1422                  else                  else
1423                          m->md.pc.pic1->irr &= ~0x04;                          m->isa_pic_data.pic1->irr &= ~0x04;
1424          }          }
1425    
1426          /*  Now, PIC1:  */          /*  Now, PIC1:  */
1427          if (m->md.pc.pic1->irr & ~m->md.pc.pic1->ier)          if (m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier)
1428                  cpu->cd.x86.interrupt_asserted = 1;                  cpu->cd.x86.interrupt_asserted = 1;
1429          else          else
1430                  cpu->cd.x86.interrupt_asserted = 0;                  cpu->cd.x86.interrupt_asserted = 0;
1431  }  }
1432    
1433    
1434    /*
1435     *  Footbridge interrupts:
1436     *
1437     *  0..31  = footbridge interrupt
1438     *  32..47 = ISA (connected to IRQ_IN_L2 on CATS, L3 on NetWinder)
1439     *  64     = reassert
1440     */
1441    void footbridge_interrupt(struct machine *m, struct cpu *cpu, int irq_nr,
1442            int assrt)
1443    {
1444            uint32_t mask = 1 << (irq_nr & 31);
1445            int old_isa_assert, new_isa_assert;
1446            int isa_int = m->machine_type == MACHINE_CATS? 10 : 11;
1447    
1448            old_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1449    
1450            if (irq_nr >= 32 && irq_nr < 32 + 8) {
1451                    int mm = 1 << (irq_nr & 7);
1452                    if (assrt)
1453                            m->isa_pic_data.pic1->irr |= mm;
1454                    else
1455                            m->isa_pic_data.pic1->irr &= ~mm;
1456            } else if (irq_nr >= 32+8 && irq_nr < 32+16) {
1457                    int mm = 1 << (irq_nr & 7);
1458                    if (assrt)
1459                            m->isa_pic_data.pic2->irr |= mm;
1460                    else
1461                            m->isa_pic_data.pic2->irr &= ~mm;
1462            }
1463    
1464            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1465            /*  (TODO: don't hardcode this here)  */
1466            if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1467                    m->isa_pic_data.pic1->irr |= 0x04;
1468            else
1469                    m->isa_pic_data.pic1->irr &= ~0x04;
1470    
1471            /*  Now, PIC1:  */
1472            new_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1473            if (old_isa_assert != new_isa_assert) {
1474                    if (new_isa_assert)
1475                            cpu_interrupt(cpu, isa_int);
1476                    else
1477                            cpu_interrupt_ack(cpu, isa_int);
1478                    return;
1479            }
1480    
1481            if (irq_nr < 32) {
1482                    if (assrt)
1483                            m->md_int.footbridge_data->irq_status |= mask;
1484                    else
1485                            m->md_int.footbridge_data->irq_status &= ~mask;
1486            }
1487    
1488            if (m->md_int.footbridge_data->irq_status &
1489                m->md_int.footbridge_data->irq_enable)
1490                    cpu_interrupt(cpu, 65);
1491            else
1492                    cpu_interrupt_ack(cpu, 65);
1493    }
1494    
1495    
1496  /****************************************************************************  /****************************************************************************
1497   *                                                                          *   *                                                                          *
1498   *                  Machine dependant Initialization routines               *   *                  Machine dependant Initialization routines               *
# Line 1463  void machine_setup(struct machine *machi Line 1528  void machine_setup(struct machine *machi
1528                  struct btinfo_symtab c;                  struct btinfo_symtab c;
1529          } xx;          } xx;
1530          struct hpc_bootinfo hpc_bootinfo;          struct hpc_bootinfo hpc_bootinfo;
1531          uint64_t hpcmips_fb_addr = 0;          int hpc_platid_flags = 0, hpc_platid_cpu_submodel = 0,
1532          int hpcmips_fb_bits = 0, hpcmips_fb_encoding = 0;              hpc_platid_cpu_model = 0, hpc_platid_cpu_series = 0,
1533          int hpcmips_fb_xsize = 0;              hpc_platid_cpu_arch = 0,
1534          int hpcmips_fb_ysize = 0;              hpc_platid_submodel = 0, hpc_platid_model = 0,
1535          int hpcmips_fb_xsize_mem = 0;              hpc_platid_series = 0, hpc_platid_vendor = 0;
1536          int hpcmips_fb_ysize_mem = 0;          uint64_t hpc_fb_addr = 0;
1537            int hpc_fb_bits = 0, hpc_fb_encoding = 0;
1538            int hpc_fb_xsize = 0;
1539            int hpc_fb_ysize = 0;
1540            int hpc_fb_xsize_mem = 0;
1541            int hpc_fb_ysize_mem = 0;
1542    
1543          /*  ARCBIOS stuff:  */          /*  ARCBIOS stuff:  */
1544          uint64_t sgi_ram_offset = 0;          uint64_t sgi_ram_offset = 0;
# Line 1484  void machine_setup(struct machine *machi Line 1554  void machine_setup(struct machine *machi
1554          char *init_bootpath;          char *init_bootpath;
1555    
1556          /*  PCI stuff:  */          /*  PCI stuff:  */
1557          struct pci_data *pci_data;          struct pci_data *pci_data = NULL;
1558    
1559          /*  Framebuffer stuff:  */          /*  Framebuffer stuff:  */
1560          struct vfb_data *fb;          struct vfb_data *fb = NULL;
1561    
1562          /*  Abreviation:  :-)  */          /*  Abreviation:  :-)  */
1563          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];
# Line 1504  void machine_setup(struct machine *machi Line 1574  void machine_setup(struct machine *machi
1574                  case MACHINE_ARC:                  case MACHINE_ARC:
1575                          machine->boot_string_argument = "-aN";                          machine->boot_string_argument = "-aN";
1576                          break;                          break;
1577                    case MACHINE_CATS:
1578                            machine->boot_string_argument = "-A";
1579                            break;
1580                  case MACHINE_DEC:                  case MACHINE_DEC:
1581                          machine->boot_string_argument = "-a";                          machine->boot_string_argument = "-a";
1582                          break;                          break;
# Line 2053  void machine_setup(struct machine *machi Line 2126  void machine_setup(struct machine *machi
2126    
2127                  /*                  /*
2128                   *  Most OSes on DECstation use physical addresses below                   *  Most OSes on DECstation use physical addresses below
2129                   *  0x20000000, but OSF/1 seems to use 0xbe...... as if it was                   *  0x20000000, but both OSF/1 and Sprite use 0xbe...... as if
2130                   *  0x1e......, so we need this hack:                   *  it was 0x1e......, so we need this hack:
2131                   */                   */
2132                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);                  dev_ram_init(machine, 0xa0000000, 0x20000000,
2133                        DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2134    
2135                  /*  DECstation PROM stuff:  (TODO: endianness)  */                  if (machine->prom_emulation) {
2136                  for (i=0; i<100; i++)                          /*  DECstation PROM stuff:  (TODO: endianness)  */
2137                          store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,                          for (i=0; i<100; i++)
2138                              DEC_PROM_EMULATION + i*8);                                  store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
2139                                        DEC_PROM_EMULATION + i*8);
2140                  /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */  
2141                  for (i=0; i<100; i++) {                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2142                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,                          for (i=0; i<100; i++) {
2143                              0x03e00008);        /*  return  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2144                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,                                      0x03e00008);        /*  return  */
2145                              0x00000000);        /*  nop  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2146                  }                                      0x00000000);        /*  nop  */
2147                            }
2148    
2149                  /*                          /*
2150                   *  According to dec_prom.h from NetBSD:                           *  According to dec_prom.h from NetBSD:
2151                   *                           *
2152                   *  "Programs loaded by the new PROMs pass the following arguments:                           *  "Programs loaded by the new PROMs pass the following arguments:
2153                   *      a0      argc                           *      a0      argc
2154                   *      a1      argv                           *      a1      argv
2155                   *      a2      DEC_PROM_MAGIC                           *      a2      DEC_PROM_MAGIC
2156                   *      a3      The callback vector defined below"                           *      a3      The callback vector defined below"
2157                   *                           *
2158                   *  So we try to emulate a PROM, even though no such thing has been                           *  So we try to emulate a PROM, even though no such thing has been
2159                   *  loaded.                           *  loaded.
2160                   */                           */
2161    
2162                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2163                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2164                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2165                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2166    
2167                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2168                      BOOTINFO_MAGIC);                              BOOTINFO_MAGIC);
2169                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2170                      BOOTINFO_ADDR);                              BOOTINFO_ADDR);
2171    
2172                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2173                      (DEC_PROM_INITIAL_ARGV + 0x10));                              (DEC_PROM_INITIAL_ARGV + 0x10));
2174                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2175                      (DEC_PROM_INITIAL_ARGV + 0x70));                              (DEC_PROM_INITIAL_ARGV + 0x70));
2176                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2177                      (DEC_PROM_INITIAL_ARGV + 0xe0));                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2178                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2179    
2180                  /*                          /*
2181                   *  NetBSD and Ultrix expect the boot args to be like this:                           *  NetBSD and Ultrix expect the boot args to be like this:
2182                   *                           *
2183                   *      "boot" "bootdev" [args?]                           *      "boot" "bootdev" [args?]
2184                   *                           *
2185                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                           *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2186                   *  3100/2100 (although that crashes Ultrix :-/), and                           *  3100/2100 (although that crashes Ultrix :-/), and
2187                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                           *  "5/rz0a/netbsd" for all others.  The number '5' is the
2188                   *  slot number of the boot device.                           *  slot number of the boot device.
2189                   *                           *
2190                   *  'rz' for disks, 'tz' for tapes.                           *  'rz' for disks, 'tz' for tapes.
2191                   *                           *
2192                   *  TODO:  Make this nicer.                           *  TODO:  Make this nicer.
2193                   */                           */
2194                  {                          {
2195                          char bootpath[200];                          char bootpath[200];
   
2196  #if 0  #if 0
2197                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
2198                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
# Line 2140  void machine_setup(struct machine *machi Line 2214  void machine_setup(struct machine *machi
2214                          }                          }
2215    
2216                          init_bootpath = bootpath;                          init_bootpath = bootpath;
2217                  }                          }
2218    
2219                  bootarg = malloc(BOOTARG_BUFLEN);                          bootarg = malloc(BOOTARG_BUFLEN);
2220                  if (bootarg == NULL) {                          if (bootarg == NULL) {
2221                          fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2222                          exit(1);                                  exit(1);
2223                  }                          }
2224                  strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);                          strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2225                  if (strlcat(bootarg, machine->boot_kernel_filename,                          if (strlcat(bootarg, machine->boot_kernel_filename,
2226                      BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {                              BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2227                          fprintf(stderr, "bootarg truncated?\n");                                  fprintf(stderr, "bootarg truncated?\n");
2228                          exit(1);                                  exit(1);
2229                  }                          }
2230    
2231                  bootstr = "boot";                          bootstr = "boot";
2232    
2233                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2234                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2235                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2236                      machine->boot_string_argument);                              machine->boot_string_argument);
2237    
2238                  /*  Decrease the nr of args, if there are no args :-)  */                          /*  Decrease the nr of args, if there are no args :-)  */
2239                  if (machine->boot_string_argument == NULL ||                          if (machine->boot_string_argument == NULL ||
2240                      machine->boot_string_argument[0] == '\0')                              machine->boot_string_argument[0] == '\0')
2241                          cpu->cd.mips.gpr[MIPS_GPR_A0] --;                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2242    
2243                  if (machine->boot_string_argument[0] != '\0') {                          if (machine->boot_string_argument[0] != '\0') {
2244                          strlcat(bootarg, " ", BOOTARG_BUFLEN);                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2245                          if (strlcat(bootarg, machine->boot_string_argument,                                  if (strlcat(bootarg, machine->boot_string_argument,
2246                              BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2247                                  fprintf(stderr, "bootstr truncated?\n");                                          fprintf(stderr, "bootstr truncated?\n");
2248                                  exit(1);                                          exit(1);
2249                                    }
2250                          }                          }
                 }  
2251    
2252                  xx.a.common.next = (char *)&xx.b - (char *)&xx;                          xx.a.common.next = (char *)&xx.b - (char *)&xx;
2253                  xx.a.common.type = BTINFO_MAGIC;                          xx.a.common.type = BTINFO_MAGIC;
2254                  xx.a.magic = BOOTINFO_MAGIC;                          xx.a.magic = BOOTINFO_MAGIC;
2255    
2256                  xx.b.common.next = (char *)&xx.c - (char *)&xx.b;                          xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2257                  xx.b.common.type = BTINFO_BOOTPATH;                          xx.b.common.type = BTINFO_BOOTPATH;
2258                  strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));                          strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2259    
2260                  xx.c.common.next = 0;                          xx.c.common.next = 0;
2261                  xx.c.common.type = BTINFO_SYMTAB;                          xx.c.common.type = BTINFO_SYMTAB;
2262                  xx.c.nsym = 0;                          xx.c.nsym = 0;
2263                  xx.c.ssym = 0;                          xx.c.ssym = 0;
2264                  xx.c.esym = machine->file_loaded_end_addr;                          xx.c.esym = machine->file_loaded_end_addr;
2265    
2266                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
2267    
2268                  /*                          /*
2269                   *  The system's memmap:  (memmap is a global variable, in                           *  The system's memmap:  (memmap is a global variable, in
2270                   *  dec_prom.h)                           *  dec_prom.h)
2271                   */                           */
2272                  store_32bit_word_in_host(cpu,                          store_32bit_word_in_host(cpu,
2273                      (unsigned char *)&memmap.pagesize, 4096);                              (unsigned char *)&memmap.pagesize, 4096);
2274                  {                          {
2275                          unsigned int i;                                  unsigned int i;
2276                          for (i=0; i<sizeof(memmap.bitmap); i++)                                  for (i=0; i<sizeof(memmap.bitmap); i++)
2277                                  memmap.bitmap[i] = ((int)i * 4096*8 <                                          memmap.bitmap[i] = ((int)i * 4096*8 <
2278                                      1048576*machine->physical_ram_in_mb)?                                              1048576*machine->physical_ram_in_mb)?
2279                                      0xff : 0x00;                                              0xff : 0x00;
2280                  }                          }
2281                  store_buf(cpu, DEC_MEMMAP_ADDR, (char *)&memmap, sizeof(memmap));                          store_buf(cpu, DEC_MEMMAP_ADDR, (char *)&memmap, sizeof(memmap));
   
                 /*  Environment variables:  */  
                 addr = DEC_PROM_STRINGS;  
   
                 if (machine->use_x11 && machine->n_gfx_cards > 0)  
                         /*  (0,3)  Keyboard and Framebuffer  */  
                         add_environment_string(cpu, framebuffer_console_name, &addr);  
                 else  
                         /*  Serial console  */  
                         add_environment_string(cpu, serial_console_name, &addr);  
2282    
2283                  /*                          /*  Environment variables:  */
2284                   *  The KN5800 (SMP system) uses a CCA (console communications                          addr = DEC_PROM_STRINGS;
                  *  area):  (See VAX 6000 documentation for details.)  
                  */  
                 {  
                         char tmps[300];  
                         snprintf(tmps, sizeof(tmps), "cca=%x",  
                             (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));  
                         add_environment_string(cpu, tmps, &addr);  
                 }  
2285    
2286                  /*  These are needed for Sprite to boot:  */                          if (machine->use_x11 && machine->n_gfx_cards > 0)
2287                  {                                  /*  (0,3)  Keyboard and Framebuffer  */
2288                          char tmps[500];                                  add_environment_string(cpu, framebuffer_console_name, &addr);
2289                            else
2290                                    /*  Serial console  */
2291                                    add_environment_string(cpu, serial_console_name, &addr);
2292    
2293                            /*
2294                             *  The KN5800 (SMP system) uses a CCA (console communications
2295                             *  area):  (See VAX 6000 documentation for details.)
2296                             */
2297                            {
2298                                    char tmps[300];
2299                                    snprintf(tmps, sizeof(tmps), "cca=%x",
2300                                        (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2301                                    add_environment_string(cpu, tmps, &addr);
2302                            }
2303    
2304                            /*  These are needed for Sprite to boot:  */
2305                            {
2306                                    char tmps[500];
2307    
2308                                    snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2309                                    tmps[sizeof(tmps)-1] = '\0';
2310                                    add_environment_string(cpu, tmps, &addr);
2311    
2312                                    snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2313                                        DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2314                                        & 0xffffffffULL));
2315                                    tmps[sizeof(tmps)-1] = '\0';
2316                                    add_environment_string(cpu, tmps, &addr);
2317    
2318                                    snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2319                                        machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2320                                    tmps[sizeof(tmps)-1] = '\0';
2321                                    add_environment_string(cpu, tmps, &addr);
2322                            }
2323    
2324                          snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);                          add_environment_string(cpu, "scsiid0=7", &addr);
2325                          tmps[sizeof(tmps)-1] = '\0';                          add_environment_string(cpu, "bootmode=a", &addr);
2326                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, "testaction=q", &addr);
2327                            add_environment_string(cpu, "haltaction=h", &addr);
2328                          snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((                          add_environment_string(cpu, "more=24", &addr);
2329                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))  
2330                              & 0xffffffffULL));                          /*  Used in at least Ultrix on the 5100:  */
2331                          tmps[sizeof(tmps)-1] = '\0';                          add_environment_string(cpu, "scsiid=7", &addr);
2332                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, "baud0=9600", &addr);
2333                            add_environment_string(cpu, "baud1=9600", &addr);
2334                          snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",                          add_environment_string(cpu, "baud2=9600", &addr);
2335                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                          add_environment_string(cpu, "baud3=9600", &addr);
2336                          tmps[sizeof(tmps)-1] = '\0';                          add_environment_string(cpu, "iooption=0x1", &addr);
                         add_environment_string(cpu, tmps, &addr);  
                 }  
   
                 add_environment_string(cpu, "scsiid0=7", &addr);  
                 add_environment_string(cpu, "bootmode=a", &addr);  
                 add_environment_string(cpu, "testaction=q", &addr);  
                 add_environment_string(cpu, "haltaction=h", &addr);  
                 add_environment_string(cpu, "more=24", &addr);  
   
                 /*  Used in at least Ultrix on the 5100:  */  
                 add_environment_string(cpu, "scsiid=7", &addr);  
                 add_environment_string(cpu, "baud0=9600", &addr);  
                 add_environment_string(cpu, "baud1=9600", &addr);  
                 add_environment_string(cpu, "baud2=9600", &addr);  
                 add_environment_string(cpu, "baud3=9600", &addr);  
                 add_environment_string(cpu, "iooption=0x1", &addr);  
2337    
2338                  /*  The end:  */                          /*  The end:  */
2339                  add_environment_string(cpu, "", &addr);                          add_environment_string(cpu, "", &addr);
2340                    }
2341    
2342                  break;                  break;
2343    
# Line 2285  void machine_setup(struct machine *machi Line 2360  void machine_setup(struct machine *machi
2360    
2361                  /*  ISA interrupt controllers:  */                  /*  ISA interrupt controllers:  */
2362                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2363                  machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2364                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2365                  machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2366                  machine->md_interrupt = cobalt_interrupt;                  machine->md_interrupt = cobalt_interrupt;
2367    
2368                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);
# Line 2318  void machine_setup(struct machine *machi Line 2393  void machine_setup(struct machine *machi
2393                  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, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
2394                  /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr);  */                  /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr);  */
2395    
2396                  /*                  if (machine->prom_emulation) {
2397                   *  NetBSD/cobalt expects memsize in a0, but it seems that what                          /*
2398                   *  it really wants is the end of memory + 0x80000000.                           *  NetBSD/cobalt expects memsize in a0, but it seems that what
2399                   *                           *  it really wants is the end of memory + 0x80000000.
2400                   *  The bootstring is stored 512 bytes before the end of                           *
2401                   *  physical ram.                           *  The bootstring is stored 512 bytes before the end of
2402                   */                           *  physical ram.
2403                  cpu->cd.mips.gpr[MIPS_GPR_A0] =                           */
2404                      machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A0] =
2405                  bootstr = "root=/dev/hda1 ro";                              machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2406                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                          bootstr = "root=/dev/hda1 ro";
2407                  /*  TODO: bootarg, and/or automagic boot device detection  */                          /*  bootstr = "nfsroot=/usr/cobalt/";  */
2408                  store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);                          /*  TODO: bootarg, and/or automagic boot device detection  */
2409                            store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);
2410                    }
2411                  break;                  break;
2412    
2413          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
2414                  cpu->byte_order = EMUL_LITTLE_ENDIAN;                  cpu->byte_order = EMUL_LITTLE_ENDIAN;
2415                  memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));                  memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));
                 /*  TODO:  set platid from netbsd/usr/src/sys/arch/hpc/include/platid*  */  
                 /*  
                 #define PLATID_FLAGS_SHIFT              0  
                 #define PLATID_CPU_SUBMODEL_SHIFT       8  
                 #define PLATID_CPU_MODEL_SHIFT          14  
                 #define PLATID_CPU_SERIES_SHIFT         20  
                 #define PLATID_CPU_ARCH_SHIFT           26  
   
                 #define PLATID_SUBMODEL_SHIFT           0  
                 #define PLATID_MODEL_SHIFT              8  
                 #define PLATID_SERIES_SHIFT             16  
                 #define PLATID_VENDOR_SHIFT             22  
                 */  
   
2416                  /*                  /*
2417                  NOTE: See http://forums.projectmayo.com/viewtopic.php?topic=2743&forum=23                  NOTE: See http://forums.projectmayo.com/viewtopic.php?topic=2743&forum=23
2418                  for info on framebuffer addresses.                  for info on framebuffer addresses.
# Line 2359  void machine_setup(struct machine *machi Line 2422  void machine_setup(struct machine *machi
2422                  case MACHINE_HPCMIPS_CASIO_BE300:                  case MACHINE_HPCMIPS_CASIO_BE300:
2423                          /*  166MHz VR4131  */                          /*  166MHz VR4131  */
2424                          machine->machine_name = "Casio Cassiopeia BE-300";                          machine->machine_name = "Casio Cassiopeia BE-300";
2425                          hpcmips_fb_addr = 0x0a200000;                          hpc_fb_addr = 0x0a200000;
2426                          hpcmips_fb_xsize = 240;                          hpc_fb_xsize = 240;
2427                          hpcmips_fb_ysize = 320;                          hpc_fb_ysize = 320;
2428                          hpcmips_fb_xsize_mem = 256;                          hpc_fb_xsize_mem = 256;
2429                          hpcmips_fb_ysize_mem = 320;                          hpc_fb_ysize_mem = 320;
2430                          hpcmips_fb_bits = 15;                          hpc_fb_bits = 15;
2431                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2432    
2433                          /*  TODO: irq?  */                          /*  TODO: irq?  */
2434                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
# Line 2374  void machine_setup(struct machine *machi Line 2437  void machine_setup(struct machine *machi
2437                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);
2438                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2439    
2440                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2441                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2442                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2443                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 6;    /*  VR4131  */
2444                              + (6 <<  8)         /*  6 = VR4131  */                          hpc_platid_vendor = 3;          /*  Casio  */
2445                              );                          hpc_platid_series = 1;          /*  CASSIOPEIAE  */
2446                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  EXXX  */
2447                                (3 << 22)         /*  22: vendor  3=casio */                          hpc_platid_submodel = 3;        /*  E500  */
                             + (1 << 16)         /*  16: series  1=CASSIOPEIAE*/  
                             + (2 <<  8)         /*   8: model   2=EXXX*/  
                             + (3)               /*   0: submodel 3=E500 */  
                             );  
2448                          /*  TODO: Don't use model number for E500, it's a BE300!  */                          /*  TODO: Don't use model number for E500, it's a BE300!  */
2449                          break;                          break;
2450                  case MACHINE_HPCMIPS_CASIO_E105:                  case MACHINE_HPCMIPS_CASIO_E105:
2451                          /*  131MHz VR4121  */                          /*  131MHz VR4121  */
2452                          machine->machine_name = "Casio Cassiopeia E-105";                          machine->machine_name = "Casio Cassiopeia E-105";
2453                          hpcmips_fb_addr = 0x0a200000;   /*  TODO?  */                          hpc_fb_addr = 0x0a200000;       /*  TODO?  */
2454                          hpcmips_fb_xsize = 240;                          hpc_fb_xsize = 240;
2455                          hpcmips_fb_ysize = 320;                          hpc_fb_ysize = 320;
2456                          hpcmips_fb_xsize_mem = 256;                          hpc_fb_xsize_mem = 256;
2457                          hpcmips_fb_ysize_mem = 320;                          hpc_fb_ysize_mem = 320;
2458                          hpcmips_fb_bits = 16;                          hpc_fb_bits = 16;
2459                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2460    
2461                          /*  TODO: irq?  */                          /*  TODO: irq?  */
2462                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
# Line 2406  void machine_setup(struct machine *machi Line 2465  void machine_setup(struct machine *machi
2465                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2466                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2467    
2468                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2469                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2470                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2471                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2472                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 3;          /*  Casio  */
2473                              );                          hpc_platid_series = 1;          /*  CASSIOPEIAE  */
2474                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  EXXX  */
2475                                (3 << 22)         /*  22: vendor  3=casio */                          hpc_platid_submodel = 2;        /*  E105  */
                             + (1 << 16)         /*  16: series  1=CASSIOPEIAE*/  
                             + (2 <<  8)         /*   8: model   2=EXXX*/  
                             + (2)               /*   0: submodel 2=E105  */  
                             );  
2476                          break;                          break;
2477                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:
2478                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2479                          machine->machine_name = "NEC MobilePro 770";                          machine->machine_name = "NEC MobilePro 770";
2480                          /*  TODO:  */                          hpc_fb_addr = 0xa000000;
2481                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_xsize = 640;
2482                          hpcmips_fb_xsize = 640;                          hpc_fb_ysize = 240;
2483                          hpcmips_fb_ysize = 240;                          hpc_fb_xsize_mem = 800;
2484                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 240;
2485                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_bits = 16;
2486                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2487    
2488                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2489                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2490    
2491                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2492                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2493                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2494                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2495                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2496                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2497                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  MCR 5XX  */
2498                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 4;        /*  MCR 520A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (2 <<  8)         /*   8: model   2="MCR 5XX" */  
                             + (4)               /*   0: submodel 4="MCR 520A" */  
                             );  
2499                          break;                          break;
2500                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:
2501                          /*  166 (or 168) MHz VR4121  */                          /*  166 (or 168) MHz VR4121  */
2502                          machine->machine_name = "NEC MobilePro 780";                          machine->machine_name = "NEC MobilePro 780";
2503                          /*  TODO:  */                          hpc_fb_addr = 0xa180100;
2504                          hpcmips_fb_addr = 0xa180100;                          hpc_fb_xsize = 640;
2505                          hpcmips_fb_xsize = 640;                          hpc_fb_ysize = 240;
2506                          hpcmips_fb_ysize = 240;                          hpc_fb_xsize_mem = 640;
2507                          hpcmips_fb_xsize_mem = 640;                          hpc_fb_ysize_mem = 240;
2508                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_bits = 16;
2509                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2510    
2511                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2512                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2513    
2514                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2515                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2516                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2517                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2518                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2519                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2520                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  MCR 5XX  */
2521                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 8;        /*  MCR 530A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (2 <<  8)         /*   8: model   2="MCR 5XX" */  
                             + (8)               /*   0: submodel 8="MCR 530A" */  
                             );  
2522                          break;                          break;
2523                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:
2524                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2525                          machine->machine_name = "NEC MobilePro 800";                          machine->machine_name = "NEC MobilePro 800";
2526                          /*  TODO:  */                          hpc_fb_addr = 0xa000000;
2527                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_xsize = 800;
2528                          hpcmips_fb_xsize = 800;                          hpc_fb_ysize = 600;
2529                          hpcmips_fb_ysize = 600;                          hpc_fb_xsize_mem = 800;
2530                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 600;
2531                          hpcmips_fb_ysize_mem = 600;                          hpc_fb_bits = 16;
2532                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2533    
2534                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2535                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2536    
2537                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2538                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2539                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2540                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2541                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2542                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2543                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 3;           /*  MCR 7XX  */
2544                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 2;        /*  MCR 700A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (3 <<  8)         /*   8: model   3="MCR 7XX" */  
                             + (2)               /*   0: submodel 2="MCR 700A" */  
                             );  
2545                          break;                          break;
2546                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:
2547                          /*  168 MHz VR4121  */                          /*  168 MHz VR4121  */
2548                          machine->machine_name = "NEC MobilePro 880";                          machine->machine_name = "NEC MobilePro 880";
2549                          /*  TODO:  */                          hpc_fb_addr = 0xa0ea600;
2550                          hpcmips_fb_addr = 0xa0ea600;                          hpc_fb_xsize = 800;
2551                          hpcmips_fb_xsize = 800;                          hpc_fb_ysize = 600;
2552                          hpcmips_fb_ysize = 600;                          hpc_fb_xsize_mem = 800;
2553                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 600;
2554                          hpcmips_fb_ysize_mem = 600;                          hpc_fb_bits = 16;
2555                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2556    
2557                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2558                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2559    
2560                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2561                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2562                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2563                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2564                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2565                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2566                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 3;           /*  MCR 7XX  */
2567                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 4;        /*  MCR 730A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (3 <<  8)         /*   8: model   3="MCR 7XX" */  
                             + (4)               /*   0: submodel 4="MCR 730A" */  
                             );  
2568                          break;                          break;
2569                  case MACHINE_HPCMIPS_AGENDA_VR3:                  case MACHINE_HPCMIPS_AGENDA_VR3:
2570                          /*  66 MHz VR4181  */                          /*  66 MHz VR4181  */
2571                          machine->machine_name = "Agenda VR3";                          machine->machine_name = "Agenda VR3";
2572                          /*  TODO:  */                          /*  TODO:  */
2573                          hpcmips_fb_addr = 0x1000;                          hpc_fb_addr = 0x1000;
2574                          hpcmips_fb_xsize = 160;                          hpc_fb_xsize = 160;
2575                          hpcmips_fb_ysize = 240;                          hpc_fb_ysize = 240;
2576                          hpcmips_fb_xsize_mem = 160;                          hpc_fb_xsize_mem = 160;
2577                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_ysize_mem = 240;
2578                          hpcmips_fb_bits = 4;                          hpc_fb_bits = 4;
2579                          hpcmips_fb_encoding = BIFB_D4_M2L_F;                          hpc_fb_encoding = BIFB_D4_M2L_F;
2580    
2581                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4181);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4181);
2582                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
# Line 2557  void machine_setup(struct machine *machi Line 2592  void machine_setup(struct machine *machi
2592                                          machine->main_console_handle = x;                                          machine->main_console_handle = x;
2593                          }                          }
2594    
2595                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2596                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2597                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2598                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 4;    /*  VR4181  */
2599                              + (4 <<  8)         /*  4 = VR4181  */                          hpc_platid_vendor = 15;         /*  Agenda  */
2600                              );                          hpc_platid_series = 1;          /*  VR  */
2601                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 1;           /*  VR3  */
2602                                (15 << 22)        /*  22: vendor  15=Agenda  */                          hpc_platid_submodel = 0;        /*  -  */
                             + (1 << 16)         /*  16: series  2=VR */  
                             + (1 <<  8)         /*   8: model   1=VR3  */  
                             + (0)               /*   0: submodel 0="VR3" */  
                             );  
2603    
2604                          dev_ram_init(mem, 0x0f000000, 0x01000000, DEV_RAM_MIRROR, 0x0);                          dev_ram_init(machine, 0x0f000000, 0x01000000,
2605                                DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2606                          break;                          break;
2607                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:
2608                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2609                          machine->machine_name = "IBM Workpad Z50";                          machine->machine_name = "IBM Workpad Z50";
2610                          /*  TODO:  */                          /*  TODO:  */
2611                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_addr = 0xa000000;
2612                          hpcmips_fb_xsize = 640;                          hpc_fb_xsize = 640;
2613                          hpcmips_fb_ysize = 480;                          hpc_fb_ysize = 480;
2614                          hpcmips_fb_xsize_mem = 640;                          hpc_fb_xsize_mem = 640;
2615                          hpcmips_fb_ysize_mem = 480;                          hpc_fb_ysize_mem = 480;
2616                          hpcmips_fb_bits = 16;                          hpc_fb_bits = 16;
2617                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2618    
2619                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2620                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2621    
2622                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2623                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2624                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2625                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2626                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 9;          /*  IBM  */
2627                              );                          hpc_platid_series = 1;          /*  WorkPad  */
2628                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 1;           /*  Z50  */
2629                                (9 << 22)         /*  22: vendor  9=IBM  */                          hpc_platid_submodel = 0;        /*  0  */
                             + (1 << 16)         /*  16: series  1=WorkPad */  
                             + (1 <<  8)         /*   8: model   1=Z50  */  
                             + (0)               /*   0: submodel 0 */  
                             );  
2630                          break;                          break;
2631                  default:                  default:
2632                          printf("Unimplemented hpcmips machine number.\n");                          printf("Unimplemented hpcmips machine number.\n");
2633                          exit(1);                          exit(1);
2634                  }                  }
2635    
2636                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2637                          (hpc_platid_cpu_arch << 26) + (hpc_platid_cpu_series << 20)
2638                        + (hpc_platid_cpu_model << 14) + (hpc_platid_cpu_submodel <<  8)
2639                        + hpc_platid_flags);
2640                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2641                          (hpc_platid_vendor << 22) + (hpc_platid_series << 16)
2642                        + (hpc_platid_model <<  8) + hpc_platid_submodel);
2643    
2644                  if (machine->use_x11)                  if (machine->use_x11)
2645                          machine->main_console_handle =                          machine->main_console_handle =
2646                              machine->md_int.vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
2647    
2648                  /*  NetBSD/hpcmips and possibly others expects the following:  */                  if (machine->prom_emulation) {
2649                            /*  NetBSD/hpcmips and possibly others expects the following:  */
                 cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */  
                 cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576  
                     + 0xffffffff80000000ULL - 512;      /*  argv  */  
                 cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576  
                     + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */  
   
                 bootstr = machine->boot_kernel_filename;  
                 store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16);  
                 store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);  
                 store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);  
   
                 /*  Special case for the Agenda VR3:  */  
                 if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {  
                         const int tmplen = 1000;  
                         char *tmp = malloc(tmplen);  
2650    
2651                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2652                            cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2653                                + 0xffffffff80000000ULL - 512;      /*  argv  */
2654                            cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2655                                + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */
2656    
2657                            bootstr = machine->boot_kernel_filename;
2658                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512,
2659                                0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2660                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2661                            store_string(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2662    
2663                            /*  Special case for the Agenda VR3:  */
2664                            if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2665                                    const int tmplen = 1000;
2666                                    char *tmp = malloc(tmplen);
2667    
2668                                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */
2669    
2670                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2671                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2672    
2673                                    snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2674                                        "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2675                                    tmp[tmplen-1] = '\0';
2676    
2677                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  if (!machine->use_x11)
2678                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2679                                    tmp[tmplen-1] = '\0';
2680    
2681                          snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"                                  if (machine->boot_string_argument[0])
2682                              "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2683                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2684    
2685                          if (!machine->use_x11)                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
                                 snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");  
                         tmp[tmplen-1] = '\0';  
2686    
2687                          if (machine->boot_string_argument[0])                                  bootarg = tmp;
2688                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);                          } else if (machine->boot_string_argument[0]) {
2689                          tmp[tmplen-1] = '\0';                                  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2690    
2691                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2692                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2693    
2694                          bootarg = tmp;                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2695                  } else if (machine->boot_string_argument[0]) {                                      machine->boot_string_argument);
                         cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */  
2696    
2697                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  bootarg = machine->boot_string_argument;
2698                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                          }
   
                         store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,  
                             machine->boot_string_argument);  
   
                         bootarg = machine->boot_string_argument;  
                 }  
2699    
2700                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2701                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2702                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpc_fb_addr);
2703                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpc_fb_xsize_mem * (((hpc_fb_bits-1)|7)+1) / 8);
2704                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpc_fb_xsize);
2705                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpc_fb_ysize);
2706                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpc_fb_encoding);
2707                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */
2708    
2709                  /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);                          /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);
2710                      printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */                              printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */
2711                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2712                  store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));                          store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2713                    }
2714                  if (hpcmips_fb_addr != 0) {  
2715                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,                  if (hpc_fb_addr != 0) {
2716                              hpcmips_fb_xsize, hpcmips_fb_ysize,                          dev_fb_init(machine, mem, hpc_fb_addr, VFB_HPC,
2717                              hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,                              hpc_fb_xsize, hpc_fb_ysize,
2718                              hpcmips_fb_bits, "HPCmips");                              hpc_fb_xsize_mem, hpc_fb_ysize_mem,
2719                                hpc_fb_bits, machine->machine_name);
2720    
2721                          /*  NetBSD/hpcmips uses framebuffer at physical                          /*  NetBSD/hpcmips uses framebuffer at physical
2722                              address 0x8.......:  */                              address 0x8.......:  */
2723                          dev_ram_init(mem, 0x80000000, 0x20000000,                          dev_ram_init(machine, 0x80000000, 0x20000000,
2724                              DEV_RAM_MIRROR, 0x0);                              DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2725                  }                  }
2726    
2727                  break;                  break;
# Line 2710  void machine_setup(struct machine *machi Line 2749  void machine_setup(struct machine *machi
2749                  machine->md_int.ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);                  machine->md_int.ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);
2750                  device_add(machine, "ps2_gs addr=0x12000000");                  device_add(machine, "ps2_gs addr=0x12000000");
2751                  device_add(machine, "ps2_ether addr=0x14001000");                  device_add(machine, "ps2_ether addr=0x14001000");
2752                  dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0);     /*  TODO: how much?  */                  dev_ram_init(machine, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0); /*  TODO: how much?  */
2753                  /*  irq = 8 + 32 + 1 (SBUS/USB)  */                  /*  irq = 8 + 32 + 1 (SBUS/USB)  */
2754                  device_add(machine, "ohci addr=0x1f801600 irq=41");                  device_add(machine, "ohci addr=0x1f801600 irq=41");
2755    
2756                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2757    
                 add_symbol_name(&machine->symbol_context,  
                     PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);  
                 store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);  
                 store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);  
   
2758                  /*  Set the Harddisk controller present flag, if either                  /*  Set the Harddisk controller present flag, if either
2759                      disk 0 or 1 is present:  */                      disk 0 or 1 is present:  */
2760                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2761                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2762                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                          if (machine->prom_emulation)
2763                                    store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2764                          dev_ps2_spd_init(machine, mem, 0x14000000);                          dev_ps2_spd_init(machine, mem, 0x14000000);
2765                  }                  }
2766    
2767                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                  if (machine->prom_emulation) {
                 {  
2768                          int tmplen = 1000;                          int tmplen = 1000;
2769                          char *tmp = malloc(tmplen);                          char *tmp = malloc(tmplen);
2770                            time_t timet;
2771                            struct tm *tm_ptr;
2772    
2773                            add_symbol_name(&machine->symbol_context,
2774                                PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2775                            store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2776                            store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2777    
2778                            store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2779                          if (tmp == NULL) {                          if (tmp == NULL) {
2780                                  fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2781                                  exit(1);                                  exit(1);
# Line 2747  void machine_setup(struct machine *machi Line 2790  void machine_setup(struct machine *machi
2790    
2791                          bootstr = tmp;                          bootstr = tmp;
2792                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
                 }  
2793    
2794                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
                 {  
                         time_t timet;  
                         struct tm *tmp;  
2795    
2796                          /*  RTC data given by the BIOS:  */                          /*  RTC data given by the BIOS:  */
2797                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */
2798                          tmp = gmtime(&timet);                          tm_ptr = gmtime(&timet);
2799                          /*  TODO:  are these 0- or 1-based?  */                          /*  TODO:  are these 0- or 1-based?  */
2800                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 1, int_to_bcd(tmp->tm_sec));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 1, int_to_bcd(tm_ptr->tm_sec));
2801                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 2, int_to_bcd(tmp->tm_min));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 2, int_to_bcd(tm_ptr->tm_min));
2802                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 3, int_to_bcd(tmp->tm_hour));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 3, int_to_bcd(tm_ptr->tm_hour));
2803                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 5, int_to_bcd(tmp->tm_mday));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 5, int_to_bcd(tm_ptr->tm_mday));
2804                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 6, int_to_bcd(tmp->tm_mon + 1));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 6, int_to_bcd(tm_ptr->tm_mon + 1));
2805                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 7, int_to_bcd(tmp->tm_year - 100));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 7, int_to_bcd(tm_ptr->tm_year - 100));
                 }  
2806    
2807                  /*  "BOOTINFO_PCMCIA_TYPE" in NetBSD's bootinfo.h. This contains the sbus controller type.  */                          /*  "BOOTINFO_PCMCIA_TYPE" in NetBSD's bootinfo.h. This contains the sbus controller type.  */
2808                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);
2809                    }
2810    
2811                  break;                  break;
2812    
# Line 2797  void machine_setup(struct machine *machi Line 2836  void machine_setup(struct machine *machi
2836                          /*  Special cases for IP20,22,24,26 memory offset:  */                          /*  Special cases for IP20,22,24,26 memory offset:  */
2837                          if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||                          if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||
2838                              machine->machine_subtype == 24 || machine->machine_subtype == 26) {                              machine->machine_subtype == 24 || machine->machine_subtype == 26) {
2839                                  dev_ram_init(mem, 0x00000000, 0x10000, DEV_RAM_MIRROR, sgi_ram_offset);                                  dev_ram_init(machine, 0x00000000, 0x10000, DEV_RAM_MIRROR
2840                                  dev_ram_init(mem, 0x00050000, sgi_ram_offset-0x50000, DEV_RAM_MIRROR, sgi_ram_offset + 0x50000);                                      | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
2841                                    dev_ram_init(machine, 0x00050000, sgi_ram_offset-0x50000,
2842                                        DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset + 0x50000);
2843                          }                          }
2844    
2845                          /*  Special cases for IP28,30 memory offset:  */                          /*  Special cases for IP28,30 memory offset:  */
2846                          if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {                          if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {
2847                                  /*  TODO: length below should maybe not be 128MB?  */                                  /*  TODO: length below should maybe not be 128MB?  */
2848                                  dev_ram_init(mem, 0x00000000, 128*1048576, DEV_RAM_MIRROR, sgi_ram_offset);                                  dev_ram_init(machine, 0x00000000, 128*1048576, DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
2849                          }                          }
2850                  } else {                  } else {
2851                          cpu->byte_order = EMUL_LITTLE_ENDIAN;                          cpu->byte_order = EMUL_LITTLE_ENDIAN;
# Line 2815  void machine_setup(struct machine *machi Line 2856  void machine_setup(struct machine *machi
2856                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2857                          /*  TODO:  Other SGI machine types?  */                          /*  TODO:  Other SGI machine types?  */
2858                          switch (machine->machine_subtype) {                          switch (machine->machine_subtype) {
2859                            case 10:
2860                                    strlcat(machine->machine_name, " (4D/25)", MACHINE_NAME_MAXBUF);
2861                                    /*  TODO  */
2862                                    break;
2863                          case 12:                          case 12:
2864                                  strlcat(machine->machine_name,                                  strlcat(machine->machine_name,
2865                                      " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);                                      " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);
# Line 2916  void machine_setup(struct machine *machi Line 2961  void machine_setup(struct machine *machi
2961    
2962  /*  /*
2963  Why is this here? TODO  Why is this here? TODO
2964                                  dev_ram_init(mem, 0x88000000ULL,                                  dev_ram_init(machine, 0x88000000ULL,
2965                                      128 * 1048576, DEV_RAM_MIRROR, 0x08000000);                                      128 * 1048576, DEV_RAM_MIRROR, 0x08000000);
2966  */  */
2967                                  machine->md_interrupt = sgi_ip22_interrupt;                                  machine->md_interrupt = sgi_ip22_interrupt;
# Line 3043  Why is this here? TODO Line 3088  Why is this here? TODO
3088                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);
3089                                  machine->md_interrupt = sgi_ip30_interrupt;                                  machine->md_interrupt = sgi_ip30_interrupt;
3090    
3091                                  dev_ram_init(mem,    0xa0000000ULL,                                  dev_ram_init(machine,    0xa0000000ULL,
3092                                      128 * 1048576, DEV_RAM_MIRROR, 0x00000000);                                      128 * 1048576, DEV_RAM_MIRROR
3093                                        | DEV_RAM_MIGHT_POINT_TO_DEVICES,
3094                                        0x00000000);
3095    
3096                                  dev_ram_init(mem,    0x80000000ULL,                                  dev_ram_init(machine,    0x80000000ULL,
3097                                      32 * 1048576, DEV_RAM_RAM, 0x00000000);                                      32 * 1048576, DEV_RAM_RAM, 0x00000000);
3098    
3099                                  /*                                  /*
# Line 3078  Why is this here? TODO Line 3125  Why is this here? TODO
3125                                      " (O2)", MACHINE_NAME_MAXBUF);                                      " (O2)", MACHINE_NAME_MAXBUF);
3126    
3127                                  /*  TODO:  Find out where the physical ram is actually located.  */                                  /*  TODO:  Find out where the physical ram is actually located.  */
3128                                  dev_ram_init(mem, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(machine, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
3129                                  dev_ram_init(mem, 0x10000000ULL,           256, DEV_RAM_MIRROR, 0x00000000);                                  dev_ram_init(machine, 0x10000000ULL,           256, DEV_RAM_MIRROR, 0x00000000);
3130                                  dev_ram_init(mem, 0x11ffff00ULL,           256, DEV_RAM_MIRROR, 0x01ffff00);                                  dev_ram_init(machine, 0x11ffff00ULL,           256, DEV_RAM_MIRROR, 0x01ffff00);
3131                                  dev_ram_init(mem, 0x12000000ULL,           256, DEV_RAM_MIRROR, 0x02000000);                                  dev_ram_init(machine, 0x12000000ULL,           256, DEV_RAM_MIRROR, 0x02000000);
3132                                  dev_ram_init(mem, 0x17ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(machine, 0x17ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
3133                                  dev_ram_init(mem, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);                                  dev_ram_init(machine, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);
3134                                  dev_ram_init(mem, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);                                  dev_ram_init(machine, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);
3135    
3136                                  machine->md_int.ip32.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  */
3137                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */
# Line 3130  Why is this here? TODO Line 3177  Why is this here? TODO
3177                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
3178                                   */                                   */
3179    
 #if 0  
                                 i = dev_pckbc_init(machine, mem, 0x1f320000,  
                                     PCKBC_8242, 0x200 + MACE_PERIPH_MISC,  
                                     0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);  
                                                         /*  keyb+mouse (mace irq numbers)  */  
 #endif  
   
3180                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3181                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3182                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
# Line 3158  Why is this here? TODO Line 3198  Why is this here? TODO
3198                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",
3199                                      (1<<26) + MACE_PERIPH_SERIAL, 0);                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3200                                  device_add(machine, tmpstr);                                  device_add(machine, tmpstr);
3201  #if 0  
3202                                  if (machine->use_x11)                                  machine->main_console_handle = j;
3203    
3204                                    /*  TODO: Once this works, it should be enabled
3205                                        always, not just when using X!  */
3206                                    if (machine->use_x11) {
3207                                            i = dev_pckbc_init(machine, mem, 0x1f320000,
3208                                                PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
3209                                                0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
3210                                                    /*  keyb+mouse (mace irq numbers)  */
3211                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3212                                  else                                  }
 #endif  
                                         machine->main_console_handle = j;  
3213    
3214                                  dev_mc146818_init(machine, mem, 0x1f3a0000, (1<<8) + MACE_PERIPH_MISC, MC146818_SGI, 0x40);  /*  mcclock0  */                                  dev_mc146818_init(machine, mem, 0x1f3a0000, (1<<8) + MACE_PERIPH_MISC, MC146818_SGI, 0x40);  /*  mcclock0  */
3215                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");
# Line 3396  Why is this here? TODO Line 3442  Why is this here? TODO
3442                                          break;                                          break;
3443                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3444                                          /*  PROM mirror?  */                                          /*  PROM mirror?  */
3445                                          dev_ram_init(mem, 0xfff00000, 0x100000,                                          dev_ram_init(machine, 0xfff00000, 0x100000,
3446                                              DEV_RAM_MIRROR, 0x1fc00000);                                              DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x1fc00000);
3447    
3448                                          /*  VXL. TODO  */                                          /*  VXL. TODO  */
3449                                          /*  control at 0x60100000?  */                                          /*  control at 0x60100000?  */
# Line 3422  Why is this here? TODO Line 3468  Why is this here? TODO
3468    
3469  #if 0  #if 0
3470  Not yet.  Not yet.
3471                                  dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);                                  /*  irq = 8+16 + 14  */
3472                                    device_add(machine, "wdc addr=0x900001f0, irq=38");
3473  #endif  #endif
3474    
3475                                  break;                                  break;
# Line 3489  Not yet. Line 3536  Not yet.
3536                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3537    
3538  #if 0  #if 0
3539                                  dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);                                  /*  TODO: irq, etc  */
3540                                  dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);                                  device_add(machine, "wdc addr=0x9000001f0, irq=0");
3541                                    device_add(machine, "wdc addr=0x900000170, irq=0");
3542  #endif  #endif
3543                                  /*  PC kbd  */                                  /*  PC kbd  */
3544                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,
# Line 3524  Not yet. Line 3572  Not yet.
3572                   *  point.                   *  point.
3573                   */                   */
3574    
3575                  if (machine->prom_emulation)                  if (machine->prom_emulation) {
3576                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),
3577                              sgi_ram_offset);                              sgi_ram_offset);
                 else  
                         goto no_arc_prom_emulation;     /*  TODO: ugly  */  
   
                 /*  
                  *  TODO: How to build the component tree intermixed with  
                  *  the rest of device initialization?  
                  */  
3578    
3579                  /*                          /*
3580                   *  Boot string in ARC format:                           *  TODO: How to build the component tree intermixed with
3581                   *                           *  the rest of device initialization?
3582                   *  TODO: How about floppies? multi()disk()fdisk()                           */
                  *        Is tftp() good for netbooting?  
                  */  
                 init_bootpath = malloc(500);  
                 if (init_bootpath == NULL) {  
                         fprintf(stderr, "out of mem, bootpath\n");  
                         exit(1);  
                 }  
                 init_bootpath[0] = '\0';  
3583    
3584                  if (bootdev_id < 0 || machine->force_netboot) {                          /*
3585                          snprintf(init_bootpath, 400, "tftp()");                           *  Boot string in ARC format:
3586                  } else {                           *
3587                          /*  TODO: Make this nicer.  */                           *  TODO: How about floppies? multi()disk()fdisk()
3588                          if (machine->machine_type == MACHINE_SGI) {                           *        Is tftp() good for netbooting?
3589                                  if (machine->machine_subtype == 30)                           */
3590                                          strlcat(init_bootpath, "xio(0)pci(15)",                          init_bootpath = malloc(500);
3591                                              MACHINE_NAME_MAXBUF);                          if (init_bootpath == NULL) {
3592                                  if (machine->machine_subtype == 32)                                  fprintf(stderr, "out of mem, bootpath\n");
3593                                          strlcat(init_bootpath, "pci(0)",                                  exit(1);
                                             MACHINE_NAME_MAXBUF);  
3594                          }                          }
3595                            init_bootpath[0] = '\0';
3596    
3597                          if (diskimage_is_a_cdrom(machine, bootdev_id,                          if (bootdev_id < 0 || machine->force_netboot) {
3598                              bootdev_type))                                  snprintf(init_bootpath, 400, "tftp()");
3599                                  snprintf(init_bootpath + strlen(init_bootpath),                          } else {
3600                                      400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);                                  /*  TODO: Make this nicer.  */
3601                          else                                  if (machine->machine_type == MACHINE_SGI) {
3602                                  snprintf(init_bootpath + strlen(init_bootpath),                                          if (machine->machine_subtype == 30)
3603                                      400,"scsi(0)disk(%i)rdisk(0)partition(1)",                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3604                                      bootdev_id);                                                      MACHINE_NAME_MAXBUF);
3605                  }                                          if (machine->machine_subtype == 32)
3606                                                    strlcat(init_bootpath, "pci(0)",
3607                                                        MACHINE_NAME_MAXBUF);
3608                                    }
3609    
3610                  if (machine->machine_type == MACHINE_ARC)                                  if (diskimage_is_a_cdrom(machine, bootdev_id,
3611                          strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);                                      bootdev_type))
3612                                            snprintf(init_bootpath + strlen(init_bootpath),
3613                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3614                                    else
3615                                            snprintf(init_bootpath + strlen(init_bootpath),
3616                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3617                                                bootdev_id);
3618                            }
3619    
3620                  bootstr = malloc(BOOTSTR_BUFLEN);                          if (machine->machine_type == MACHINE_ARC)
3621                  if (bootstr == NULL) {                                  strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
                 strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);  
                 if (strlcat(bootstr, machine->boot_kernel_filename,  
                     BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {  
                         fprintf(stderr, "boot string too long?\n");  
                         exit(1);  
                 }  
3622    
3623                  /*  Boot args., eg "-a"  */                          bootstr = malloc(BOOTSTR_BUFLEN);
3624                  bootarg = machine->boot_string_argument;                          if (bootstr == NULL) {
3625                                    fprintf(stderr, "out of memory\n");
3626                                    exit(1);
3627                            }
3628                            strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3629                            if (strlcat(bootstr, machine->boot_kernel_filename,
3630                                BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3631                                    fprintf(stderr, "boot string too long?\n");
3632                                    exit(1);
3633                            }
3634    
3635                            /*  Boot args., eg "-a"  */
3636                            bootarg = machine->boot_string_argument;
3637    
3638                  /*  argc, argv, envp in a0, a1, a2:  */                          /*  argc, argv, envp in a0, a1, a2:  */
3639                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */
3640    
3641                  /*  TODO:  not needed?  */                          /*  TODO:  not needed?  */
3642                  cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3643                      (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3644    
3645                  /*  Set up argc/argv:  */                          /*  Set up argc/argv:  */
3646                  addr = ARC_ENV_STRINGS;                          addr = ARC_ENV_STRINGS;
3647                  addr2 = ARC_ARGV_START;                          addr2 = ARC_ARGV_START;
3648                  cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
   
                 /*  bootstr:  */  
                 store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                 add_environment_string(cpu, bootstr, &addr);  
                 cpu->cd.mips.gpr[MIPS_GPR_A0] ++;  
3649    
3650                  /*  bootarg:  */                          /*  bootstr:  */
                 if (bootarg[0] != '\0') {  
3651                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3652                          add_environment_string(cpu, bootarg, &addr);                          add_environment_string(cpu, bootstr, &addr);
3653                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                 }  
3654    
3655                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                          /*  bootarg:  */
3656                            if (bootarg[0] != '\0') {
3657                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3658                                    add_environment_string(cpu, bootarg, &addr);
3659                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3660                            }
3661    
3662                  /*                          cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
3663                   *  Add environment variables.  For each variable, add it  
3664                   *  as a string using add_environment_string(), and add a                          /*
3665                   *  pointer to it to the ARC_ENV_POINTERS array.                           *  Add environment variables.  For each variable, add it
3666                   */                           *  as a string using add_environment_string(), and add a
3667                  if (machine->use_x11) {                           *  pointer to it to the ARC_ENV_POINTERS array.
3668                          if (machine->machine_type == MACHINE_ARC) {                           */
3669                            if (machine->use_x11) {
3670                                    if (machine->machine_type == MACHINE_ARC) {
3671                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3672                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3673                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3674                                            add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3675                                    } else {
3676                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3677                                            add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3678                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3679                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3680    
3681                                            /*  g for graphical mode. G for graphical mode
3682                                                with SGI logo visible on Irix?  */
3683                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3684                                            add_environment_string(cpu, "console=g", &addr);
3685                                    }
3686                            } else {
3687                                    if (machine->machine_type == MACHINE_ARC) {
3688                                            /*  TODO: serial console for ARC?  */
3689                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3690                                            add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3691                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3692                                            add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3693                                    } else {
3694                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3695                                            add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3696                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3697                                            add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3698    
3699                                            /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3700                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3701                                            add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
3702                                    }
3703                            }
3704    
3705                            if (machine->machine_type == MACHINE_SGI) {
3706                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3707                                  add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3708                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3709                                  add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "diskless=0", &addr);
                         } else {  
3710                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3711                                  add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);                                  add_environment_string(cpu, "volume=80", &addr);
3712                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3713                                  add_environment_string(cpu, "ConsoleOut=video()", &addr);                                  add_environment_string(cpu, "sgilogo=y", &addr);
3714    
                                 /*  g for graphical mode. G for graphical mode  
                                     with SGI logo visible on Irix?  */  
3715                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3716                                  add_environment_string(cpu, "console=g", &addr);                                  add_environment_string(cpu, "monitor=h", &addr);
                         }  
                 } else {  
                         if (machine->machine_type == MACHINE_ARC) {  
                                 /*  TODO: serial console for ARC?  */  
3717                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3718                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "TimeZone=GMT", &addr);
3719                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3720                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "nogfxkbd=1", &addr);
3721                          } else {  
3722                                    /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */
3723    
3724                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3725                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);
3726                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3727                                  add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);                                  add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);
   
                                 /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */  
3728                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3729                                  add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */                                  add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
3730                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3731                  }                                  add_environment_string(cpu, "OSLoader=sash", &addr);
   
                 if (machine->machine_type == MACHINE_SGI) {  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "AutoLoad=No", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "diskless=0", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "volume=80", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "sgilogo=y", &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "monitor=h", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "TimeZone=GMT", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "nogfxkbd=1", &addr);  
3732    
3733                          /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3734                                    add_environment_string(cpu, "rbaud=9600", &addr);
3735                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3736                                    add_environment_string(cpu, "rebound=y", &addr);
3737                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3738                                    add_environment_string(cpu, "crt_option=1", &addr);
3739                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3740                                    add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
3741    
3742                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3743                          add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);                                  add_environment_string(cpu, "keybd=US", &addr);
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLoadFilename=/unix", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLoader=sash", &addr);  
3744    
3745                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3746                          add_environment_string(cpu, "rbaud=9600", &addr);                                  add_environment_string(cpu, "cpufreq=3", &addr);
3747                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3748                          add_environment_string(cpu, "rebound=y", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
3749                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3750                          add_environment_string(cpu, "crt_option=1", &addr);                                  add_environment_string(cpu, eaddr_string, &addr);
3751                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3752                          add_environment_string(cpu, "netaddr=10.0.0.1", &addr);                                  add_environment_string(cpu, "verbose=istrue", &addr);
3753                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3754                                    add_environment_string(cpu, "showconfig=istrue", &addr);
3755                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3756                                    add_environment_string(cpu, "diagmode=v", &addr);
3757                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3758                                    add_environment_string(cpu, "kernname=unix", &addr);
3759                            } else {
3760                                    char *tmp;
3761                                    size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3762                                    tmp = malloc(mlen);
3763                                    snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3764                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3765                                    add_environment_string(cpu, tmp, &addr);
3766    
3767                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3768                          add_environment_string(cpu, "keybd=US", &addr);                                  add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3769    
3770                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3771                          add_environment_string(cpu, "cpufreq=3", &addr);                                  add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3772                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          }
                         add_environment_string(cpu, "dbaud=9600", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, eaddr_string, &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "verbose=istrue", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "showconfig=istrue", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "diagmode=v", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "kernname=unix", &addr);  
                 } else {  
                         char *tmp;  
                         size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;  
                         tmp = malloc(mlen);  
                         snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, tmp, &addr);  
3773    
3774                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  End the environment strings with an empty zero-terminated
3775                          add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);                              string, and the envp array with a NULL pointer.  */
3776                            add_environment_string(cpu, "", &addr); /*  the end  */
3777                            store_pointer_and_advance(cpu, &addr2,
3778                                0, arc_wordlen==sizeof(uint64_t));
3779    
3780                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  Return address:  (0x20 = ReturnFromMain())  */
3781                          add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);                          cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;
3782                  }                  }
3783    
                 /*  End the environment strings with an empty zero-terminated  
                     string, and the envp array with a NULL pointer.  */  
                 add_environment_string(cpu, "", &addr); /*  the end  */  
                 store_pointer_and_advance(cpu, &addr2,  
                     0, arc_wordlen==sizeof(uint64_t));  
   
 no_arc_prom_emulation:          /*  TODO: ugly, get rid of the goto  */  
   
                 /*  Return address:  (0x20 = ReturnFromMain())  */  
                 cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;  
   
3784                  break;                  break;
3785    
3786          case MACHINE_MESHCUBE:          case MACHINE_MESHCUBE:
# Line 3765  no_arc_prom_emulation:         /*  TODO: ugly, Line 3810  no_arc_prom_emulation:         /*  TODO: ugly,
3810    
3811                  device_add(machine, "random addr=0x1017fffc len=4");                  device_add(machine, "random addr=0x1017fffc len=4");
3812    
3813                  /*                  if (machine->prom_emulation) {
3814                   *  TODO:  A Linux kernel wants "memsize" from somewhere... I                          /*
3815                   *  haven't found any docs on how it is used though.                           *  TODO:  A Linux kernel wants "memsize" from somewhere... I
3816                   */                           *  haven't found any docs on how it is used though.
3817                             */
3818                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
3819                  cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
3820                  store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
3821                      0xa0002000ULL);                              0xa0002000ULL);
3822                  store_string(cpu, 0xa0002000ULL, "something=somethingelse");                          store_string(cpu, 0xa0002000ULL, "something=somethingelse");
   
                 cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;  
                 store_string(cpu, 0xa0002000ULL, "hello=world\n");  
3823    
3824                            cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
3825                            store_string(cpu, 0xa0002000ULL, "hello=world\n");
3826                    }
3827                  break;                  break;
3828    
3829          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
3830                  machine->machine_name = "NetGear WG602";                  machine->machine_name = "NetGear WG602v1";
3831    
3832                  if (machine->use_x11)                  if (machine->use_x11)
3833                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
3834                  if (machine->physical_ram_in_mb != 16)                  if (machine->physical_ram_in_mb != 16)
3835                          fprintf(stderr, "WARNING! Real NetGear WG602 boxes have exactly 16 MB RAM. Continuing anyway.\n");                          fprintf(stderr, "WARNING! Real NetGear WG602v1 boxes have exactly 16 MB RAM. Continuing anyway.\n");
3836    
3837                  /*                  /*
3838                   *  Lots of info about the IDT 79RC 32334                   *  Lots of info about the IDT 79RC 32334
# Line 3820  no_arc_prom_emulation:         /*  TODO: ugly, Line 3865  no_arc_prom_emulation:         /*  TODO: ugly,
3865                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
3866                  machine->machine_name = "Sony NeWS (NET WORK STATION)";                  machine->machine_name = "Sony NeWS (NET WORK STATION)";
3867    
3868                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3869                  {                          /*  This is just a test.  TODO  */
3870                          int i;                          int i;
3871                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
3872                                  cpu->cd.mips.gpr[i] =                                  cpu->cd.mips.gpr[i] =
# Line 3850  no_arc_prom_emulation:         /*  TODO: ugly, Line 3895  no_arc_prom_emulation:         /*  TODO: ugly,
3895    
3896                          /*  ISA interrupt controllers:  */                          /*  ISA interrupt controllers:  */
3897                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");
3898                          machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
3899                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");
3900                          machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
3901                          machine->md_interrupt = malta_interrupt;                          machine->md_interrupt = malta_interrupt;
3902    
3903                          dev_mc146818_init(machine, mem, 0x18000070, 8 + 8, MC146818_PC_CMOS, 1);                          dev_mc146818_init(machine, mem, 0x18000070, 8 + 8, MC146818_PC_CMOS, 1);
# Line 3970  no_arc_prom_emulation:         /*  TODO: ugly, Line 4015  no_arc_prom_emulation:         /*  TODO: ugly,
4015                              "------------------------------------------\n");                              "------------------------------------------\n");
4016    
4017                  /*  480 x 272 pixels framebuffer (512 bytes per line)  */                  /*  480 x 272 pixels framebuffer (512 bytes per line)  */
4018                  fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPCMIPS,                  fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPC,
4019                      480,272, 512,1088, -15, "Playstation Portable");                      480,272, 512,1088, -15, "Playstation Portable");
4020    
4021                  /*                  /*
# Line 4083  no_arc_prom_emulation:         /*  TODO: ugly, Line 4128  no_arc_prom_emulation:         /*  TODO: ugly,
4128                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");
4129                  device_add(machine, "ns16550 irq=0 addr=0x800002f8 name2=tty1 in_use=0");                  device_add(machine, "ns16550 irq=0 addr=0x800002f8 name2=tty1 in_use=0");
4130    
4131                    dev_pckbc_init(machine, mem, 0x80000060, PCKBC_8042,
4132                        1, 12, machine->use_x11, 1);
4133    
4134                  if (machine->use_x11)                  if (machine->use_x11)
4135                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,
4136                              machine->machine_name);                              machine->machine_name);
4137    
4138                  store_32bit_word(cpu, 0x3010,                  if (machine->prom_emulation) {
4139                      machine->physical_ram_in_mb * 1048576);                          store_32bit_word(cpu, 0x3010, machine->physical_ram_in_mb * 1048576);
   
                 /*  TODO: List of stuff, see http://www.beatjapan.org/  
                     mirror/www.be.com/aboutbe/benewsletter/  
                     Issue27.html#Cookbook  for the details.  */  
                 store_32bit_word(cpu, 0x301c, 0);  
   
                 /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,  
                     r5 = args, r6 = ptr to bootinfo?  */  
                 cpu->cd.ppc.gpr[3] = 0x3100;  
                 cpu->cd.ppc.gpr[4] = 0x200000;  
                 cpu->cd.ppc.gpr[5] = 0x2000;  
                 store_string(cpu, cpu->cd.ppc.gpr[5], "-a");  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x100;  
   
                 /*  See NetBSD's bebox/include/bootinfo.h for details  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,  
                     machine->physical_ram_in_mb * 1048576);  
   
                 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,  
                     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 */  
   
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);  
4140    
4141                            /*  TODO: List of stuff, see http://www.beatjapan.org/
4142                                mirror/www.be.com/aboutbe/benewsletter/
4143                                Issue27.html#Cookbook  for the details.  */
4144                            store_32bit_word(cpu, 0x301c, 0);
4145    
4146                            /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4147                                r5 = args, r6 = ptr to bootinfo?  */
4148                            cpu->cd.ppc.gpr[3] = 0x3100;
4149                            cpu->cd.ppc.gpr[4] = 0x200000;
4150                            cpu->cd.ppc.gpr[5] = 0x2000;
4151                            store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4152                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4153    
4154                            /*  See NetBSD's bebox/include/bootinfo.h for details  */
4155                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */
4156                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4157                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4158                                machine->physical_ram_in_mb * 1048576);
4159    
4160                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */
4161                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4162                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4163                                machine->use_x11? "vga" : "com", 4);
4164                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4165                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4166    
4167                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4168                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */
4169                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4170                    }
4171                  break;                  break;
4172    
4173          case MACHINE_PREP:          case MACHINE_PREP:
# Line 4129  no_arc_prom_emulation:         /*  TODO: ugly, Line 4176  no_arc_prom_emulation:         /*  TODO: ugly,
4176                   */                   */
4177                  machine->machine_name = "PowerPC Reference Platform";                  machine->machine_name = "PowerPC Reference Platform";
4178    
4179                  {                  if (machine->prom_emulation) {
4180                          int i;                          /*  Linux on PReP has 0xdeadc0de at address 0? (See
4181                          for (i=0; i<32; i++)                              http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */
4182                                  cpu->cd.ppc.gpr[i] =                          store_32bit_word(cpu, 0, 0xdeadc0de);
                                     0x12340000 + (i << 8) + 0x55;  
                 }  
   
                 /*  Linux on PReP has 0xdeadc0de at address 0? (See  
                     http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */  
                 store_32bit_word(cpu, 0, 0xdeadc0de);  
   
                 /*  r6 should point to "residual data"?  */  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x1000;  
4183    
4184                            /*  r6 should point to "residual data"?  */
4185                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x1000;
4186                    }
4187                  break;                  break;
4188    
4189          case MACHINE_MACPPC:          case MACHINE_MACPPC:
# Line 4153  no_arc_prom_emulation:         /*  TODO: ugly, Line 4193  no_arc_prom_emulation:         /*  TODO: ugly,
4193                   */                   */
4194                  machine->machine_name = "Macintosh (PPC)";                  machine->machine_name = "Macintosh (PPC)";
4195    
4196                  /*  r5 = OpenFirmware entry point  */                  if (machine->prom_emulation) {
4197                  cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;                          uint64_t b = 8 * 1048576, a = b - 0x800;
4198                            int i;
4199                            /*
4200                             *  r3 = pointer to boot_args (for the Mach kernel).
4201                             *  See http://darwinsource.opendarwin.org/10.3/
4202                             *  BootX-59/bootx.tproj/include.subproj/boot_args.h
4203                             *  for more info.
4204                             */
4205                            cpu->cd.ppc.gpr[3] = a;
4206                            store_16bit_word(cpu, a + 0x0000, 1);   /*  revision  */
4207                            store_16bit_word(cpu, a + 0x0002, 2);   /*  version  */
4208                            store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
4209                            /*  26 dram banks; "long base; long size"  */
4210                            store_32bit_word(cpu, a + 0x0104, 0);   /*  base  */
4211                            store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
4212                                * 256);             /*  size (in pages)  */
4213                            for (i=8; i<26*8; i+= 4)
4214                                    store_32bit_word(cpu, a + 0x0104 + i, 0);
4215                            a += (0x104 + 26 * 8);
4216                            /*  Video info:  */
4217                            store_32bit_word(cpu, a+0, 0xd0000000); /*  video base  */
4218                            store_32bit_word(cpu, a+4, 0);          /*  display code (?)  */
4219                            store_32bit_word(cpu, a+8, 800);        /*  bytes per pixel row  */
4220                            store_32bit_word(cpu, a+12, 800);       /*  width  */
4221                            store_32bit_word(cpu, a+16, 600);       /*  height  */
4222                            store_32bit_word(cpu, a+20, 8);         /*  pixel depth  */
4223                            a += 24;
4224                            store_32bit_word(cpu, a+0, 127);        /*  gestalt number (TODO)  */
4225                            store_32bit_word(cpu, a+4, 0);          /*  device tree pointer (TODO)  */
4226                            store_32bit_word(cpu, a+8, 0);          /*  device tree length  */
4227                            store_32bit_word(cpu, a+12, b);         /*  last address of kernel data area  */
4228    
4229                            /*  r4 = "MOSX" (0x4D4F5358)  */
4230                            cpu->cd.ppc.gpr[4] = 0x4D4F5358;
4231    
4232                            /*
4233                             *  r5 = OpenFirmware entry point.  NOTE: See
4234                             *  cpu_ppc.c for the rest of this semi-ugly hack.
4235                             */
4236                            dev_ram_init(machine, cpu->cd.ppc.of_emul_addr,
4237                                0x1000, DEV_RAM_RAM, 0x0);
4238                            store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
4239                                0x44ee0002);
4240                            cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4241                    }
4242                  break;                  break;
4243    
4244          case MACHINE_DB64360:          case MACHINE_DB64360:
4245                  /*  For playing with PMON2000 for PPC:  */                  /*  For playing with PMON2000 for PPC:  */
4246                  machine->machine_name = "DB64360";                  machine->machine_name = "DB64360";
4247    
4248                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0x1d000020");                  machine->main_console_handle = (size_t)device_add(machine,
4249                        "ns16550 irq=0 addr=0x1d000020 addr_mult=4");
4250    
4251                  {                  if (machine->prom_emulation) {
4252                          int i;                          int i;
4253                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
4254                                  cpu->cd.ppc.gpr[i] =                                  cpu->cd.ppc.gpr[i] =
# Line 4174  no_arc_prom_emulation:         /*  TODO: ugly, Line 4258  no_arc_prom_emulation:         /*  TODO: ugly,
4258                  break;                  break;
4259  #endif  /*  ENABLE_PPC  */  #endif  /*  ENABLE_PPC  */
4260    
4261    #ifdef ENABLE_SH
4262            case MACHINE_BARESH:
4263                    /*  A bare SH machine, with no devices.  */
4264                    machine->machine_name = "\"Bare\" SH machine";
4265                    break;
4266    
4267            case MACHINE_TESTSH:
4268                    machine->machine_name = "SH test machine";
4269    
4270                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4271                        (long long)DEV_CONS_ADDRESS);
4272                    cons_data = device_add(machine, tmpstr);
4273                    machine->main_console_handle = cons_data->console_handle;
4274    
4275                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4276                        (long long)DEV_MP_ADDRESS);
4277                    device_add(machine, tmpstr);
4278    
4279                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4280                        640,480, 640,480, 24, "testsh generic");
4281    
4282                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4283                        (long long)DEV_DISK_ADDRESS);
4284                    device_add(machine, tmpstr);
4285    
4286                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4287                        (long long)DEV_ETHER_ADDRESS);
4288                    device_add(machine, tmpstr);
4289    
4290                    break;
4291    
4292            case MACHINE_HPCSH:
4293                    /*  Handheld SH-based machines:  */
4294                    machine->machine_name = "HPCsh";
4295    
4296                    /*  TODO  */
4297    
4298                    break;
4299    #endif  /*  ENABLE_SH  */
4300    
4301    #ifdef ENABLE_HPPA
4302            case MACHINE_BAREHPPA:
4303                    /*  A bare HPPA machine, with no devices.  */
4304                    machine->machine_name = "\"Bare\" HPPA machine";
4305                    break;
4306    
4307            case MACHINE_TESTHPPA:
4308                    machine->machine_name = "HPPA test machine";
4309    
4310                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4311                        (long long)DEV_CONS_ADDRESS);
4312                    cons_data = device_add(machine, tmpstr);
4313                    machine->main_console_handle = cons_data->console_handle;
4314    
4315                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4316                        (long long)DEV_MP_ADDRESS);
4317                    device_add(machine, tmpstr);
4318    
4319                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4320                        640,480, 640,480, 24, "testhppa generic");
4321    
4322                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4323                        (long long)DEV_DISK_ADDRESS);
4324                    device_add(machine, tmpstr);
4325    
4326                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4327                        (long long)DEV_ETHER_ADDRESS);
4328                    device_add(machine, tmpstr);
4329    
4330                    break;
4331    #endif  /*  ENABLE_HPPA  */
4332    
4333    #ifdef ENABLE_I960
4334            case MACHINE_BAREI960:
4335                    /*  A bare I960 machine, with no devices.  */
4336                    machine->machine_name = "\"Bare\" i960 machine";
4337                    break;
4338    
4339            case MACHINE_TESTI960:
4340                    machine->machine_name = "i960 test machine";
4341    
4342                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4343                        (long long)DEV_CONS_ADDRESS);
4344                    cons_data = device_add(machine, tmpstr);
4345                    machine->main_console_handle = cons_data->console_handle;
4346    
4347                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4348                        (long long)DEV_MP_ADDRESS);
4349                    device_add(machine, tmpstr);
4350    
4351                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4352                        640,480, 640,480, 24, "testi960 generic");
4353    
4354                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4355                        (long long)DEV_DISK_ADDRESS);
4356                    device_add(machine, tmpstr);
4357    
4358                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4359                        (long long)DEV_ETHER_ADDRESS);
4360                    device_add(machine, tmpstr);
4361    
4362                    break;
4363    #endif  /*  ENABLE_I960  */
4364    
4365  #ifdef ENABLE_SPARC  #ifdef ENABLE_SPARC
4366          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
4367                  /*  A bare SPARC machine, with no devices.  */                  /*  A bare SPARC machine, with no devices.  */
# Line 4245  no_arc_prom_emulation:         /*  TODO: ugly, Line 4433  no_arc_prom_emulation:         /*  TODO: ugly,
4433                  break;                  break;
4434    
4435          case MACHINE_ALPHA:          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;  
   
4436                  if (machine->prom_emulation) {                  if (machine->prom_emulation) {
4437                          struct rpb rpb;                          struct rpb rpb;
4438                          struct crb crb;                          struct crb crb;
4439                          struct ctb ctb;                          struct ctb ctb;
4440    
4441                            /*  TODO:  Most of these... They are used by NetBSD/alpha:  */
4442                            /*  a0 = First free Page Frame Number  */
4443                            /*  a1 = PFN of current Level 1 page table  */
4444                            /*  a2 = Bootinfo magic  */
4445                            /*  a3 = Bootinfo pointer  */
4446                            /*  a4 = Bootinfo version  */
4447                            cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
4448                            cpu->cd.alpha.r[ALPHA_A1] = 0;
4449                            cpu->cd.alpha.r[ALPHA_A2] = 0;
4450                            cpu->cd.alpha.r[ALPHA_A3] = 0;
4451                            cpu->cd.alpha.r[ALPHA_A4] = 0;
4452    
4453                          /*  HWRPB: Hardware Restart Parameter Block  */                          /*  HWRPB: Hardware Restart Parameter Block  */
4454                          memset(&rpb, 0, sizeof(struct rpb));                          memset(&rpb, 0, sizeof(struct rpb));
4455                          store_64bit_word_in_host(cpu, (unsigned char *)                          store_64bit_word_in_host(cpu, (unsigned char *)
# Line 4306  no_arc_prom_emulation:         /*  TODO: ugly, Line 4494  no_arc_prom_emulation:         /*  TODO: ugly,
4494                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
4495                  case ST_DEC_3000_300:                  case ST_DEC_3000_300:
4496                          machine->machine_name = "DEC 3000/300";                          machine->machine_name = "DEC 3000/300";
4497                            machine->main_console_handle =
4498                                dev_zs_init(machine, mem, 0x1b0200000ULL,
4499                                0, 4, "serial zs"); /*  serial? netbsd?  */
4500                            break;
4501                    case ST_EB164:
4502                            machine->machine_name = "EB164";
4503                          break;                          break;
4504                  default:fatal("Unimplemented Alpha machine type %i\n",                  default:fatal("Unimplemented Alpha machine type %i\n",
4505                              machine->machine_subtype);                              machine->machine_subtype);
# Line 4353  no_arc_prom_emulation:         /*  TODO: ugly, Line 4547  no_arc_prom_emulation:         /*  TODO: ugly,
4547                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4548                      0xeafffffe);                      0xeafffffe);
4549                  break;                  break;
4550    
4551            case MACHINE_CATS:
4552                    machine->machine_name = "CATS evaluation board";
4553    
4554                    if (machine->emulated_hz == 0)
4555                            machine->emulated_hz = 50000000;
4556    
4557                    if (machine->physical_ram_in_mb > 256)
4558                            fprintf(stderr, "WARNING! Real CATS machines cannot"
4559                                " have more than 256 MB RAM. Continuing anyway.\n");
4560    
4561                    machine->md_int.footbridge_data =
4562                        device_add(machine, "footbridge addr=0x42000000");
4563                    machine->md_interrupt = footbridge_interrupt;
4564    
4565                    /*  NetBSD and OpenBSD clean their caches here:  */
4566                    dev_ram_init(machine, 0x50000000, 0x4000, DEV_RAM_RAM, 0);
4567    
4568                    /*  Interrupt ack space?  */
4569                    dev_ram_init(machine, 0x80000000, 0x1000, DEV_RAM_RAM, 0);
4570    
4571                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4572                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4573                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4574                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4575    
4576                    device_add(machine, "pccmos addr=0x7c000070");
4577    
4578                    if (machine->use_x11) {
4579                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4580                                mem, 0xc0, 8, 0, pci_s3_virge_init, pci_s3_virge_rr);
4581                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4582                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4583                                32 + 1, 32 + 12, machine->use_x11, 0);
4584                            machine->main_console_handle = j;
4585                    }
4586    
4587                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0 in_use=0");
4588                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1 in_use=0");
4589    
4590                    device_add(machine, "lpt irq=39 addr=0x7c000378 name2=lpt in_use=0");
4591    
4592                    if (machine->prom_emulation) {
4593                            struct ebsaboot ebsaboot;
4594                            char bs[300];
4595                            int boot_id = bootdev_id >= 0? bootdev_id : 0;
4596    
4597                            cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
4598                                7 * 1048576 - 0x1000;
4599    
4600                            memset(&ebsaboot, 0, sizeof(struct ebsaboot));
4601                            store_32bit_word_in_host(cpu, (unsigned char *)
4602                                &(ebsaboot.bt_magic), BT_MAGIC_NUMBER_CATS);
4603                            store_32bit_word_in_host(cpu, (unsigned char *)
4604                                &(ebsaboot.bt_vargp), 0);
4605                            store_32bit_word_in_host(cpu, (unsigned char *)
4606                                &(ebsaboot.bt_pargp), 0);
4607                            store_32bit_word_in_host(cpu, (unsigned char *)
4608                                &(ebsaboot.bt_args), cpu->cd.arm.r[0]
4609                                + sizeof(struct ebsaboot));
4610                            store_32bit_word_in_host(cpu, (unsigned char *)
4611                                &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
4612                            store_32bit_word_in_host(cpu, (unsigned char *)
4613                                &(ebsaboot.bt_memstart), 0);
4614                            store_32bit_word_in_host(cpu, (unsigned char *)
4615                                &(ebsaboot.bt_memend),
4616                                machine->physical_ram_in_mb * 1048576);
4617                            store_32bit_word_in_host(cpu, (unsigned char *)
4618                                &(ebsaboot.bt_memavail), 7 * 1048576);
4619                            store_32bit_word_in_host(cpu, (unsigned char *)
4620                                &(ebsaboot.bt_fclk), 50 * 1000000);
4621                            store_32bit_word_in_host(cpu, (unsigned char *)
4622                                &(ebsaboot.bt_pciclk), 66 * 1000000);
4623                            /*  TODO: bt_vers  */
4624                            /*  TODO: bt_features  */
4625    
4626                            store_buf(cpu, cpu->cd.arm.r[0],
4627                                (char *)&ebsaboot, sizeof(struct ebsaboot));
4628    
4629                            snprintf(bs, sizeof(bs), "(hd%i)%s%s%s",
4630                                boot_id, machine->boot_kernel_filename,
4631                                (machine->boot_string_argument[0])? " " : "",
4632                                machine->boot_string_argument);
4633    
4634                            store_string(cpu, cpu->cd.arm.r[0] +
4635                                sizeof(struct ebsaboot), bs);
4636    
4637                            arm_setup_initial_translation_table(cpu,
4638                                7 * 1048576 - 32768);
4639                    }
4640                    break;
4641    
4642            case MACHINE_HPCARM:
4643                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
4644                    memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));
4645                    switch (machine->machine_subtype) {
4646                    case MACHINE_HPCARM_IPAQ:
4647                            /*  SA-1110 206MHz  */
4648                            machine->machine_name = "Compaq iPAQ H3600";
4649                            hpc_fb_addr = 0x48200000;       /*  TODO  */
4650                            hpc_fb_xsize = 240;
4651                            hpc_fb_ysize = 320;
4652                            hpc_fb_xsize_mem = 256;
4653                            hpc_fb_ysize_mem = 320;
4654                            hpc_fb_bits = 15;
4655                            hpc_fb_encoding = BIFB_D16_0000;
4656                            hpc_platid_cpu_arch = 3;        /*  ARM  */
4657                            hpc_platid_cpu_series = 1;      /*  StrongARM  */
4658                            hpc_platid_cpu_model = 2;       /*  SA-1110  */
4659                            hpc_platid_cpu_submodel = 0;
4660                            hpc_platid_vendor = 7;          /*  Compaq  */
4661                            hpc_platid_series = 4;          /*  IPAQ  */
4662                            hpc_platid_model = 2;           /*  H36xx  */
4663                            hpc_platid_submodel = 1;        /*  H3600  */
4664                            break;
4665                    case MACHINE_HPCARM_JORNADA720:
4666                            /*  SA-1110 206MHz  */
4667                            machine->machine_name = "Jornada 720";
4668                            hpc_fb_addr = 0x48200000;
4669                            hpc_fb_xsize = 640;
4670                            hpc_fb_ysize = 240;
4671                            hpc_fb_xsize_mem = 640;
4672                            hpc_fb_ysize_mem = 240;
4673                            hpc_fb_bits = 16;
4674                            hpc_fb_encoding = BIFB_D16_0000;
4675                            hpc_platid_cpu_arch = 3;        /*  ARM  */
4676                            hpc_platid_cpu_series = 1;      /*  StrongARM  */
4677                            hpc_platid_cpu_model = 2;       /*  SA-1110  */
4678                            hpc_platid_cpu_submodel = 0;
4679                            hpc_platid_vendor = 11;         /*  HP  */
4680                            hpc_platid_series = 2;          /*  Jornada  */
4681                            hpc_platid_model = 2;           /*  7xx  */
4682                            hpc_platid_submodel = 1;        /*  720  */
4683                            break;
4684                    default:
4685                            printf("Unimplemented hpcarm machine number.\n");
4686                            exit(1);
4687                    }
4688    
4689                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
4690                          (hpc_platid_cpu_arch << 26) + (hpc_platid_cpu_series << 20)
4691                        + (hpc_platid_cpu_model << 14) + (hpc_platid_cpu_submodel <<  8)
4692                        + hpc_platid_flags);
4693                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
4694                          (hpc_platid_vendor << 22) + (hpc_platid_series << 16)
4695                        + (hpc_platid_model <<  8) + hpc_platid_submodel);
4696    
4697                    if (machine->prom_emulation) {
4698                            /*  NetBSD/hpcarm and possibly others expects the following:  */
4699    
4700                            cpu->cd.arm.r[0] = 1;   /*  argc  */
4701                            cpu->cd.arm.r[1] = machine->physical_ram_in_mb * 1048576 - 512; /*  argv  */
4702                            cpu->cd.arm.r[2] = machine->physical_ram_in_mb * 1048576 - 256; /*  ptr to hpc_bootinfo  */
4703    
4704                            bootstr = machine->boot_kernel_filename;
4705                            store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512,
4706                                machine->physical_ram_in_mb * 1048576 - 512 + 16);
4707                            store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
4708                            store_string(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
4709    
4710                            if (machine->boot_string_argument[0]) {
4711                                    cpu->cd.arm.r[0] ++;    /*  argc  */
4712    
4713                                    store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 4, machine->physical_ram_in_mb * 1048576 - 512 + 64);
4714                                    store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
4715    
4716                                    store_string(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 64,
4717                                        machine->boot_string_argument);
4718    
4719                                    bootarg = machine->boot_string_argument;
4720                            }
4721    
4722                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
4723                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
4724                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, hpc_fb_addr);
4725                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpc_fb_xsize_mem * (((hpc_fb_bits-1)|7)+1) / 8);
4726                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpc_fb_xsize);
4727                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpc_fb_ysize);
4728                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpc_fb_encoding);
4729                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse,
4730                                machine->use_x11? BI_CNUSE_BUILTIN : BI_CNUSE_SERIAL);
4731    
4732                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
4733                            store_buf(cpu, machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
4734    
4735                            /*
4736                             *  TODO: ugly hack, only works with small NetBSD
4737                             *        kernels!
4738                             */
4739                            cpu->cd.arm.r[ARM_SP] = 0xc02c0000;
4740                    }
4741    
4742                    /*  Physical RAM at 0xc0000000:  */
4743                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4744                        DEV_RAM_MIRROR, 0x0);
4745    
4746                    /*  Cache flush region:  */
4747                    dev_ram_init(machine, 0xe0000000, 0x10000, DEV_RAM_RAM, 0x0);
4748    
4749                    if (hpc_fb_addr != 0) {
4750                            dev_fb_init(machine, mem, hpc_fb_addr, VFB_HPC,
4751                                hpc_fb_xsize, hpc_fb_ysize,
4752                                hpc_fb_xsize_mem, hpc_fb_ysize_mem,
4753                                hpc_fb_bits, machine->machine_name);
4754                    }
4755                    break;
4756    
4757            case MACHINE_ZAURUS:
4758                    machine->machine_name = "Zaurus";
4759                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4760                        DEV_RAM_MIRROR, 0x0);
4761                    device_add(machine, "ns16550 irq=0 addr=0x40100000 addr_mult=4");
4762                    /*  TODO  */
4763                    if (machine->prom_emulation) {
4764                            arm_setup_initial_translation_table(cpu, 0x4000);
4765                    }
4766                    break;
4767    
4768            case MACHINE_NETWINDER:
4769                    machine->machine_name = "NetWinder";
4770    
4771                    if (machine->physical_ram_in_mb > 256)
4772                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4773                                " have more than 256 MB RAM. Continuing anyway.\n");
4774    
4775                    machine->md_int.footbridge_data =
4776                        device_add(machine, "footbridge addr=0x42000000");
4777                    machine->md_interrupt = footbridge_interrupt;
4778    
4779                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4780                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4781                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4782                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4783    
4784                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4785                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4786    
4787                    if (machine->use_x11) {
4788                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4789                                mem, 0xc0, 8, 0, pci_igsfb_init, pci_igsfb_rr);
4790                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4791                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4792                                32 + 1, 32 + 12, machine->use_x11, 0);
4793                            machine->main_console_handle = j;
4794                    }
4795    
4796                    if (machine->prom_emulation) {
4797                            arm_setup_initial_translation_table(cpu, 0x4000);
4798                    }
4799                    break;
4800    
4801            case MACHINE_SHARK:
4802                    machine->machine_name = "Digital DNARD (\"Shark\")";
4803                    if (machine->prom_emulation) {
4804                            arm_setup_initial_translation_table(cpu,
4805                                machine->physical_ram_in_mb * 1048576 - 65536);
4806    
4807                            /*
4808                             *  r0 = OpenFirmware entry point.  NOTE: See
4809                             *  cpu_arm.c for the rest of this semi-ugly hack.
4810                             */
4811                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4812                    }
4813                    break;
4814    
4815            case MACHINE_IQ80321:
4816                    /*
4817                     *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4818                     *  for more details about the memory map.
4819                     */
4820                    machine->machine_name = "Intel IQ80321 (ARM)";
4821                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4822                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4823                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4824    
4825                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
4826                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4827                        DEV_RAM_MIRROR, 0x0);
4828                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4829                        DEV_RAM_MIRROR, 0x0);
4830    
4831                    /*  0xe0000000 and 0xff000000 = cache flush regions  */
4832                    dev_ram_init(machine, 0xe0000000, 0x100000, DEV_RAM_RAM, 0x0);
4833                    dev_ram_init(machine, 0xff000000, 0x100000, DEV_RAM_RAM, 0x0);
4834    
4835                    device_add(machine, "i80321 addr=0xffffe000");
4836    
4837                    if (machine->prom_emulation) {
4838                            arm_setup_initial_translation_table(cpu, 0x4000);
4839                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
4840                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
4841                            arm_translation_table_set_l1(cpu, 0xe0000000, 0xe0000000);
4842                            arm_translation_table_set_l1(cpu, 0xf0000000, 0xf0000000);
4843                    }
4844                    break;
4845    
4846            case MACHINE_IYONIX:
4847                    machine->machine_name = "Iyonix";
4848                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4849                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4850    
4851                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4852    
4853                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
4854                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4855                        DEV_RAM_MIRROR, 0x0);
4856                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4857                        DEV_RAM_MIRROR, 0x0);
4858    
4859                    device_add(machine, "i80321 addr=0xffffe000");
4860    
4861                    if (machine->prom_emulation) {
4862                            arm_setup_initial_translation_table(cpu,
4863                                machine->physical_ram_in_mb * 1048576 - 65536);
4864                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
4865                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
4866                            arm_translation_table_set_l1_b(cpu, 0xff000000, 0xff000000);
4867                    }
4868                    break;
4869  #endif  /*  ENABLE_ARM  */  #endif  /*  ENABLE_ARM  */
4870    
4871    #ifdef ENABLE_AVR
4872            case MACHINE_BAREAVR:
4873                    /*  A bare Atmel AVR machine, with no devices.  */
4874                    machine->machine_name = "\"Bare\" Atmel AVR machine";
4875                    break;
4876    #endif  /*  ENABLE_AVR  */
4877    
4878  #ifdef ENABLE_IA64  #ifdef ENABLE_IA64
4879          case MACHINE_BAREIA64:          case MACHINE_BAREIA64:
4880                  machine->machine_name = "\"Bare\" IA64 machine";                  machine->machine_name = "\"Bare\" IA64 machine";
# Line 4431  no_arc_prom_emulation:         /*  TODO: ugly, Line 4951  no_arc_prom_emulation:         /*  TODO: ugly,
4951                  /*  Interrupt controllers:  */                  /*  Interrupt controllers:  */
4952                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",
4953                      (long long)(X86_IO_BASE + 0x20));                      (long long)(X86_IO_BASE + 0x20));
4954                  machine->md.pc.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4955                  if (machine->machine_subtype != MACHINE_X86_XT) {                  if (machine->machine_subtype != MACHINE_X86_XT) {
4956                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",
4957                              (long long)(X86_IO_BASE + 0xa0));                              (long long)(X86_IO_BASE + 0xa0));
4958                          machine->md.pc.pic2 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4959                  }                  }
4960    
4961                  machine->md_interrupt = x86_pc_interrupt;                  machine->md_interrupt = x86_pc_interrupt;
# Line 4453  no_arc_prom_emulation:         /*  TODO: ugly, Line 4973  no_arc_prom_emulation:         /*  TODO: ugly,
4973    
4974                  /*  IDE controllers:  */                  /*  IDE controllers:  */
4975                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
4976                      diskimage_exist(machine, 1, DISKIMAGE_IDE))                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
4977                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x1f0, 14, 0);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4978                                X86_IO_BASE + 0x1f0, 14);
4979                            device_add(machine, tmpstr);
4980                    }
4981                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||
4982                      diskimage_exist(machine, 3, DISKIMAGE_IDE))                      diskimage_exist(machine, 3, DISKIMAGE_IDE)) {
4983                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x170, 15, 2);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4984                                X86_IO_BASE + 0x170, 15);
4985                            device_add(machine, tmpstr);
4986                    }
4987    
4988                  /*  Floppy controller at irq 6  */                  /*  Floppy controller at irq 6  */
4989                  snprintf(tmpstr, sizeof(tmpstr), "fdc addr=0x%llx irq=6",                  snprintf(tmpstr, sizeof(tmpstr), "fdc addr=0x%llx irq=6",
# Line 4602  void machine_memsize_fix(struct machine Line 5128  void machine_memsize_fix(struct machine
5128                  case MACHINE_BEBOX:                  case MACHINE_BEBOX:
5129                          m->physical_ram_in_mb = 64;                          m->physical_ram_in_mb = 64;
5130                          break;                          break;
5131                    case MACHINE_CATS:
5132                            m->physical_ram_in_mb = 64;
5133                            break;
5134                    case MACHINE_ZAURUS:
5135                            m->physical_ram_in_mb = 64;
5136                            break;
5137                    case MACHINE_HPCARM:
5138                            m->physical_ram_in_mb = 32;
5139                            break;
5140                    case MACHINE_NETWINDER:
5141                            m->physical_ram_in_mb = 16;
5142                            break;
5143                  case MACHINE_X86:                  case MACHINE_X86:
5144                          if (m->machine_subtype == MACHINE_X86_XT)                          if (m->machine_subtype == MACHINE_X86_XT)
5145                                  m->physical_ram_in_mb = 1;                                  m->physical_ram_in_mb = 1;
# Line 4787  void machine_default_cputype(struct mach Line 5325  void machine_default_cputype(struct mach
5325          case MACHINE_MACPPC:          case MACHINE_MACPPC:
5326                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5327                  case MACHINE_MACPPC_G4:                  case MACHINE_MACPPC_G4:
5328                          m->cpu_name = strdup("G4e");                          m->cpu_name = strdup("PPC750");
5329                          break;                          break;
5330                  case MACHINE_MACPPC_G5:                  case MACHINE_MACPPC_G5:
5331                          m->cpu_name = strdup("PPC970");                          m->cpu_name = strdup("PPC970");
# Line 4798  void machine_default_cputype(struct mach Line 5336  void machine_default_cputype(struct mach
5336                  m->cpu_name = strdup("PPC750");                  m->cpu_name = strdup("PPC750");
5337                  break;                  break;
5338    
5339            /*  SH:  */
5340            case MACHINE_BARESH:
5341            case MACHINE_TESTSH:
5342            case MACHINE_HPCSH:
5343                    m->cpu_name = strdup("SH");
5344                    break;
5345    
5346            /*  HPPA:  */
5347            case MACHINE_BAREHPPA:
5348            case MACHINE_TESTHPPA:
5349                    m->cpu_name = strdup("HPPA");
5350                    break;
5351    
5352            /*  i960:  */
5353            case MACHINE_BAREI960:
5354            case MACHINE_TESTI960:
5355                    m->cpu_name = strdup("i960");
5356                    break;
5357    
5358          /*  SPARC:  */          /*  SPARC:  */
5359          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
5360          case MACHINE_TESTSPARC:          case MACHINE_TESTSPARC:
# Line 4815  void machine_default_cputype(struct mach Line 5372  void machine_default_cputype(struct mach
5372          /*  ARM:  */          /*  ARM:  */
5373          case MACHINE_BAREARM:          case MACHINE_BAREARM:
5374          case MACHINE_TESTARM:          case MACHINE_TESTARM:
5375                  m->cpu_name = strdup("ARM");          case MACHINE_HPCARM:
5376                    m->cpu_name = strdup("SA1110");
5377                    break;
5378            case MACHINE_IQ80321:
5379            case MACHINE_IYONIX:
5380                    m->cpu_name = strdup("80321_600_B0");
5381                    break;
5382            case MACHINE_CATS:
5383            case MACHINE_NETWINDER:
5384            case MACHINE_SHARK:
5385                    m->cpu_name = strdup("SA110");
5386                    break;
5387            case MACHINE_ZAURUS:
5388                    m->cpu_name = strdup("PXA210");
5389                    break;
5390    
5391            /*  AVR:  */
5392            case MACHINE_BAREAVR:
5393                    m->cpu_name = strdup("AVR");
5394                  break;                  break;
5395    
5396          /*  IA64:  */          /*  IA64:  */
# Line 5090  void machine_init(void) Line 5665  void machine_init(void)
5665           *  entries will appear in normal order when listed.  :-)           *  entries will appear in normal order when listed.  :-)
5666           */           */
5667    
5668            /*  Zaurus:  */
5669            me = machine_entry_new("Zaurus (ARM)",
5670                ARCH_ARM, MACHINE_ZAURUS, 1, 0);
5671            me->aliases[0] = "zaurus";
5672            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5673                    me->next = first_machine_entry; first_machine_entry = me;
5674            }
5675    
5676          /*  X86 machine:  */          /*  X86 machine:  */
5677          me = machine_entry_new("x86-based PC", ARCH_X86,          me = machine_entry_new("x86-based PC", ARCH_X86,
5678              MACHINE_X86, 2, 2);              MACHINE_X86, 2, 2);
# Line 5121  void machine_init(void) Line 5704  void machine_init(void)
5704                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5705          }          }
5706    
5707            /*  Test-machine for SH:  */
5708            me = machine_entry_new("Test-machine for SH", ARCH_SH,
5709                MACHINE_TESTSH, 1, 0);
5710            me->aliases[0] = "testsh";
5711            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5712                    me->next = first_machine_entry; first_machine_entry = me;
5713            }
5714    
5715          /*  Test-machine for PPC:  */          /*  Test-machine for PPC:  */
5716          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,
5717              MACHINE_TESTPPC, 1, 0);              MACHINE_TESTPPC, 1, 0);
# Line 5153  void machine_init(void) Line 5744  void machine_init(void)
5744                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5745          }          }
5746    
5747            /*  Test-machine for i960:  */
5748            me = machine_entry_new("Test-machine for i960", ARCH_I960,
5749                MACHINE_TESTI960, 1, 0);
5750            me->aliases[0] = "testi960";
5751            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5752                    me->next = first_machine_entry; first_machine_entry = me;
5753            }
5754    
5755            /*  Test-machine for HPPA:  */
5756            me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5757                MACHINE_TESTHPPA, 1, 0);
5758            me->aliases[0] = "testhppa";
5759            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5760                    me->next = first_machine_entry; first_machine_entry = me;
5761            }
5762    
5763          /*  Test-machine for ARM:  */          /*  Test-machine for ARM:  */
5764          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,
5765              MACHINE_TESTARM, 1, 0);              MACHINE_TESTARM, 1, 0);
# Line 5243  void machine_init(void) Line 5850  void machine_init(void)
5850                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5851          }          }
5852    
5853            /*  NetWinder:  */
5854            me = machine_entry_new("NetWinder", ARCH_ARM, MACHINE_NETWINDER, 1, 0);
5855            me->aliases[0] = "netwinder";
5856            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5857                    me->next = first_machine_entry; first_machine_entry = me;
5858            }
5859    
5860          /*  NetGear:  */          /*  NetGear:  */
5861          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602v1", ARCH_MIPS,
5862              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);
5863          me->aliases[0] = "netgear";          me->aliases[0] = "netgear";
5864          me->aliases[1] = "wg602";          me->aliases[1] = "wg602v1";
5865          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5866                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5867          }          }
# Line 5281  void machine_init(void) Line 5895  void machine_init(void)
5895                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5896          }          }
5897    
5898            /*  Iyonix:  */
5899            me = machine_entry_new("Iyonix", ARCH_ARM,
5900                MACHINE_IYONIX, 1, 0);
5901            me->aliases[0] = "iyonix";
5902            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5903                    me->next = first_machine_entry; first_machine_entry = me;
5904            }
5905    
5906            /*  Intel IQ80321 (ARM):  */
5907            me = machine_entry_new("Intel IQ80321 (ARM)", ARCH_ARM,
5908                MACHINE_IQ80321, 1, 0);
5909            me->aliases[0] = "iq80321";
5910            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5911                    me->next = first_machine_entry; first_machine_entry = me;
5912            }
5913    
5914            /*  HPCarm:  */
5915            me = machine_entry_new("Handheld SH (HPCsh)",
5916                ARCH_SH, MACHINE_HPCSH, 1, 2);
5917            me->aliases[0] = "hpcsh";
5918            me->subtype[0] = machine_entry_subtype_new("Jornada 680",
5919                MACHINE_HPCSH_JORNADA680, 1);
5920            me->subtype[0]->aliases[0] = "jornada680";
5921            me->subtype[1] = machine_entry_subtype_new(
5922                "Jornada 690", MACHINE_HPCSH_JORNADA690, 1);
5923            me->subtype[1]->aliases[0] = "jornada690";
5924            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5925                    me->next = first_machine_entry; first_machine_entry = me;
5926            }
5927    
5928          /*  HPCmips:  */          /*  HPCmips:  */
5929          me = machine_entry_new("Handheld MIPS (HPCmips)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
5930              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
# Line 5317  void machine_init(void) Line 5961  void machine_init(void)
5961                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5962          }          }
5963    
5964            /*  HPCarm:  */
5965            me = machine_entry_new("Handheld ARM (HPCarm)",
5966                ARCH_ARM, MACHINE_HPCARM, 1, 2);
5967            me->aliases[0] = "hpcarm";
5968            me->subtype[0] = machine_entry_subtype_new("Ipaq",
5969                MACHINE_HPCARM_IPAQ, 1);
5970            me->subtype[0]->aliases[0] = "ipaq";
5971            me->subtype[1] = machine_entry_subtype_new(
5972                "Jornada 720", MACHINE_HPCARM_JORNADA720, 1);
5973            me->subtype[1]->aliases[0] = "jornada720";
5974            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5975                    me->next = first_machine_entry; first_machine_entry = me;
5976            }
5977    
5978          /*  Generic "bare" X86 machine:  */          /*  Generic "bare" X86 machine:  */
5979          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
5980              MACHINE_BAREX86, 1, 0);              MACHINE_BAREX86, 1, 0);
# Line 5333  void machine_init(void) Line 5991  void machine_init(void)
5991                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5992          }          }
5993    
5994            /*  Generic "bare" SH machine:  */
5995            me = machine_entry_new("Generic \"bare\" SH machine", ARCH_SH,
5996                MACHINE_BARESH, 1, 0);
5997            me->aliases[0] = "baresh";
5998            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5999                    me->next = first_machine_entry; first_machine_entry = me;
6000            }
6001    
6002          /*  Generic "bare" PPC machine:  */          /*  Generic "bare" PPC machine:  */
6003          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
6004              MACHINE_BAREPPC, 1, 0);              MACHINE_BAREPPC, 1, 0);
# Line 5365  void machine_init(void) Line 6031  void machine_init(void)
6031                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6032          }          }
6033    
6034            /*  Generic "bare" i960 machine:  */
6035            me = machine_entry_new("Generic \"bare\" i960 machine", ARCH_I960,
6036                MACHINE_BAREI960, 1, 0);
6037            me->aliases[0] = "barei960";
6038            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
6039                    me->next = first_machine_entry; first_machine_entry = me;
6040            }
6041    
6042            /*  Generic "bare" HPPA machine:  */
6043            me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
6044                MACHINE_BAREHPPA, 1, 0);
6045            me->aliases[0] = "barehppa";
6046            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
6047                    me->next = first_machine_entry; first_machine_entry = me;
6048            }
6049    
6050            /*  Generic "bare" Atmel AVR machine:  */
6051            me = machine_entry_new("Generic \"bare\" Atmel AVR machine", ARCH_AVR,
6052                MACHINE_BAREAVR, 1, 0);
6053            me->aliases[0] = "bareavr";
6054            if (cpu_family_ptr_by_number(ARCH_AVR) != NULL) {
6055                    me->next = first_machine_entry; first_machine_entry = me;
6056            }
6057    
6058          /*  Generic "bare" ARM machine:  */          /*  Generic "bare" ARM machine:  */
6059          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
6060              MACHINE_BAREARM, 1, 0);              MACHINE_BAREARM, 1, 0);
# Line 5398  void machine_init(void) Line 6088  void machine_init(void)
6088                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6089          }          }
6090    
6091            /*  Digital DNARD ("Shark"):  */
6092            me = machine_entry_new("Digital DNARD (\"Shark\")", ARCH_ARM,
6093                MACHINE_SHARK, 2, 0);
6094            me->aliases[0] = "shark";
6095            me->aliases[1] = "dnard";
6096            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6097                    me->next = first_machine_entry; first_machine_entry = me;
6098            }
6099    
6100          /*  DECstation:  */          /*  DECstation:  */
6101          me = machine_entry_new("DECstation/DECsystem",          me = machine_entry_new("DECstation/DECsystem",
6102              ARCH_MIPS, MACHINE_DEC, 3, 9);              ARCH_MIPS, MACHINE_DEC, 3, 9);
# Line 5465  void machine_init(void) Line 6164  void machine_init(void)
6164                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6165          }          }
6166    
6167            /*  CATS (ARM) evaluation board:  */
6168            me = machine_entry_new("CATS evaluation board (ARM)", ARCH_ARM,
6169                MACHINE_CATS, 1, 0);
6170            me->aliases[0] = "cats";
6171            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6172                    me->next = first_machine_entry; first_machine_entry = me;
6173            }
6174    
6175          /*  BeBox: (NetBSD/bebox)  */          /*  BeBox: (NetBSD/bebox)  */
6176          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
6177          me->aliases[0] = "bebox";          me->aliases[0] = "bebox";
# Line 5531  void machine_init(void) Line 6238  void machine_init(void)
6238          }          }
6239    
6240          /*  Alpha:  */          /*  Alpha:  */
6241          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 1);          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6242          me->aliases[0] = "alpha";          me->aliases[0] = "alpha";
6243          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
6244              "DEC 3000/300", ST_DEC_3000_300, 1);              "DEC 3000/300", ST_DEC_3000_300, 1);
6245          me->subtype[0]->aliases[0] = "3000/300";          me->subtype[0]->aliases[0] = "3000/300";
6246            me->subtype[1] = machine_entry_subtype_new(
6247                "EB164", ST_EB164, 1);
6248            me->subtype[1]->aliases[0] = "eb164";
6249          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
6250                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6251          }          }

Legend:
Removed from v.12  
changed lines
  Added in v.18

  ViewVC Help
Powered by ViewVC 1.1.26