/[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 16 by dpavlin, Mon Oct 8 16:19:01 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.569 2005/10/11 03:31:27 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 1504  void machine_setup(struct machine *machi Line 1569  void machine_setup(struct machine *machi
1569                  case MACHINE_ARC:                  case MACHINE_ARC:
1570                          machine->boot_string_argument = "-aN";                          machine->boot_string_argument = "-aN";
1571                          break;                          break;
1572                    case MACHINE_CATS:
1573                            machine->boot_string_argument = "-A";
1574                            break;
1575                  case MACHINE_DEC:                  case MACHINE_DEC:
1576                          machine->boot_string_argument = "-a";                          machine->boot_string_argument = "-a";
1577                          break;                          break;
# Line 2058  void machine_setup(struct machine *machi Line 2126  void machine_setup(struct machine *machi
2126                   */                   */
2127                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
2128    
2129                  /*  DECstation PROM stuff:  (TODO: endianness)  */                  if (machine->prom_emulation) {
2130                  for (i=0; i<100; i++)                          /*  DECstation PROM stuff:  (TODO: endianness)  */
2131                          store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,                          for (i=0; i<100; i++)
2132                              DEC_PROM_EMULATION + i*8);                                  store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
2133                                        DEC_PROM_EMULATION + i*8);
2134                  /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */  
2135                  for (i=0; i<100; i++) {                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2136                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,                          for (i=0; i<100; i++) {
2137                              0x03e00008);        /*  return  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2138                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,                                      0x03e00008);        /*  return  */
2139                              0x00000000);        /*  nop  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2140                  }                                      0x00000000);        /*  nop  */
2141                            }
2142    
2143                  /*                          /*
2144                   *  According to dec_prom.h from NetBSD:                           *  According to dec_prom.h from NetBSD:
2145                   *                           *
2146                   *  "Programs loaded by the new PROMs pass the following arguments:                           *  "Programs loaded by the new PROMs pass the following arguments:
2147                   *      a0      argc                           *      a0      argc
2148                   *      a1      argv                           *      a1      argv
2149                   *      a2      DEC_PROM_MAGIC                           *      a2      DEC_PROM_MAGIC
2150                   *      a3      The callback vector defined below"                           *      a3      The callback vector defined below"
2151                   *                           *
2152                   *  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
2153                   *  loaded.                           *  loaded.
2154                   */                           */
2155    
2156                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2157                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2158                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2159                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2160    
2161                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2162                      BOOTINFO_MAGIC);                              BOOTINFO_MAGIC);
2163                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2164                      BOOTINFO_ADDR);                              BOOTINFO_ADDR);
2165    
2166                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2167                      (DEC_PROM_INITIAL_ARGV + 0x10));                              (DEC_PROM_INITIAL_ARGV + 0x10));
2168                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2169                      (DEC_PROM_INITIAL_ARGV + 0x70));                              (DEC_PROM_INITIAL_ARGV + 0x70));
2170                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2171                      (DEC_PROM_INITIAL_ARGV + 0xe0));                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2172                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2173    
2174                  /*                          /*
2175                   *  NetBSD and Ultrix expect the boot args to be like this:                           *  NetBSD and Ultrix expect the boot args to be like this:
2176                   *                           *
2177                   *      "boot" "bootdev" [args?]                           *      "boot" "bootdev" [args?]
2178                   *                           *
2179                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                           *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2180                   *  3100/2100 (although that crashes Ultrix :-/), and                           *  3100/2100 (although that crashes Ultrix :-/), and
2181                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                           *  "5/rz0a/netbsd" for all others.  The number '5' is the
2182                   *  slot number of the boot device.                           *  slot number of the boot device.
2183                   *                           *
2184                   *  'rz' for disks, 'tz' for tapes.                           *  'rz' for disks, 'tz' for tapes.
2185                   *                           *
2186                   *  TODO:  Make this nicer.                           *  TODO:  Make this nicer.
2187                   */                           */
2188                  {                          {
2189                          char bootpath[200];                          char bootpath[200];
   
2190  #if 0  #if 0
2191                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
2192                                  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 2208  void machine_setup(struct machine *machi
2208                          }                          }
2209    
2210                          init_bootpath = bootpath;                          init_bootpath = bootpath;
2211                  }                          }
2212    
2213                  bootarg = malloc(BOOTARG_BUFLEN);                          bootarg = malloc(BOOTARG_BUFLEN);
2214                  if (bootarg == NULL) {                          if (bootarg == NULL) {
2215                          fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2216                          exit(1);                                  exit(1);
2217                  }                          }
2218                  strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);                          strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2219                  if (strlcat(bootarg, machine->boot_kernel_filename,                          if (strlcat(bootarg, machine->boot_kernel_filename,
2220                      BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {                              BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2221                          fprintf(stderr, "bootarg truncated?\n");                                  fprintf(stderr, "bootarg truncated?\n");
2222                          exit(1);                                  exit(1);
2223                  }                          }
2224    
2225                  bootstr = "boot";                          bootstr = "boot";
2226    
2227                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2228                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2229                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2230                      machine->boot_string_argument);                              machine->boot_string_argument);
2231    
2232                  /*  Decrease the nr of args, if there are no args :-)  */                          /*  Decrease the nr of args, if there are no args :-)  */
2233                  if (machine->boot_string_argument == NULL ||                          if (machine->boot_string_argument == NULL ||
2234                      machine->boot_string_argument[0] == '\0')                              machine->boot_string_argument[0] == '\0')
2235                          cpu->cd.mips.gpr[MIPS_GPR_A0] --;                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2236    
2237                  if (machine->boot_string_argument[0] != '\0') {                          if (machine->boot_string_argument[0] != '\0') {
2238                          strlcat(bootarg, " ", BOOTARG_BUFLEN);                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2239                          if (strlcat(bootarg, machine->boot_string_argument,                                  if (strlcat(bootarg, machine->boot_string_argument,
2240                              BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2241                                  fprintf(stderr, "bootstr truncated?\n");                                          fprintf(stderr, "bootstr truncated?\n");
2242                                  exit(1);                                          exit(1);
2243                                    }
2244                          }                          }
                 }  
2245    
2246                  xx.a.common.next = (char *)&xx.b - (char *)&xx;                          xx.a.common.next = (char *)&xx.b - (char *)&xx;
2247                  xx.a.common.type = BTINFO_MAGIC;                          xx.a.common.type = BTINFO_MAGIC;
2248                  xx.a.magic = BOOTINFO_MAGIC;                          xx.a.magic = BOOTINFO_MAGIC;
2249    
2250                  xx.b.common.next = (char *)&xx.c - (char *)&xx.b;                          xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2251                  xx.b.common.type = BTINFO_BOOTPATH;                          xx.b.common.type = BTINFO_BOOTPATH;
2252                  strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));                          strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2253    
2254                  xx.c.common.next = 0;                          xx.c.common.next = 0;
2255                  xx.c.common.type = BTINFO_SYMTAB;                          xx.c.common.type = BTINFO_SYMTAB;
2256                  xx.c.nsym = 0;                          xx.c.nsym = 0;
2257                  xx.c.ssym = 0;                          xx.c.ssym = 0;
2258                  xx.c.esym = machine->file_loaded_end_addr;                          xx.c.esym = machine->file_loaded_end_addr;
2259    
2260                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
2261    
2262                  /*                          /*
2263                   *  The system's memmap:  (memmap is a global variable, in                           *  The system's memmap:  (memmap is a global variable, in
2264                   *  dec_prom.h)                           *  dec_prom.h)
2265                   */                           */
2266                  store_32bit_word_in_host(cpu,                          store_32bit_word_in_host(cpu,
2267                      (unsigned char *)&memmap.pagesize, 4096);                              (unsigned char *)&memmap.pagesize, 4096);
2268                  {                          {
2269                          unsigned int i;                                  unsigned int i;
2270                          for (i=0; i<sizeof(memmap.bitmap); i++)                                  for (i=0; i<sizeof(memmap.bitmap); i++)
2271                                  memmap.bitmap[i] = ((int)i * 4096*8 <                                          memmap.bitmap[i] = ((int)i * 4096*8 <
2272                                      1048576*machine->physical_ram_in_mb)?                                              1048576*machine->physical_ram_in_mb)?
2273                                      0xff : 0x00;                                              0xff : 0x00;
2274                  }                          }
2275                  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);  
2276    
2277                  /*                          /*  Environment variables:  */
2278                   *  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);  
                 }  
2279    
2280                  /*  These are needed for Sprite to boot:  */                          if (machine->use_x11 && machine->n_gfx_cards > 0)
2281                  {                                  /*  (0,3)  Keyboard and Framebuffer  */
2282                          char tmps[500];                                  add_environment_string(cpu, framebuffer_console_name, &addr);
2283                            else
2284                                    /*  Serial console  */
2285                                    add_environment_string(cpu, serial_console_name, &addr);
2286    
2287                          snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);                          /*
2288                          tmps[sizeof(tmps)-1] = '\0';                           *  The KN5800 (SMP system) uses a CCA (console communications
2289                          add_environment_string(cpu, tmps, &addr);                           *  area):  (See VAX 6000 documentation for details.)
2290                             */
2291                          snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((                          {
2292                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))                                  char tmps[300];
2293                              & 0xffffffffULL));                                  snprintf(tmps, sizeof(tmps), "cca=%x",
2294                          tmps[sizeof(tmps)-1] = '\0';                                      (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2295                          add_environment_string(cpu, tmps, &addr);                                  add_environment_string(cpu, tmps, &addr);
2296                            }
2297                          snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",  
2298                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                          /*  These are needed for Sprite to boot:  */
2299                          tmps[sizeof(tmps)-1] = '\0';                          {
2300                          add_environment_string(cpu, tmps, &addr);                                  char tmps[500];
                 }  
   
                 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);  
2301    
2302                  /*  The end:  */                                  snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2303                  add_environment_string(cpu, "", &addr);                                  tmps[sizeof(tmps)-1] = '\0';
2304                                    add_environment_string(cpu, tmps, &addr);
2305    
2306                                    snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2307                                        DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2308                                        & 0xffffffffULL));
2309                                    tmps[sizeof(tmps)-1] = '\0';
2310                                    add_environment_string(cpu, tmps, &addr);
2311    
2312                                    snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2313                                        machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2314                                    tmps[sizeof(tmps)-1] = '\0';
2315                                    add_environment_string(cpu, tmps, &addr);
2316                            }
2317    
2318                            add_environment_string(cpu, "scsiid0=7", &addr);
2319                            add_environment_string(cpu, "bootmode=a", &addr);
2320                            add_environment_string(cpu, "testaction=q", &addr);
2321                            add_environment_string(cpu, "haltaction=h", &addr);
2322                            add_environment_string(cpu, "more=24", &addr);
2323    
2324                            /*  Used in at least Ultrix on the 5100:  */
2325                            add_environment_string(cpu, "scsiid=7", &addr);
2326                            add_environment_string(cpu, "baud0=9600", &addr);
2327                            add_environment_string(cpu, "baud1=9600", &addr);
2328                            add_environment_string(cpu, "baud2=9600", &addr);
2329                            add_environment_string(cpu, "baud3=9600", &addr);
2330                            add_environment_string(cpu, "iooption=0x1", &addr);
2331    
2332                            /*  The end:  */
2333                            add_environment_string(cpu, "", &addr);
2334                    }
2335    
2336                  break;                  break;
2337    
# Line 2285  void machine_setup(struct machine *machi Line 2354  void machine_setup(struct machine *machi
2354    
2355                  /*  ISA interrupt controllers:  */                  /*  ISA interrupt controllers:  */
2356                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2357                  machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2358                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2359                  machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2360                  machine->md_interrupt = cobalt_interrupt;                  machine->md_interrupt = cobalt_interrupt;
2361    
2362                  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 2387  void machine_setup(struct machine *machi
2387                  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);
2388                  /*  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);  */
2389    
2390                  /*                  if (machine->prom_emulation) {
2391                   *  NetBSD/cobalt expects memsize in a0, but it seems that what                          /*
2392                   *  it really wants is the end of memory + 0x80000000.                           *  NetBSD/cobalt expects memsize in a0, but it seems that what
2393                   *                           *  it really wants is the end of memory + 0x80000000.
2394                   *  The bootstring is stored 512 bytes before the end of                           *
2395                   *  physical ram.                           *  The bootstring is stored 512 bytes before the end of
2396                   */                           *  physical ram.
2397                  cpu->cd.mips.gpr[MIPS_GPR_A0] =                           */
2398                      machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A0] =
2399                  bootstr = "root=/dev/hda1 ro";                              machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2400                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                          bootstr = "root=/dev/hda1 ro";
2401                  /*  TODO: bootarg, and/or automagic boot device detection  */                          /*  bootstr = "nfsroot=/usr/cobalt/";  */
2402                  store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);                          /*  TODO: bootarg, and/or automagic boot device detection  */
2403                            store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);
2404                    }
2405                  break;                  break;
2406    
2407          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
# Line 2609  void machine_setup(struct machine *machi Line 2680  void machine_setup(struct machine *machi
2680                          machine->main_console_handle =                          machine->main_console_handle =
2681                              machine->md_int.vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
2682    
2683                  /*  NetBSD/hpcmips and possibly others expects the following:  */                  if (machine->prom_emulation) {
2684                            /*  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  */  
2685    
2686                          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  */
2687                          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
2688                                + 0xffffffff80000000ULL - 512;      /*  argv  */
2689                            cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2690                                + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */
2691    
2692                            bootstr = machine->boot_kernel_filename;
2693                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512,
2694                                0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2695                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2696                            store_string(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2697    
2698                            /*  Special case for the Agenda VR3:  */
2699                            if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2700                                    const int tmplen = 1000;
2701                                    char *tmp = malloc(tmplen);
2702    
2703                                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */
2704    
2705                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2706                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2707    
2708                                    snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2709                                        "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2710                                    tmp[tmplen-1] = '\0';
2711    
2712                          snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"                                  if (!machine->use_x11)
2713                              "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2714                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2715    
2716                          if (!machine->use_x11)                                  if (machine->boot_string_argument[0])
2717                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2718                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2719    
2720                          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';  
2721    
2722                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  bootarg = tmp;
2723                            } else if (machine->boot_string_argument[0]) {
2724                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2725    
2726                          bootarg = tmp;                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2727                  } 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  */  
2728    
2729                          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,
2730                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                      machine->boot_string_argument);
2731    
2732                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,                                  bootarg = machine->boot_string_argument;
2733                              machine->boot_string_argument);                          }
2734    
2735                          bootarg = machine->boot_string_argument;                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2736                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2737                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);
2738                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);
2739                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);
2740                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);
2741                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);
2742                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */
2743    
2744                            /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);
2745                                printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */
2746                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2747                            store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2748                  }                  }
2749    
                 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));  
   
2750                  if (hpcmips_fb_addr != 0) {                  if (hpcmips_fb_addr != 0) {
2751                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,
2752                              hpcmips_fb_xsize, hpcmips_fb_ysize,                              hpcmips_fb_xsize, hpcmips_fb_ysize,
# Line 2716  void machine_setup(struct machine *machi Line 2790  void machine_setup(struct machine *machi
2790    
2791                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2792    
                 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);  
   
2793                  /*  Set the Harddisk controller present flag, if either                  /*  Set the Harddisk controller present flag, if either
2794                      disk 0 or 1 is present:  */                      disk 0 or 1 is present:  */
2795                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2796                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2797                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                          if (machine->prom_emulation)
2798                                    store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2799                          dev_ps2_spd_init(machine, mem, 0x14000000);                          dev_ps2_spd_init(machine, mem, 0x14000000);
2800                  }                  }
2801    
2802                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                  if (machine->prom_emulation) {
                 {  
2803                          int tmplen = 1000;                          int tmplen = 1000;
2804                          char *tmp = malloc(tmplen);                          char *tmp = malloc(tmplen);
2805                            time_t timet;
2806                            struct tm *tm_ptr;
2807    
2808                            add_symbol_name(&machine->symbol_context,
2809                                PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2810                            store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2811                            store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2812    
2813                            store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2814                          if (tmp == NULL) {                          if (tmp == NULL) {
2815                                  fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2816                                  exit(1);                                  exit(1);
# Line 2747  void machine_setup(struct machine *machi Line 2825  void machine_setup(struct machine *machi
2825    
2826                          bootstr = tmp;                          bootstr = tmp;
2827                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
                 }  
2828    
2829                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
                 {  
                         time_t timet;  
                         struct tm *tmp;  
2830    
2831                          /*  RTC data given by the BIOS:  */                          /*  RTC data given by the BIOS:  */
2832                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */
2833                          tmp = gmtime(&timet);                          tm_ptr = gmtime(&timet);
2834                          /*  TODO:  are these 0- or 1-based?  */                          /*  TODO:  are these 0- or 1-based?  */
2835                          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));
2836                          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));
2837                          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));
2838                          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));
2839                          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));
2840                          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));
                 }  
2841    
2842                  /*  "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.  */
2843                  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);
2844                    }
2845    
2846                  break;                  break;
2847    
# Line 3130  Why is this here? TODO Line 3204  Why is this here? TODO
3204                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
3205                                   */                                   */
3206    
 #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  
   
3207                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3208                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3209                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
# Line 3158  Why is this here? TODO Line 3225  Why is this here? TODO
3225                                  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",
3226                                      (1<<26) + MACE_PERIPH_SERIAL, 0);                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3227                                  device_add(machine, tmpstr);                                  device_add(machine, tmpstr);
3228  #if 0  
3229                                  if (machine->use_x11)                                  machine->main_console_handle = j;
3230    
3231                                    /*  TODO: Once this works, it should be enabled
3232                                        always, not just when using X!  */
3233                                    if (machine->use_x11) {
3234                                            i = dev_pckbc_init(machine, mem, 0x1f320000,
3235                                                PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
3236                                                0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
3237                                                    /*  keyb+mouse (mace irq numbers)  */
3238                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3239                                  else                                  }
 #endif  
                                         machine->main_console_handle = j;  
3240    
3241                                  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  */
3242                                  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 3495  Why is this here? TODO
3495    
3496  #if 0  #if 0
3497  Not yet.  Not yet.
3498                                  dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);                                  /*  irq = 8+16 + 14  */
3499                                    device_add(machine, "wdc addr=0x900001f0, irq=38");
3500  #endif  #endif
3501    
3502                                  break;                                  break;
# Line 3489  Not yet. Line 3563  Not yet.
3563                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3564    
3565  #if 0  #if 0
3566                                  dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);                                  /*  TODO: irq, etc  */
3567                                  dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);                                  device_add(machine, "wdc addr=0x9000001f0, irq=0");
3568                                    device_add(machine, "wdc addr=0x900000170, irq=0");
3569  #endif  #endif
3570                                  /*  PC kbd  */                                  /*  PC kbd  */
3571                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,
# Line 3524  Not yet. Line 3599  Not yet.
3599                   *  point.                   *  point.
3600                   */                   */
3601    
3602                  if (machine->prom_emulation)                  if (machine->prom_emulation) {
3603                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),
3604                              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?  
                  */  
3605    
3606                  /*                          /*
3607                   *  Boot string in ARC format:                           *  TODO: How to build the component tree intermixed with
3608                   *                           *  the rest of device initialization?
3609                   *  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';  
3610    
3611                  if (bootdev_id < 0 || machine->force_netboot) {                          /*
3612                          snprintf(init_bootpath, 400, "tftp()");                           *  Boot string in ARC format:
3613                  } else {                           *
3614                          /*  TODO: Make this nicer.  */                           *  TODO: How about floppies? multi()disk()fdisk()
3615                          if (machine->machine_type == MACHINE_SGI) {                           *        Is tftp() good for netbooting?
3616                                  if (machine->machine_subtype == 30)                           */
3617                                          strlcat(init_bootpath, "xio(0)pci(15)",                          init_bootpath = malloc(500);
3618                                              MACHINE_NAME_MAXBUF);                          if (init_bootpath == NULL) {
3619                                  if (machine->machine_subtype == 32)                                  fprintf(stderr, "out of mem, bootpath\n");
3620                                          strlcat(init_bootpath, "pci(0)",                                  exit(1);
                                             MACHINE_NAME_MAXBUF);  
3621                          }                          }
3622                            init_bootpath[0] = '\0';
3623    
3624                          if (diskimage_is_a_cdrom(machine, bootdev_id,                          if (bootdev_id < 0 || machine->force_netboot) {
3625                              bootdev_type))                                  snprintf(init_bootpath, 400, "tftp()");
3626                                  snprintf(init_bootpath + strlen(init_bootpath),                          } else {
3627                                      400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);                                  /*  TODO: Make this nicer.  */
3628                          else                                  if (machine->machine_type == MACHINE_SGI) {
3629                                  snprintf(init_bootpath + strlen(init_bootpath),                                          if (machine->machine_subtype == 30)
3630                                      400,"scsi(0)disk(%i)rdisk(0)partition(1)",                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3631                                      bootdev_id);                                                      MACHINE_NAME_MAXBUF);
3632                  }                                          if (machine->machine_subtype == 32)
3633                                                    strlcat(init_bootpath, "pci(0)",
3634                                                        MACHINE_NAME_MAXBUF);
3635                                    }
3636    
3637                                    if (diskimage_is_a_cdrom(machine, bootdev_id,
3638                                        bootdev_type))
3639                                            snprintf(init_bootpath + strlen(init_bootpath),
3640                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3641                                    else
3642                                            snprintf(init_bootpath + strlen(init_bootpath),
3643                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3644                                                bootdev_id);
3645                            }
3646    
3647                  if (machine->machine_type == MACHINE_ARC)                          if (machine->machine_type == MACHINE_ARC)
3648                          strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);                                  strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
3649    
3650                  bootstr = malloc(BOOTSTR_BUFLEN);                          bootstr = malloc(BOOTSTR_BUFLEN);
3651                  if (bootstr == NULL) {                          if (bootstr == NULL) {
3652                          fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
3653                          exit(1);                                  exit(1);
3654                  }                          }
3655                  strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);                          strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3656                  if (strlcat(bootstr, machine->boot_kernel_filename,                          if (strlcat(bootstr, machine->boot_kernel_filename,
3657                      BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {                              BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3658                          fprintf(stderr, "boot string too long?\n");                                  fprintf(stderr, "boot string too long?\n");
3659                          exit(1);                                  exit(1);
3660                  }                          }
3661    
3662                  /*  Boot args., eg "-a"  */                          /*  Boot args., eg "-a"  */
3663                  bootarg = machine->boot_string_argument;                          bootarg = machine->boot_string_argument;
3664    
3665                  /*  argc, argv, envp in a0, a1, a2:  */                          /*  argc, argv, envp in a0, a1, a2:  */
3666                  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  */
3667    
3668                  /*  TODO:  not needed?  */                          /*  TODO:  not needed?  */
3669                  cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3670                      (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3671    
3672                  /*  Set up argc/argv:  */                          /*  Set up argc/argv:  */
3673                  addr = ARC_ENV_STRINGS;                          addr = ARC_ENV_STRINGS;
3674                  addr2 = ARC_ARGV_START;                          addr2 = ARC_ARGV_START;
3675                  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] ++;  
3676    
3677                  /*  bootarg:  */                          /*  bootstr:  */
                 if (bootarg[0] != '\0') {  
3678                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3679                          add_environment_string(cpu, bootarg, &addr);                          add_environment_string(cpu, bootstr, &addr);
3680                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                 }  
3681    
3682                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                          /*  bootarg:  */
3683                            if (bootarg[0] != '\0') {
3684                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3685                                    add_environment_string(cpu, bootarg, &addr);
3686                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3687                            }
3688    
3689                  /*                          cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
3690                   *  Add environment variables.  For each variable, add it  
3691                   *  as a string using add_environment_string(), and add a                          /*
3692                   *  pointer to it to the ARC_ENV_POINTERS array.                           *  Add environment variables.  For each variable, add it
3693                   */                           *  as a string using add_environment_string(), and add a
3694                  if (machine->use_x11) {                           *  pointer to it to the ARC_ENV_POINTERS array.
3695                          if (machine->machine_type == MACHINE_ARC) {                           */
3696                            if (machine->use_x11) {
3697                                    if (machine->machine_type == MACHINE_ARC) {
3698                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3699                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3700                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3701                                            add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3702                                    } else {
3703                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3704                                            add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3705                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3706                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3707    
3708                                            /*  g for graphical mode. G for graphical mode
3709                                                with SGI logo visible on Irix?  */
3710                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3711                                            add_environment_string(cpu, "console=g", &addr);
3712                                    }
3713                            } else {
3714                                    if (machine->machine_type == MACHINE_ARC) {
3715                                            /*  TODO: serial console for ARC?  */
3716                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3717                                            add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3718                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3719                                            add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3720                                    } else {
3721                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3722                                            add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3723                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3724                                            add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3725    
3726                                            /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3727                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3728                                            add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
3729                                    }
3730                            }
3731    
3732                            if (machine->machine_type == MACHINE_SGI) {
3733                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3734                                  add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3735                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3736                                  add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "diskless=0", &addr);
                         } else {  
3737                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3738                                  add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);                                  add_environment_string(cpu, "volume=80", &addr);
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, "ConsoleOut=video()", &addr);                                  add_environment_string(cpu, "sgilogo=y", &addr);
3741    
                                 /*  g for graphical mode. G for graphical mode  
                                     with SGI logo visible on Irix?  */  
3742                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3743                                  add_environment_string(cpu, "console=g", &addr);                                  add_environment_string(cpu, "monitor=h", &addr);
                         }  
                 } else {  
                         if (machine->machine_type == MACHINE_ARC) {  
                                 /*  TODO: serial console for ARC?  */  
3744                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3745                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "TimeZone=GMT", &addr);
3746                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3747                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "nogfxkbd=1", &addr);
3748                          } else {  
3749                                    /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */
3750    
3751                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3752                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);
3753                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3754                                  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?  */  
3755                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3756                                  add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */                                  add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
3757                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3758                  }                                  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);  
3759    
3760                          /*  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));
3761                                    add_environment_string(cpu, "rbaud=9600", &addr);
3762                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3763                                    add_environment_string(cpu, "rebound=y", &addr);
3764                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3765                                    add_environment_string(cpu, "crt_option=1", &addr);
3766                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3767                                    add_environment_string(cpu, "netaddr=10.0.0.1", &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, "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);  
3771    
3772                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3773                          add_environment_string(cpu, "rbaud=9600", &addr);                                  add_environment_string(cpu, "cpufreq=3", &addr);
3774                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3775                          add_environment_string(cpu, "rebound=y", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
3776                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3777                          add_environment_string(cpu, "crt_option=1", &addr);                                  add_environment_string(cpu, eaddr_string, &addr);
3778                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3779                          add_environment_string(cpu, "netaddr=10.0.0.1", &addr);                                  add_environment_string(cpu, "verbose=istrue", &addr);
3780                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3781                                    add_environment_string(cpu, "showconfig=istrue", &addr);
3782                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3783                                    add_environment_string(cpu, "diagmode=v", &addr);
3784                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3785                                    add_environment_string(cpu, "kernname=unix", &addr);
3786                            } else {
3787                                    char *tmp;
3788                                    size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3789                                    tmp = malloc(mlen);
3790                                    snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3791                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3792                                    add_environment_string(cpu, tmp, &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, "keybd=US", &addr);                                  add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3796    
3797                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3798                          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);
3799                          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);  
3800    
3801                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  End the environment strings with an empty zero-terminated
3802                          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.  */
3803                            add_environment_string(cpu, "", &addr); /*  the end  */
3804                            store_pointer_and_advance(cpu, &addr2,
3805                                0, arc_wordlen==sizeof(uint64_t));
3806    
3807                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  Return address:  (0x20 = ReturnFromMain())  */
3808                          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;
3809                  }                  }
3810    
                 /*  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;  
   
3811                  break;                  break;
3812    
3813          case MACHINE_MESHCUBE:          case MACHINE_MESHCUBE:
# Line 3765  no_arc_prom_emulation:         /*  TODO: ugly, Line 3837  no_arc_prom_emulation:         /*  TODO: ugly,
3837    
3838                  device_add(machine, "random addr=0x1017fffc len=4");                  device_add(machine, "random addr=0x1017fffc len=4");
3839    
3840                  /*                  if (machine->prom_emulation) {
3841                   *  TODO:  A Linux kernel wants "memsize" from somewhere... I                          /*
3842                   *  haven't found any docs on how it is used though.                           *  TODO:  A Linux kernel wants "memsize" from somewhere... I
3843                   */                           *  haven't found any docs on how it is used though.
3844                             */
3845                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
3846                  cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
3847                  store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
3848                      0xa0002000ULL);                              0xa0002000ULL);
3849                  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");  
3850    
3851                            cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
3852                            store_string(cpu, 0xa0002000ULL, "hello=world\n");
3853                    }
3854                  break;                  break;
3855    
3856          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
3857                  machine->machine_name = "NetGear WG602";                  machine->machine_name = "NetGear WG602v1";
3858    
3859                  if (machine->use_x11)                  if (machine->use_x11)
3860                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
3861                  if (machine->physical_ram_in_mb != 16)                  if (machine->physical_ram_in_mb != 16)
3862                          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");
3863    
3864                  /*                  /*
3865                   *  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 3892  no_arc_prom_emulation:         /*  TODO: ugly,
3892                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
3893                  machine->machine_name = "Sony NeWS (NET WORK STATION)";                  machine->machine_name = "Sony NeWS (NET WORK STATION)";
3894    
3895                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3896                  {                          /*  This is just a test.  TODO  */
3897                          int i;                          int i;
3898                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
3899                                  cpu->cd.mips.gpr[i] =                                  cpu->cd.mips.gpr[i] =
# Line 3850  no_arc_prom_emulation:         /*  TODO: ugly, Line 3922  no_arc_prom_emulation:         /*  TODO: ugly,
3922    
3923                          /*  ISA interrupt controllers:  */                          /*  ISA interrupt controllers:  */
3924                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");
3925                          machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
3926                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");
3927                          machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
3928                          machine->md_interrupt = malta_interrupt;                          machine->md_interrupt = malta_interrupt;
3929    
3930                          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 4155  no_arc_prom_emulation:         /*  TODO: ugly,
4155                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");
4156                  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");
4157    
4158                    dev_pckbc_init(machine, mem, 0x80000060, PCKBC_8042,
4159                        1, 12, machine->use_x11, 1);
4160    
4161                  if (machine->use_x11)                  if (machine->use_x11)
4162                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,
4163                              machine->machine_name);                              machine->machine_name);
4164    
4165                  store_32bit_word(cpu, 0x3010,                  if (machine->prom_emulation) {
4166                      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);  
4167    
4168                            /*  TODO: List of stuff, see http://www.beatjapan.org/
4169                                mirror/www.be.com/aboutbe/benewsletter/
4170                                Issue27.html#Cookbook  for the details.  */
4171                            store_32bit_word(cpu, 0x301c, 0);
4172    
4173                            /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4174                                r5 = args, r6 = ptr to bootinfo?  */
4175                            cpu->cd.ppc.gpr[3] = 0x3100;
4176                            cpu->cd.ppc.gpr[4] = 0x200000;
4177                            cpu->cd.ppc.gpr[5] = 0x2000;
4178                            store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4179                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4180    
4181                            /*  See NetBSD's bebox/include/bootinfo.h for details  */
4182                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */
4183                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4184                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4185                                machine->physical_ram_in_mb * 1048576);
4186    
4187                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */
4188                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4189                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4190                                machine->use_x11? "vga" : "com", 4);
4191                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4192                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4193    
4194                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4195                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */
4196                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4197                    }
4198                  break;                  break;
4199    
4200          case MACHINE_PREP:          case MACHINE_PREP:
# Line 4129  no_arc_prom_emulation:         /*  TODO: ugly, Line 4203  no_arc_prom_emulation:         /*  TODO: ugly,
4203                   */                   */
4204                  machine->machine_name = "PowerPC Reference Platform";                  machine->machine_name = "PowerPC Reference Platform";
4205    
4206                  {                  if (machine->prom_emulation) {
4207                          int i;                          /*  Linux on PReP has 0xdeadc0de at address 0? (See
4208                          for (i=0; i<32; i++)                              http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */
4209                                  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;  
4210    
4211                            /*  r6 should point to "residual data"?  */
4212                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x1000;
4213                    }
4214                  break;                  break;
4215    
4216          case MACHINE_MACPPC:          case MACHINE_MACPPC:
# Line 4153  no_arc_prom_emulation:         /*  TODO: ugly, Line 4220  no_arc_prom_emulation:         /*  TODO: ugly,
4220                   */                   */
4221                  machine->machine_name = "Macintosh (PPC)";                  machine->machine_name = "Macintosh (PPC)";
4222    
4223                  /*  r5 = OpenFirmware entry point  */                  if (machine->prom_emulation) {
4224                  cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;                          uint64_t b = 8 * 1048576, a = b - 0x800;
4225                            int i;
4226                            /*
4227                             *  r3 = pointer to boot_args (for the Mach kernel).
4228                             *  See http://darwinsource.opendarwin.org/10.3/
4229                             *  BootX-59/bootx.tproj/include.subproj/boot_args.h
4230                             *  for more info.
4231                             */
4232                            cpu->cd.ppc.gpr[3] = a;
4233                            store_16bit_word(cpu, a + 0x0000, 1);   /*  revision  */
4234                            store_16bit_word(cpu, a + 0x0002, 2);   /*  version  */
4235                            store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
4236                            /*  26 dram banks; "long base; long size"  */
4237                            store_32bit_word(cpu, a + 0x0104, 0);   /*  base  */
4238                            store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
4239                                * 256);             /*  size (in pages)  */
4240                            for (i=8; i<26*8; i+= 4)
4241                                    store_32bit_word(cpu, a + 0x0104 + i, 0);
4242                            a += (0x104 + 26 * 8);
4243                            /*  Video info:  */
4244                            store_32bit_word(cpu, a+0, 0xd0000000); /*  video base  */
4245                            store_32bit_word(cpu, a+4, 0);          /*  display code (?)  */
4246                            store_32bit_word(cpu, a+8, 800);        /*  bytes per pixel row  */
4247                            store_32bit_word(cpu, a+12, 800);       /*  width  */
4248                            store_32bit_word(cpu, a+16, 600);       /*  height  */
4249                            store_32bit_word(cpu, a+20, 8);         /*  pixel depth  */
4250                            a += 24;
4251                            store_32bit_word(cpu, a+0, 127);        /*  gestalt number (TODO)  */
4252                            store_32bit_word(cpu, a+4, 0);          /*  device tree pointer (TODO)  */
4253                            store_32bit_word(cpu, a+8, 0);          /*  device tree length  */
4254                            store_32bit_word(cpu, a+12, b);         /*  last address of kernel data area  */
4255    
4256                            /*  r4 = "MOSX" (0x4D4F5358)  */
4257                            cpu->cd.ppc.gpr[4] = 0x4D4F5358;
4258    
4259                            /*
4260                             *  r5 = OpenFirmware entry point.  NOTE: See
4261                             *  cpu_ppc.c for the rest of this semi-ugly hack.
4262                             */
4263                            dev_ram_init(cpu->mem, cpu->cd.ppc.of_emul_addr,
4264                                0x1000, DEV_RAM_RAM, 0x0);
4265                            store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
4266                                0x44ee0002);
4267                            cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4268                    }
4269                  break;                  break;
4270    
4271          case MACHINE_DB64360:          case MACHINE_DB64360:
4272                  /*  For playing with PMON2000 for PPC:  */                  /*  For playing with PMON2000 for PPC:  */
4273                  machine->machine_name = "DB64360";                  machine->machine_name = "DB64360";
4274    
4275                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0x1d000020");                  machine->main_console_handle = (size_t)device_add(machine,
4276                        "ns16550 irq=0 addr=0x1d000020 addr_mult=4");
4277    
4278                  {                  if (machine->prom_emulation) {
4279                          int i;                          int i;
4280                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
4281                                  cpu->cd.ppc.gpr[i] =                                  cpu->cd.ppc.gpr[i] =
# Line 4174  no_arc_prom_emulation:         /*  TODO: ugly, Line 4285  no_arc_prom_emulation:         /*  TODO: ugly,
4285                  break;                  break;
4286  #endif  /*  ENABLE_PPC  */  #endif  /*  ENABLE_PPC  */
4287    
4288    #ifdef ENABLE_SH
4289            case MACHINE_BARESH:
4290                    /*  A bare SH machine, with no devices.  */
4291                    machine->machine_name = "\"Bare\" SH machine";
4292                    break;
4293    
4294            case MACHINE_TESTSH:
4295                    machine->machine_name = "SH test machine";
4296    
4297                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4298                        (long long)DEV_CONS_ADDRESS);
4299                    cons_data = device_add(machine, tmpstr);
4300                    machine->main_console_handle = cons_data->console_handle;
4301    
4302                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4303                        (long long)DEV_MP_ADDRESS);
4304                    device_add(machine, tmpstr);
4305    
4306                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4307                        640,480, 640,480, 24, "testsh generic");
4308    
4309                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4310                        (long long)DEV_DISK_ADDRESS);
4311                    device_add(machine, tmpstr);
4312    
4313                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4314                        (long long)DEV_ETHER_ADDRESS);
4315                    device_add(machine, tmpstr);
4316    
4317                    break;
4318    
4319            case MACHINE_HPCSH:
4320                    /*  Handheld SH-based machines:  */
4321                    machine->machine_name = "HPCsh";
4322    
4323                    /*  TODO  */
4324    
4325                    break;
4326    #endif  /*  ENABLE_SH  */
4327    
4328    #ifdef ENABLE_HPPA
4329            case MACHINE_BAREHPPA:
4330                    /*  A bare HPPA machine, with no devices.  */
4331                    machine->machine_name = "\"Bare\" HPPA machine";
4332                    break;
4333    
4334            case MACHINE_TESTHPPA:
4335                    machine->machine_name = "HPPA test machine";
4336    
4337                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4338                        (long long)DEV_CONS_ADDRESS);
4339                    cons_data = device_add(machine, tmpstr);
4340                    machine->main_console_handle = cons_data->console_handle;
4341    
4342                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4343                        (long long)DEV_MP_ADDRESS);
4344                    device_add(machine, tmpstr);
4345    
4346                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4347                        640,480, 640,480, 24, "testhppa generic");
4348    
4349                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4350                        (long long)DEV_DISK_ADDRESS);
4351                    device_add(machine, tmpstr);
4352    
4353                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4354                        (long long)DEV_ETHER_ADDRESS);
4355                    device_add(machine, tmpstr);
4356    
4357                    break;
4358    #endif  /*  ENABLE_HPPA  */
4359    
4360    #ifdef ENABLE_I960
4361            case MACHINE_BAREI960:
4362                    /*  A bare I960 machine, with no devices.  */
4363                    machine->machine_name = "\"Bare\" i960 machine";
4364                    break;
4365    
4366            case MACHINE_TESTI960:
4367                    machine->machine_name = "i960 test machine";
4368    
4369                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4370                        (long long)DEV_CONS_ADDRESS);
4371                    cons_data = device_add(machine, tmpstr);
4372                    machine->main_console_handle = cons_data->console_handle;
4373    
4374                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4375                        (long long)DEV_MP_ADDRESS);
4376                    device_add(machine, tmpstr);
4377    
4378                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4379                        640,480, 640,480, 24, "testi960 generic");
4380    
4381                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4382                        (long long)DEV_DISK_ADDRESS);
4383                    device_add(machine, tmpstr);
4384    
4385                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4386                        (long long)DEV_ETHER_ADDRESS);
4387                    device_add(machine, tmpstr);
4388    
4389                    break;
4390    #endif  /*  ENABLE_I960  */
4391    
4392  #ifdef ENABLE_SPARC  #ifdef ENABLE_SPARC
4393          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
4394                  /*  A bare SPARC machine, with no devices.  */                  /*  A bare SPARC machine, with no devices.  */
# Line 4245  no_arc_prom_emulation:         /*  TODO: ugly, Line 4460  no_arc_prom_emulation:         /*  TODO: ugly,
4460                  break;                  break;
4461    
4462          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;  
   
4463                  if (machine->prom_emulation) {                  if (machine->prom_emulation) {
4464                          struct rpb rpb;                          struct rpb rpb;
4465                          struct crb crb;                          struct crb crb;
4466                          struct ctb ctb;                          struct ctb ctb;
4467    
4468                            /*  TODO:  Most of these... They are used by NetBSD/alpha:  */
4469                            /*  a0 = First free Page Frame Number  */
4470                            /*  a1 = PFN of current Level 1 page table  */
4471                            /*  a2 = Bootinfo magic  */
4472                            /*  a3 = Bootinfo pointer  */
4473                            /*  a4 = Bootinfo version  */
4474                            cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
4475                            cpu->cd.alpha.r[ALPHA_A1] = 0;
4476                            cpu->cd.alpha.r[ALPHA_A2] = 0;
4477                            cpu->cd.alpha.r[ALPHA_A3] = 0;
4478                            cpu->cd.alpha.r[ALPHA_A4] = 0;
4479    
4480                          /*  HWRPB: Hardware Restart Parameter Block  */                          /*  HWRPB: Hardware Restart Parameter Block  */
4481                          memset(&rpb, 0, sizeof(struct rpb));                          memset(&rpb, 0, sizeof(struct rpb));
4482                          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 4521  no_arc_prom_emulation:         /*  TODO: ugly,
4521                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
4522                  case ST_DEC_3000_300:                  case ST_DEC_3000_300:
4523                          machine->machine_name = "DEC 3000/300";                          machine->machine_name = "DEC 3000/300";
4524                            machine->main_console_handle =
4525                                dev_zs_init(machine, mem, 0x1b0200000ULL,
4526                                0, 4, "serial zs"); /*  serial? netbsd?  */
4527                            break;
4528                    case ST_EB164:
4529                            machine->machine_name = "EB164";
4530                          break;                          break;
4531                  default:fatal("Unimplemented Alpha machine type %i\n",                  default:fatal("Unimplemented Alpha machine type %i\n",
4532                              machine->machine_subtype);                              machine->machine_subtype);
# Line 4353  no_arc_prom_emulation:         /*  TODO: ugly, Line 4574  no_arc_prom_emulation:         /*  TODO: ugly,
4574                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4575                      0xeafffffe);                      0xeafffffe);
4576                  break;                  break;
4577    
4578            case MACHINE_CATS:
4579                    machine->machine_name = "CATS evaluation board";
4580    
4581                    if (machine->emulated_hz == 0)
4582                            machine->emulated_hz = 50000000;
4583    
4584                    if (machine->physical_ram_in_mb > 256)
4585                            fprintf(stderr, "WARNING! Real CATS machines cannot"
4586                                " have more than 256 MB RAM. Continuing anyway.\n");
4587    
4588                    machine->md_int.footbridge_data =
4589                        device_add(machine, "footbridge addr=0x42000000");
4590                    machine->md_interrupt = footbridge_interrupt;
4591    
4592                    /*  NetBSD and OpenBSD clean their caches here:  */
4593                    dev_ram_init(mem, 0x50000000, 0x4000, DEV_RAM_RAM, 0);
4594    
4595                    /*  Interrupt ack space?  */
4596                    dev_ram_init(mem, 0x80000000, 0x1000, DEV_RAM_RAM, 0);
4597    
4598                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4599                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4600                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4601                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4602    
4603                    device_add(machine, "pccmos addr=0x7c000070");
4604    
4605                    if (machine->use_x11) {
4606                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4607                                mem, 0xc0, 8, 0, pci_s3_virge_init, pci_s3_virge_rr);
4608                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4609                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4610                                32 + 1, 32 + 12, machine->use_x11, 0);
4611                            machine->main_console_handle = j;
4612                    }
4613    
4614                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0 in_use=0");
4615                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1 in_use=0");
4616    
4617                    device_add(machine, "lpt irq=39 addr=0x7c000378 name2=lpt in_use=0");
4618    
4619                    if (machine->prom_emulation) {
4620                            struct ebsaboot ebsaboot;
4621                            char bs[300];
4622                            int boot_id = bootdev_id >= 0? bootdev_id : 0;
4623    
4624                            cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
4625                                7 * 1048576 - 0x1000;
4626    
4627                            memset(&ebsaboot, 0, sizeof(struct ebsaboot));
4628                            store_32bit_word_in_host(cpu, (unsigned char *)
4629                                &(ebsaboot.bt_magic), BT_MAGIC_NUMBER_CATS);
4630                            store_32bit_word_in_host(cpu, (unsigned char *)
4631                                &(ebsaboot.bt_vargp), 0);
4632                            store_32bit_word_in_host(cpu, (unsigned char *)
4633                                &(ebsaboot.bt_pargp), 0);
4634                            store_32bit_word_in_host(cpu, (unsigned char *)
4635                                &(ebsaboot.bt_args), cpu->cd.arm.r[0]
4636                                + sizeof(struct ebsaboot));
4637                            store_32bit_word_in_host(cpu, (unsigned char *)
4638                                &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
4639                            store_32bit_word_in_host(cpu, (unsigned char *)
4640                                &(ebsaboot.bt_memstart), 0);
4641                            store_32bit_word_in_host(cpu, (unsigned char *)
4642                                &(ebsaboot.bt_memend),
4643                                machine->physical_ram_in_mb * 1048576);
4644                            store_32bit_word_in_host(cpu, (unsigned char *)
4645                                &(ebsaboot.bt_memavail), 7 * 1048576);
4646                            store_32bit_word_in_host(cpu, (unsigned char *)
4647                                &(ebsaboot.bt_fclk), 50 * 1000000);
4648                            store_32bit_word_in_host(cpu, (unsigned char *)
4649                                &(ebsaboot.bt_pciclk), 66 * 1000000);
4650                            /*  TODO: bt_vers  */
4651                            /*  TODO: bt_features  */
4652    
4653                            store_buf(cpu, cpu->cd.arm.r[0],
4654                                (char *)&ebsaboot, sizeof(struct ebsaboot));
4655    
4656                            snprintf(bs, sizeof(bs), "(hd%i)%s%s%s",
4657                                boot_id, machine->boot_kernel_filename,
4658                                (machine->boot_string_argument[0])? " " : "",
4659                                machine->boot_string_argument);
4660    
4661                            store_string(cpu, cpu->cd.arm.r[0] +
4662                                sizeof(struct ebsaboot), bs);
4663    
4664                            arm_setup_initial_translation_table(cpu,
4665                                7 * 1048576 - 32768);
4666                    }
4667                    break;
4668    
4669            case MACHINE_HPCARM:
4670                    machine->machine_name = "HPCarm";
4671                    dev_ram_init(mem, 0xc0000000, 0x10000000, DEV_RAM_MIRROR, 0x0);
4672    
4673                    /*  TODO: Different models  */
4674    
4675                    if (machine->prom_emulation) {
4676                            cpu->cd.arm.r[0] = 1;
4677                            cpu->cd.arm.r[ARM_SP] = 0xc000c000;
4678                    }
4679                    break;
4680    
4681            case MACHINE_ZAURUS:
4682                    machine->machine_name = "Zaurus";
4683                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4684                    device_add(machine, "ns16550 irq=0 addr=0x40100000 addr_mult=4");
4685                    /*  TODO  */
4686                    if (machine->prom_emulation) {
4687                            arm_setup_initial_translation_table(cpu, 0x4000);
4688                    }
4689                    break;
4690    
4691            case MACHINE_NETWINDER:
4692                    machine->machine_name = "NetWinder";
4693    
4694                    if (machine->physical_ram_in_mb > 256)
4695                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4696                                " have more than 256 MB RAM. Continuing anyway.\n");
4697    
4698                    machine->md_int.footbridge_data =
4699                        device_add(machine, "footbridge addr=0x42000000");
4700                    machine->md_interrupt = footbridge_interrupt;
4701    
4702                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4703                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4704                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4705                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4706    
4707                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4708                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4709    
4710                    if (machine->use_x11) {
4711                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4712                                mem, 0xc0, 8, 0, pci_igsfb_init, pci_igsfb_rr);
4713                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4714                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4715                                32 + 1, 32 + 12, machine->use_x11, 0);
4716                            machine->main_console_handle = j;
4717                    }
4718    
4719                    if (machine->prom_emulation) {
4720                            arm_setup_initial_translation_table(cpu, 0x4000);
4721                    }
4722                    break;
4723    
4724            case MACHINE_SHARK:
4725                    machine->machine_name = "Digital DNARD (\"Shark\")";
4726                    if (machine->prom_emulation) {
4727                            arm_setup_initial_translation_table(cpu,
4728                                machine->physical_ram_in_mb * 1048576 - 65536);
4729    
4730                            /*
4731                             *  r0 = OpenFirmware entry point.  NOTE: See
4732                             *  cpu_arm.c for the rest of this semi-ugly hack.
4733                             */
4734                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4735                    }
4736                    break;
4737    
4738            case MACHINE_IQ80321:
4739                    /*
4740                     *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4741                     *  for more details about the memory map.
4742                     */
4743                    machine->machine_name = "Intel IQ80321 (ARM)";
4744                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4745                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4746                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4747                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4748                    dev_ram_init(mem, 0xc0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4749                    if (machine->prom_emulation) {
4750                            arm_setup_initial_translation_table(cpu, 0x8000);
4751                    }
4752                    break;
4753    
4754            case MACHINE_IYONIX:
4755                    machine->machine_name = "Iyonix";
4756                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4757                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4758                    if (machine->prom_emulation) {
4759                            arm_setup_initial_translation_table(cpu,
4760                                machine->physical_ram_in_mb * 1048576 - 65536);
4761                    }
4762                    break;
4763  #endif  /*  ENABLE_ARM  */  #endif  /*  ENABLE_ARM  */
4764    
4765    #ifdef ENABLE_AVR
4766            case MACHINE_BAREAVR:
4767                    /*  A bare Atmel AVR machine, with no devices.  */
4768                    machine->machine_name = "\"Bare\" Atmel AVR machine";
4769                    break;
4770    #endif  /*  ENABLE_AVR  */
4771    
4772  #ifdef ENABLE_IA64  #ifdef ENABLE_IA64
4773          case MACHINE_BAREIA64:          case MACHINE_BAREIA64:
4774                  machine->machine_name = "\"Bare\" IA64 machine";                  machine->machine_name = "\"Bare\" IA64 machine";
# Line 4431  no_arc_prom_emulation:         /*  TODO: ugly, Line 4845  no_arc_prom_emulation:         /*  TODO: ugly,
4845                  /*  Interrupt controllers:  */                  /*  Interrupt controllers:  */
4846                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",
4847                      (long long)(X86_IO_BASE + 0x20));                      (long long)(X86_IO_BASE + 0x20));
4848                  machine->md.pc.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4849                  if (machine->machine_subtype != MACHINE_X86_XT) {                  if (machine->machine_subtype != MACHINE_X86_XT) {
4850                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",
4851                              (long long)(X86_IO_BASE + 0xa0));                              (long long)(X86_IO_BASE + 0xa0));
4852                          machine->md.pc.pic2 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4853                  }                  }
4854    
4855                  machine->md_interrupt = x86_pc_interrupt;                  machine->md_interrupt = x86_pc_interrupt;
# Line 4453  no_arc_prom_emulation:         /*  TODO: ugly, Line 4867  no_arc_prom_emulation:         /*  TODO: ugly,
4867    
4868                  /*  IDE controllers:  */                  /*  IDE controllers:  */
4869                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
4870                      diskimage_exist(machine, 1, DISKIMAGE_IDE))                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
4871                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x1f0, 14, 0);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4872                                X86_IO_BASE + 0x1f0, 14);
4873                            device_add(machine, tmpstr);
4874                    }
4875                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||
4876                      diskimage_exist(machine, 3, DISKIMAGE_IDE))                      diskimage_exist(machine, 3, DISKIMAGE_IDE)) {
4877                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x170, 15, 2);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4878                                X86_IO_BASE + 0x170, 15);
4879                            device_add(machine, tmpstr);
4880                    }
4881    
4882                  /*  Floppy controller at irq 6  */                  /*  Floppy controller at irq 6  */
4883                  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 5022  void machine_memsize_fix(struct machine
5022                  case MACHINE_BEBOX:                  case MACHINE_BEBOX:
5023                          m->physical_ram_in_mb = 64;                          m->physical_ram_in_mb = 64;
5024                          break;                          break;
5025                    case MACHINE_CATS:
5026                            m->physical_ram_in_mb = 64;
5027                            break;
5028                    case MACHINE_ZAURUS:
5029                            m->physical_ram_in_mb = 64;
5030                            break;
5031                    case MACHINE_HPCARM:
5032                            m->physical_ram_in_mb = 32;
5033                            break;
5034                    case MACHINE_NETWINDER:
5035                            m->physical_ram_in_mb = 16;
5036                            break;
5037                  case MACHINE_X86:                  case MACHINE_X86:
5038                          if (m->machine_subtype == MACHINE_X86_XT)                          if (m->machine_subtype == MACHINE_X86_XT)
5039                                  m->physical_ram_in_mb = 1;                                  m->physical_ram_in_mb = 1;
# Line 4787  void machine_default_cputype(struct mach Line 5219  void machine_default_cputype(struct mach
5219          case MACHINE_MACPPC:          case MACHINE_MACPPC:
5220                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5221                  case MACHINE_MACPPC_G4:                  case MACHINE_MACPPC_G4:
5222                          m->cpu_name = strdup("G4e");                          m->cpu_name = strdup("PPC750");
5223                          break;                          break;
5224                  case MACHINE_MACPPC_G5:                  case MACHINE_MACPPC_G5:
5225                          m->cpu_name = strdup("PPC970");                          m->cpu_name = strdup("PPC970");
# Line 4798  void machine_default_cputype(struct mach Line 5230  void machine_default_cputype(struct mach
5230                  m->cpu_name = strdup("PPC750");                  m->cpu_name = strdup("PPC750");
5231                  break;                  break;
5232    
5233            /*  SH:  */
5234            case MACHINE_BARESH:
5235            case MACHINE_TESTSH:
5236            case MACHINE_HPCSH:
5237                    m->cpu_name = strdup("SH");
5238                    break;
5239    
5240            /*  HPPA:  */
5241            case MACHINE_BAREHPPA:
5242            case MACHINE_TESTHPPA:
5243                    m->cpu_name = strdup("HPPA");
5244                    break;
5245    
5246            /*  i960:  */
5247            case MACHINE_BAREI960:
5248            case MACHINE_TESTI960:
5249                    m->cpu_name = strdup("i960");
5250                    break;
5251    
5252          /*  SPARC:  */          /*  SPARC:  */
5253          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
5254          case MACHINE_TESTSPARC:          case MACHINE_TESTSPARC:
# Line 4815  void machine_default_cputype(struct mach Line 5266  void machine_default_cputype(struct mach
5266          /*  ARM:  */          /*  ARM:  */
5267          case MACHINE_BAREARM:          case MACHINE_BAREARM:
5268          case MACHINE_TESTARM:          case MACHINE_TESTARM:
5269                  m->cpu_name = strdup("ARM");          case MACHINE_HPCARM:
5270                    m->cpu_name = strdup("SA1110");
5271                    break;
5272            case MACHINE_IQ80321:
5273            case MACHINE_IYONIX:
5274                    m->cpu_name = strdup("80321_600_B0");
5275                    break;
5276            case MACHINE_CATS:
5277            case MACHINE_NETWINDER:
5278            case MACHINE_SHARK:
5279                    m->cpu_name = strdup("SA110");
5280                    break;
5281            case MACHINE_ZAURUS:
5282                    m->cpu_name = strdup("PXA210");
5283                    break;
5284    
5285            /*  AVR:  */
5286            case MACHINE_BAREAVR:
5287                    m->cpu_name = strdup("AVR");
5288                  break;                  break;
5289    
5290          /*  IA64:  */          /*  IA64:  */
# Line 5090  void machine_init(void) Line 5559  void machine_init(void)
5559           *  entries will appear in normal order when listed.  :-)           *  entries will appear in normal order when listed.  :-)
5560           */           */
5561    
5562            /*  Zaurus:  */
5563            me = machine_entry_new("Zaurus (ARM)",
5564                ARCH_ARM, MACHINE_ZAURUS, 1, 0);
5565            me->aliases[0] = "zaurus";
5566            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5567                    me->next = first_machine_entry; first_machine_entry = me;
5568            }
5569    
5570          /*  X86 machine:  */          /*  X86 machine:  */
5571          me = machine_entry_new("x86-based PC", ARCH_X86,          me = machine_entry_new("x86-based PC", ARCH_X86,
5572              MACHINE_X86, 2, 2);              MACHINE_X86, 2, 2);
# Line 5121  void machine_init(void) Line 5598  void machine_init(void)
5598                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5599          }          }
5600    
5601            /*  Test-machine for SH:  */
5602            me = machine_entry_new("Test-machine for SH", ARCH_SH,
5603                MACHINE_TESTSH, 1, 0);
5604            me->aliases[0] = "testsh";
5605            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5606                    me->next = first_machine_entry; first_machine_entry = me;
5607            }
5608    
5609          /*  Test-machine for PPC:  */          /*  Test-machine for PPC:  */
5610          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,
5611              MACHINE_TESTPPC, 1, 0);              MACHINE_TESTPPC, 1, 0);
# Line 5153  void machine_init(void) Line 5638  void machine_init(void)
5638                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5639          }          }
5640    
5641            /*  Test-machine for i960:  */
5642            me = machine_entry_new("Test-machine for i960", ARCH_I960,
5643                MACHINE_TESTI960, 1, 0);
5644            me->aliases[0] = "testi960";
5645            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5646                    me->next = first_machine_entry; first_machine_entry = me;
5647            }
5648    
5649            /*  Test-machine for HPPA:  */
5650            me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5651                MACHINE_TESTHPPA, 1, 0);
5652            me->aliases[0] = "testhppa";
5653            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5654                    me->next = first_machine_entry; first_machine_entry = me;
5655            }
5656    
5657          /*  Test-machine for ARM:  */          /*  Test-machine for ARM:  */
5658          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,
5659              MACHINE_TESTARM, 1, 0);              MACHINE_TESTARM, 1, 0);
# Line 5243  void machine_init(void) Line 5744  void machine_init(void)
5744                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5745          }          }
5746    
5747            /*  NetWinder:  */
5748            me = machine_entry_new("NetWinder", ARCH_ARM, MACHINE_NETWINDER, 1, 0);
5749            me->aliases[0] = "netwinder";
5750            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5751                    me->next = first_machine_entry; first_machine_entry = me;
5752            }
5753    
5754          /*  NetGear:  */          /*  NetGear:  */
5755          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602v1", ARCH_MIPS,
5756              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);
5757          me->aliases[0] = "netgear";          me->aliases[0] = "netgear";
5758          me->aliases[1] = "wg602";          me->aliases[1] = "wg602v1";
5759          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5760                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5761          }          }
# Line 5281  void machine_init(void) Line 5789  void machine_init(void)
5789                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5790          }          }
5791    
5792            /*  Iyonix:  */
5793            me = machine_entry_new("Iyonix", ARCH_ARM,
5794                MACHINE_IYONIX, 1, 0);
5795            me->aliases[0] = "iyonix";
5796            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5797                    me->next = first_machine_entry; first_machine_entry = me;
5798            }
5799    
5800            /*  Intel IQ80321 (ARM):  */
5801            me = machine_entry_new("Intel IQ80321 (ARM)", ARCH_ARM,
5802                MACHINE_IQ80321, 1, 0);
5803            me->aliases[0] = "iq80321";
5804            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5805                    me->next = first_machine_entry; first_machine_entry = me;
5806            }
5807    
5808            /*  HPCarm:  */
5809            me = machine_entry_new("Handheld SH (HPCsh)",
5810                ARCH_SH, MACHINE_HPCSH, 1, 2);
5811            me->aliases[0] = "hpcsh";
5812            me->subtype[0] = machine_entry_subtype_new("Jornada 680",
5813                MACHINE_HPCSH_JORNADA680, 1);
5814            me->subtype[0]->aliases[0] = "jornada680";
5815            me->subtype[1] = machine_entry_subtype_new(
5816                "Jornada 690", MACHINE_HPCSH_JORNADA690, 1);
5817            me->subtype[1]->aliases[0] = "jornada690";
5818            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5819                    me->next = first_machine_entry; first_machine_entry = me;
5820            }
5821    
5822          /*  HPCmips:  */          /*  HPCmips:  */
5823          me = machine_entry_new("Handheld MIPS (HPCmips)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
5824              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
# Line 5317  void machine_init(void) Line 5855  void machine_init(void)
5855                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5856          }          }
5857    
5858            /*  HPCarm:  */
5859            me = machine_entry_new("Handheld ARM (HPCarm)",
5860                ARCH_ARM, MACHINE_HPCARM, 1, 2);
5861            me->aliases[0] = "hpcarm";
5862            me->subtype[0] = machine_entry_subtype_new("Ipaq",
5863                MACHINE_HPCARM_IPAQ, 1);
5864            me->subtype[0]->aliases[0] = "ipaq";
5865            me->subtype[1] = machine_entry_subtype_new(
5866                "Jornada 720", MACHINE_HPCARM_JORNADA720, 1);
5867            me->subtype[1]->aliases[0] = "jornada720";
5868            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5869                    me->next = first_machine_entry; first_machine_entry = me;
5870            }
5871    
5872          /*  Generic "bare" X86 machine:  */          /*  Generic "bare" X86 machine:  */
5873          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
5874              MACHINE_BAREX86, 1, 0);              MACHINE_BAREX86, 1, 0);
# Line 5333  void machine_init(void) Line 5885  void machine_init(void)
5885                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5886          }          }
5887    
5888            /*  Generic "bare" SH machine:  */
5889            me = machine_entry_new("Generic \"bare\" SH machine", ARCH_SH,
5890                MACHINE_BARESH, 1, 0);
5891            me->aliases[0] = "baresh";
5892            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5893                    me->next = first_machine_entry; first_machine_entry = me;
5894            }
5895    
5896          /*  Generic "bare" PPC machine:  */          /*  Generic "bare" PPC machine:  */
5897          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
5898              MACHINE_BAREPPC, 1, 0);              MACHINE_BAREPPC, 1, 0);
# Line 5365  void machine_init(void) Line 5925  void machine_init(void)
5925                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5926          }          }
5927    
5928            /*  Generic "bare" i960 machine:  */
5929            me = machine_entry_new("Generic \"bare\" i960 machine", ARCH_I960,
5930                MACHINE_BAREI960, 1, 0);
5931            me->aliases[0] = "barei960";
5932            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5933                    me->next = first_machine_entry; first_machine_entry = me;
5934            }
5935    
5936            /*  Generic "bare" HPPA machine:  */
5937            me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
5938                MACHINE_BAREHPPA, 1, 0);
5939            me->aliases[0] = "barehppa";
5940            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5941                    me->next = first_machine_entry; first_machine_entry = me;
5942            }
5943    
5944            /*  Generic "bare" Atmel AVR machine:  */
5945            me = machine_entry_new("Generic \"bare\" Atmel AVR machine", ARCH_AVR,
5946                MACHINE_BAREAVR, 1, 0);
5947            me->aliases[0] = "bareavr";
5948            if (cpu_family_ptr_by_number(ARCH_AVR) != NULL) {
5949                    me->next = first_machine_entry; first_machine_entry = me;
5950            }
5951    
5952          /*  Generic "bare" ARM machine:  */          /*  Generic "bare" ARM machine:  */
5953          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
5954              MACHINE_BAREARM, 1, 0);              MACHINE_BAREARM, 1, 0);
# Line 5398  void machine_init(void) Line 5982  void machine_init(void)
5982                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5983          }          }
5984    
5985            /*  Digital DNARD ("Shark"):  */
5986            me = machine_entry_new("Digital DNARD (\"Shark\")", ARCH_ARM,
5987                MACHINE_SHARK, 2, 0);
5988            me->aliases[0] = "shark";
5989            me->aliases[1] = "dnard";
5990            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5991                    me->next = first_machine_entry; first_machine_entry = me;
5992            }
5993    
5994          /*  DECstation:  */          /*  DECstation:  */
5995          me = machine_entry_new("DECstation/DECsystem",          me = machine_entry_new("DECstation/DECsystem",
5996              ARCH_MIPS, MACHINE_DEC, 3, 9);              ARCH_MIPS, MACHINE_DEC, 3, 9);
# Line 5465  void machine_init(void) Line 6058  void machine_init(void)
6058                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6059          }          }
6060    
6061            /*  CATS (ARM) evaluation board:  */
6062            me = machine_entry_new("CATS evaluation board (ARM)", ARCH_ARM,
6063                MACHINE_CATS, 1, 0);
6064            me->aliases[0] = "cats";
6065            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6066                    me->next = first_machine_entry; first_machine_entry = me;
6067            }
6068    
6069          /*  BeBox: (NetBSD/bebox)  */          /*  BeBox: (NetBSD/bebox)  */
6070          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
6071          me->aliases[0] = "bebox";          me->aliases[0] = "bebox";
# Line 5531  void machine_init(void) Line 6132  void machine_init(void)
6132          }          }
6133    
6134          /*  Alpha:  */          /*  Alpha:  */
6135          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 1);          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6136          me->aliases[0] = "alpha";          me->aliases[0] = "alpha";
6137          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
6138              "DEC 3000/300", ST_DEC_3000_300, 1);              "DEC 3000/300", ST_DEC_3000_300, 1);
6139          me->subtype[0]->aliases[0] = "3000/300";          me->subtype[0]->aliases[0] = "3000/300";
6140            me->subtype[1] = machine_entry_subtype_new(
6141                "EB164", ST_EB164, 1);
6142            me->subtype[1]->aliases[0] = "eb164";
6143          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
6144                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6145          }          }

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

  ViewVC Help
Powered by ViewVC 1.1.26