/[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 14 by dpavlin, Mon Oct 8 16:18:51 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.565 2005/10/07 22:10:50 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 1484  void machine_setup(struct machine *machi Line 1549  void machine_setup(struct machine *machi
1549          char *init_bootpath;          char *init_bootpath;
1550    
1551          /*  PCI stuff:  */          /*  PCI stuff:  */
1552          struct pci_data *pci_data;          struct pci_data *pci_data = NULL;
1553    
1554          /*  Framebuffer stuff:  */          /*  Framebuffer stuff:  */
1555          struct vfb_data *fb;          struct vfb_data *fb = NULL;
1556    
1557          /*  Abreviation:  :-)  */          /*  Abreviation:  :-)  */
1558          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];
# Line 2058  void machine_setup(struct machine *machi Line 2123  void machine_setup(struct machine *machi
2123                   */                   */
2124                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
2125    
2126                  /*  DECstation PROM stuff:  (TODO: endianness)  */                  if (machine->prom_emulation) {
2127                  for (i=0; i<100; i++)                          /*  DECstation PROM stuff:  (TODO: endianness)  */
2128                          store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,                          for (i=0; i<100; i++)
2129                              DEC_PROM_EMULATION + i*8);                                  store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
2130                                        DEC_PROM_EMULATION + i*8);
2131                  /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */  
2132                  for (i=0; i<100; i++) {                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2133                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,                          for (i=0; i<100; i++) {
2134                              0x03e00008);        /*  return  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2135                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,                                      0x03e00008);        /*  return  */
2136                              0x00000000);        /*  nop  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2137                  }                                      0x00000000);        /*  nop  */
2138                            }
2139    
2140                  /*                          /*
2141                   *  According to dec_prom.h from NetBSD:                           *  According to dec_prom.h from NetBSD:
2142                   *                           *
2143                   *  "Programs loaded by the new PROMs pass the following arguments:                           *  "Programs loaded by the new PROMs pass the following arguments:
2144                   *      a0      argc                           *      a0      argc
2145                   *      a1      argv                           *      a1      argv
2146                   *      a2      DEC_PROM_MAGIC                           *      a2      DEC_PROM_MAGIC
2147                   *      a3      The callback vector defined below"                           *      a3      The callback vector defined below"
2148                   *                           *
2149                   *  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
2150                   *  loaded.                           *  loaded.
2151                   */                           */
2152    
2153                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2154                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2155                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2156                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2157    
2158                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2159                      BOOTINFO_MAGIC);                              BOOTINFO_MAGIC);
2160                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2161                      BOOTINFO_ADDR);                              BOOTINFO_ADDR);
2162    
2163                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2164                      (DEC_PROM_INITIAL_ARGV + 0x10));                              (DEC_PROM_INITIAL_ARGV + 0x10));
2165                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2166                      (DEC_PROM_INITIAL_ARGV + 0x70));                              (DEC_PROM_INITIAL_ARGV + 0x70));
2167                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2168                      (DEC_PROM_INITIAL_ARGV + 0xe0));                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2169                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2170    
2171                  /*                          /*
2172                   *  NetBSD and Ultrix expect the boot args to be like this:                           *  NetBSD and Ultrix expect the boot args to be like this:
2173                   *                           *
2174                   *      "boot" "bootdev" [args?]                           *      "boot" "bootdev" [args?]
2175                   *                           *
2176                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                           *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2177                   *  3100/2100 (although that crashes Ultrix :-/), and                           *  3100/2100 (although that crashes Ultrix :-/), and
2178                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                           *  "5/rz0a/netbsd" for all others.  The number '5' is the
2179                   *  slot number of the boot device.                           *  slot number of the boot device.
2180                   *                           *
2181                   *  'rz' for disks, 'tz' for tapes.                           *  'rz' for disks, 'tz' for tapes.
2182                   *                           *
2183                   *  TODO:  Make this nicer.                           *  TODO:  Make this nicer.
2184                   */                           */
2185                  {                          {
2186                          char bootpath[200];                          char bootpath[200];
   
2187  #if 0  #if 0
2188                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
2189                                  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 2205  void machine_setup(struct machine *machi
2205                          }                          }
2206    
2207                          init_bootpath = bootpath;                          init_bootpath = bootpath;
2208                  }                          }
2209    
2210                  bootarg = malloc(BOOTARG_BUFLEN);                          bootarg = malloc(BOOTARG_BUFLEN);
2211                  if (bootarg == NULL) {                          if (bootarg == NULL) {
2212                          fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2213                          exit(1);                                  exit(1);
2214                  }                          }
2215                  strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);                          strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2216                  if (strlcat(bootarg, machine->boot_kernel_filename,                          if (strlcat(bootarg, machine->boot_kernel_filename,
2217                      BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {                              BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2218                          fprintf(stderr, "bootarg truncated?\n");                                  fprintf(stderr, "bootarg truncated?\n");
2219                          exit(1);                                  exit(1);
2220                  }                          }
2221    
2222                  bootstr = "boot";                          bootstr = "boot";
2223    
2224                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2225                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2226                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2227                      machine->boot_string_argument);                              machine->boot_string_argument);
2228    
2229                  /*  Decrease the nr of args, if there are no args :-)  */                          /*  Decrease the nr of args, if there are no args :-)  */
2230                  if (machine->boot_string_argument == NULL ||                          if (machine->boot_string_argument == NULL ||
2231                      machine->boot_string_argument[0] == '\0')                              machine->boot_string_argument[0] == '\0')
2232                          cpu->cd.mips.gpr[MIPS_GPR_A0] --;                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2233    
2234                  if (machine->boot_string_argument[0] != '\0') {                          if (machine->boot_string_argument[0] != '\0') {
2235                          strlcat(bootarg, " ", BOOTARG_BUFLEN);                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2236                          if (strlcat(bootarg, machine->boot_string_argument,                                  if (strlcat(bootarg, machine->boot_string_argument,
2237                              BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2238                                  fprintf(stderr, "bootstr truncated?\n");                                          fprintf(stderr, "bootstr truncated?\n");
2239                                  exit(1);                                          exit(1);
2240                                    }
2241                          }                          }
                 }  
2242    
2243                  xx.a.common.next = (char *)&xx.b - (char *)&xx;                          xx.a.common.next = (char *)&xx.b - (char *)&xx;
2244                  xx.a.common.type = BTINFO_MAGIC;                          xx.a.common.type = BTINFO_MAGIC;
2245                  xx.a.magic = BOOTINFO_MAGIC;                          xx.a.magic = BOOTINFO_MAGIC;
2246    
2247                  xx.b.common.next = (char *)&xx.c - (char *)&xx.b;                          xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2248                  xx.b.common.type = BTINFO_BOOTPATH;                          xx.b.common.type = BTINFO_BOOTPATH;
2249                  strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));                          strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2250    
2251                  xx.c.common.next = 0;                          xx.c.common.next = 0;
2252                  xx.c.common.type = BTINFO_SYMTAB;                          xx.c.common.type = BTINFO_SYMTAB;
2253                  xx.c.nsym = 0;                          xx.c.nsym = 0;
2254                  xx.c.ssym = 0;                          xx.c.ssym = 0;
2255                  xx.c.esym = machine->file_loaded_end_addr;                          xx.c.esym = machine->file_loaded_end_addr;
2256    
2257                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
2258    
2259                  /*                          /*
2260                   *  The system's memmap:  (memmap is a global variable, in                           *  The system's memmap:  (memmap is a global variable, in
2261                   *  dec_prom.h)                           *  dec_prom.h)
2262                   */                           */
2263                  store_32bit_word_in_host(cpu,                          store_32bit_word_in_host(cpu,
2264                      (unsigned char *)&memmap.pagesize, 4096);                              (unsigned char *)&memmap.pagesize, 4096);
2265                  {                          {
2266                          unsigned int i;                                  unsigned int i;
2267                          for (i=0; i<sizeof(memmap.bitmap); i++)                                  for (i=0; i<sizeof(memmap.bitmap); i++)
2268                                  memmap.bitmap[i] = ((int)i * 4096*8 <                                          memmap.bitmap[i] = ((int)i * 4096*8 <
2269                                      1048576*machine->physical_ram_in_mb)?                                              1048576*machine->physical_ram_in_mb)?
2270                                      0xff : 0x00;                                              0xff : 0x00;
2271                  }                          }
2272                  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);  
2273    
2274                  /*                          /*  Environment variables:  */
2275                   *  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);  
                 }  
2276    
2277                  /*  These are needed for Sprite to boot:  */                          if (machine->use_x11 && machine->n_gfx_cards > 0)
2278                  {                                  /*  (0,3)  Keyboard and Framebuffer  */
2279                          char tmps[500];                                  add_environment_string(cpu, framebuffer_console_name, &addr);
2280                            else
2281                                    /*  Serial console  */
2282                                    add_environment_string(cpu, serial_console_name, &addr);
2283    
2284                            /*
2285                             *  The KN5800 (SMP system) uses a CCA (console communications
2286                             *  area):  (See VAX 6000 documentation for details.)
2287                             */
2288                            {
2289                                    char tmps[300];
2290                                    snprintf(tmps, sizeof(tmps), "cca=%x",
2291                                        (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2292                                    add_environment_string(cpu, tmps, &addr);
2293                            }
2294    
2295                            /*  These are needed for Sprite to boot:  */
2296                            {
2297                                    char tmps[500];
2298    
2299                                    snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2300                                    tmps[sizeof(tmps)-1] = '\0';
2301                                    add_environment_string(cpu, tmps, &addr);
2302    
2303                                    snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2304                                        DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2305                                        & 0xffffffffULL));
2306                                    tmps[sizeof(tmps)-1] = '\0';
2307                                    add_environment_string(cpu, tmps, &addr);
2308    
2309                                    snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2310                                        machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2311                                    tmps[sizeof(tmps)-1] = '\0';
2312                                    add_environment_string(cpu, tmps, &addr);
2313                            }
2314    
2315                          snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);                          add_environment_string(cpu, "scsiid0=7", &addr);
2316                          tmps[sizeof(tmps)-1] = '\0';                          add_environment_string(cpu, "bootmode=a", &addr);
2317                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, "testaction=q", &addr);
2318                            add_environment_string(cpu, "haltaction=h", &addr);
2319                          snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((                          add_environment_string(cpu, "more=24", &addr);
2320                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))  
2321                              & 0xffffffffULL));                          /*  Used in at least Ultrix on the 5100:  */
2322                          tmps[sizeof(tmps)-1] = '\0';                          add_environment_string(cpu, "scsiid=7", &addr);
2323                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, "baud0=9600", &addr);
2324                            add_environment_string(cpu, "baud1=9600", &addr);
2325                          snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",                          add_environment_string(cpu, "baud2=9600", &addr);
2326                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                          add_environment_string(cpu, "baud3=9600", &addr);
2327                          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);  
2328    
2329                  /*  The end:  */                          /*  The end:  */
2330                  add_environment_string(cpu, "", &addr);                          add_environment_string(cpu, "", &addr);
2331                    }
2332    
2333                  break;                  break;
2334    
# Line 2285  void machine_setup(struct machine *machi Line 2351  void machine_setup(struct machine *machi
2351    
2352                  /*  ISA interrupt controllers:  */                  /*  ISA interrupt controllers:  */
2353                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2354                  machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2355                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2356                  machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2357                  machine->md_interrupt = cobalt_interrupt;                  machine->md_interrupt = cobalt_interrupt;
2358    
2359                  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 2384  void machine_setup(struct machine *machi
2384                  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);
2385                  /*  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);  */
2386    
2387                  /*                  if (machine->prom_emulation) {
2388                   *  NetBSD/cobalt expects memsize in a0, but it seems that what                          /*
2389                   *  it really wants is the end of memory + 0x80000000.                           *  NetBSD/cobalt expects memsize in a0, but it seems that what
2390                   *                           *  it really wants is the end of memory + 0x80000000.
2391                   *  The bootstring is stored 512 bytes before the end of                           *
2392                   *  physical ram.                           *  The bootstring is stored 512 bytes before the end of
2393                   */                           *  physical ram.
2394                  cpu->cd.mips.gpr[MIPS_GPR_A0] =                           */
2395                      machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A0] =
2396                  bootstr = "root=/dev/hda1 ro";                              machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2397                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                          bootstr = "root=/dev/hda1 ro";
2398                  /*  TODO: bootarg, and/or automagic boot device detection  */                          /*  bootstr = "nfsroot=/usr/cobalt/";  */
2399                  store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);                          /*  TODO: bootarg, and/or automagic boot device detection  */
2400                            store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);
2401                    }
2402                  break;                  break;
2403    
2404          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
# Line 2609  void machine_setup(struct machine *machi Line 2677  void machine_setup(struct machine *machi
2677                          machine->main_console_handle =                          machine->main_console_handle =
2678                              machine->md_int.vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
2679    
2680                  /*  NetBSD/hpcmips and possibly others expects the following:  */                  if (machine->prom_emulation) {
2681                            /*  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);  
   
                         cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */  
2682    
2683                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2684                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                          cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2685                                + 0xffffffff80000000ULL - 512;      /*  argv  */
2686                            cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2687                                + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */
2688    
2689                            bootstr = machine->boot_kernel_filename;
2690                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512,
2691                                0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2692                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2693                            store_string(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2694    
2695                            /*  Special case for the Agenda VR3:  */
2696                            if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2697                                    const int tmplen = 1000;
2698                                    char *tmp = malloc(tmplen);
2699    
2700                                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */
2701    
2702                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2703                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2704    
2705                                    snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2706                                        "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2707                                    tmp[tmplen-1] = '\0';
2708    
2709                          snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"                                  if (!machine->use_x11)
2710                              "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2711                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2712    
2713                          if (!machine->use_x11)                                  if (machine->boot_string_argument[0])
2714                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2715                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2716    
2717                          if (machine->boot_string_argument[0])                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
                                 snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);  
                         tmp[tmplen-1] = '\0';  
2718    
2719                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  bootarg = tmp;
2720                            } else if (machine->boot_string_argument[0]) {
2721                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2722    
2723                          bootarg = tmp;                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2724                  } else if (machine->boot_string_argument[0]) {                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
                         cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */  
2725    
2726                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2727                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                      machine->boot_string_argument);
2728    
2729                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,                                  bootarg = machine->boot_string_argument;
2730                              machine->boot_string_argument);                          }
2731    
2732                          bootarg = machine->boot_string_argument;                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2733                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2734                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);
2735                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);
2736                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);
2737                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);
2738                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);
2739                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */
2740    
2741                            /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);
2742                                printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */
2743                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2744                            store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2745                  }                  }
2746    
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);  
                 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_width, hpcmips_fb_xsize);  
                 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_type, hpcmips_fb_encoding);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */  
   
                 /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);  
                     printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);  
                 store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));  
   
2747                  if (hpcmips_fb_addr != 0) {                  if (hpcmips_fb_addr != 0) {
2748                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,
2749                              hpcmips_fb_xsize, hpcmips_fb_ysize,                              hpcmips_fb_xsize, hpcmips_fb_ysize,
# Line 2716  void machine_setup(struct machine *machi Line 2787  void machine_setup(struct machine *machi
2787    
2788                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2789    
                 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);  
   
2790                  /*  Set the Harddisk controller present flag, if either                  /*  Set the Harddisk controller present flag, if either
2791                      disk 0 or 1 is present:  */                      disk 0 or 1 is present:  */
2792                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2793                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2794                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                          if (machine->prom_emulation)
2795                                    store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2796                          dev_ps2_spd_init(machine, mem, 0x14000000);                          dev_ps2_spd_init(machine, mem, 0x14000000);
2797                  }                  }
2798    
2799                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                  if (machine->prom_emulation) {
                 {  
2800                          int tmplen = 1000;                          int tmplen = 1000;
2801                          char *tmp = malloc(tmplen);                          char *tmp = malloc(tmplen);
2802                            time_t timet;
2803                            struct tm *tm_ptr;
2804    
2805                            add_symbol_name(&machine->symbol_context,
2806                                PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2807                            store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2808                            store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2809    
2810                            store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2811                          if (tmp == NULL) {                          if (tmp == NULL) {
2812                                  fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2813                                  exit(1);                                  exit(1);
# Line 2747  void machine_setup(struct machine *machi Line 2822  void machine_setup(struct machine *machi
2822    
2823                          bootstr = tmp;                          bootstr = tmp;
2824                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
                 }  
2825    
2826                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
                 {  
                         time_t timet;  
                         struct tm *tmp;  
2827    
2828                          /*  RTC data given by the BIOS:  */                          /*  RTC data given by the BIOS:  */
2829                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */
2830                          tmp = gmtime(&timet);                          tm_ptr = gmtime(&timet);
2831                          /*  TODO:  are these 0- or 1-based?  */                          /*  TODO:  are these 0- or 1-based?  */
2832                          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));
2833                          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));
2834                          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));
2835                          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));
2836                          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));
2837                          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));
                 }  
2838    
2839                  /*  "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.  */
2840                  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);
2841                    }
2842    
2843                  break;                  break;
2844    
# Line 3130  Why is this here? TODO Line 3201  Why is this here? TODO
3201                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
3202                                   */                                   */
3203    
 #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  
   
3204                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3205                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3206                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
# Line 3158  Why is this here? TODO Line 3222  Why is this here? TODO
3222                                  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",
3223                                      (1<<26) + MACE_PERIPH_SERIAL, 0);                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3224                                  device_add(machine, tmpstr);                                  device_add(machine, tmpstr);
3225  #if 0  
3226                                  if (machine->use_x11)                                  machine->main_console_handle = j;
3227    
3228                                    /*  TODO: Once this works, it should be enabled
3229                                        always, not just when using X!  */
3230                                    if (machine->use_x11) {
3231                                            i = dev_pckbc_init(machine, mem, 0x1f320000,
3232                                                PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
3233                                                0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
3234                                                    /*  keyb+mouse (mace irq numbers)  */
3235                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3236                                  else                                  }
 #endif  
                                         machine->main_console_handle = j;  
3237    
3238                                  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  */
3239                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");
# Line 3422  Why is this here? TODO Line 3492  Why is this here? TODO
3492    
3493  #if 0  #if 0
3494  Not yet.  Not yet.
3495                                  dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);                                  /*  irq = 8+16 + 14  */
3496                                    device_add(machine, "wdc addr=0x900001f0, irq=38");
3497  #endif  #endif
3498    
3499                                  break;                                  break;
# Line 3489  Not yet. Line 3560  Not yet.
3560                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3561    
3562  #if 0  #if 0
3563                                  dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);                                  /*  TODO: irq, etc  */
3564                                  dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);                                  device_add(machine, "wdc addr=0x9000001f0, irq=0");
3565                                    device_add(machine, "wdc addr=0x900000170, irq=0");
3566  #endif  #endif
3567                                  /*  PC kbd  */                                  /*  PC kbd  */
3568                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,
# Line 3524  Not yet. Line 3596  Not yet.
3596                   *  point.                   *  point.
3597                   */                   */
3598    
3599                  if (machine->prom_emulation)                  if (machine->prom_emulation) {
3600                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),
3601                              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?  
                  */  
3602    
3603                  /*                          /*
3604                   *  Boot string in ARC format:                           *  TODO: How to build the component tree intermixed with
3605                   *                           *  the rest of device initialization?
3606                   *  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';  
3607    
3608                  if (bootdev_id < 0 || machine->force_netboot) {                          /*
3609                          snprintf(init_bootpath, 400, "tftp()");                           *  Boot string in ARC format:
3610                  } else {                           *
3611                          /*  TODO: Make this nicer.  */                           *  TODO: How about floppies? multi()disk()fdisk()
3612                          if (machine->machine_type == MACHINE_SGI) {                           *        Is tftp() good for netbooting?
3613                                  if (machine->machine_subtype == 30)                           */
3614                                          strlcat(init_bootpath, "xio(0)pci(15)",                          init_bootpath = malloc(500);
3615                                              MACHINE_NAME_MAXBUF);                          if (init_bootpath == NULL) {
3616                                  if (machine->machine_subtype == 32)                                  fprintf(stderr, "out of mem, bootpath\n");
3617                                          strlcat(init_bootpath, "pci(0)",                                  exit(1);
                                             MACHINE_NAME_MAXBUF);  
3618                          }                          }
3619                            init_bootpath[0] = '\0';
3620    
3621                          if (diskimage_is_a_cdrom(machine, bootdev_id,                          if (bootdev_id < 0 || machine->force_netboot) {
3622                              bootdev_type))                                  snprintf(init_bootpath, 400, "tftp()");
3623                                  snprintf(init_bootpath + strlen(init_bootpath),                          } else {
3624                                      400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);                                  /*  TODO: Make this nicer.  */
3625                          else                                  if (machine->machine_type == MACHINE_SGI) {
3626                                  snprintf(init_bootpath + strlen(init_bootpath),                                          if (machine->machine_subtype == 30)
3627                                      400,"scsi(0)disk(%i)rdisk(0)partition(1)",                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3628                                      bootdev_id);                                                      MACHINE_NAME_MAXBUF);
3629                  }                                          if (machine->machine_subtype == 32)
3630                                                    strlcat(init_bootpath, "pci(0)",
3631                                                        MACHINE_NAME_MAXBUF);
3632                                    }
3633    
3634                                    if (diskimage_is_a_cdrom(machine, bootdev_id,
3635                                        bootdev_type))
3636                                            snprintf(init_bootpath + strlen(init_bootpath),
3637                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3638                                    else
3639                                            snprintf(init_bootpath + strlen(init_bootpath),
3640                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3641                                                bootdev_id);
3642                            }
3643    
3644                  if (machine->machine_type == MACHINE_ARC)                          if (machine->machine_type == MACHINE_ARC)
3645                          strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);                                  strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
3646    
3647                  bootstr = malloc(BOOTSTR_BUFLEN);                          bootstr = malloc(BOOTSTR_BUFLEN);
3648                  if (bootstr == NULL) {                          if (bootstr == NULL) {
3649                          fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
3650                          exit(1);                                  exit(1);
3651                  }                          }
3652                  strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);                          strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3653                  if (strlcat(bootstr, machine->boot_kernel_filename,                          if (strlcat(bootstr, machine->boot_kernel_filename,
3654                      BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {                              BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3655                          fprintf(stderr, "boot string too long?\n");                                  fprintf(stderr, "boot string too long?\n");
3656                          exit(1);                                  exit(1);
3657                  }                          }
3658    
3659                  /*  Boot args., eg "-a"  */                          /*  Boot args., eg "-a"  */
3660                  bootarg = machine->boot_string_argument;                          bootarg = machine->boot_string_argument;
3661    
3662                  /*  argc, argv, envp in a0, a1, a2:  */                          /*  argc, argv, envp in a0, a1, a2:  */
3663                  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  */
3664    
3665                  /*  TODO:  not needed?  */                          /*  TODO:  not needed?  */
3666                  cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3667                      (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3668    
3669                  /*  Set up argc/argv:  */                          /*  Set up argc/argv:  */
3670                  addr = ARC_ENV_STRINGS;                          addr = ARC_ENV_STRINGS;
3671                  addr2 = ARC_ARGV_START;                          addr2 = ARC_ARGV_START;
3672                  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] ++;  
3673    
3674                  /*  bootarg:  */                          /*  bootstr:  */
                 if (bootarg[0] != '\0') {  
3675                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3676                          add_environment_string(cpu, bootarg, &addr);                          add_environment_string(cpu, bootstr, &addr);
3677                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                 }  
3678    
3679                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                          /*  bootarg:  */
3680                            if (bootarg[0] != '\0') {
3681                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3682                                    add_environment_string(cpu, bootarg, &addr);
3683                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3684                            }
3685    
3686                            cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
3687    
3688                  /*                          /*
3689                   *  Add environment variables.  For each variable, add it                           *  Add environment variables.  For each variable, add it
3690                   *  as a string using add_environment_string(), and add a                           *  as a string using add_environment_string(), and add a
3691                   *  pointer to it to the ARC_ENV_POINTERS array.                           *  pointer to it to the ARC_ENV_POINTERS array.
3692                   */                           */
3693                  if (machine->use_x11) {                          if (machine->use_x11) {
3694                          if (machine->machine_type == MACHINE_ARC) {                                  if (machine->machine_type == MACHINE_ARC) {
3695                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3696                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3697                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3698                                            add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3699                                    } else {
3700                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3701                                            add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3702                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3703                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3704    
3705                                            /*  g for graphical mode. G for graphical mode
3706                                                with SGI logo visible on Irix?  */
3707                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3708                                            add_environment_string(cpu, "console=g", &addr);
3709                                    }
3710                            } else {
3711                                    if (machine->machine_type == MACHINE_ARC) {
3712                                            /*  TODO: serial console for ARC?  */
3713                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3714                                            add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3715                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3716                                            add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3717                                    } else {
3718                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3719                                            add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3720                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3721                                            add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3722    
3723                                            /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3724                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3725                                            add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
3726                                    }
3727                            }
3728    
3729                            if (machine->machine_type == MACHINE_SGI) {
3730                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3731                                  add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3732                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3733                                  add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "diskless=0", &addr);
                         } else {  
3734                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3735                                  add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);                                  add_environment_string(cpu, "volume=80", &addr);
3736                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3737                                  add_environment_string(cpu, "ConsoleOut=video()", &addr);                                  add_environment_string(cpu, "sgilogo=y", &addr);
3738    
                                 /*  g for graphical mode. G for graphical mode  
                                     with SGI logo visible on Irix?  */  
3739                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3740                                  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?  */  
3741                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3742                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "TimeZone=GMT", &addr);
3743                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3744                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "nogfxkbd=1", &addr);
3745                          } else {  
3746                                    /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */
3747    
3748                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3749                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);
3750                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3751                                  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?  */  
3752                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3753                                  add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */                                  add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
3754                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3755                  }                                  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);  
3756    
3757                          /*  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));
3758                                    add_environment_string(cpu, "rbaud=9600", &addr);
3759                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3760                                    add_environment_string(cpu, "rebound=y", &addr);
3761                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3762                                    add_environment_string(cpu, "crt_option=1", &addr);
3763                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3764                                    add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
3765    
3766                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3767                          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);  
3768    
3769                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3770                          add_environment_string(cpu, "rbaud=9600", &addr);                                  add_environment_string(cpu, "cpufreq=3", &addr);
3771                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3772                          add_environment_string(cpu, "rebound=y", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
3773                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3774                          add_environment_string(cpu, "crt_option=1", &addr);                                  add_environment_string(cpu, eaddr_string, &addr);
3775                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3776                          add_environment_string(cpu, "netaddr=10.0.0.1", &addr);                                  add_environment_string(cpu, "verbose=istrue", &addr);
3777                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3778                                    add_environment_string(cpu, "showconfig=istrue", &addr);
3779                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3780                                    add_environment_string(cpu, "diagmode=v", &addr);
3781                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3782                                    add_environment_string(cpu, "kernname=unix", &addr);
3783                            } else {
3784                                    char *tmp;
3785                                    size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3786                                    tmp = malloc(mlen);
3787                                    snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3788                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3789                                    add_environment_string(cpu, tmp, &addr);
3790    
3791                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3792                          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);
3793    
3794                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3795                          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);
3796                          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);  
3797    
3798                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  End the environment strings with an empty zero-terminated
3799                          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.  */
3800                            add_environment_string(cpu, "", &addr); /*  the end  */
3801                            store_pointer_and_advance(cpu, &addr2,
3802                                0, arc_wordlen==sizeof(uint64_t));
3803    
3804                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  Return address:  (0x20 = ReturnFromMain())  */
3805                          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;
3806                  }                  }
3807    
                 /*  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;  
   
3808                  break;                  break;
3809    
3810          case MACHINE_MESHCUBE:          case MACHINE_MESHCUBE:
# Line 3765  no_arc_prom_emulation:         /*  TODO: ugly, Line 3834  no_arc_prom_emulation:         /*  TODO: ugly,
3834    
3835                  device_add(machine, "random addr=0x1017fffc len=4");                  device_add(machine, "random addr=0x1017fffc len=4");
3836    
3837                  /*                  if (machine->prom_emulation) {
3838                   *  TODO:  A Linux kernel wants "memsize" from somewhere... I                          /*
3839                   *  haven't found any docs on how it is used though.                           *  TODO:  A Linux kernel wants "memsize" from somewhere... I
3840                   */                           *  haven't found any docs on how it is used though.
3841                             */
3842                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
3843                  cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
3844                  store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
3845                      0xa0002000ULL);                              0xa0002000ULL);
3846                  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");  
3847    
3848                            cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
3849                            store_string(cpu, 0xa0002000ULL, "hello=world\n");
3850                    }
3851                  break;                  break;
3852    
3853          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
3854                  machine->machine_name = "NetGear WG602";                  machine->machine_name = "NetGear WG602v1";
3855    
3856                  if (machine->use_x11)                  if (machine->use_x11)
3857                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
3858                  if (machine->physical_ram_in_mb != 16)                  if (machine->physical_ram_in_mb != 16)
3859                          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");
3860    
3861                  /*                  /*
3862                   *  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 3889  no_arc_prom_emulation:         /*  TODO: ugly,
3889                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
3890                  machine->machine_name = "Sony NeWS (NET WORK STATION)";                  machine->machine_name = "Sony NeWS (NET WORK STATION)";
3891    
3892                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3893                  {                          /*  This is just a test.  TODO  */
3894                          int i;                          int i;
3895                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
3896                                  cpu->cd.mips.gpr[i] =                                  cpu->cd.mips.gpr[i] =
# Line 3850  no_arc_prom_emulation:         /*  TODO: ugly, Line 3919  no_arc_prom_emulation:         /*  TODO: ugly,
3919    
3920                          /*  ISA interrupt controllers:  */                          /*  ISA interrupt controllers:  */
3921                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");
3922                          machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
3923                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");
3924                          machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
3925                          machine->md_interrupt = malta_interrupt;                          machine->md_interrupt = malta_interrupt;
3926    
3927                          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 4083  no_arc_prom_emulation:         /*  TODO: ugly, Line 4152  no_arc_prom_emulation:         /*  TODO: ugly,
4152                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");
4153                  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");
4154    
4155                    dev_pckbc_init(machine, mem, 0x80000060, PCKBC_8042,
4156                        1, 12, machine->use_x11, 1);
4157    
4158                  if (machine->use_x11)                  if (machine->use_x11)
4159                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,
4160                              machine->machine_name);                              machine->machine_name);
4161    
4162                  store_32bit_word(cpu, 0x3010,                  if (machine->prom_emulation) {
4163                      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);  
4164    
4165                            /*  TODO: List of stuff, see http://www.beatjapan.org/
4166                                mirror/www.be.com/aboutbe/benewsletter/
4167                                Issue27.html#Cookbook  for the details.  */
4168                            store_32bit_word(cpu, 0x301c, 0);
4169    
4170                            /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4171                                r5 = args, r6 = ptr to bootinfo?  */
4172                            cpu->cd.ppc.gpr[3] = 0x3100;
4173                            cpu->cd.ppc.gpr[4] = 0x200000;
4174                            cpu->cd.ppc.gpr[5] = 0x2000;
4175                            store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4176                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4177    
4178                            /*  See NetBSD's bebox/include/bootinfo.h for details  */
4179                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */
4180                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4181                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4182                                machine->physical_ram_in_mb * 1048576);
4183    
4184                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */
4185                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4186                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4187                                machine->use_x11? "vga" : "com", 4);
4188                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4189                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4190    
4191                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4192                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */
4193                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4194                    }
4195                  break;                  break;
4196    
4197          case MACHINE_PREP:          case MACHINE_PREP:
# Line 4129  no_arc_prom_emulation:         /*  TODO: ugly, Line 4200  no_arc_prom_emulation:         /*  TODO: ugly,
4200                   */                   */
4201                  machine->machine_name = "PowerPC Reference Platform";                  machine->machine_name = "PowerPC Reference Platform";
4202    
4203                  {                  if (machine->prom_emulation) {
4204                          int i;                          /*  Linux on PReP has 0xdeadc0de at address 0? (See
4205                          for (i=0; i<32; i++)                              http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */
4206                                  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;  
4207    
4208                            /*  r6 should point to "residual data"?  */
4209                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x1000;
4210                    }
4211                  break;                  break;
4212    
4213          case MACHINE_MACPPC:          case MACHINE_MACPPC:
# Line 4153  no_arc_prom_emulation:         /*  TODO: ugly, Line 4217  no_arc_prom_emulation:         /*  TODO: ugly,
4217                   */                   */
4218                  machine->machine_name = "Macintosh (PPC)";                  machine->machine_name = "Macintosh (PPC)";
4219    
4220                  /*  r5 = OpenFirmware entry point  */                  if (machine->prom_emulation) {
4221                  cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;                          uint64_t b = 8 * 1048576, a = b - 0x800;
4222                            int i;
4223                            /*
4224                             *  r3 = pointer to boot_args (for the Mach kernel).
4225                             *  See http://darwinsource.opendarwin.org/10.3/
4226                             *  BootX-59/bootx.tproj/include.subproj/boot_args.h
4227                             *  for more info.
4228                             */
4229                            cpu->cd.ppc.gpr[3] = a;
4230                            store_16bit_word(cpu, a + 0x0000, 1);   /*  revision  */
4231                            store_16bit_word(cpu, a + 0x0002, 2);   /*  version  */
4232                            store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
4233                            /*  26 dram banks; "long base; long size"  */
4234                            store_32bit_word(cpu, a + 0x0104, 0);   /*  base  */
4235                            store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
4236                                * 256);             /*  size (in pages)  */
4237                            for (i=8; i<26*8; i+= 4)
4238                                    store_32bit_word(cpu, a + 0x0104 + i, 0);
4239                            a += (0x104 + 26 * 8);
4240                            /*  Video info:  */
4241                            store_32bit_word(cpu, a+0, 0xd0000000); /*  video base  */
4242                            store_32bit_word(cpu, a+4, 0);          /*  display code (?)  */
4243                            store_32bit_word(cpu, a+8, 800);        /*  bytes per pixel row  */
4244                            store_32bit_word(cpu, a+12, 800);       /*  width  */
4245                            store_32bit_word(cpu, a+16, 600);       /*  height  */
4246                            store_32bit_word(cpu, a+20, 8);         /*  pixel depth  */
4247                            a += 24;
4248                            store_32bit_word(cpu, a+0, 127);        /*  gestalt number (TODO)  */
4249                            store_32bit_word(cpu, a+4, 0);          /*  device tree pointer (TODO)  */
4250                            store_32bit_word(cpu, a+8, 0);          /*  device tree length  */
4251                            store_32bit_word(cpu, a+12, b);         /*  last address of kernel data area  */
4252    
4253                            /*  r4 = "MOSX" (0x4D4F5358)  */
4254                            cpu->cd.ppc.gpr[4] = 0x4D4F5358;
4255    
4256                            /*
4257                             *  r5 = OpenFirmware entry point.  NOTE: See
4258                             *  cpu_ppc.c for the rest of this semi-ugly hack.
4259                             */
4260                            dev_ram_init(cpu->mem, cpu->cd.ppc.of_emul_addr,
4261                                0x1000, DEV_RAM_RAM, 0x0);
4262                            store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
4263                                0x44ee0002);
4264                            cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4265                    }
4266                  break;                  break;
4267    
4268          case MACHINE_DB64360:          case MACHINE_DB64360:
4269                  /*  For playing with PMON2000 for PPC:  */                  /*  For playing with PMON2000 for PPC:  */
4270                  machine->machine_name = "DB64360";                  machine->machine_name = "DB64360";
4271    
4272                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0x1d000020");                  machine->main_console_handle = (size_t)device_add(machine,
4273                        "ns16550 irq=0 addr=0x1d000020 addr_mult=4");
4274    
4275                  {                  if (machine->prom_emulation) {
4276                          int i;                          int i;
4277                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
4278                                  cpu->cd.ppc.gpr[i] =                                  cpu->cd.ppc.gpr[i] =
# Line 4174  no_arc_prom_emulation:         /*  TODO: ugly, Line 4282  no_arc_prom_emulation:         /*  TODO: ugly,
4282                  break;                  break;
4283  #endif  /*  ENABLE_PPC  */  #endif  /*  ENABLE_PPC  */
4284    
4285    #ifdef ENABLE_SH
4286            case MACHINE_BARESH:
4287                    /*  A bare SH machine, with no devices.  */
4288                    machine->machine_name = "\"Bare\" SH machine";
4289                    break;
4290    
4291            case MACHINE_TESTSH:
4292                    machine->machine_name = "SH test machine";
4293    
4294                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4295                        (long long)DEV_CONS_ADDRESS);
4296                    cons_data = device_add(machine, tmpstr);
4297                    machine->main_console_handle = cons_data->console_handle;
4298    
4299                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4300                        (long long)DEV_MP_ADDRESS);
4301                    device_add(machine, tmpstr);
4302    
4303                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4304                        640,480, 640,480, 24, "testsh generic");
4305    
4306                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4307                        (long long)DEV_DISK_ADDRESS);
4308                    device_add(machine, tmpstr);
4309    
4310                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4311                        (long long)DEV_ETHER_ADDRESS);
4312                    device_add(machine, tmpstr);
4313    
4314                    break;
4315    
4316            case MACHINE_HPCSH:
4317                    /*  Handheld SH-based machines:  */
4318                    machine->machine_name = "HPCsh";
4319    
4320                    /*  TODO  */
4321    
4322                    break;
4323    #endif  /*  ENABLE_SH  */
4324    
4325    #ifdef ENABLE_HPPA
4326            case MACHINE_BAREHPPA:
4327                    /*  A bare HPPA machine, with no devices.  */
4328                    machine->machine_name = "\"Bare\" HPPA machine";
4329                    break;
4330    
4331            case MACHINE_TESTHPPA:
4332                    machine->machine_name = "HPPA test machine";
4333    
4334                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4335                        (long long)DEV_CONS_ADDRESS);
4336                    cons_data = device_add(machine, tmpstr);
4337                    machine->main_console_handle = cons_data->console_handle;
4338    
4339                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4340                        (long long)DEV_MP_ADDRESS);
4341                    device_add(machine, tmpstr);
4342    
4343                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4344                        640,480, 640,480, 24, "testhppa generic");
4345    
4346                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4347                        (long long)DEV_DISK_ADDRESS);
4348                    device_add(machine, tmpstr);
4349    
4350                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4351                        (long long)DEV_ETHER_ADDRESS);
4352                    device_add(machine, tmpstr);
4353    
4354                    break;
4355    #endif  /*  ENABLE_HPPA  */
4356    
4357    #ifdef ENABLE_I960
4358            case MACHINE_BAREI960:
4359                    /*  A bare I960 machine, with no devices.  */
4360                    machine->machine_name = "\"Bare\" i960 machine";
4361                    break;
4362    
4363            case MACHINE_TESTI960:
4364                    machine->machine_name = "i960 test machine";
4365    
4366                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4367                        (long long)DEV_CONS_ADDRESS);
4368                    cons_data = device_add(machine, tmpstr);
4369                    machine->main_console_handle = cons_data->console_handle;
4370    
4371                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4372                        (long long)DEV_MP_ADDRESS);
4373                    device_add(machine, tmpstr);
4374    
4375                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4376                        640,480, 640,480, 24, "testi960 generic");
4377    
4378                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4379                        (long long)DEV_DISK_ADDRESS);
4380                    device_add(machine, tmpstr);
4381    
4382                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4383                        (long long)DEV_ETHER_ADDRESS);
4384                    device_add(machine, tmpstr);
4385    
4386                    break;
4387    #endif  /*  ENABLE_I960  */
4388    
4389  #ifdef ENABLE_SPARC  #ifdef ENABLE_SPARC
4390          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
4391                  /*  A bare SPARC machine, with no devices.  */                  /*  A bare SPARC machine, with no devices.  */
# Line 4245  no_arc_prom_emulation:         /*  TODO: ugly, Line 4457  no_arc_prom_emulation:         /*  TODO: ugly,
4457                  break;                  break;
4458    
4459          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;  
   
4460                  if (machine->prom_emulation) {                  if (machine->prom_emulation) {
4461                          struct rpb rpb;                          struct rpb rpb;
4462                          struct crb crb;                          struct crb crb;
4463                          struct ctb ctb;                          struct ctb ctb;
4464    
4465                            /*  TODO:  Most of these... They are used by NetBSD/alpha:  */
4466                            /*  a0 = First free Page Frame Number  */
4467                            /*  a1 = PFN of current Level 1 page table  */
4468                            /*  a2 = Bootinfo magic  */
4469                            /*  a3 = Bootinfo pointer  */
4470                            /*  a4 = Bootinfo version  */
4471                            cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
4472                            cpu->cd.alpha.r[ALPHA_A1] = 0;
4473                            cpu->cd.alpha.r[ALPHA_A2] = 0;
4474                            cpu->cd.alpha.r[ALPHA_A3] = 0;
4475                            cpu->cd.alpha.r[ALPHA_A4] = 0;
4476    
4477                          /*  HWRPB: Hardware Restart Parameter Block  */                          /*  HWRPB: Hardware Restart Parameter Block  */
4478                          memset(&rpb, 0, sizeof(struct rpb));                          memset(&rpb, 0, sizeof(struct rpb));
4479                          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 4518  no_arc_prom_emulation:         /*  TODO: ugly,
4518                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
4519                  case ST_DEC_3000_300:                  case ST_DEC_3000_300:
4520                          machine->machine_name = "DEC 3000/300";                          machine->machine_name = "DEC 3000/300";
4521                            machine->main_console_handle =
4522                                dev_zs_init(machine, mem, 0x1b0200000ULL,
4523                                0, 4, "serial zs"); /*  serial? netbsd?  */
4524                            break;
4525                    case ST_EB164:
4526                            machine->machine_name = "EB164";
4527                          break;                          break;
4528                  default:fatal("Unimplemented Alpha machine type %i\n",                  default:fatal("Unimplemented Alpha machine type %i\n",
4529                              machine->machine_subtype);                              machine->machine_subtype);
# Line 4353  no_arc_prom_emulation:         /*  TODO: ugly, Line 4571  no_arc_prom_emulation:         /*  TODO: ugly,
4571                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4572                      0xeafffffe);                      0xeafffffe);
4573                  break;                  break;
4574    
4575            case MACHINE_CATS:
4576                    machine->machine_name = "CATS evaluation board";
4577    
4578                    if (machine->physical_ram_in_mb > 256)
4579                            fprintf(stderr, "WARNING! Real CATS machines cannot"
4580                                " have more than 256 MB RAM. Continuing anyway.\n");
4581    
4582                    machine->md_int.footbridge_data =
4583                        device_add(machine, "footbridge addr=0x42000000");
4584                    machine->md_interrupt = footbridge_interrupt;
4585    
4586                    /*  NetBSD and OpenBSD clean their caches here:  */
4587                    dev_ram_init(mem, 0x50000000, 0x4000, DEV_RAM_RAM, 0);
4588    
4589                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4590                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4591                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4592                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4593    
4594                    device_add(machine, "pccmos addr=0x7c000070");
4595    
4596                    if (machine->use_x11) {
4597                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4598                                mem, 0xc0, 8, 0, pci_s3_virge_init, pci_s3_virge_rr);
4599                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4600                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4601                                32 + 1, 32 + 12, machine->use_x11, 0);
4602                            machine->main_console_handle = j;
4603                    }
4604    
4605                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0 in_use=0");
4606                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1 in_use=0");
4607    
4608                    if (machine->prom_emulation) {
4609                            struct ebsaboot ebsaboot;
4610    
4611                            cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
4612                                7 * 1048576 - 0x1000;
4613    
4614                            memset(&ebsaboot, 0, sizeof(struct ebsaboot));
4615                            store_32bit_word_in_host(cpu, (unsigned char *)
4616                                &(ebsaboot.bt_magic), BT_MAGIC_NUMBER_CATS);
4617                            store_32bit_word_in_host(cpu, (unsigned char *)
4618                                &(ebsaboot.bt_vargp), 0);
4619                            store_32bit_word_in_host(cpu, (unsigned char *)
4620                                &(ebsaboot.bt_pargp), 0);
4621                            store_32bit_word_in_host(cpu, (unsigned char *)
4622                                &(ebsaboot.bt_args), cpu->cd.arm.r[0]
4623                                + sizeof(struct ebsaboot));
4624                            store_32bit_word_in_host(cpu, (unsigned char *)
4625                                &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
4626                            store_32bit_word_in_host(cpu, (unsigned char *)
4627                                &(ebsaboot.bt_memstart), 0);
4628                            store_32bit_word_in_host(cpu, (unsigned char *)
4629                                &(ebsaboot.bt_memend),
4630                                machine->physical_ram_in_mb * 1048576);
4631                            store_32bit_word_in_host(cpu, (unsigned char *)
4632                                &(ebsaboot.bt_memavail), 7 * 1048576);
4633                            store_32bit_word_in_host(cpu, (unsigned char *)
4634                                &(ebsaboot.bt_fclk), 50 * 1000000);
4635                            store_32bit_word_in_host(cpu, (unsigned char *)
4636                                &(ebsaboot.bt_pciclk), 66 * 1000000);
4637                            /*  TODO: bt_vers  */
4638                            /*  TODO: bt_features  */
4639    
4640                            store_buf(cpu, cpu->cd.arm.r[0],
4641                                (char *)&ebsaboot, sizeof(struct ebsaboot));
4642                            store_string(cpu, cpu->cd.arm.r[0] +
4643                                sizeof(struct ebsaboot),
4644                                machine->boot_string_argument);
4645    
4646                            arm_setup_initial_translation_table(cpu,
4647                                7 * 1048576 - 32768);
4648                    }
4649                    break;
4650    
4651            case MACHINE_HPCARM:
4652                    machine->machine_name = "HPCarm";
4653                    dev_ram_init(mem, 0xc0000000, 0x10000000, DEV_RAM_MIRROR, 0x0);
4654    
4655                    /*  TODO: Different models  */
4656    
4657                    if (machine->prom_emulation) {
4658                            cpu->cd.arm.r[0] = 1;
4659                            cpu->cd.arm.r[ARM_SP] = 0xc000c000;
4660                    }
4661                    break;
4662    
4663            case MACHINE_ZAURUS:
4664                    machine->machine_name = "Zaurus";
4665                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4666                    device_add(machine, "ns16550 irq=0 addr=0x40100000 addr_mult=4");
4667                    /*  TODO  */
4668                    if (machine->prom_emulation) {
4669                            arm_setup_initial_translation_table(cpu, 0x4000);
4670                    }
4671                    break;
4672    
4673            case MACHINE_NETWINDER:
4674                    machine->machine_name = "NetWinder";
4675    
4676                    if (machine->physical_ram_in_mb > 256)
4677                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4678                                " have more than 256 MB RAM. Continuing anyway.\n");
4679    
4680                    machine->md_int.footbridge_data =
4681                        device_add(machine, "footbridge addr=0x42000000");
4682                    machine->md_interrupt = footbridge_interrupt;
4683    
4684                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4685                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4686                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4687                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4688    
4689                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4690                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4691    
4692                    if (machine->use_x11) {
4693                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4694                                mem, 0xc0, 8, 0, pci_igsfb_init, pci_igsfb_rr);
4695                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4696                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4697                                32 + 1, 32 + 12, machine->use_x11, 0);
4698                            machine->main_console_handle = j;
4699                    }
4700    
4701                    if (machine->prom_emulation) {
4702                            arm_setup_initial_translation_table(cpu, 0x4000);
4703                    }
4704                    break;
4705    
4706            case MACHINE_SHARK:
4707                    machine->machine_name = "Digital DNARD (\"Shark\")";
4708                    if (machine->prom_emulation) {
4709                            arm_setup_initial_translation_table(cpu,
4710                                machine->physical_ram_in_mb * 1048576 - 65536);
4711    
4712                            /*
4713                             *  r0 = OpenFirmware entry point.  NOTE: See
4714                             *  cpu_arm.c for the rest of this semi-ugly hack.
4715                             */
4716                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4717                    }
4718                    break;
4719    
4720            case MACHINE_IQ80321:
4721                    /*
4722                     *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4723                     *  for more details about the memory map.
4724                     */
4725                    machine->machine_name = "Intel IQ80321 (ARM)";
4726                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4727                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4728                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4729                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4730                    dev_ram_init(mem, 0xc0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4731                    if (machine->prom_emulation) {
4732                            arm_setup_initial_translation_table(cpu, 0x8000);
4733                    }
4734                    break;
4735    
4736            case MACHINE_IYONIX:
4737                    machine->machine_name = "Iyonix";
4738                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4739                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4740                    if (machine->prom_emulation) {
4741                            arm_setup_initial_translation_table(cpu,
4742                                machine->physical_ram_in_mb * 1048576 - 65536);
4743                    }
4744                    break;
4745  #endif  /*  ENABLE_ARM  */  #endif  /*  ENABLE_ARM  */
4746    
4747    #ifdef ENABLE_AVR
4748            case MACHINE_BAREAVR:
4749                    /*  A bare Atmel AVR machine, with no devices.  */
4750                    machine->machine_name = "\"Bare\" Atmel AVR machine";
4751                    break;
4752    #endif  /*  ENABLE_AVR  */
4753    
4754  #ifdef ENABLE_IA64  #ifdef ENABLE_IA64
4755          case MACHINE_BAREIA64:          case MACHINE_BAREIA64:
4756                  machine->machine_name = "\"Bare\" IA64 machine";                  machine->machine_name = "\"Bare\" IA64 machine";
# Line 4431  no_arc_prom_emulation:         /*  TODO: ugly, Line 4827  no_arc_prom_emulation:         /*  TODO: ugly,
4827                  /*  Interrupt controllers:  */                  /*  Interrupt controllers:  */
4828                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",
4829                      (long long)(X86_IO_BASE + 0x20));                      (long long)(X86_IO_BASE + 0x20));
4830                  machine->md.pc.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4831                  if (machine->machine_subtype != MACHINE_X86_XT) {                  if (machine->machine_subtype != MACHINE_X86_XT) {
4832                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",
4833                              (long long)(X86_IO_BASE + 0xa0));                              (long long)(X86_IO_BASE + 0xa0));
4834                          machine->md.pc.pic2 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4835                  }                  }
4836    
4837                  machine->md_interrupt = x86_pc_interrupt;                  machine->md_interrupt = x86_pc_interrupt;
# Line 4453  no_arc_prom_emulation:         /*  TODO: ugly, Line 4849  no_arc_prom_emulation:         /*  TODO: ugly,
4849    
4850                  /*  IDE controllers:  */                  /*  IDE controllers:  */
4851                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
4852                      diskimage_exist(machine, 1, DISKIMAGE_IDE))                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
4853                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x1f0, 14, 0);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4854                                X86_IO_BASE + 0x1f0, 14);
4855                            device_add(machine, tmpstr);
4856                    }
4857                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||
4858                      diskimage_exist(machine, 3, DISKIMAGE_IDE))                      diskimage_exist(machine, 3, DISKIMAGE_IDE)) {
4859                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x170, 15, 2);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4860                                X86_IO_BASE + 0x170, 15);
4861                            device_add(machine, tmpstr);
4862                    }
4863    
4864                  /*  Floppy controller at irq 6  */                  /*  Floppy controller at irq 6  */
4865                  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 5004  void machine_memsize_fix(struct machine
5004                  case MACHINE_BEBOX:                  case MACHINE_BEBOX:
5005                          m->physical_ram_in_mb = 64;                          m->physical_ram_in_mb = 64;
5006                          break;                          break;
5007                    case MACHINE_CATS:
5008                            m->physical_ram_in_mb = 64;
5009                            break;
5010                    case MACHINE_ZAURUS:
5011                            m->physical_ram_in_mb = 64;
5012                            break;
5013                    case MACHINE_HPCARM:
5014                            m->physical_ram_in_mb = 32;
5015                            break;
5016                    case MACHINE_NETWINDER:
5017                            m->physical_ram_in_mb = 16;
5018                            break;
5019                  case MACHINE_X86:                  case MACHINE_X86:
5020                          if (m->machine_subtype == MACHINE_X86_XT)                          if (m->machine_subtype == MACHINE_X86_XT)
5021                                  m->physical_ram_in_mb = 1;                                  m->physical_ram_in_mb = 1;
# Line 4787  void machine_default_cputype(struct mach Line 5201  void machine_default_cputype(struct mach
5201          case MACHINE_MACPPC:          case MACHINE_MACPPC:
5202                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5203                  case MACHINE_MACPPC_G4:                  case MACHINE_MACPPC_G4:
5204                          m->cpu_name = strdup("G4e");                          m->cpu_name = strdup("PPC750");
5205                          break;                          break;
5206                  case MACHINE_MACPPC_G5:                  case MACHINE_MACPPC_G5:
5207                          m->cpu_name = strdup("PPC970");                          m->cpu_name = strdup("PPC970");
# Line 4798  void machine_default_cputype(struct mach Line 5212  void machine_default_cputype(struct mach
5212                  m->cpu_name = strdup("PPC750");                  m->cpu_name = strdup("PPC750");
5213                  break;                  break;
5214    
5215            /*  SH:  */
5216            case MACHINE_BARESH:
5217            case MACHINE_TESTSH:
5218            case MACHINE_HPCSH:
5219                    m->cpu_name = strdup("SH");
5220                    break;
5221    
5222            /*  HPPA:  */
5223            case MACHINE_BAREHPPA:
5224            case MACHINE_TESTHPPA:
5225                    m->cpu_name = strdup("HPPA");
5226                    break;
5227    
5228            /*  i960:  */
5229            case MACHINE_BAREI960:
5230            case MACHINE_TESTI960:
5231                    m->cpu_name = strdup("i960");
5232                    break;
5233    
5234          /*  SPARC:  */          /*  SPARC:  */
5235          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
5236          case MACHINE_TESTSPARC:          case MACHINE_TESTSPARC:
# Line 4815  void machine_default_cputype(struct mach Line 5248  void machine_default_cputype(struct mach
5248          /*  ARM:  */          /*  ARM:  */
5249          case MACHINE_BAREARM:          case MACHINE_BAREARM:
5250          case MACHINE_TESTARM:          case MACHINE_TESTARM:
5251                  m->cpu_name = strdup("ARM");          case MACHINE_HPCARM:
5252                    m->cpu_name = strdup("SA1110");
5253                    break;
5254            case MACHINE_IQ80321:
5255            case MACHINE_IYONIX:
5256                    m->cpu_name = strdup("80321_600_B0");
5257                    break;
5258            case MACHINE_CATS:
5259            case MACHINE_NETWINDER:
5260            case MACHINE_SHARK:
5261                    m->cpu_name = strdup("SA110");
5262                    break;
5263            case MACHINE_ZAURUS:
5264                    m->cpu_name = strdup("PXA210");
5265                    break;
5266    
5267            /*  AVR:  */
5268            case MACHINE_BAREAVR:
5269                    m->cpu_name = strdup("AVR");
5270                  break;                  break;
5271    
5272          /*  IA64:  */          /*  IA64:  */
# Line 5090  void machine_init(void) Line 5541  void machine_init(void)
5541           *  entries will appear in normal order when listed.  :-)           *  entries will appear in normal order when listed.  :-)
5542           */           */
5543    
5544            /*  Zaurus:  */
5545            me = machine_entry_new("Zaurus (ARM)",
5546                ARCH_ARM, MACHINE_ZAURUS, 1, 0);
5547            me->aliases[0] = "zaurus";
5548            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5549                    me->next = first_machine_entry; first_machine_entry = me;
5550            }
5551    
5552          /*  X86 machine:  */          /*  X86 machine:  */
5553          me = machine_entry_new("x86-based PC", ARCH_X86,          me = machine_entry_new("x86-based PC", ARCH_X86,
5554              MACHINE_X86, 2, 2);              MACHINE_X86, 2, 2);
# Line 5121  void machine_init(void) Line 5580  void machine_init(void)
5580                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5581          }          }
5582    
5583            /*  Test-machine for SH:  */
5584            me = machine_entry_new("Test-machine for SH", ARCH_SH,
5585                MACHINE_TESTSH, 1, 0);
5586            me->aliases[0] = "testsh";
5587            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5588                    me->next = first_machine_entry; first_machine_entry = me;
5589            }
5590    
5591          /*  Test-machine for PPC:  */          /*  Test-machine for PPC:  */
5592          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,
5593              MACHINE_TESTPPC, 1, 0);              MACHINE_TESTPPC, 1, 0);
# Line 5153  void machine_init(void) Line 5620  void machine_init(void)
5620                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5621          }          }
5622    
5623            /*  Test-machine for i960:  */
5624            me = machine_entry_new("Test-machine for i960", ARCH_I960,
5625                MACHINE_TESTI960, 1, 0);
5626            me->aliases[0] = "testi960";
5627            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5628                    me->next = first_machine_entry; first_machine_entry = me;
5629            }
5630    
5631            /*  Test-machine for HPPA:  */
5632            me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5633                MACHINE_TESTHPPA, 1, 0);
5634            me->aliases[0] = "testhppa";
5635            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5636                    me->next = first_machine_entry; first_machine_entry = me;
5637            }
5638    
5639          /*  Test-machine for ARM:  */          /*  Test-machine for ARM:  */
5640          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,
5641              MACHINE_TESTARM, 1, 0);              MACHINE_TESTARM, 1, 0);
# Line 5243  void machine_init(void) Line 5726  void machine_init(void)
5726                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5727          }          }
5728    
5729            /*  NetWinder:  */
5730            me = machine_entry_new("NetWinder", ARCH_ARM, MACHINE_NETWINDER, 1, 0);
5731            me->aliases[0] = "netwinder";
5732            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5733                    me->next = first_machine_entry; first_machine_entry = me;
5734            }
5735    
5736          /*  NetGear:  */          /*  NetGear:  */
5737          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602v1", ARCH_MIPS,
5738              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);
5739          me->aliases[0] = "netgear";          me->aliases[0] = "netgear";
5740          me->aliases[1] = "wg602";          me->aliases[1] = "wg602v1";
5741          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5742                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5743          }          }
# Line 5281  void machine_init(void) Line 5771  void machine_init(void)
5771                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5772          }          }
5773    
5774            /*  Iyonix:  */
5775            me = machine_entry_new("Iyonix", ARCH_ARM,
5776                MACHINE_IYONIX, 1, 0);
5777            me->aliases[0] = "iyonix";
5778            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5779                    me->next = first_machine_entry; first_machine_entry = me;
5780            }
5781    
5782            /*  Intel IQ80321 (ARM):  */
5783            me = machine_entry_new("Intel IQ80321 (ARM)", ARCH_ARM,
5784                MACHINE_IQ80321, 1, 0);
5785            me->aliases[0] = "iq80321";
5786            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5787                    me->next = first_machine_entry; first_machine_entry = me;
5788            }
5789    
5790            /*  HPCarm:  */
5791            me = machine_entry_new("Handheld SH (HPCsh)",
5792                ARCH_SH, MACHINE_HPCSH, 1, 2);
5793            me->aliases[0] = "hpcsh";
5794            me->subtype[0] = machine_entry_subtype_new("Jornada 680",
5795                MACHINE_HPCSH_JORNADA680, 1);
5796            me->subtype[0]->aliases[0] = "jornada680";
5797            me->subtype[1] = machine_entry_subtype_new(
5798                "Jornada 690", MACHINE_HPCSH_JORNADA690, 1);
5799            me->subtype[1]->aliases[0] = "jornada690";
5800            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5801                    me->next = first_machine_entry; first_machine_entry = me;
5802            }
5803    
5804          /*  HPCmips:  */          /*  HPCmips:  */
5805          me = machine_entry_new("Handheld MIPS (HPCmips)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
5806              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
# Line 5317  void machine_init(void) Line 5837  void machine_init(void)
5837                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5838          }          }
5839    
5840            /*  HPCarm:  */
5841            me = machine_entry_new("Handheld ARM (HPCarm)",
5842                ARCH_ARM, MACHINE_HPCARM, 1, 2);
5843            me->aliases[0] = "hpcarm";
5844            me->subtype[0] = machine_entry_subtype_new("Ipaq",
5845                MACHINE_HPCARM_IPAQ, 1);
5846            me->subtype[0]->aliases[0] = "ipaq";
5847            me->subtype[1] = machine_entry_subtype_new(
5848                "Jornada 720", MACHINE_HPCARM_JORNADA720, 1);
5849            me->subtype[1]->aliases[0] = "jornada720";
5850            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5851                    me->next = first_machine_entry; first_machine_entry = me;
5852            }
5853    
5854          /*  Generic "bare" X86 machine:  */          /*  Generic "bare" X86 machine:  */
5855          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
5856              MACHINE_BAREX86, 1, 0);              MACHINE_BAREX86, 1, 0);
# Line 5333  void machine_init(void) Line 5867  void machine_init(void)
5867                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5868          }          }
5869    
5870            /*  Generic "bare" SH machine:  */
5871            me = machine_entry_new("Generic \"bare\" SH machine", ARCH_SH,
5872                MACHINE_BARESH, 1, 0);
5873            me->aliases[0] = "baresh";
5874            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5875                    me->next = first_machine_entry; first_machine_entry = me;
5876            }
5877    
5878          /*  Generic "bare" PPC machine:  */          /*  Generic "bare" PPC machine:  */
5879          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
5880              MACHINE_BAREPPC, 1, 0);              MACHINE_BAREPPC, 1, 0);
# Line 5365  void machine_init(void) Line 5907  void machine_init(void)
5907                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5908          }          }
5909    
5910            /*  Generic "bare" i960 machine:  */
5911            me = machine_entry_new("Generic \"bare\" i960 machine", ARCH_I960,
5912                MACHINE_BAREI960, 1, 0);
5913            me->aliases[0] = "barei960";
5914            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5915                    me->next = first_machine_entry; first_machine_entry = me;
5916            }
5917    
5918            /*  Generic "bare" HPPA machine:  */
5919            me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
5920                MACHINE_BAREHPPA, 1, 0);
5921            me->aliases[0] = "barehppa";
5922            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5923                    me->next = first_machine_entry; first_machine_entry = me;
5924            }
5925    
5926            /*  Generic "bare" Atmel AVR machine:  */
5927            me = machine_entry_new("Generic \"bare\" Atmel AVR machine", ARCH_AVR,
5928                MACHINE_BAREAVR, 1, 0);
5929            me->aliases[0] = "bareavr";
5930            if (cpu_family_ptr_by_number(ARCH_AVR) != NULL) {
5931                    me->next = first_machine_entry; first_machine_entry = me;
5932            }
5933    
5934          /*  Generic "bare" ARM machine:  */          /*  Generic "bare" ARM machine:  */
5935          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
5936              MACHINE_BAREARM, 1, 0);              MACHINE_BAREARM, 1, 0);
# Line 5398  void machine_init(void) Line 5964  void machine_init(void)
5964                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5965          }          }
5966    
5967            /*  Digital DNARD ("Shark"):  */
5968            me = machine_entry_new("Digital DNARD (\"Shark\")", ARCH_ARM,
5969                MACHINE_SHARK, 2, 0);
5970            me->aliases[0] = "shark";
5971            me->aliases[1] = "dnard";
5972            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5973                    me->next = first_machine_entry; first_machine_entry = me;
5974            }
5975    
5976          /*  DECstation:  */          /*  DECstation:  */
5977          me = machine_entry_new("DECstation/DECsystem",          me = machine_entry_new("DECstation/DECsystem",
5978              ARCH_MIPS, MACHINE_DEC, 3, 9);              ARCH_MIPS, MACHINE_DEC, 3, 9);
# Line 5465  void machine_init(void) Line 6040  void machine_init(void)
6040                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6041          }          }
6042    
6043            /*  CATS (ARM) evaluation board:  */
6044            me = machine_entry_new("CATS evaluation board (ARM)", ARCH_ARM,
6045                MACHINE_CATS, 1, 0);
6046            me->aliases[0] = "cats";
6047            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6048                    me->next = first_machine_entry; first_machine_entry = me;
6049            }
6050    
6051          /*  BeBox: (NetBSD/bebox)  */          /*  BeBox: (NetBSD/bebox)  */
6052          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
6053          me->aliases[0] = "bebox";          me->aliases[0] = "bebox";
# Line 5531  void machine_init(void) Line 6114  void machine_init(void)
6114          }          }
6115    
6116          /*  Alpha:  */          /*  Alpha:  */
6117          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 1);          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6118          me->aliases[0] = "alpha";          me->aliases[0] = "alpha";
6119          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
6120              "DEC 3000/300", ST_DEC_3000_300, 1);              "DEC 3000/300", ST_DEC_3000_300, 1);
6121          me->subtype[0]->aliases[0] = "3000/300";          me->subtype[0]->aliases[0] = "3000/300";
6122            me->subtype[1] = machine_entry_subtype_new(
6123                "EB164", ST_EB164, 1);
6124            me->subtype[1]->aliases[0] = "eb164";
6125          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
6126                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6127          }          }

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

  ViewVC Help
Powered by ViewVC 1.1.26