/[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 10 by dpavlin, Mon Oct 8 16:18:27 2007 UTC revision 14 by dpavlin, Mon Oct 8 16:18:51 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: machine.c,v 1.470 2005/06/26 11:36:28 debug Exp $   *  $Id: machine.c,v 1.565 2005/10/07 22:10:50 debug Exp $
29   *   *
30   *  Emulation of specific machines.   *  Emulation of specific machines.
31   *   *
# Line 53  Line 53 
53  #include "arcbios.h"  #include "arcbios.h"
54  #include "bus_pci.h"  #include "bus_pci.h"
55  #include "cpu.h"  #include "cpu.h"
 #include "cpu_mips.h"  
56  #include "device.h"  #include "device.h"
57  #include "devices.h"  #include "devices.h"
58  #include "diskimage.h"  #include "diskimage.h"
# Line 65  Line 64 
64  #include "net.h"  #include "net.h"
65  #include "symbol.h"  #include "symbol.h"
66    
67    /*  For Alpha emulation:  */
68    #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"
76    
77    /*  For evbmips emulation:  */
78    #include "maltareg.h"
79    
80  /*  For DECstation emulation:  */  /*  For DECstation emulation:  */
81  #include "dec_prom.h"  #include "dec_prom.h"
82  #include "dec_bootinfo.h"  #include "dec_bootinfo.h"
# Line 147  struct machine *machine_new(char *name, Line 155  struct machine *machine_new(char *name,
155          m->bintrans_enable = 1;          m->bintrans_enable = 1;
156          m->old_bintrans_enable = 1;          m->old_bintrans_enable = 1;
157  #endif  #endif
158            m->arch_pagesize = 4096;        /*  Should be overriden in
159                                                emul.c for other pagesizes.  */
160            m->dyntrans_alignment_check = 1;
161          m->prom_emulation = 1;          m->prom_emulation = 1;
162          m->speed_tricks = 1;          m->speed_tricks = 1;
163          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;
# Line 177  int machine_name_to_type(char *stype, ch Line 188  int machine_name_to_type(char *stype, ch
188          int *type, int *subtype, int *arch)          int *type, int *subtype, int *arch)
189  {  {
190          struct machine_entry *me;          struct machine_entry *me;
191          int i, j, k;          int i, j, k, nmatches = 0;
192    
193          *type = MACHINE_NONE;          *type = MACHINE_NONE;
194          *subtype = 0;          *subtype = 0;
195    
196            /*  Check stype, and optionally ssubtype:  */
197          me = first_machine_entry;          me = first_machine_entry;
198          while (me != NULL) {          while (me != NULL) {
199                  for (i=0; i<me->n_aliases; i++)                  for (i=0; i<me->n_aliases; i++)
# Line 216  int machine_name_to_type(char *stype, ch Line 228  int machine_name_to_type(char *stype, ch
228                  me = me->next;                  me = me->next;
229          }          }
230    
231          fatal("\nSorry, emulation \"%s\"", stype);          /*  Not found? Then just check ssubtype:  */
232          if (ssubtype != NULL && ssubtype[0] != '\0')          me = first_machine_entry;
233                  fatal(" (subtype \"%s\")", ssubtype);          while (me != NULL) {
234          fatal(" is unknown.\n");                  if (me->n_subtypes == 0) {
235          fatal("Use the -H command line option to get a list of available"                          me = me->next;
236              " types and subtypes.\n\n");                          continue;
237                    }
238    
239                    /*  Check for subtype:  */
240                    for (j=0; j<me->n_subtypes; j++)
241                            for (k=0; k<me->subtype[j]->n_aliases; k++)
242                                    if (strcasecmp(ssubtype, me->subtype[j]->
243                                        aliases[k]) == 0) {
244                                            *type = me->machine_type;
245                                            *arch = me->arch;
246                                            *subtype = me->subtype[j]->
247                                                machine_subtype;
248                                            nmatches ++;
249                                    }
250    
251                    me = me->next;
252            }
253    
254            switch (nmatches) {
255            case 0: fatal("\nSorry, emulation \"%s\"", stype);
256                    if (ssubtype != NULL && ssubtype[0] != '\0')
257                            fatal(" (subtype \"%s\")", ssubtype);
258                    fatal(" is unknown.\n");
259                    break;
260            case 1: return 1;
261            default:fatal("\nSorry, multiple matches for \"%s\"", stype);
262                    if (ssubtype != NULL && ssubtype[0] != '\0')
263                            fatal(" (subtype \"%s\")", ssubtype);
264                    fatal(".\n");
265            }
266    
267            *type = MACHINE_NONE;
268            *subtype = 0;
269    
270            fatal("Use the -H command line option to get a list of "
271                "available types and subtypes.\n\n");
272    
273          return 0;          return 0;
274  }  }
275    
# Line 343  void add_environment_string(struct cpu * Line 391  void add_environment_string(struct cpu *
391    
392    
393  /*  /*
394     *  add_environment_string_dual():
395     *
396     *  Add "dual" environment strings, one for the variable name and one for the
397     *  value, and update pointers afterwards.
398     */
399    void add_environment_string_dual(struct cpu *cpu,
400            uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2)
401    {
402            uint64_t ptr = *ptrp, addr = *addrp;
403    
404            store_32bit_word(cpu, ptr, addr);
405            ptr += sizeof(uint32_t);
406            if (addr != 0) {
407                    store_string(cpu, addr, s1);
408                    addr += strlen(s1) + 1;
409            }
410            store_32bit_word(cpu, ptr, addr);
411            ptr += sizeof(uint32_t);
412            if (addr != 0) {
413                    store_string(cpu, addr, s2);
414                    addr += strlen(s2) + 1;
415            }
416    
417            *ptrp = ptr;
418            *addrp = addr;
419    }
420    
421    
422    /*
423   *  store_64bit_word():   *  store_64bit_word():
424   *   *
425   *  Stores a 64-bit word in emulated RAM.  Byte order is taken into account.   *  Stores a 64-bit word in emulated RAM.  Byte order is taken into account.
# Line 382  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 407  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 428  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 481  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 505  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 1231  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.malta_data->assert_lo |= mask;                          m->isa_pic_data.pic1->irr |= mask;
1312                  else                  else
1313                          m->md_int.malta_data->assert_lo &= ~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.malta_data->assert_hi |= mask;                          m->isa_pic_data.pic2->irr |= mask;
1317                  else                  else
1318                          m->md_int.malta_data->assert_hi &= ~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          if (m->md_int.malta_data->assert_hi &          /*  (TODO: don't hardcode this here)  */
1323              ~m->md_int.malta_data->disable_hi)          if (m->isa_pic_data.pic2->irr &
1324                  m->md_int.malta_data->assert_lo |= 0x04;              ~m->isa_pic_data.pic2->ier)
1325                    m->isa_pic_data.pic1->irr |= 0x04;
1326          else          else
1327                  m->md_int.malta_data->assert_lo &= ~0x04;                  m->isa_pic_data.pic1->irr &= ~0x04;
1328    
1329          /*  Now, PIC1:  */          /*  Now, PIC1:  */
1330          if (m->md_int.malta_data->assert_lo &          if (m->isa_pic_data.pic1->irr &
1331              ~m->md_int.malta_data->disable_lo)              ~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 "
1337                "ier=0x%02x\n", m->isa_pic_data.pic1->irr,
1338                m->isa_pic_data.pic1->ier,
1339                m->isa_pic_data.pic2->irr,
1340                m->isa_pic_data.pic2->ier);  */
1341    }
1342    
1343    
1344    /*
1345     *  Cobalt interrupts:
1346     *
1347     *  (irq_nr = 8 + 16 can be used to just reassert/deassert interrupts.)
1348     */
1349    void cobalt_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
1350    {
1351            int mask;
1352    
1353            irq_nr -= 8;
1354            mask = 1 << (irq_nr & 7);
1355    
1356            if (irq_nr < 8) {
1357                    if (assrt)
1358                            m->isa_pic_data.pic1->irr |= mask;
1359                    else
1360                            m->isa_pic_data.pic1->irr &= ~mask;
1361            } else if (irq_nr < 16) {
1362                    if (assrt)
1363                            m->isa_pic_data.pic2->irr |= mask;
1364                    else
1365                            m->isa_pic_data.pic2->irr &= ~mask;
1366            }
1367    
1368            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1369            /*  (TODO: don't hardcode this here)  */
1370            if (m->isa_pic_data.pic2->irr &
1371                ~m->isa_pic_data.pic2->ier)
1372                    m->isa_pic_data.pic1->irr |= 0x04;
1373            else
1374                    m->isa_pic_data.pic1->irr &= ~0x04;
1375    
1376            /*  Now, PIC1:  */
1377            if (m->isa_pic_data.pic1->irr &
1378                ~m->isa_pic_data.pic1->ier)
1379                    cpu_interrupt(cpu, 6);
1380            else
1381                    cpu_interrupt_ack(cpu, 6);
1382    
1383            /*  printf("COBALT: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "
1384                "ier=0x%02x\n", m->isa_pic_data.pic1->irr,
1385                m->isa_pic_data.pic1->ier,
1386                m->isa_pic_data.pic2->irr,
1387                m->isa_pic_data.pic2->ier);  */
1388  }  }
1389    
1390    
# Line 1268  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 1319  void machine_setup(struct machine *machi Line 1512  void machine_setup(struct machine *machi
1512          int i, j;          int i, j;
1513          struct memory *mem;          struct memory *mem;
1514          char tmpstr[1000];          char tmpstr[1000];
1515            struct cons_data *cons_data;
1516    
1517          /*  DECstation:  */          /*  DECstation:  */
1518          char *framebuffer_console_name, *serial_console_name;          char *framebuffer_console_name, *serial_console_name;
# Line 1355  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 1391  void machine_setup(struct machine *machi Line 1585  void machine_setup(struct machine *machi
1585                  printf("\nNo emulation type specified.\n");                  printf("\nNo emulation type specified.\n");
1586                  exit(1);                  exit(1);
1587    
1588    #ifdef ENABLE_MIPS
1589          case MACHINE_BAREMIPS:          case MACHINE_BAREMIPS:
1590                  /*                  /*
1591                   *  A "bare" MIPS test machine.                   *  A "bare" MIPS test machine.
# Line 1405  void machine_setup(struct machine *machi Line 1600  void machine_setup(struct machine *machi
1600                  /*                  /*
1601                   *  A MIPS test machine (which happens to work with the                   *  A MIPS test machine (which happens to work with the
1602                   *  code in my master's thesis).  :-)                   *  code in my master's thesis).  :-)
1603                     *
1604                     *  IRQ map:
1605                     *      7       CPU counter
1606                     *      6       SMP IPIs
1607                     *      5       not used yet
1608                     *      4       not used yet
1609                     *      3       ethernet
1610                     *      2       serial console
1611                   */                   */
1612                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
1613                  machine->machine_name = "MIPS test machine";                  machine->machine_name = "MIPS test machine";
1614    
1615                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=2",
1616                      machine, mem, DEV_CONS_ADDRESS, "console", 2);                      (long long)DEV_CONS_ADDRESS);
1617                    cons_data = device_add(machine, tmpstr);
1618                    machine->main_console_handle = cons_data->console_handle;
1619    
1620                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
1621                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
1622                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
1623    
1624                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
1625                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testmips generic");
1626    
1627                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
1628                        (long long)DEV_DISK_ADDRESS);
1629                    device_add(machine, tmpstr);
1630    
1631                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=3",
1632                        (long long)DEV_ETHER_ADDRESS);
1633                    device_add(machine, tmpstr);
1634    
1635                  break;                  break;
1636    
1637          case MACHINE_DEC:          case MACHINE_DEC:
# Line 1459  void machine_setup(struct machine *machi Line 1673  void machine_setup(struct machine *machi
1673                           */                           */
1674                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,
1675                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,
1676                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01", 1);                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01");
1677                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);
1678                          dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag);                          dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag);
1679                          dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576);                          dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576);
# Line 1891  void machine_setup(struct machine *machi Line 2105  void machine_setup(struct machine *machi
2105                          dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576);                          dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576);
2106                          dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII);                          dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII);
2107    
2108                          snprintf(tmpstr, sizeof(tmpstr) - 1,                          snprintf(tmpstr, sizeof(tmpstr),
2109                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);
2110                          machine->md_int.kn230_csr = device_add(machine, tmpstr);                          machine->md_int.kn230_csr = device_add(machine, tmpstr);
2111    
# Line 1909  void machine_setup(struct machine *machi Line 2123  void machine_setup(struct machine *machi
2123                   */                   */
2124                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
2125    
2126                  /*  DECstation PROM stuff:  (TODO: endianness)  */                  if (machine->prom_emulation) {
2127                  for (i=0; i<100; i++)                          /*  DECstation PROM stuff:  (TODO: endianness)  */
2128                          store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,                          for (i=0; i<100; i++)
2129                              DEC_PROM_EMULATION + i*8);                                  store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
2130                                        DEC_PROM_EMULATION + i*8);
2131                  /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */  
2132                  for (i=0; i<100; i++) {                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2133                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,                          for (i=0; i<100; i++) {
2134                              0x03e00008);        /*  return  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2135                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,                                      0x03e00008);        /*  return  */
2136                              0x00000000);        /*  nop  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2137                  }                                      0x00000000);        /*  nop  */
2138                            }
2139    
2140                  /*                          /*
2141                   *  According to dec_prom.h from NetBSD:                           *  According to dec_prom.h from NetBSD:
2142                   *                           *
2143                   *  "Programs loaded by the new PROMs pass the following arguments:                           *  "Programs loaded by the new PROMs pass the following arguments:
2144                   *      a0      argc                           *      a0      argc
2145                   *      a1      argv                           *      a1      argv
2146                   *      a2      DEC_PROM_MAGIC                           *      a2      DEC_PROM_MAGIC
2147                   *      a3      The callback vector defined below"                           *      a3      The callback vector defined below"
2148                   *                           *
2149                   *  So we try to emulate a PROM, even though no such thing has been                           *  So we try to emulate a PROM, even though no such thing has been
2150                   *  loaded.                           *  loaded.
2151                   */                           */
2152    
2153                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2154                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2155                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2156                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2157    
2158                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2159                      BOOTINFO_MAGIC);                              BOOTINFO_MAGIC);
2160                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2161                      BOOTINFO_ADDR);                              BOOTINFO_ADDR);
2162    
2163                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2164                      (DEC_PROM_INITIAL_ARGV + 0x10));                              (DEC_PROM_INITIAL_ARGV + 0x10));
2165                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2166                      (DEC_PROM_INITIAL_ARGV + 0x70));                              (DEC_PROM_INITIAL_ARGV + 0x70));
2167                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2168                      (DEC_PROM_INITIAL_ARGV + 0xe0));                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2169                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2170    
2171                  /*                          /*
2172                   *  NetBSD and Ultrix expect the boot args to be like this:                           *  NetBSD and Ultrix expect the boot args to be like this:
2173                   *                           *
2174                   *      "boot" "bootdev" [args?]                           *      "boot" "bootdev" [args?]
2175                   *                           *
2176                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                           *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2177                   *  3100/2100 (although that crashes Ultrix :-/), and                           *  3100/2100 (although that crashes Ultrix :-/), and
2178                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                           *  "5/rz0a/netbsd" for all others.  The number '5' is the
2179                   *  slot number of the boot device.                           *  slot number of the boot device.
2180                   *                           *
2181                   *  'rz' for disks, 'tz' for tapes.                           *  'rz' for disks, 'tz' for tapes.
2182                   *                           *
2183                   *  TODO:  Make this nicer.                           *  TODO:  Make this nicer.
2184                   */                           */
2185                  {                          {
2186                          char bootpath[200];                          char bootpath[200];
   
2187  #if 0  #if 0
2188                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
2189                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
# Line 1991  void machine_setup(struct machine *machi Line 2205  void machine_setup(struct machine *machi
2205                          }                          }
2206    
2207                          init_bootpath = bootpath;                          init_bootpath = bootpath;
2208                  }                          }
2209    
2210                  bootarg = malloc(BOOTARG_BUFLEN);                          bootarg = malloc(BOOTARG_BUFLEN);
2211                  if (bootarg == NULL) {                          if (bootarg == NULL) {
2212                          fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2213                          exit(1);                                  exit(1);
2214                  }                          }
2215                  strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);                          strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2216                  if (strlcat(bootarg, machine->boot_kernel_filename,                          if (strlcat(bootarg, machine->boot_kernel_filename,
2217                      BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {                              BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2218                          fprintf(stderr, "bootarg truncated?\n");                                  fprintf(stderr, "bootarg truncated?\n");
2219                          exit(1);                                  exit(1);
2220                  }                          }
2221    
2222                  bootstr = "boot";                          bootstr = "boot";
2223    
2224                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2225                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2226                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2227                      machine->boot_string_argument);                              machine->boot_string_argument);
2228    
2229                  /*  Decrease the nr of args, if there are no args :-)  */                          /*  Decrease the nr of args, if there are no args :-)  */
2230                  if (machine->boot_string_argument == NULL ||                          if (machine->boot_string_argument == NULL ||
2231                      machine->boot_string_argument[0] == '\0')                              machine->boot_string_argument[0] == '\0')
2232                          cpu->cd.mips.gpr[MIPS_GPR_A0] --;                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2233    
2234                  if (machine->boot_string_argument[0] != '\0') {                          if (machine->boot_string_argument[0] != '\0') {
2235                          strlcat(bootarg, " ", BOOTARG_BUFLEN);                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2236                          if (strlcat(bootarg, machine->boot_string_argument,                                  if (strlcat(bootarg, machine->boot_string_argument,
2237                              BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2238                                  fprintf(stderr, "bootstr truncated?\n");                                          fprintf(stderr, "bootstr truncated?\n");
2239                                  exit(1);                                          exit(1);
2240                                    }
2241                          }                          }
                 }  
2242    
2243                  xx.a.common.next = (char *)&xx.b - (char *)&xx;                          xx.a.common.next = (char *)&xx.b - (char *)&xx;
2244                  xx.a.common.type = BTINFO_MAGIC;                          xx.a.common.type = BTINFO_MAGIC;
2245                  xx.a.magic = BOOTINFO_MAGIC;                          xx.a.magic = BOOTINFO_MAGIC;
2246    
2247                  xx.b.common.next = (char *)&xx.c - (char *)&xx.b;                          xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2248                  xx.b.common.type = BTINFO_BOOTPATH;                          xx.b.common.type = BTINFO_BOOTPATH;
2249                  strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));                          strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2250    
2251                  xx.c.common.next = 0;                          xx.c.common.next = 0;
2252                  xx.c.common.type = BTINFO_SYMTAB;                          xx.c.common.type = BTINFO_SYMTAB;
2253                  xx.c.nsym = 0;                          xx.c.nsym = 0;
2254                  xx.c.ssym = 0;                          xx.c.ssym = 0;
2255                  xx.c.esym = machine->file_loaded_end_addr;                          xx.c.esym = machine->file_loaded_end_addr;
2256    
2257                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
2258    
2259                  /*                          /*
2260                   *  The system's memmap:  (memmap is a global variable, in                           *  The system's memmap:  (memmap is a global variable, in
2261                   *  dec_prom.h)                           *  dec_prom.h)
2262                   */                           */
2263                  store_32bit_word_in_host(cpu,                          store_32bit_word_in_host(cpu,
2264                      (unsigned char *)&memmap.pagesize, 4096);                              (unsigned char *)&memmap.pagesize, 4096);
2265                  {                          {
2266                          unsigned int i;                                  unsigned int i;
2267                          for (i=0; i<sizeof(memmap.bitmap); i++)                                  for (i=0; i<sizeof(memmap.bitmap); i++)
2268                                  memmap.bitmap[i] = ((int)i * 4096*8 <                                          memmap.bitmap[i] = ((int)i * 4096*8 <
2269                                      1048576*machine->physical_ram_in_mb)?                                              1048576*machine->physical_ram_in_mb)?
2270                                      0xff : 0x00;                                              0xff : 0x00;
2271                  }                          }
2272                  store_buf(cpu, DEC_MEMMAP_ADDR, (char *)&memmap, sizeof(memmap));                          store_buf(cpu, DEC_MEMMAP_ADDR, (char *)&memmap, sizeof(memmap));
   
                 /*  Environment variables:  */  
                 addr = DEC_PROM_STRINGS;  
   
                 if (machine->use_x11 && machine->n_gfx_cards > 0)  
                         /*  (0,3)  Keyboard and Framebuffer  */  
                         add_environment_string(cpu, framebuffer_console_name, &addr);  
                 else  
                         /*  Serial console  */  
                         add_environment_string(cpu, serial_console_name, &addr);  
2273    
2274                  /*                          /*  Environment variables:  */
2275                   *  The KN5800 (SMP system) uses a CCA (console communications                          addr = DEC_PROM_STRINGS;
                  *  area):  (See VAX 6000 documentation for details.)  
                  */  
                 {  
                         char tmps[300];  
                         snprintf(tmps, sizeof(tmps), "cca=%x",  
                             (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));  
                         add_environment_string(cpu, tmps, &addr);  
                 }  
2276    
2277                  /*  These are needed for Sprite to boot:  */                          if (machine->use_x11 && machine->n_gfx_cards > 0)
2278                  {                                  /*  (0,3)  Keyboard and Framebuffer  */
2279                          char tmps[500];                                  add_environment_string(cpu, framebuffer_console_name, &addr);
2280                            else
2281                                    /*  Serial console  */
2282                                    add_environment_string(cpu, serial_console_name, &addr);
2283    
2284                          snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);                          /*
2285                          tmps[sizeof(tmps)-1] = '\0';                           *  The KN5800 (SMP system) uses a CCA (console communications
2286                          add_environment_string(cpu, tmps, &addr);                           *  area):  (See VAX 6000 documentation for details.)
2287                             */
2288                          snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((                          {
2289                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))                                  char tmps[300];
2290                              & 0xffffffffULL));                                  snprintf(tmps, sizeof(tmps), "cca=%x",
2291                          tmps[sizeof(tmps)-1] = '\0';                                      (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2292                          add_environment_string(cpu, tmps, &addr);                                  add_environment_string(cpu, tmps, &addr);
2293                            }
2294                          snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",  
2295                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                          /*  These are needed for Sprite to boot:  */
2296                          tmps[sizeof(tmps)-1] = '\0';                          {
2297                          add_environment_string(cpu, tmps, &addr);                                  char tmps[500];
2298                  }  
2299                                    snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2300                  add_environment_string(cpu, "scsiid0=7", &addr);                                  tmps[sizeof(tmps)-1] = '\0';
2301                  add_environment_string(cpu, "bootmode=a", &addr);                                  add_environment_string(cpu, tmps, &addr);
2302                  add_environment_string(cpu, "testaction=q", &addr);  
2303                  add_environment_string(cpu, "haltaction=h", &addr);                                  snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2304                  add_environment_string(cpu, "more=24", &addr);                                      DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2305                                        & 0xffffffffULL));
2306                  /*  Used in at least Ultrix on the 5100:  */                                  tmps[sizeof(tmps)-1] = '\0';
2307                  add_environment_string(cpu, "scsiid=7", &addr);                                  add_environment_string(cpu, tmps, &addr);
2308                  add_environment_string(cpu, "baud0=9600", &addr);  
2309                  add_environment_string(cpu, "baud1=9600", &addr);                                  snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2310                  add_environment_string(cpu, "baud2=9600", &addr);                                      machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2311                  add_environment_string(cpu, "baud3=9600", &addr);                                  tmps[sizeof(tmps)-1] = '\0';
2312                  add_environment_string(cpu, "iooption=0x1", &addr);                                  add_environment_string(cpu, tmps, &addr);
2313                            }
2314    
2315                  /*  The end:  */                          add_environment_string(cpu, "scsiid0=7", &addr);
2316                  add_environment_string(cpu, "", &addr);                          add_environment_string(cpu, "bootmode=a", &addr);
2317                            add_environment_string(cpu, "testaction=q", &addr);
2318                            add_environment_string(cpu, "haltaction=h", &addr);
2319                            add_environment_string(cpu, "more=24", &addr);
2320    
2321                            /*  Used in at least Ultrix on the 5100:  */
2322                            add_environment_string(cpu, "scsiid=7", &addr);
2323                            add_environment_string(cpu, "baud0=9600", &addr);
2324                            add_environment_string(cpu, "baud1=9600", &addr);
2325                            add_environment_string(cpu, "baud2=9600", &addr);
2326                            add_environment_string(cpu, "baud3=9600", &addr);
2327                            add_environment_string(cpu, "iooption=0x1", &addr);
2328    
2329                            /*  The end:  */
2330                            add_environment_string(cpu, "", &addr);
2331                    }
2332    
2333                  break;                  break;
2334    
# Line 2130  void machine_setup(struct machine *machi Line 2345  void machine_setup(struct machine *machi
2345                   *      4       Tulip 1                   *      4       Tulip 1
2346                   *      5       16550 UART (serial console)                   *      5       16550 UART (serial console)
2347                   *      6       VIA southbridge PIC                   *      6       VIA southbridge PIC
2348                   *      7       PCI                   *      7       PCI  (Note: Not used. The PCI controller
2349                     *              interrupts at ISA interrupt 9.)
2350                   */                   */
2351  /*              dev_XXX_init(cpu, mem, 0x10000000, machine->emulated_hz);       */  
2352                    /*  ISA interrupt controllers:  */
2353                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2354                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2355                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2356                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2357                    machine->md_interrupt = cobalt_interrupt;
2358    
2359                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);
2360    
2361                  machine->main_console_handle = dev_ns16550_init(machine, mem,                  machine->main_console_handle = (size_t)
2362                      0x1c800000, 5, 1, 1, "serial console");                      device_add(machine, "ns16550 irq=5 addr=0x1c800000 name2=tty0 in_use=1");
2363    
2364  #if 0  #if 0
2365                  dev_ns16550_init(machine, mem, 0x1f000010, 0, 1, 1,                  device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0");
                     "other serial console");  
2366  #endif  #endif
2367    
2368                  /*                  /*
# Line 2152  void machine_setup(struct machine *machi Line 2374  void machine_setup(struct machine *machi
2374                   *  pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37                   *  pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37
2375                   *  pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr                   *  pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr
2376                   *  tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1                   *  tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1
2377                     *
2378                     *  The PCI controller interrupts at ISA interrupt 9.
2379                   */                   */
2380                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 6, 11);     /*  7 for PCI, not 6?  */                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 8 + 9, 11);
2381                  /*  bus_pci_add(machine, pci_data, mem, 0,  7, 0, pci_dec21143_init, pci_dec21143_rr);  */                  /*  bus_pci_add(machine, pci_data, mem, 0,  7, 0, pci_dec21143_init, pci_dec21143_rr);  */
2382                  bus_pci_add(machine, pci_data, mem, 0,  8, 0, NULL, NULL);  /*  PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860  */                  bus_pci_add(machine, pci_data, mem, 0,  8, 0, NULL, NULL);  /*  PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860  */
2383                  bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);                  bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);
2384                  bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);                  bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
2385                  /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr);  */                  /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr);  */
2386    
2387                  /*                  if (machine->prom_emulation) {
2388                   *  NetBSD/cobalt expects memsize in a0, but it seems that what                          /*
2389                   *  it really wants is the end of memory + 0x80000000.                           *  NetBSD/cobalt expects memsize in a0, but it seems that what
2390                   *                           *  it really wants is the end of memory + 0x80000000.
2391                   *  The bootstring should be stored starting 512 bytes before end                           *
2392                   *  of physical ram.                           *  The bootstring is stored 512 bytes before the end of
2393                   */                           *  physical ram.
2394                  cpu->cd.mips.gpr[MIPS_GPR_A0] = machine->physical_ram_in_mb * 1048576 + 0x80000000;                           */
2395                  bootstr = "root=/dev/hda1 ro";                          cpu->cd.mips.gpr[MIPS_GPR_A0] =
2396                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                              machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2397                  store_string(cpu, 0xffffffff80000000ULL +                          bootstr = "root=/dev/hda1 ro";
2398                      machine->physical_ram_in_mb * 1048576 - 512, bootstr);                          /*  bootstr = "nfsroot=/usr/cobalt/";  */
2399                            /*  TODO: bootarg, and/or automagic boot device detection  */
2400                            store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);
2401                    }
2402                  break;                  break;
2403    
2404          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
# Line 2208  void machine_setup(struct machine *machi Line 2435  void machine_setup(struct machine *machi
2435                          hpcmips_fb_bits = 15;                          hpcmips_fb_bits = 15;
2436                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2437    
2438                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2439                              machine, mem, 0xa008680, 0, 4,                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
2440                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2441    
2442                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);
2443                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2444    
# Line 2239  void machine_setup(struct machine *machi Line 2467  void machine_setup(struct machine *machi
2467                          hpcmips_fb_bits = 16;                          hpcmips_fb_bits = 16;
2468                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2469    
2470                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2471                              machine, mem, 0xa008680, 0, 4,                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
2472                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2473    
2474                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2475                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2476    
# Line 2389  void machine_setup(struct machine *machi Line 2618  void machine_setup(struct machine *machi
2618                              VRIP_INTR_SIU (=9) here?  */                              VRIP_INTR_SIU (=9) here?  */
2619                          {                          {
2620                                  int x;                                  int x;
2621                                  x = dev_ns16550_init(machine, mem, 0x0c000010,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x0c000010", 8 + VRIP_INTR_SIU);
2622                                      8 + VRIP_INTR_SIU, 1, 1, "serial 0");                                  x = (size_t)device_add(machine, tmpstr);
2623    
2624                                  if (!machine->use_x11)                                  if (!machine->use_x11)
2625                                          machine->main_console_handle = x;                                          machine->main_console_handle = x;
# Line 2413  void machine_setup(struct machine *machi Line 2642  void machine_setup(struct machine *machi
2642                          break;                          break;
2643                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:
2644                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2645                          machine->machine_name = "Agenda VR3";                          machine->machine_name = "IBM Workpad Z50";
2646                          /*  TODO:  */                          /*  TODO:  */
2647                          hpcmips_fb_addr = 0xa000000;                          hpcmips_fb_addr = 0xa000000;
2648                          hpcmips_fb_xsize = 640;                          hpcmips_fb_xsize = 640;
# Line 2448  void machine_setup(struct machine *machi Line 2677  void machine_setup(struct machine *machi
2677                          machine->main_console_handle =                          machine->main_console_handle =
2678                              machine->md_int.vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
2679    
2680                  /*  NetBSD/hpcmips and possibly others expects the following:  */                  if (machine->prom_emulation) {
2681                            /*  NetBSD/hpcmips and possibly others expects the following:  */
2682    
2683                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2684                  cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576                          cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2685                      + 0xffffffff80000000ULL - 512;      /*  argv  */                              + 0xffffffff80000000ULL - 512;      /*  argv  */
2686                  cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576                          cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2687                      + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */                              + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */
2688    
2689                  bootstr = machine->boot_kernel_filename;                          bootstr = machine->boot_kernel_filename;
2690                  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, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512,
2691                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);                              0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2692                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);                          store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2693                            store_string(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2694                  /*  Special case for the Agenda VR3:  */  
2695                  if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {                          /*  Special case for the Agenda VR3:  */
2696                          const int tmplen = 1000;                          if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2697                          char *tmp = malloc(tmplen);                                  const int tmplen = 1000;
2698                                    char *tmp = malloc(tmplen);
2699    
2700                                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */
2701    
2702                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2703                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2704    
2705                                    snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2706                                        "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2707                                    tmp[tmplen-1] = '\0';
2708    
2709                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */                                  if (!machine->use_x11)
2710                                            snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2711                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  tmp[tmplen-1] = '\0';
                         store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);  
   
                         snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"  
                             "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");  
                         tmp[tmplen-1] = '\0';  
2712    
2713                          if (!machine->use_x11)                                  if (machine->boot_string_argument[0])
2714                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2715                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2716    
2717                          if (machine->boot_string_argument[0])                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
                                 snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);  
                         tmp[tmplen-1] = '\0';  
2718    
2719                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  bootarg = tmp;
2720                            } else if (machine->boot_string_argument[0]) {
2721                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2722    
2723                          bootarg = tmp;                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2724                  } else if (machine->boot_string_argument[0]) {                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
                         cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */  
2725    
2726                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2727                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                      machine->boot_string_argument);
2728    
2729                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,                                  bootarg = machine->boot_string_argument;
2730                              machine->boot_string_argument);                          }
2731    
2732                          bootarg = machine->boot_string_argument;                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2733                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2734                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);
2735                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);
2736                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);
2737                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);
2738                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);
2739                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */
2740    
2741                            /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);
2742                                printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */
2743                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2744                            store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2745                  }                  }
2746    
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */  
   
                 /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);  
                     printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);  
                 store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));  
   
2747                  if (hpcmips_fb_addr != 0) {                  if (hpcmips_fb_addr != 0) {
2748                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,
2749                              hpcmips_fb_xsize, hpcmips_fb_ysize,                              hpcmips_fb_xsize, hpcmips_fb_ysize,
2750                              hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,                              hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,
2751                              hpcmips_fb_bits, "HPCmips", 0);                              hpcmips_fb_bits, "HPCmips");
2752    
2753                          /*  NetBSD/hpcmips uses framebuffer at physical                          /*  NetBSD/hpcmips uses framebuffer at physical
2754                              address 0x8.......:  */                              address 0x8.......:  */
# Line 2555  void machine_setup(struct machine *machi Line 2787  void machine_setup(struct machine *machi
2787    
2788                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2789    
                 add_symbol_name(&machine->symbol_context,  
                     PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0);  
                 store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);  
                 store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);  
   
2790                  /*  Set the Harddisk controller present flag, if either                  /*  Set the Harddisk controller present flag, if either
2791                      disk 0 or 1 is present:  */                      disk 0 or 1 is present:  */
2792                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2793                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2794                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                          if (machine->prom_emulation)
2795                                    store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2796                          dev_ps2_spd_init(machine, mem, 0x14000000);                          dev_ps2_spd_init(machine, mem, 0x14000000);
2797                  }                  }
2798    
2799                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                  if (machine->prom_emulation) {
                 {  
2800                          int tmplen = 1000;                          int tmplen = 1000;
2801                          char *tmp = malloc(tmplen);                          char *tmp = malloc(tmplen);
2802                            time_t timet;
2803                            struct tm *tm_ptr;
2804    
2805                            add_symbol_name(&machine->symbol_context,
2806                                PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2807                            store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2808                            store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2809    
2810                            store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2811                          if (tmp == NULL) {                          if (tmp == NULL) {
2812                                  fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2813                                  exit(1);                                  exit(1);
# Line 2586  void machine_setup(struct machine *machi Line 2822  void machine_setup(struct machine *machi
2822    
2823                          bootstr = tmp;                          bootstr = tmp;
2824                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
                 }  
2825    
2826                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
                 {  
                         time_t timet;  
                         struct tm *tmp;  
2827    
2828                          /*  RTC data given by the BIOS:  */                          /*  RTC data given by the BIOS:  */
2829                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */
2830                          tmp = gmtime(&timet);                          tm_ptr = gmtime(&timet);
2831                          /*  TODO:  are these 0- or 1-based?  */                          /*  TODO:  are these 0- or 1-based?  */
2832                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 1, int_to_bcd(tmp->tm_sec));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 1, int_to_bcd(tm_ptr->tm_sec));
2833                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 2, int_to_bcd(tmp->tm_min));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 2, int_to_bcd(tm_ptr->tm_min));
2834                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 3, int_to_bcd(tmp->tm_hour));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 3, int_to_bcd(tm_ptr->tm_hour));
2835                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 5, int_to_bcd(tmp->tm_mday));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 5, int_to_bcd(tm_ptr->tm_mday));
2836                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 6, int_to_bcd(tmp->tm_mon + 1));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 6, int_to_bcd(tm_ptr->tm_mon + 1));
2837                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 7, int_to_bcd(tmp->tm_year - 100));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 7, int_to_bcd(tm_ptr->tm_year - 100));
                 }  
2838    
2839                  /*  "BOOTINFO_PCMCIA_TYPE" in NetBSD's bootinfo.h. This contains the sbus controller type.  */                          /*  "BOOTINFO_PCMCIA_TYPE" in NetBSD's bootinfo.h. This contains the sbus controller type.  */
2840                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);
2841                    }
2842    
2843                  break;                  break;
2844    
# Line 2901  Why is this here? TODO Line 3133  Why is this here? TODO
3133                                   *  program dumps something there, but it doesn't look like                                   *  program dumps something there, but it doesn't look like
3134                                   *  readable text.  (TODO)                                   *  readable text.  (TODO)
3135                                   */                                   */
3136                                  machine->main_console_handle = dev_ns16550_init(machine, mem, 0x1f620170, 0, 1,  
3137                                      machine->use_x11? 0 : 1, "serial 0");  /*  TODO: irq?  */                                  /*  TODO: irq!  */
3138                                  dev_ns16550_init(machine, mem, 0x1f620178, 0, 1,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620170 name2=tty0 in_use=%i", machine->use_x11? 0 : 1);
3139                                      0, "serial 1");  /*  TODO: irq?  */                                  machine->main_console_handle = (size_t)device_add(machine, tmpstr);
3140                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620178 name2=tty1 in_use=0");
3141                                    device_add(machine, tmpstr);
3142    
3143                                  /*  MardiGras graphics:  */                                  /*  MardiGras graphics:  */
3144                                  device_add(machine, "sgi_mardigras addr=0x1c000000");                                  device_add(machine, "sgi_mardigras addr=0x1c000000");
# Line 2967  Why is this here? TODO Line 3201  Why is this here? TODO
3201                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
3202                                   */                                   */
3203    
 #if 0  
                                 i = dev_pckbc_init(machine, mem, 0x1f320000,  
                                     PCKBC_8242, 0x200 + MACE_PERIPH_MISC,  
                                     0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);  
                                                         /*  keyb+mouse (mace irq numbers)  */  
 #endif  
   
3204                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3205                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3206                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
# Line 2989  Why is this here? TODO Line 3216  Why is this here? TODO
3216    
3217                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */
3218    
3219                                  j = dev_ns16550_init(machine, mem, 0x1f390000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f390000 addr_mult=0x100 in_use=%i name2=tty0",
3220                                      (1<<20) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<20) + MACE_PERIPH_SERIAL, machine->use_x11? 0 : 1);
3221                                      machine->use_x11? 0 : 1, "serial 0");       /*  com0  */                                  j = (size_t)device_add(machine, tmpstr);
3222                                  dev_ns16550_init(machine, mem, 0x1f398000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",
3223                                      (1<<26) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3224                                      0, "serial 1");                             /*  com1  */                                  device_add(machine, tmpstr);
3225    
3226  #if 0                                  machine->main_console_handle = j;
3227                                  if (machine->use_x11)  
3228                                    /*  TODO: Once this works, it should be enabled
3229                                        always, not just when using X!  */
3230                                    if (machine->use_x11) {
3231                                            i = dev_pckbc_init(machine, mem, 0x1f320000,
3232                                                PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
3233                                                0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
3234                                                    /*  keyb+mouse (mace irq numbers)  */
3235                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3236                                  else                                  }
 #endif  
                                         machine->main_console_handle = j;  
3237    
3238                                  dev_mc146818_init(machine, mem, 0x1f3a0000, (1<<8) + MACE_PERIPH_MISC, MC146818_SGI, 0x40);  /*  mcclock0  */                                  dev_mc146818_init(machine, mem, 0x1f3a0000, (1<<8) + MACE_PERIPH_MISC, MC146818_SGI, 0x40);  /*  mcclock0  */
3239                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");
# Line 3092  Why is this here? TODO Line 3324  Why is this here? TODO
3324                                  device_add(machine, "sn addr=0x80001000 irq=0");                                  device_add(machine, "sn addr=0x80001000 irq=0");
3325                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);
3326                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11, 0);                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11, 0);
3327                                  j = dev_ns16550_init(machine, mem, 0x80006000ULL,  
3328                                      3, 1, machine->use_x11? 0 : 1, "serial 0");  /*  com0  */                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3329                                  dev_ns16550_init(machine, mem, 0x80007000ULL,                                  j = (size_t)device_add(machine, tmpstr);
3330                                      0, 1, 0, "serial 1"); /*  com1  */                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0);
3331                                    device_add(machine, tmpstr);
3332    
3333                                  if (machine->use_x11)                                  if (machine->use_x11)
3334                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3115  Why is this here? TODO Line 3348  Why is this here? TODO
3348                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3349                                          dev_fb_init(machine, mem, 0x100e00000ULL,                                          dev_fb_init(machine, mem, 0x100e00000ULL,
3350                                              VFB_GENERIC, 640,480, 1024,480,                                              VFB_GENERIC, 640,480, 1024,480,
3351                                              8, "necvdfrb", 1);                                              8, "necvdfrb");
3352                                          break;                                          break;
3353                                  }                                  }
3354                                  break;                                  break;
# Line 3211  Why is this here? TODO Line 3444  Why is this here? TODO
3444                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3445                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3446    
3447                                  j = dev_ns16550_init(machine, mem,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3448                                      0x80006000ULL, 8 + 8, 1,                                  j = (size_t)device_add(machine, tmpstr);
3449                                      machine->use_x11? 0 : 1, "serial 0");                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3450                                  dev_ns16550_init(machine, mem,                                  device_add(machine, tmpstr);
                                     0x80007000ULL, 8 + 9, 1, 0, "serial 1");  
3451    
3452                                  if (machine->use_x11)                                  if (machine->use_x11)
3453                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3241  Why is this here? TODO Line 3473  Why is this here? TODO
3473                                          /*  control at 0x60100000?  */                                          /*  control at 0x60100000?  */
3474                                          dev_fb_init(machine, mem, 0x60200000ULL,                                          dev_fb_init(machine, mem, 0x60200000ULL,
3475                                              VFB_GENERIC, 1024,768, 1024,768,                                              VFB_GENERIC, 1024,768, 1024,768,
3476                                              8, "VXL", 1);                                              8, "VXL");
3477                                          break;                                          break;
3478                                  }                                  }
3479    
# Line 3260  Why is this here? TODO Line 3492  Why is this here? TODO
3492    
3493  #if 0  #if 0
3494  Not yet.  Not yet.
3495                                  dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);                                  /*  irq = 8+16 + 14  */
3496                                    device_add(machine, "wdc addr=0x900001f0, irq=38");
3497  #endif  #endif
3498    
3499                                  break;                                  break;
# Line 3290  Not yet. Line 3523  Not yet.
3523                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3524                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3525  #endif  #endif
3526                                  j = dev_ns16550_init(machine, mem,  
3527                                      0x80006000ULL, 8 + 8, 1,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3528                                      machine->use_x11? 0 : 1, "serial 0");                                  j = (size_t)device_add(machine, tmpstr);
3529                                  dev_ns16550_init(machine, mem,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3530                                      0x80007000ULL, 8 + 9, 1, 0, "serial 1");                                  device_add(machine, tmpstr);
3531    
3532                                  if (machine->use_x11)                                  if (machine->use_x11)
3533                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3317  Not yet. Line 3550  Not yet.
3550                                  strlcat(machine->machine_name, " (Deskstation Tyne)",                                  strlcat(machine->machine_name, " (Deskstation Tyne)",
3551                                      MACHINE_NAME_MAXBUF);                                      MACHINE_NAME_MAXBUF);
3552    
3553                                  i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3554                                  dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1");                                  i = (size_t)device_add(machine, tmpstr);
3555                                  dev_ns16550_init(machine, mem, 0x9000003e8ULL, 0, 1, 0, "serial 2");                                  device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0 name2=tty1");
3556                                  dev_ns16550_init(machine, mem, 0x9000002e8ULL, 0, 1, 0, "serial 3");                                  device_add(machine, "ns16550 irq=0 addr=0x9000003e8 in_use=0 name2=tty2");
3557                                    device_add(machine, "ns16550 irq=0 addr=0x9000002e8 in_use=0 name2=tty3");
3558    
3559                                  dev_mc146818_init(machine, mem,                                  dev_mc146818_init(machine, mem,
3560                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3561    
3562  #if 0  #if 0
3563                                  dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);                                  /*  TODO: irq, etc  */
3564                                  dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);                                  device_add(machine, "wdc addr=0x9000001f0, irq=0");
3565                                    device_add(machine, "wdc addr=0x900000170, irq=0");
3566  #endif  #endif
3567                                  /*  PC kbd  */                                  /*  PC kbd  */
3568                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,
# Line 3361  Not yet. Line 3596  Not yet.
3596                   *  point.                   *  point.
3597                   */                   */
3598    
3599                  if (machine->prom_emulation)                  if (machine->prom_emulation) {
3600                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),
3601                              sgi_ram_offset);                              sgi_ram_offset);
                 else  
                         goto no_arc_prom_emulation;     /*  TODO: ugly  */  
3602    
3603                  /*                          /*
3604                   *  TODO: How to build the component tree intermixed with                           *  TODO: How to build the component tree intermixed with
3605                   *  the rest of device initialization?                           *  the rest of device initialization?
3606                   */                           */
   
                 /*  
                  *  Boot string in ARC format:  
                  *  
                  *  TODO: How about floppies? multi()disk()fdisk()  
                  *        Is tftp() good for netbooting?  
                  */  
                 init_bootpath = malloc(500);  
                 if (init_bootpath == NULL) {  
                         fprintf(stderr, "out of mem, bootpath\n");  
                         exit(1);  
                 }  
                 init_bootpath[0] = '\0';  
3607    
3608                  if (bootdev_id < 0 || machine->force_netboot) {                          /*
3609                          snprintf(init_bootpath, 400, "tftp()");                           *  Boot string in ARC format:
3610                  } else {                           *
3611                          /*  TODO: Make this nicer.  */                           *  TODO: How about floppies? multi()disk()fdisk()
3612                          if (machine->machine_type == MACHINE_SGI) {                           *        Is tftp() good for netbooting?
3613                                  if (machine->machine_subtype == 30)                           */
3614                                          strlcat(init_bootpath, "xio(0)pci(15)",                          init_bootpath = malloc(500);
3615                                              MACHINE_NAME_MAXBUF);                          if (init_bootpath == NULL) {
3616                                  if (machine->machine_subtype == 32)                                  fprintf(stderr, "out of mem, bootpath\n");
3617                                          strlcat(init_bootpath, "pci(0)",                                  exit(1);
                                             MACHINE_NAME_MAXBUF);  
3618                          }                          }
3619                            init_bootpath[0] = '\0';
3620    
3621                          if (diskimage_is_a_cdrom(machine, bootdev_id,                          if (bootdev_id < 0 || machine->force_netboot) {
3622                              bootdev_type))                                  snprintf(init_bootpath, 400, "tftp()");
3623                                  snprintf(init_bootpath + strlen(init_bootpath),                          } else {
3624                                      400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);                                  /*  TODO: Make this nicer.  */
3625                          else                                  if (machine->machine_type == MACHINE_SGI) {
3626                                  snprintf(init_bootpath + strlen(init_bootpath),                                          if (machine->machine_subtype == 30)
3627                                      400,"scsi(0)disk(%i)rdisk(0)partition(1)",                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3628                                      bootdev_id);                                                      MACHINE_NAME_MAXBUF);
3629                  }                                          if (machine->machine_subtype == 32)
3630                                                    strlcat(init_bootpath, "pci(0)",
3631                                                        MACHINE_NAME_MAXBUF);
3632                                    }
3633    
3634                  if (machine->machine_type == MACHINE_ARC)                                  if (diskimage_is_a_cdrom(machine, bootdev_id,
3635                          strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);                                      bootdev_type))
3636                                            snprintf(init_bootpath + strlen(init_bootpath),
3637                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3638                                    else
3639                                            snprintf(init_bootpath + strlen(init_bootpath),
3640                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3641                                                bootdev_id);
3642                            }
3643    
3644                  bootstr = malloc(BOOTSTR_BUFLEN);                          if (machine->machine_type == MACHINE_ARC)
3645                  if (bootstr == NULL) {                                  strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
                 strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);  
                 if (strlcat(bootstr, machine->boot_kernel_filename,  
                     BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {  
                         fprintf(stderr, "boot string too long?\n");  
                         exit(1);  
                 }  
3646    
3647                  /*  Boot args., eg "-a"  */                          bootstr = malloc(BOOTSTR_BUFLEN);
3648                  bootarg = machine->boot_string_argument;                          if (bootstr == NULL) {
3649                                    fprintf(stderr, "out of memory\n");
3650                                    exit(1);
3651                            }
3652                            strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3653                            if (strlcat(bootstr, machine->boot_kernel_filename,
3654                                BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3655                                    fprintf(stderr, "boot string too long?\n");
3656                                    exit(1);
3657                            }
3658    
3659                  /*  argc, argv, envp in a0, a1, a2:  */                          /*  Boot args., eg "-a"  */
3660                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */                          bootarg = machine->boot_string_argument;
3661    
3662                  /*  TODO:  not needed?  */                          /*  argc, argv, envp in a0, a1, a2:  */
3663                  cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */
                     (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);  
   
                 /*  Set up argc/argv:  */  
                 addr = ARC_ENV_STRINGS;  
                 addr2 = ARC_ARGV_START;  
                 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] ++;  
3664    
3665                  /*  bootarg:  */                          /*  TODO:  not needed?  */
3666                  if (bootarg[0] != '\0') {                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3667                                (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3668    
3669                            /*  Set up argc/argv:  */
3670                            addr = ARC_ENV_STRINGS;
3671                            addr2 = ARC_ARGV_START;
3672                            cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
3673    
3674                            /*  bootstr:  */
3675                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3676                          add_environment_string(cpu, bootarg, &addr);                          add_environment_string(cpu, bootstr, &addr);
3677                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                 }  
3678    
3679                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                          /*  bootarg:  */
3680                            if (bootarg[0] != '\0') {
3681                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3682                                    add_environment_string(cpu, bootarg, &addr);
3683                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3684                            }
3685    
3686                  /*                          cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
3687                   *  Add environment variables.  For each variable, add it  
3688                   *  as a string using add_environment_string(), and add a                          /*
3689                   *  pointer to it to the ARC_ENV_POINTERS array.                           *  Add environment variables.  For each variable, add it
3690                   */                           *  as a string using add_environment_string(), and add a
3691                  if (machine->use_x11) {                           *  pointer to it to the ARC_ENV_POINTERS array.
3692                          if (machine->machine_type == MACHINE_ARC) {                           */
3693                            if (machine->use_x11) {
3694                                    if (machine->machine_type == MACHINE_ARC) {
3695                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3696                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3697                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3698                                            add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3699                                    } else {
3700                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3701                                            add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3702                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3703                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3704    
3705                                            /*  g for graphical mode. G for graphical mode
3706                                                with SGI logo visible on Irix?  */
3707                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3708                                            add_environment_string(cpu, "console=g", &addr);
3709                                    }
3710                            } else {
3711                                    if (machine->machine_type == MACHINE_ARC) {
3712                                            /*  TODO: serial console for ARC?  */
3713                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3714                                            add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3715                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3716                                            add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3717                                    } else {
3718                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3719                                            add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3720                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3721                                            add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3722    
3723                                            /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3724                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3725                                            add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
3726                                    }
3727                            }
3728    
3729                            if (machine->machine_type == MACHINE_SGI) {
3730                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3731                                  add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3732                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3733                                  add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "diskless=0", &addr);
                         } else {  
3734                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3735                                  add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);                                  add_environment_string(cpu, "volume=80", &addr);
3736                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3737                                  add_environment_string(cpu, "ConsoleOut=video()", &addr);                                  add_environment_string(cpu, "sgilogo=y", &addr);
3738    
                                 /*  g for graphical mode. G for graphical mode  
                                     with SGI logo visible on Irix?  */  
3739                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3740                                  add_environment_string(cpu, "console=g", &addr);                                  add_environment_string(cpu, "monitor=h", &addr);
                         }  
                 } else {  
                         if (machine->machine_type == MACHINE_ARC) {  
                                 /*  TODO: serial console for ARC?  */  
3741                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3742                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "TimeZone=GMT", &addr);
3743                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3744                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "nogfxkbd=1", &addr);
3745                          } else {  
3746                                    /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */
3747    
3748                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3749                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);
3750                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3751                                  add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);                                  add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);
   
                                 /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */  
3752                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3753                                  add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */                                  add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
3754                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3755                  }                                  add_environment_string(cpu, "OSLoader=sash", &addr);
   
                 if (machine->machine_type == MACHINE_SGI) {  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "AutoLoad=No", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "diskless=0", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "volume=80", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "sgilogo=y", &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "monitor=h", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "TimeZone=GMT", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "nogfxkbd=1", &addr);  
3756    
3757                          /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3758                                    add_environment_string(cpu, "rbaud=9600", &addr);
3759                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3760                                    add_environment_string(cpu, "rebound=y", &addr);
3761                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3762                                    add_environment_string(cpu, "crt_option=1", &addr);
3763                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3764                                    add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
3765    
3766                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3767                          add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);                                  add_environment_string(cpu, "keybd=US", &addr);
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLoadFilename=/unix", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLoader=sash", &addr);  
3768    
3769                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3770                          add_environment_string(cpu, "rbaud=9600", &addr);                                  add_environment_string(cpu, "cpufreq=3", &addr);
3771                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3772                          add_environment_string(cpu, "rebound=y", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
3773                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3774                          add_environment_string(cpu, "crt_option=1", &addr);                                  add_environment_string(cpu, eaddr_string, &addr);
3775                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3776                          add_environment_string(cpu, "netaddr=10.0.0.1", &addr);                                  add_environment_string(cpu, "verbose=istrue", &addr);
3777                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3778                                    add_environment_string(cpu, "showconfig=istrue", &addr);
3779                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3780                                    add_environment_string(cpu, "diagmode=v", &addr);
3781                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3782                                    add_environment_string(cpu, "kernname=unix", &addr);
3783                            } else {
3784                                    char *tmp;
3785                                    size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3786                                    tmp = malloc(mlen);
3787                                    snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3788                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3789                                    add_environment_string(cpu, tmp, &addr);
3790    
3791                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3792                          add_environment_string(cpu, "keybd=US", &addr);                                  add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3793    
3794                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3795                          add_environment_string(cpu, "cpufreq=3", &addr);                                  add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3796                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          }
                         add_environment_string(cpu, "dbaud=9600", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, eaddr_string, &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "verbose=istrue", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "showconfig=istrue", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "diagmode=v", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "kernname=unix", &addr);  
                 } else {  
                         char *tmp;  
                         size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;  
                         tmp = malloc(mlen);  
                         snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, tmp, &addr);  
3797    
3798                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  End the environment strings with an empty zero-terminated
3799                          add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);                              string, and the envp array with a NULL pointer.  */
3800                            add_environment_string(cpu, "", &addr); /*  the end  */
3801                            store_pointer_and_advance(cpu, &addr2,
3802                                0, arc_wordlen==sizeof(uint64_t));
3803    
3804                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  Return address:  (0x20 = ReturnFromMain())  */
3805                          add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);                          cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;
3806                  }                  }
3807    
                 /*  End the environment strings with an empty zero-terminated  
                     string, and the envp array with a NULL pointer.  */  
                 add_environment_string(cpu, "", &addr); /*  the end  */  
                 store_pointer_and_advance(cpu, &addr2,  
                     0, arc_wordlen==sizeof(uint64_t));  
   
 no_arc_prom_emulation:          /*  TODO: ugly, get rid of the goto  */  
   
                 /*  Return address:  (0x20 = ReturnFromMain())  */  
                 cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;  
   
3808                  break;                  break;
3809    
3810          case MACHINE_MESHCUBE:          case MACHINE_MESHCUBE:
# Line 3602  no_arc_prom_emulation:         /*  TODO: ugly, Line 3834  no_arc_prom_emulation:         /*  TODO: ugly,
3834    
3835                  device_add(machine, "random addr=0x1017fffc len=4");                  device_add(machine, "random addr=0x1017fffc len=4");
3836    
3837                  /*                  if (machine->prom_emulation) {
3838                   *  TODO:  A Linux kernel wants "memsize" from somewhere... I                          /*
3839                   *  haven't found any docs on how it is used though.                           *  TODO:  A Linux kernel wants "memsize" from somewhere... I
3840                   */                           *  haven't found any docs on how it is used though.
3841                             */
3842                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
3843                  cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
3844                  store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
3845                      0xa0002000ULL);                              0xa0002000ULL);
3846                  store_string(cpu, 0xa0002000ULL, "something=somethingelse");                          store_string(cpu, 0xa0002000ULL, "something=somethingelse");
   
                 cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;  
                 store_string(cpu, 0xa0002000ULL, "hello=world\n");  
3847    
3848                            cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
3849                            store_string(cpu, 0xa0002000ULL, "hello=world\n");
3850                    }
3851                  break;                  break;
3852    
3853          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
3854                  machine->machine_name = "NetGear WG602";                  machine->machine_name = "NetGear WG602v1";
3855    
3856                  if (machine->use_x11)                  if (machine->use_x11)
3857                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
3858                  if (machine->physical_ram_in_mb != 16)                  if (machine->physical_ram_in_mb != 16)
3859                          fprintf(stderr, "WARNING! Real NetGear WG602 boxes have exactly 16 MB RAM. Continuing anyway.\n");                          fprintf(stderr, "WARNING! Real NetGear WG602v1 boxes have exactly 16 MB RAM. Continuing anyway.\n");
3860    
3861                  /*                  /*
3862                   *  Lots of info about the IDT 79RC 32334                   *  Lots of info about the IDT 79RC 32334
# Line 3657  no_arc_prom_emulation:         /*  TODO: ugly, Line 3889  no_arc_prom_emulation:         /*  TODO: ugly,
3889                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
3890                  machine->machine_name = "Sony NeWS (NET WORK STATION)";                  machine->machine_name = "Sony NeWS (NET WORK STATION)";
3891    
3892                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3893                  {                          /*  This is just a test.  TODO  */
3894                          int i;                          int i;
3895                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
3896                                  cpu->cd.mips.gpr[i] =                                  cpu->cd.mips.gpr[i] =
# Line 3676  no_arc_prom_emulation:         /*  TODO: ugly, Line 3908  no_arc_prom_emulation:         /*  TODO: ugly,
3908    
3909                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
3910                  case MACHINE_EVBMIPS_MALTA:                  case MACHINE_EVBMIPS_MALTA:
3911                          machine->machine_name = "MALTA (evbmips)";                  case MACHINE_EVBMIPS_MALTA_BE:
3912                            machine->machine_name = "MALTA (evbmips, little endian)";
3913                            cpu->byte_order = EMUL_LITTLE_ENDIAN;
3914    
3915                            if (machine->machine_subtype == MACHINE_EVBMIPS_MALTA_BE) {
3916                                    machine->machine_name = "MALTA (evbmips, big endian)";
3917                                    cpu->byte_order = EMUL_BIG_ENDIAN;
3918                            }
3919    
3920                          machine->md_int.malta_data =                          /*  ISA interrupt controllers:  */
3921                              device_add(machine, "malta addr=0x18000020");                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");
3922                            machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
3923                            snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");
3924                            machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
3925                          machine->md_interrupt = malta_interrupt;                          machine->md_interrupt = malta_interrupt;
3926    
3927                          dev_mc146818_init(machine, mem, 0x18000070,                          dev_mc146818_init(machine, mem, 0x18000070, 8 + 8, MC146818_PC_CMOS, 1);
3928                              8 + 8, MC146818_PC_CMOS, 1);  
3929                          machine->main_console_handle = dev_ns16550_init(machine, mem,                          machine->main_console_handle = (size_t)
3930                              0x180003f8, 8 + 4, 1, 1, "serial console");                              device_add(machine, "ns16550 irq=12 addr=0x180003f8 name2=tty0");
3931                            device_add(machine, "ns16550 irq=11 addr=0x180002f8 name2=tty1");
3932    
3933                            snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x name2=tty2", MALTA_CBUSUART);
3934                            device_add(machine, tmpstr);
3935                          /*  TODO: Irqs  */                          /*  TODO: Irqs  */
3936                          pci_data = dev_gt_init(machine, mem, 0x1be00000,                          pci_data = dev_gt_init(machine, mem, 0x1be00000, 8+9, 8+9, 120);
                             8+16, 8+16, 120);  
3937    
3938                          /*  TODO: Haha, this is bogus. Just a cut&paste                          /*  TODO: Haha, this is bogus. Just a cut&paste
3939                              from the Cobalt emulation above.  */                              from the Cobalt emulation above.  */
3940                          bus_pci_add(machine, pci_data, mem, 0,  9, 0,                          bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);
3941                              pci_vt82c586_isa_init, pci_vt82c586_isa_rr);                          bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
                         bus_pci_add(machine, pci_data, mem, 0,  9, 1,  
                             pci_vt82c586_ide_init, pci_vt82c586_ide_rr);  
3942    
3943                          device_add(machine, "malta_lcd addr=0x1f000400");                          device_add(machine, "malta_lcd addr=0x1f000400");
3944                          break;                          break;
3945                  case MACHINE_EVBMIPS_PB1000:                  case MACHINE_EVBMIPS_PB1000:
3946                          machine->machine_name = "PB1000 (evbmips)";                          machine->machine_name = "PB1000 (evbmips)";
3947                            cpu->byte_order = EMUL_BIG_ENDIAN;
3948    
3949                          machine->md_interrupt = au1x00_interrupt;                          machine->md_interrupt = au1x00_interrupt;
3950                          machine->md_int.au1x00_ic_data =                          machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem);
3951                              dev_au1x00_init(machine, mem);                          /*  TODO  */
3952                          break;                          break;
3953                  default:                  default:
3954                          fatal("Unimplemented EVBMIPS model.\n");                          fatal("Unimplemented EVBMIPS model.\n");
3955                          exit(1);                          exit(1);
3956                  }                  }
3957    
3958                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3959                  for (i=0; i<32; i++)                          /*  This is just a test.  TODO  */
3960                          cpu->cd.mips.gpr[i] =                          for (i=0; i<32; i++)
3961                              0x01230000 + (i << 8) + 0x55;                                  cpu->cd.mips.gpr[i] =
3962                                        0x01230000 + (i << 8) + 0x55;
3963                  /*  NetBSD/evbmips wants these: (at least for Malta)  */  
3964                            /*  NetBSD/evbmips wants these: (at least for Malta)  */
3965                  /*  a0 = argc  */  
3966                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;                          /*  a0 = argc  */
3967                            cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
3968                  /*  a1 = argv  */  
3969                  cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;                          /*  a1 = argv  */
3970                  store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);                          cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
3971                  store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);                          store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
3972                            store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
3973                  bootstr = strdup(machine->boot_kernel_filename);                          store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
3974                  bootarg = strdup(machine->boot_string_argument);  
3975                  store_string(cpu, (int32_t)0x9fc01040, bootstr);                          bootstr = strdup(machine->boot_kernel_filename);
3976                  store_string(cpu, (int32_t)0x9fc01200, bootarg);                          bootarg = strdup(machine->boot_string_argument);
3977                            store_string(cpu, (int32_t)0x9fc01040, bootstr);
3978                  /*  a2 = (yamon_env_var *)envp  */                          store_string(cpu, (int32_t)0x9fc01200, bootarg);
3979                  cpu->cd.mips.gpr[MIPS_GPR_A2] = 0;  
3980                            /*  a2 = (yamon_env_var *)envp  */
3981                  /*  a3 = memsize  */                          cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
3982                  cpu->cd.mips.gpr[MIPS_GPR_A3] =                          {
3983                      machine->physical_ram_in_mb * 1048576;                                  uint64_t env = cpu->cd.mips.gpr[MIPS_GPR_A2];
3984                                    uint64_t tmpptr = 0xffffffff9fc01c00ULL;
3985                  /*  Yamon emulation vectors at 0x9fc005xx:  */                                  char tmps[50];
3986                  for (i=0; i<0x100; i+=4)  
3987                          store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,                                  snprintf(tmps, sizeof(tmps), "0x%08x",
3988                              (int64_t)(int32_t)0x9fc00800 + i);                                      machine->physical_ram_in_mb * 1048576);
3989                                    add_environment_string_dual(cpu,
3990                                        &env, &tmpptr, "memsize", tmps);
3991    
3992                                    add_environment_string_dual(cpu,
3993                                        &env, &tmpptr, "yamonrev", "02.06");
3994    
3995                                    /*  End of env:  */
3996                                    tmpptr = 0;
3997                                    add_environment_string_dual(cpu,
3998                                        &env, &tmpptr, NULL, NULL);
3999                            }
4000    
4001                            /*  a3 = memsize  */
4002                            cpu->cd.mips.gpr[MIPS_GPR_A3] =
4003                                machine->physical_ram_in_mb * 1048576;
4004                            /*  Hm. Linux ignores a3.  */
4005    
4006                            /*
4007                             *  TODO:
4008                             *      Core ID numbers.
4009                             *      How much of this is not valid for PBxxxx?
4010                             *
4011                             *  See maltareg.h for more info.
4012                             */
4013                            store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION), (1 << 10) + 0x26);
4014    
4015                            /*  Call vectors at 0x9fc005xx:  */
4016                            for (i=0; i<0x100; i+=4)
4017                                    store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,
4018                                        (int64_t)(int32_t)0x9fc00800 + i);
4019                    }
4020                  break;                  break;
4021    
4022          case MACHINE_PSP:          case MACHINE_PSP:
# Line 3765  no_arc_prom_emulation:         /*  TODO: ugly, Line 4040  no_arc_prom_emulation:         /*  TODO: ugly,
4040    
4041                  /*  480 x 272 pixels framebuffer (512 bytes per line)  */                  /*  480 x 272 pixels framebuffer (512 bytes per line)  */
4042                  fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPCMIPS,                  fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPCMIPS,
4043                      480,272, 512,1088, -15, "Playstation Portable", 0);                      480,272, 512,1088, -15, "Playstation Portable");
4044    
4045                  /*                  /*
4046                   *  TODO/NOTE: This is ugly, but necessary since GXemul doesn't                   *  TODO/NOTE: This is ugly, but necessary since GXemul doesn't
# Line 3786  no_arc_prom_emulation:         /*  TODO: ugly, Line 4061  no_arc_prom_emulation:         /*  TODO: ugly,
4061                  cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;                  cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;
4062    
4063                  break;                  break;
4064    #endif  /*  ENABLE_MIPS  */
4065    
4066    #ifdef ENABLE_PPC
4067          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
4068                  /*                  /*
4069                   *  A "bare" PPC machine.                   *  A "bare" PPC machine.
# Line 3803  no_arc_prom_emulation:         /*  TODO: ugly, Line 4080  no_arc_prom_emulation:         /*  TODO: ugly,
4080                  machine->machine_name = "PPC test machine";                  machine->machine_name = "PPC test machine";
4081    
4082                  /*  TODO: interrupt for PPC?  */                  /*  TODO: interrupt for PPC?  */
4083                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4084                      machine, mem, DEV_CONS_ADDRESS, "console", 0);                      (long long)DEV_CONS_ADDRESS);
4085                    cons_data = device_add(machine, tmpstr);
4086                    machine->main_console_handle = cons_data->console_handle;
4087    
4088                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4089                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
4090                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
4091    
4092                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4093                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testppc generic");
4094    
4095                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4096                        (long long)DEV_DISK_ADDRESS);
4097                    device_add(machine, tmpstr);
4098    
4099                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4100                        (long long)DEV_ETHER_ADDRESS);
4101                    device_add(machine, tmpstr);
4102    
4103                  break;                  break;
4104    
4105          case MACHINE_WALNUT:          case MACHINE_WALNUT:
# Line 3831  no_arc_prom_emulation:         /*  TODO: ugly, Line 4119  no_arc_prom_emulation:         /*  TODO: ugly,
4119                  dev_pmppc_init(mem);                  dev_pmppc_init(mem);
4120    
4121                  /*  com0 = 0xff600300, com1 = 0xff600400  */                  /*  com0 = 0xff600300, com1 = 0xff600400  */
4122                  machine->main_console_handle = dev_ns16550_init(machine, mem,  
4123                      0xff600300, 0, 1, 1, "serial 0");                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0xff600300 name2=tty0");
4124                  dev_ns16550_init(machine, mem,                  device_add(machine, "ns16550 irq=0 addr=0xff600400 in_use=0 name2=tty1");
                     0xff600400, 0, 1, 0, "serial 1");  
4125    
4126                  break;                  break;
4127    
# Line 3861  no_arc_prom_emulation:         /*  TODO: ugly, Line 4148  no_arc_prom_emulation:         /*  TODO: ugly,
4148    
4149                  device_add(machine, "bebox");                  device_add(machine, "bebox");
4150    
4151                  /*  Serial, used by NetBSD:  */                  machine->main_console_handle = (size_t)
4152                  machine->main_console_handle = dev_ns16550_init(machine, mem,                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");
4153                      0x800003f8, 0, 1, 1, "serial 0");                  device_add(machine, "ns16550 irq=0 addr=0x800002f8 name2=tty1 in_use=0");
4154    
4155                  /*  Serial, used by Linux:  */                  dev_pckbc_init(machine, mem, 0x80000060, PCKBC_8042,
4156                  dev_ns16550_init(machine, mem, 0x800002f8, 0, 1, 0, "serial 1");                      1, 12, machine->use_x11, 1);
   
                 /*  This is used by Linux too:  */  
                 dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,  
                     machine->machine_name);  
   
                 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, "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);  
4157    
4158                    if (machine->use_x11)
4159                            dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,
4160                                machine->machine_name);
4161    
4162                    if (machine->prom_emulation) {
4163                            store_32bit_word(cpu, 0x3010, machine->physical_ram_in_mb * 1048576);
4164    
4165                            /*  TODO: List of stuff, see http://www.beatjapan.org/
4166                                mirror/www.be.com/aboutbe/benewsletter/
4167                                Issue27.html#Cookbook  for the details.  */
4168                            store_32bit_word(cpu, 0x301c, 0);
4169    
4170                            /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4171                                r5 = args, r6 = ptr to bootinfo?  */
4172                            cpu->cd.ppc.gpr[3] = 0x3100;
4173                            cpu->cd.ppc.gpr[4] = 0x200000;
4174                            cpu->cd.ppc.gpr[5] = 0x2000;
4175                            store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4176                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4177    
4178                            /*  See NetBSD's bebox/include/bootinfo.h for details  */
4179                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */
4180                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4181                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4182                                machine->physical_ram_in_mb * 1048576);
4183    
4184                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */
4185                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4186                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4187                                machine->use_x11? "vga" : "com", 4);
4188                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4189                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4190    
4191                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4192                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */
4193                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4194                    }
4195                  break;                  break;
4196    
4197          case MACHINE_PREP:          case MACHINE_PREP:
# Line 3913  no_arc_prom_emulation:         /*  TODO: ugly, Line 4200  no_arc_prom_emulation:         /*  TODO: ugly,
4200                   */                   */
4201                  machine->machine_name = "PowerPC Reference Platform";                  machine->machine_name = "PowerPC Reference Platform";
4202    
4203                  {                  if (machine->prom_emulation) {
4204                          int i;                          /*  Linux on PReP has 0xdeadc0de at address 0? (See
4205                          for (i=0; i<32; i++)                              http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */
4206                                  cpu->cd.ppc.gpr[i] =                          store_32bit_word(cpu, 0, 0xdeadc0de);
                                     0x12340000 + (i << 8) + 0x55;  
                 }  
   
                 /*  Linux on PReP has 0xdeadc0de at address 0? (See  
                     http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */  
                 store_32bit_word(cpu, 0, 0xdeadc0de);  
   
                 /*  r6 should point to "residual data"?  */  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x1000;  
4207    
4208                            /*  r6 should point to "residual data"?  */
4209                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x1000;
4210                    }
4211                  break;                  break;
4212    
4213          case MACHINE_MACPPC:          case MACHINE_MACPPC:
# Line 3937  no_arc_prom_emulation:         /*  TODO: ugly, Line 4217  no_arc_prom_emulation:         /*  TODO: ugly,
4217                   */                   */
4218                  machine->machine_name = "Macintosh (PPC)";                  machine->machine_name = "Macintosh (PPC)";
4219    
4220                  /*  r5 = OpenFirmware entry point  */                  if (machine->prom_emulation) {
4221                  cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;                          uint64_t b = 8 * 1048576, a = b - 0x800;
4222                            int i;
4223                            /*
4224                             *  r3 = pointer to boot_args (for the Mach kernel).
4225                             *  See http://darwinsource.opendarwin.org/10.3/
4226                             *  BootX-59/bootx.tproj/include.subproj/boot_args.h
4227                             *  for more info.
4228                             */
4229                            cpu->cd.ppc.gpr[3] = a;
4230                            store_16bit_word(cpu, a + 0x0000, 1);   /*  revision  */
4231                            store_16bit_word(cpu, a + 0x0002, 2);   /*  version  */
4232                            store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
4233                            /*  26 dram banks; "long base; long size"  */
4234                            store_32bit_word(cpu, a + 0x0104, 0);   /*  base  */
4235                            store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
4236                                * 256);             /*  size (in pages)  */
4237                            for (i=8; i<26*8; i+= 4)
4238                                    store_32bit_word(cpu, a + 0x0104 + i, 0);
4239                            a += (0x104 + 26 * 8);
4240                            /*  Video info:  */
4241                            store_32bit_word(cpu, a+0, 0xd0000000); /*  video base  */
4242                            store_32bit_word(cpu, a+4, 0);          /*  display code (?)  */
4243                            store_32bit_word(cpu, a+8, 800);        /*  bytes per pixel row  */
4244                            store_32bit_word(cpu, a+12, 800);       /*  width  */
4245                            store_32bit_word(cpu, a+16, 600);       /*  height  */
4246                            store_32bit_word(cpu, a+20, 8);         /*  pixel depth  */
4247                            a += 24;
4248                            store_32bit_word(cpu, a+0, 127);        /*  gestalt number (TODO)  */
4249                            store_32bit_word(cpu, a+4, 0);          /*  device tree pointer (TODO)  */
4250                            store_32bit_word(cpu, a+8, 0);          /*  device tree length  */
4251                            store_32bit_word(cpu, a+12, b);         /*  last address of kernel data area  */
4252    
4253                            /*  r4 = "MOSX" (0x4D4F5358)  */
4254                            cpu->cd.ppc.gpr[4] = 0x4D4F5358;
4255    
4256                            /*
4257                             *  r5 = OpenFirmware entry point.  NOTE: See
4258                             *  cpu_ppc.c for the rest of this semi-ugly hack.
4259                             */
4260                            dev_ram_init(cpu->mem, cpu->cd.ppc.of_emul_addr,
4261                                0x1000, DEV_RAM_RAM, 0x0);
4262                            store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
4263                                0x44ee0002);
4264                            cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4265                    }
4266                  break;                  break;
4267    
4268          case MACHINE_DB64360:          case MACHINE_DB64360:
4269                  /*  For playing with PMON2000 for PPC:  */                  /*  For playing with PMON2000 for PPC:  */
4270                  machine->machine_name = "DB64360";                  machine->machine_name = "DB64360";
4271    
4272                  machine->main_console_handle = dev_ns16550_init(machine, mem,                  machine->main_console_handle = (size_t)device_add(machine,
4273                      0x1d000020, 0, 4, 1, "serial console");                      "ns16550 irq=0 addr=0x1d000020 addr_mult=4");
4274    
4275                  {                  if (machine->prom_emulation) {
4276                          int i;                          int i;
4277                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
4278                                  cpu->cd.ppc.gpr[i] =                                  cpu->cd.ppc.gpr[i] =
# Line 3957  no_arc_prom_emulation:         /*  TODO: ugly, Line 4280  no_arc_prom_emulation:         /*  TODO: ugly,
4280                  }                  }
4281    
4282                  break;                  break;
4283    #endif  /*  ENABLE_PPC  */
4284    
4285          case MACHINE_BARESPARC:  #ifdef ENABLE_SH
4286                  /*  A bare SPARC machine, with no devices.  */          case MACHINE_BARESH:
4287                  machine->machine_name = "\"Bare\" SPARC machine";                  /*  A bare SH machine, with no devices.  */
4288                    machine->machine_name = "\"Bare\" SH machine";
4289                  break;                  break;
4290    
4291          case MACHINE_ULTRA1:          case MACHINE_TESTSH:
4292                  /*                  machine->machine_name = "SH test machine";
4293                   *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)  
4294                   *  OpenBSD/sparc64 (http://www.openbsd.org/sparc64.html)                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4295                   */                      (long long)DEV_CONS_ADDRESS);
4296                  machine->machine_name = "Sun Ultra1";                  cons_data = device_add(machine, tmpstr);
4297                  break;                  machine->main_console_handle = cons_data->console_handle;
4298    
4299                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4300                        (long long)DEV_MP_ADDRESS);
4301                    device_add(machine, tmpstr);
4302    
4303                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4304                        640,480, 640,480, 24, "testsh generic");
4305    
4306                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4307                        (long long)DEV_DISK_ADDRESS);
4308                    device_add(machine, tmpstr);
4309    
4310                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4311                        (long long)DEV_ETHER_ADDRESS);
4312                    device_add(machine, tmpstr);
4313    
         case MACHINE_BAREURISC:  
                 machine->machine_name = "\"Bare\" URISC machine";  
4314                  break;                  break;
4315    
4316          case MACHINE_TESTURISC:          case MACHINE_HPCSH:
4317                  machine->machine_name = "URISC test machine";                  /*  Handheld SH-based machines:  */
4318                    machine->machine_name = "HPCsh";
4319    
4320                  /*  TODO  */                  /*  TODO  */
                 /*  A special "device" for accessing normal devices  
                     using urisc accesses?  */  
   
                 device_add(machine, "urisc addr=0x12341234");  
4321    
4322                  break;                  break;
4323    #endif  /*  ENABLE_SH  */
4324    
4325    #ifdef ENABLE_HPPA
4326          case MACHINE_BAREHPPA:          case MACHINE_BAREHPPA:
4327                    /*  A bare HPPA machine, with no devices.  */
4328                  machine->machine_name = "\"Bare\" HPPA machine";                  machine->machine_name = "\"Bare\" HPPA machine";
4329                  break;                  break;
4330    
4331          case MACHINE_TESTHPPA:          case MACHINE_TESTHPPA:
4332                  machine->machine_name = "HPPA test machine";                  machine->machine_name = "HPPA test machine";
4333    
4334                  /*  TODO  */                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4335                        (long long)DEV_CONS_ADDRESS);
4336                    cons_data = device_add(machine, tmpstr);
4337                    machine->main_console_handle = cons_data->console_handle;
4338    
4339                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4340                        (long long)DEV_MP_ADDRESS);
4341                    device_add(machine, tmpstr);
4342    
4343                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4344                        640,480, 640,480, 24, "testhppa generic");
4345    
4346                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4347                        (long long)DEV_DISK_ADDRESS);
4348                    device_add(machine, tmpstr);
4349    
4350                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4351                        (long long)DEV_ETHER_ADDRESS);
4352                    device_add(machine, tmpstr);
4353    
4354                    break;
4355    #endif  /*  ENABLE_HPPA  */
4356    
4357    #ifdef ENABLE_I960
4358            case MACHINE_BAREI960:
4359                    /*  A bare I960 machine, with no devices.  */
4360                    machine->machine_name = "\"Bare\" i960 machine";
4361                    break;
4362    
4363            case MACHINE_TESTI960:
4364                    machine->machine_name = "i960 test machine";
4365    
4366                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4367                        (long long)DEV_CONS_ADDRESS);
4368                    cons_data = device_add(machine, tmpstr);
4369                    machine->main_console_handle = cons_data->console_handle;
4370    
4371                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4372                        (long long)DEV_MP_ADDRESS);
4373                    device_add(machine, tmpstr);
4374    
4375                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4376                        640,480, 640,480, 24, "testi960 generic");
4377    
4378                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4379                        (long long)DEV_DISK_ADDRESS);
4380                    device_add(machine, tmpstr);
4381    
4382                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4383                        (long long)DEV_ETHER_ADDRESS);
4384                    device_add(machine, tmpstr);
4385    
4386                    break;
4387    #endif  /*  ENABLE_I960  */
4388    
4389    #ifdef ENABLE_SPARC
4390            case MACHINE_BARESPARC:
4391                    /*  A bare SPARC machine, with no devices.  */
4392                    machine->machine_name = "\"Bare\" SPARC machine";
4393                    break;
4394    
4395            case MACHINE_TESTSPARC:
4396                    machine->machine_name = "SPARC test machine";
4397    
4398                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4399                        (long long)DEV_CONS_ADDRESS);
4400                    cons_data = device_add(machine, tmpstr);
4401                    machine->main_console_handle = cons_data->console_handle;
4402    
4403                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4404                        (long long)DEV_MP_ADDRESS);
4405                    device_add(machine, tmpstr);
4406    
4407                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4408                        640,480, 640,480, 24, "testsparc generic");
4409    
4410                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4411                        (long long)DEV_DISK_ADDRESS);
4412                    device_add(machine, tmpstr);
4413    
4414                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4415                        (long long)DEV_ETHER_ADDRESS);
4416                    device_add(machine, tmpstr);
4417    
4418                    break;
4419    
4420            case MACHINE_ULTRA1:
4421                    /*
4422                     *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)
4423                     *  OpenBSD/sparc64 (http://www.openbsd.org/sparc64.html)
4424                     */
4425                    machine->machine_name = "Sun Ultra1";
4426                  break;                  break;
4427    #endif  /*  ENABLE_SPARC  */
4428    
4429    #ifdef ENABLE_ALPHA
4430          case MACHINE_BAREALPHA:          case MACHINE_BAREALPHA:
4431                  machine->machine_name = "\"Bare\" Alpha machine";                  machine->machine_name = "\"Bare\" Alpha machine";
4432                  break;                  break;
# Line 4003  no_arc_prom_emulation:         /*  TODO: ugly, Line 4434  no_arc_prom_emulation:         /*  TODO: ugly,
4434          case MACHINE_TESTALPHA:          case MACHINE_TESTALPHA:
4435                  machine->machine_name = "Alpha test machine";                  machine->machine_name = "Alpha test machine";
4436    
4437                  /*  TODO  */                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4438                        (long long)DEV_CONS_ADDRESS);
4439                    cons_data = device_add(machine, tmpstr);
4440                    machine->main_console_handle = cons_data->console_handle;
4441    
4442                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4443                        (long long)DEV_MP_ADDRESS);
4444                    device_add(machine, tmpstr);
4445    
4446                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4447                        640,480, 640,480, 24, "testalpha generic");
4448    
4449                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4450                        (long long)DEV_DISK_ADDRESS);
4451                    device_add(machine, tmpstr);
4452    
4453                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4454                        (long long)DEV_ETHER_ADDRESS);
4455                    device_add(machine, tmpstr);
4456    
4457                  break;                  break;
4458    
4459            case MACHINE_ALPHA:
4460                    if (machine->prom_emulation) {
4461                            struct rpb rpb;
4462                            struct crb crb;
4463                            struct ctb ctb;
4464    
4465                            /*  TODO:  Most of these... They are used by NetBSD/alpha:  */
4466                            /*  a0 = First free Page Frame Number  */
4467                            /*  a1 = PFN of current Level 1 page table  */
4468                            /*  a2 = Bootinfo magic  */
4469                            /*  a3 = Bootinfo pointer  */
4470                            /*  a4 = Bootinfo version  */
4471                            cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
4472                            cpu->cd.alpha.r[ALPHA_A1] = 0;
4473                            cpu->cd.alpha.r[ALPHA_A2] = 0;
4474                            cpu->cd.alpha.r[ALPHA_A3] = 0;
4475                            cpu->cd.alpha.r[ALPHA_A4] = 0;
4476    
4477                            /*  HWRPB: Hardware Restart Parameter Block  */
4478                            memset(&rpb, 0, sizeof(struct rpb));
4479                            store_64bit_word_in_host(cpu, (unsigned char *)
4480                                &(rpb.rpb_phys), HWRPB_ADDR);
4481                            strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8);
4482                            store_64bit_word_in_host(cpu, (unsigned char *)
4483                                &(rpb.rpb_size), sizeof(struct rpb));
4484                            store_64bit_word_in_host(cpu, (unsigned char *)
4485                                &(rpb.rpb_page_size), 8192);
4486                            store_64bit_word_in_host(cpu, (unsigned char *)
4487                                &(rpb.rpb_type), machine->machine_subtype);
4488                            store_64bit_word_in_host(cpu, (unsigned char *)
4489                                &(rpb.rpb_cc_freq), 100000000);
4490                            store_64bit_word_in_host(cpu, (unsigned char *)
4491                                &(rpb.rpb_ctb_off), CTB_ADDR - HWRPB_ADDR);
4492                            store_64bit_word_in_host(cpu, (unsigned char *)
4493                                &(rpb.rpb_crb_off), CRB_ADDR - HWRPB_ADDR);
4494    
4495                            /*  CTB: Console Terminal Block  */
4496                            memset(&ctb, 0, sizeof(struct ctb));
4497                            store_64bit_word_in_host(cpu, (unsigned char *)
4498                                &(ctb.ctb_term_type), machine->use_x11?
4499                                CTB_GRAPHICS : CTB_PRINTERPORT);
4500    
4501                            /*  CRB: Console Routine Block  */
4502                            memset(&crb, 0, sizeof(struct crb));
4503                            store_64bit_word_in_host(cpu, (unsigned char *)
4504                                &(crb.crb_v_dispatch), CRB_ADDR - 0x100);
4505                            store_64bit_word(cpu, CRB_ADDR - 0x100 + 8, 0x10000);
4506    
4507                            /*
4508                             *  Place a special "hack" palcode call at 0x10000:
4509                             *  (Hopefully nothing else will be there.)
4510                             */
4511                            store_32bit_word(cpu, 0x10000, 0x3fffffe);
4512    
4513                            store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb));
4514                            store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb));
4515                            store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb));
4516                    }
4517    
4518                    switch (machine->machine_subtype) {
4519                    case ST_DEC_3000_300:
4520                            machine->machine_name = "DEC 3000/300";
4521                            machine->main_console_handle =
4522                                dev_zs_init(machine, mem, 0x1b0200000ULL,
4523                                0, 4, "serial zs"); /*  serial? netbsd?  */
4524                            break;
4525                    case ST_EB164:
4526                            machine->machine_name = "EB164";
4527                            break;
4528                    default:fatal("Unimplemented Alpha machine type %i\n",
4529                                machine->machine_subtype);
4530                            exit(1);
4531                    }
4532    
4533                    break;
4534    #endif  /*  ENABLE_ALPHA  */
4535    
4536    #ifdef ENABLE_ARM
4537          case MACHINE_BAREARM:          case MACHINE_BAREARM:
4538                  machine->machine_name = "\"Bare\" ARM machine";                  machine->machine_name = "\"Bare\" ARM machine";
4539                  break;                  break;
# Line 4013  no_arc_prom_emulation:         /*  TODO: ugly, Line 4541  no_arc_prom_emulation:         /*  TODO: ugly,
4541          case MACHINE_TESTARM:          case MACHINE_TESTARM:
4542                  machine->machine_name = "ARM test machine";                  machine->machine_name = "ARM test machine";
4543    
4544                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4545                      machine, mem, DEV_CONS_ADDRESS, "console", 2);                      (long long)DEV_CONS_ADDRESS);
4546                    cons_data = device_add(machine, tmpstr);
4547                    machine->main_console_handle = cons_data->console_handle;
4548    
4549                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4550                        (long long)DEV_MP_ADDRESS);
4551                    device_add(machine, tmpstr);
4552    
4553                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4554                        640,480, 640,480, 24, "testarm generic");
4555    
4556                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4557                        (long long)DEV_DISK_ADDRESS);
4558                    device_add(machine, tmpstr);
4559    
4560                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4561                        (long long)DEV_ETHER_ADDRESS);
4562                    device_add(machine, tmpstr);
4563    
4564                    /*  Place a tiny stub at end of memory, and set the link
4565                        register to point to it. This stub halts the machine.  */
4566                    cpu->cd.arm.r[ARM_SP] =
4567                        machine->physical_ram_in_mb * 1048576 - 4096;
4568                    cpu->cd.arm.r[ARM_LR] = cpu->cd.arm.r[ARM_SP] + 32;
4569                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 0, 0xe3a00201);
4570                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 4, 0xe5c00010);
4571                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4572                        0xeafffffe);
4573                    break;
4574    
4575            case MACHINE_CATS:
4576                    machine->machine_name = "CATS evaluation board";
4577    
4578                    if (machine->physical_ram_in_mb > 256)
4579                            fprintf(stderr, "WARNING! Real CATS machines cannot"
4580                                " have more than 256 MB RAM. Continuing anyway.\n");
4581    
4582                    machine->md_int.footbridge_data =
4583                        device_add(machine, "footbridge addr=0x42000000");
4584                    machine->md_interrupt = footbridge_interrupt;
4585    
4586                    /*  NetBSD and OpenBSD clean their caches here:  */
4587                    dev_ram_init(mem, 0x50000000, 0x4000, DEV_RAM_RAM, 0);
4588    
4589                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4590                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4591                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4592                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4593    
4594                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  device_add(machine, "pccmos addr=0x7c000070");
4595                      640,480, 640,480, 24, "generic", 1);  
4596                    if (machine->use_x11) {
4597                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4598                                mem, 0xc0, 8, 0, pci_s3_virge_init, pci_s3_virge_rr);
4599                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4600                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4601                                32 + 1, 32 + 12, machine->use_x11, 0);
4602                            machine->main_console_handle = j;
4603                    }
4604    
4605                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0 in_use=0");
4606                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1 in_use=0");
4607    
4608                    if (machine->prom_emulation) {
4609                            struct ebsaboot ebsaboot;
4610    
4611                            cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
4612                                7 * 1048576 - 0x1000;
4613    
4614                            memset(&ebsaboot, 0, sizeof(struct ebsaboot));
4615                            store_32bit_word_in_host(cpu, (unsigned char *)
4616                                &(ebsaboot.bt_magic), BT_MAGIC_NUMBER_CATS);
4617                            store_32bit_word_in_host(cpu, (unsigned char *)
4618                                &(ebsaboot.bt_vargp), 0);
4619                            store_32bit_word_in_host(cpu, (unsigned char *)
4620                                &(ebsaboot.bt_pargp), 0);
4621                            store_32bit_word_in_host(cpu, (unsigned char *)
4622                                &(ebsaboot.bt_args), cpu->cd.arm.r[0]
4623                                + sizeof(struct ebsaboot));
4624                            store_32bit_word_in_host(cpu, (unsigned char *)
4625                                &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
4626                            store_32bit_word_in_host(cpu, (unsigned char *)
4627                                &(ebsaboot.bt_memstart), 0);
4628                            store_32bit_word_in_host(cpu, (unsigned char *)
4629                                &(ebsaboot.bt_memend),
4630                                machine->physical_ram_in_mb * 1048576);
4631                            store_32bit_word_in_host(cpu, (unsigned char *)
4632                                &(ebsaboot.bt_memavail), 7 * 1048576);
4633                            store_32bit_word_in_host(cpu, (unsigned char *)
4634                                &(ebsaboot.bt_fclk), 50 * 1000000);
4635                            store_32bit_word_in_host(cpu, (unsigned char *)
4636                                &(ebsaboot.bt_pciclk), 66 * 1000000);
4637                            /*  TODO: bt_vers  */
4638                            /*  TODO: bt_features  */
4639    
4640                            store_buf(cpu, cpu->cd.arm.r[0],
4641                                (char *)&ebsaboot, sizeof(struct ebsaboot));
4642                            store_string(cpu, cpu->cd.arm.r[0] +
4643                                sizeof(struct ebsaboot),
4644                                machine->boot_string_argument);
4645    
4646                            arm_setup_initial_translation_table(cpu,
4647                                7 * 1048576 - 32768);
4648                    }
4649                  break;                  break;
4650    
4651            case MACHINE_HPCARM:
4652                    machine->machine_name = "HPCarm";
4653                    dev_ram_init(mem, 0xc0000000, 0x10000000, DEV_RAM_MIRROR, 0x0);
4654    
4655                    /*  TODO: Different models  */
4656    
4657                    if (machine->prom_emulation) {
4658                            cpu->cd.arm.r[0] = 1;
4659                            cpu->cd.arm.r[ARM_SP] = 0xc000c000;
4660                    }
4661                    break;
4662    
4663            case MACHINE_ZAURUS:
4664                    machine->machine_name = "Zaurus";
4665                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4666                    device_add(machine, "ns16550 irq=0 addr=0x40100000 addr_mult=4");
4667                    /*  TODO  */
4668                    if (machine->prom_emulation) {
4669                            arm_setup_initial_translation_table(cpu, 0x4000);
4670                    }
4671                    break;
4672    
4673            case MACHINE_NETWINDER:
4674                    machine->machine_name = "NetWinder";
4675    
4676                    if (machine->physical_ram_in_mb > 256)
4677                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4678                                " have more than 256 MB RAM. Continuing anyway.\n");
4679    
4680                    machine->md_int.footbridge_data =
4681                        device_add(machine, "footbridge addr=0x42000000");
4682                    machine->md_interrupt = footbridge_interrupt;
4683    
4684                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4685                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4686                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4687                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4688    
4689                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4690                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4691    
4692                    if (machine->use_x11) {
4693                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4694                                mem, 0xc0, 8, 0, pci_igsfb_init, pci_igsfb_rr);
4695                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4696                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4697                                32 + 1, 32 + 12, machine->use_x11, 0);
4698                            machine->main_console_handle = j;
4699                    }
4700    
4701                    if (machine->prom_emulation) {
4702                            arm_setup_initial_translation_table(cpu, 0x4000);
4703                    }
4704                    break;
4705    
4706            case MACHINE_SHARK:
4707                    machine->machine_name = "Digital DNARD (\"Shark\")";
4708                    if (machine->prom_emulation) {
4709                            arm_setup_initial_translation_table(cpu,
4710                                machine->physical_ram_in_mb * 1048576 - 65536);
4711    
4712                            /*
4713                             *  r0 = OpenFirmware entry point.  NOTE: See
4714                             *  cpu_arm.c for the rest of this semi-ugly hack.
4715                             */
4716                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4717                    }
4718                    break;
4719    
4720            case MACHINE_IQ80321:
4721                    /*
4722                     *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4723                     *  for more details about the memory map.
4724                     */
4725                    machine->machine_name = "Intel IQ80321 (ARM)";
4726                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4727                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4728                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4729                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4730                    dev_ram_init(mem, 0xc0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4731                    if (machine->prom_emulation) {
4732                            arm_setup_initial_translation_table(cpu, 0x8000);
4733                    }
4734                    break;
4735    
4736            case MACHINE_IYONIX:
4737                    machine->machine_name = "Iyonix";
4738                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4739                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4740                    if (machine->prom_emulation) {
4741                            arm_setup_initial_translation_table(cpu,
4742                                machine->physical_ram_in_mb * 1048576 - 65536);
4743                    }
4744                    break;
4745    #endif  /*  ENABLE_ARM  */
4746    
4747    #ifdef ENABLE_AVR
4748            case MACHINE_BAREAVR:
4749                    /*  A bare Atmel AVR machine, with no devices.  */
4750                    machine->machine_name = "\"Bare\" Atmel AVR machine";
4751                    break;
4752    #endif  /*  ENABLE_AVR  */
4753    
4754    #ifdef ENABLE_IA64
4755            case MACHINE_BAREIA64:
4756                    machine->machine_name = "\"Bare\" IA64 machine";
4757                    break;
4758    
4759            case MACHINE_TESTIA64:
4760                    machine->machine_name = "IA64 test machine";
4761    
4762                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4763                        (long long)DEV_CONS_ADDRESS);
4764                    cons_data = device_add(machine, tmpstr);
4765                    machine->main_console_handle = cons_data->console_handle;
4766    
4767                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4768                        (long long)DEV_MP_ADDRESS);
4769                    device_add(machine, tmpstr);
4770    
4771                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4772                        640,480, 640,480, 24, "testia64 generic");
4773    
4774                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4775                        (long long)DEV_DISK_ADDRESS);
4776                    device_add(machine, tmpstr);
4777    
4778                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4779                        (long long)DEV_ETHER_ADDRESS);
4780                    device_add(machine, tmpstr);
4781    
4782                    break;
4783    #endif  /*  ENABLE_IA64  */
4784    
4785    #ifdef ENABLE_M68K
4786            case MACHINE_BAREM68K:
4787                    machine->machine_name = "\"Bare\" M68K machine";
4788                    break;
4789    
4790            case MACHINE_TESTM68K:
4791                    machine->machine_name = "M68K test machine";
4792    
4793                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4794                        (long long)DEV_CONS_ADDRESS);
4795                    cons_data = device_add(machine, tmpstr);
4796                    machine->main_console_handle = cons_data->console_handle;
4797    
4798                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4799                        (long long)DEV_MP_ADDRESS);
4800                    device_add(machine, tmpstr);
4801    
4802                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4803                        640,480, 640,480, 24, "testm68k generic");
4804    
4805                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4806                        (long long)DEV_DISK_ADDRESS);
4807                    device_add(machine, tmpstr);
4808    
4809                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4810                        (long long)DEV_ETHER_ADDRESS);
4811                    device_add(machine, tmpstr);
4812    
4813                    break;
4814    #endif  /*  ENABLE_M68K  */
4815    
4816    #ifdef ENABLE_X86
4817          case MACHINE_BAREX86:          case MACHINE_BAREX86:
4818                  machine->machine_name = "\"Bare\" x86 machine";                  machine->machine_name = "\"Bare\" x86 machine";
4819                  break;                  break;
# Line 4031  no_arc_prom_emulation:         /*  TODO: ugly, Line 4825  no_arc_prom_emulation:         /*  TODO: ugly,
4825                          machine->machine_name = "Generic x86 PC";                          machine->machine_name = "Generic x86 PC";
4826    
4827                  /*  Interrupt controllers:  */                  /*  Interrupt controllers:  */
4828                  snprintf(tmpstr, sizeof(tmpstr) - 1, "8259 addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",
4829                      (long long)(X86_IO_BASE + 0x20));                      (long long)(X86_IO_BASE + 0x20));
4830                  machine->md.pc.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4831                  if (machine->machine_subtype != MACHINE_X86_XT) {                  if (machine->machine_subtype != MACHINE_X86_XT) {
4832                          snprintf(tmpstr, sizeof(tmpstr) - 1, "8259 addr=0x%llx irq=2",                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",
4833                              (long long)(X86_IO_BASE + 0xa0));                              (long long)(X86_IO_BASE + 0xa0));
4834                          machine->md.pc.pic2 = device_add(machine, tmpstr);                          machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4835                  }                  }
4836    
4837                  machine->md_interrupt = x86_pc_interrupt;                  machine->md_interrupt = x86_pc_interrupt;
4838    
4839                  /*  Timer:  */                  /*  Timer:  */
4840                  snprintf(tmpstr, sizeof(tmpstr) - 1, "8253 addr=0x%llx irq=0",                  snprintf(tmpstr, sizeof(tmpstr), "8253 addr=0x%llx irq=0",
4841                      (long long)(X86_IO_BASE + 0x40));                      (long long)(X86_IO_BASE + 0x40));
4842                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
4843    
4844                  snprintf(tmpstr, sizeof(tmpstr) - 1, "pccmos addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "pccmos addr=0x%llx",
4845                      (long long)(X86_IO_BASE + 0x70));                      (long long)(X86_IO_BASE + 0x70));
4846                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
4847    
# Line 4055  no_arc_prom_emulation:         /*  TODO: ugly, Line 4849  no_arc_prom_emulation:         /*  TODO: ugly,
4849    
4850                  /*  IDE controllers:  */                  /*  IDE controllers:  */
4851                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
4852                      diskimage_exist(machine, 1, DISKIMAGE_IDE))                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
4853                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x1f0, 14, 0);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4854                                X86_IO_BASE + 0x1f0, 14);
4855                            device_add(machine, tmpstr);
4856                    }
4857                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||
4858                      diskimage_exist(machine, 3, DISKIMAGE_IDE))                      diskimage_exist(machine, 3, DISKIMAGE_IDE)) {
4859                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x170, 15, 2);                          snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4860                                X86_IO_BASE + 0x170, 15);
4861                            device_add(machine, tmpstr);
4862                    }
4863    
4864                  /*  Floppy controller at irq 6  */                  /*  Floppy controller at irq 6  */
4865                  snprintf(tmpstr, sizeof(tmpstr) - 1, "fdc addr=0x%llx irq=6",                  snprintf(tmpstr, sizeof(tmpstr), "fdc addr=0x%llx irq=6",
4866                      (long long)(X86_IO_BASE + 0x3f0));                      (long long)(X86_IO_BASE + 0x3f0));
4867                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
4868    
# Line 4071  no_arc_prom_emulation:         /*  TODO: ugly, Line 4871  no_arc_prom_emulation:         /*  TODO: ugly,
4871                  /*  TODO: parallel port  */                  /*  TODO: parallel port  */
4872    
4873                  /*  Serial ports:  (TODO: 8250 for PC XT?)  */                  /*  Serial ports:  (TODO: 8250 for PC XT?)  */
4874                  dev_ns16550_init(machine, mem, X86_IO_BASE + 0x3f8, 4, 1, 0, "com1");  
4875                  dev_ns16550_init(machine, mem, X86_IO_BASE + 0x378, 3, 1, 0, "com2");                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%llx name2=com1 in_use=0",
4876                        (long long)X86_IO_BASE + 0x3f8);
4877                    device_add(machine, tmpstr);
4878                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x%llx name2=com2 in_use=0",
4879                        (long long)X86_IO_BASE + 0x2f8);
4880                    device_add(machine, tmpstr);
4881    
4882                  /*  VGA + keyboard:  */                  /*  VGA + keyboard:  */
4883                  dev_vga_init(machine, mem, 0xa0000ULL, X86_IO_BASE + 0x3c0,                  dev_vga_init(machine, mem, 0xa0000ULL, X86_IO_BASE + 0x3c0,
# Line 4091  no_arc_prom_emulation:         /*  TODO: ugly, Line 4896  no_arc_prom_emulation:         /*  TODO: ugly,
4896                              "-------------------------------------"                              "-------------------------------------"
4897                              "------------------------------------------\n");                              "------------------------------------------\n");
4898                  break;                  break;
4899    #endif  /*  ENABLE_X86  */
4900    
4901          default:          default:
4902                  fatal("Unknown emulation type %i\n", machine->machine_type);                  fatal("Unknown emulation type %i\n", machine->machine_type);
# Line 4192  void machine_memsize_fix(struct machine Line 4998  void machine_memsize_fix(struct machine
4998                                  m->physical_ram_in_mb = 32;                                  m->physical_ram_in_mb = 32;
4999                          }                          }
5000                          break;                          break;
5001                    case MACHINE_ALPHA:
5002                            m->physical_ram_in_mb = 64;
5003                            break;
5004                  case MACHINE_BEBOX:                  case MACHINE_BEBOX:
5005                          m->physical_ram_in_mb = 64;                          m->physical_ram_in_mb = 64;
5006                          break;                          break;
5007                  case MACHINE_BAREURISC:                  case MACHINE_CATS:
5008                  case MACHINE_TESTURISC:                          m->physical_ram_in_mb = 64;
5009                          m->physical_ram_in_mb = 2;                          break;
5010                    case MACHINE_ZAURUS:
5011                            m->physical_ram_in_mb = 64;
5012                            break;
5013                    case MACHINE_HPCARM:
5014                            m->physical_ram_in_mb = 32;
5015                            break;
5016                    case MACHINE_NETWINDER:
5017                            m->physical_ram_in_mb = 16;
5018                          break;                          break;
5019                  case MACHINE_X86:                  case MACHINE_X86:
5020                          if (m->machine_subtype == MACHINE_X86_XT)                          if (m->machine_subtype == MACHINE_X86_XT)
# Line 4337  void machine_default_cputype(struct mach Line 5154  void machine_default_cputype(struct mach
5154          case MACHINE_EVBMIPS:          case MACHINE_EVBMIPS:
5155                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5156                  case MACHINE_EVBMIPS_MALTA:                  case MACHINE_EVBMIPS_MALTA:
5157                    case MACHINE_EVBMIPS_MALTA_BE:
5158                          m->cpu_name = strdup("5Kc");                          m->cpu_name = strdup("5Kc");
5159                          break;                          break;
5160                  case MACHINE_EVBMIPS_PB1000:                  case MACHINE_EVBMIPS_PB1000:
# Line 4383  void machine_default_cputype(struct mach Line 5201  void machine_default_cputype(struct mach
5201          case MACHINE_MACPPC:          case MACHINE_MACPPC:
5202                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5203                  case MACHINE_MACPPC_G4:                  case MACHINE_MACPPC_G4:
5204                          m->cpu_name = strdup("G4e");                          m->cpu_name = strdup("PPC750");
5205                          break;                          break;
5206                  case MACHINE_MACPPC_G5:                  case MACHINE_MACPPC_G5:
5207                          m->cpu_name = strdup("PPC970");                          m->cpu_name = strdup("PPC970");
# Line 4394  void machine_default_cputype(struct mach Line 5212  void machine_default_cputype(struct mach
5212                  m->cpu_name = strdup("PPC750");                  m->cpu_name = strdup("PPC750");
5213                  break;                  break;
5214    
5215          /*  SPARC:  */          /*  SH:  */
5216          case MACHINE_BARESPARC:          case MACHINE_BARESH:
5217                  m->cpu_name = strdup("SPARCV9");          case MACHINE_TESTSH:
5218                  break;          case MACHINE_HPCSH:
5219          case MACHINE_ULTRA1:                  m->cpu_name = strdup("SH");
                 m->cpu_name = strdup("SPARCV9");  
                 break;  
   
         /*  URISC:  */  
         case MACHINE_BAREURISC:  
         case MACHINE_TESTURISC:  
                 m->cpu_name = strdup("URISC");  
5220                  break;                  break;
5221    
5222          /*  HPPA:  */          /*  HPPA:  */
5223          case MACHINE_BAREHPPA:          case MACHINE_BAREHPPA:
5224          case MACHINE_TESTHPPA:          case MACHINE_TESTHPPA:
5225                  m->cpu_name = strdup("HPPA2.0");                  m->cpu_name = strdup("HPPA");
5226                    break;
5227    
5228            /*  i960:  */
5229            case MACHINE_BAREI960:
5230            case MACHINE_TESTI960:
5231                    m->cpu_name = strdup("i960");
5232                    break;
5233    
5234            /*  SPARC:  */
5235            case MACHINE_BARESPARC:
5236            case MACHINE_TESTSPARC:
5237            case MACHINE_ULTRA1:
5238                    m->cpu_name = strdup("SPARCv9");
5239                  break;                  break;
5240    
5241          /*  Alpha:  */          /*  Alpha:  */
5242          case MACHINE_BAREALPHA:          case MACHINE_BAREALPHA:
5243          case MACHINE_TESTALPHA:          case MACHINE_TESTALPHA:
5244                  m->cpu_name = strdup("EV4");          case MACHINE_ALPHA:
5245                    m->cpu_name = strdup("Alpha");
5246                  break;                  break;
5247    
5248          /*  ARM:  */          /*  ARM:  */
5249          case MACHINE_BAREARM:          case MACHINE_BAREARM:
5250          case MACHINE_TESTARM:          case MACHINE_TESTARM:
5251                  m->cpu_name = strdup("ARM");          case MACHINE_HPCARM:
5252                    m->cpu_name = strdup("SA1110");
5253                    break;
5254            case MACHINE_IQ80321:
5255            case MACHINE_IYONIX:
5256                    m->cpu_name = strdup("80321_600_B0");
5257                    break;
5258            case MACHINE_CATS:
5259            case MACHINE_NETWINDER:
5260            case MACHINE_SHARK:
5261                    m->cpu_name = strdup("SA110");
5262                    break;
5263            case MACHINE_ZAURUS:
5264                    m->cpu_name = strdup("PXA210");
5265                    break;
5266    
5267            /*  AVR:  */
5268            case MACHINE_BAREAVR:
5269                    m->cpu_name = strdup("AVR");
5270                    break;
5271    
5272            /*  IA64:  */
5273            case MACHINE_BAREIA64:
5274            case MACHINE_TESTIA64:
5275                    m->cpu_name = strdup("IA64");
5276                    break;
5277    
5278            /*  M68K:  */
5279            case MACHINE_BAREM68K:
5280            case MACHINE_TESTM68K:
5281                    m->cpu_name = strdup("68020");
5282                  break;                  break;
5283    
5284          /*  x86:  */          /*  x86:  */
# Line 4472  void machine_dumpinfo(struct machine *m) Line 5327  void machine_dumpinfo(struct machine *m)
5327          if (m->single_step_on_bad_addr)          if (m->single_step_on_bad_addr)
5328                  debug("single-step on bad addresses\n");                  debug("single-step on bad addresses\n");
5329    
5330          if (m->bintrans_enable)          if (m->arch == ARCH_MIPS) {
5331                  debug("bintrans enabled (%i MB cache)\n",                  if (m->bintrans_enable)
5332                      (int) (m->bintrans_size / 1048576));                          debug("bintrans enabled (%i MB cache)\n",
5333          else                              (int) (m->bintrans_size / 1048576));
5334                  debug("bintrans disabled, other speedtricks %s\n",                  else
5335                      m->speed_tricks? "enabled" : "disabled");                          debug("bintrans disabled, other speedtricks %s\n",
5336                                m->speed_tricks? "enabled" : "disabled");
5337            }
5338    
5339          debug("clock: ");          debug("clock: ");
5340          if (m->automatic_clock_adjustment)          if (m->automatic_clock_adjustment)
# Line 4664  void machine_list_available_types_and_cp Line 5521  void machine_list_available_types_and_cp
5521          debug("\n");          debug("\n");
5522    
5523          useremul_list_emuls();          useremul_list_emuls();
5524            debug("Userland emulation works for programs with the complexity"
5525                " of Hello World,\nbut not much more.\n");
5526  }  }
5527    
5528    
# Line 4682  void machine_init(void) Line 5541  void machine_init(void)
5541           *  entries will appear in normal order when listed.  :-)           *  entries will appear in normal order when listed.  :-)
5542           */           */
5543    
5544            /*  Zaurus:  */
5545            me = machine_entry_new("Zaurus (ARM)",
5546                ARCH_ARM, MACHINE_ZAURUS, 1, 0);
5547            me->aliases[0] = "zaurus";
5548            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5549                    me->next = first_machine_entry; first_machine_entry = me;
5550            }
5551    
5552          /*  X86 machine:  */          /*  X86 machine:  */
5553          me = machine_entry_new("x86-based PC", ARCH_X86,          me = machine_entry_new("x86-based PC", ARCH_X86,
5554              MACHINE_X86, 2, 2);              MACHINE_X86, 2, 2);
# Line 4705  void machine_init(void) Line 5572  void machine_init(void)
5572                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5573          }          }
5574    
5575          /*  Test-machine for URISC:  */          /*  Test-machine for SPARC:  */
5576          me = machine_entry_new("Test-machine for URISC", ARCH_URISC,          me = machine_entry_new("Test-machine for SPARC", ARCH_SPARC,
5577              MACHINE_TESTURISC, 1, 0);              MACHINE_TESTSPARC, 1, 0);
5578          me->aliases[0] = "testurisc";          me->aliases[0] = "testsparc";
5579          if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {          if (cpu_family_ptr_by_number(ARCH_SPARC) != NULL) {
5580                    me->next = first_machine_entry; first_machine_entry = me;
5581            }
5582    
5583            /*  Test-machine for SH:  */
5584            me = machine_entry_new("Test-machine for SH", ARCH_SH,
5585                MACHINE_TESTSH, 1, 0);
5586            me->aliases[0] = "testsh";
5587            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5588                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5589          }          }
5590    
# Line 4729  void machine_init(void) Line 5604  void machine_init(void)
5604                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5605          }          }
5606    
5607            /*  Test-machine for M68K:  */
5608            me = machine_entry_new("Test-machine for M68K", ARCH_M68K,
5609                MACHINE_TESTM68K, 1, 0);
5610            me->aliases[0] = "testm68k";
5611            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
5612                    me->next = first_machine_entry; first_machine_entry = me;
5613            }
5614    
5615            /*  Test-machine for IA64:  */
5616            me = machine_entry_new("Test-machine for IA64", ARCH_IA64,
5617                MACHINE_TESTIA64, 1, 0);
5618            me->aliases[0] = "testia64";
5619            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
5620                    me->next = first_machine_entry; first_machine_entry = me;
5621            }
5622    
5623            /*  Test-machine for i960:  */
5624            me = machine_entry_new("Test-machine for i960", ARCH_I960,
5625                MACHINE_TESTI960, 1, 0);
5626            me->aliases[0] = "testi960";
5627            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5628                    me->next = first_machine_entry; first_machine_entry = me;
5629            }
5630    
5631          /*  Test-machine for HPPA:  */          /*  Test-machine for HPPA:  */
5632          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5633              MACHINE_TESTHPPA, 1, 0);              MACHINE_TESTHPPA, 1, 0);
# Line 4779  void machine_init(void) Line 5678  void machine_init(void)
5678          }          }
5679    
5680          /*  SGI:  */          /*  SGI:  */
5681          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 9);          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 10);
5682          me->aliases[0] = "silicon graphics";          me->aliases[0] = "silicon graphics";
5683          me->aliases[1] = "sgi";          me->aliases[1] = "sgi";
5684          me->subtype[0] = machine_entry_subtype_new("IP19", 19, 1);          me->subtype[0] = machine_entry_subtype_new("IP12", 12, 1);
5685          me->subtype[0]->aliases[0] = "ip19";          me->subtype[0]->aliases[0] = "ip12";
5686          me->subtype[1] = machine_entry_subtype_new("IP20", 20, 1);          me->subtype[1] = machine_entry_subtype_new("IP19", 19, 1);
5687          me->subtype[1]->aliases[0] = "ip20";          me->subtype[1]->aliases[0] = "ip19";
5688          me->subtype[2] = machine_entry_subtype_new("IP22", 22, 2);          me->subtype[2] = machine_entry_subtype_new("IP20", 20, 1);
5689          me->subtype[2]->aliases[0] = "ip22";          me->subtype[2]->aliases[0] = "ip20";
5690          me->subtype[2]->aliases[1] = "indy";          me->subtype[3] = machine_entry_subtype_new("IP22", 22, 2);
5691          me->subtype[3] = machine_entry_subtype_new("IP24", 24, 1);          me->subtype[3]->aliases[0] = "ip22";
5692          me->subtype[3]->aliases[0] = "ip24";          me->subtype[3]->aliases[1] = "indy";
5693          me->subtype[4] = machine_entry_subtype_new("IP27", 27, 3);          me->subtype[4] = machine_entry_subtype_new("IP24", 24, 1);
5694          me->subtype[4]->aliases[0] = "ip27";          me->subtype[4]->aliases[0] = "ip24";
5695          me->subtype[4]->aliases[1] = "origin 200";          me->subtype[5] = machine_entry_subtype_new("IP27", 27, 3);
5696          me->subtype[4]->aliases[2] = "origin 2000";          me->subtype[5]->aliases[0] = "ip27";
5697          me->subtype[5] = machine_entry_subtype_new("IP28", 28, 1);          me->subtype[5]->aliases[1] = "origin 200";
5698          me->subtype[5]->aliases[0] = "ip28";          me->subtype[5]->aliases[2] = "origin 2000";
5699          me->subtype[6] = machine_entry_subtype_new("IP30", 30, 2);          me->subtype[6] = machine_entry_subtype_new("IP28", 28, 1);
5700          me->subtype[6]->aliases[0] = "ip30";          me->subtype[6]->aliases[0] = "ip28";
5701          me->subtype[6]->aliases[1] = "octane";          me->subtype[7] = machine_entry_subtype_new("IP30", 30, 2);
5702          me->subtype[7] = machine_entry_subtype_new("IP32", 32, 2);          me->subtype[7]->aliases[0] = "ip30";
5703          me->subtype[7]->aliases[0] = "ip32";          me->subtype[7]->aliases[1] = "octane";
5704          me->subtype[7]->aliases[1] = "o2";          me->subtype[8] = machine_entry_subtype_new("IP32", 32, 2);
5705          me->subtype[8] = machine_entry_subtype_new("IP35", 35, 1);          me->subtype[8]->aliases[0] = "ip32";
5706          me->subtype[8]->aliases[0] = "ip35";          me->subtype[8]->aliases[1] = "o2";
5707            me->subtype[9] = machine_entry_subtype_new("IP35", 35, 1);
5708            me->subtype[9]->aliases[0] = "ip35";
5709          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5710                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5711          }          }
# Line 4825  void machine_init(void) Line 5726  void machine_init(void)
5726                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5727          }          }
5728    
5729            /*  NetWinder:  */
5730            me = machine_entry_new("NetWinder", ARCH_ARM, MACHINE_NETWINDER, 1, 0);
5731            me->aliases[0] = "netwinder";
5732            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5733                    me->next = first_machine_entry; first_machine_entry = me;
5734            }
5735    
5736          /*  NetGear:  */          /*  NetGear:  */
5737          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602v1", ARCH_MIPS,
5738              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);
5739          me->aliases[0] = "netgear";          me->aliases[0] = "netgear";
5740          me->aliases[1] = "wg602";          me->aliases[1] = "wg602v1";
5741          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5742                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5743          }          }
# Line 4849  void machine_init(void) Line 5757  void machine_init(void)
5757                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5758          }          }
5759    
         /*  Evaluation Boards (MALTA etc):  */  
         me = machine_entry_new("evbmips", ARCH_MIPS,  
             MACHINE_EVBMIPS, 1, 2);  
         me->aliases[0] = "evbmips";  
         me->subtype[0] = machine_entry_subtype_new("Malta",  
             MACHINE_EVBMIPS_MALTA, 1);  
         me->subtype[0]->aliases[0] = "malta";  
         me->subtype[1] = machine_entry_subtype_new("PB1000",  
             MACHINE_EVBMIPS_PB1000, 1);  
         me->subtype[1]->aliases[0] = "pb1000";  
         if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {  
                 me->next = first_machine_entry; first_machine_entry = me;  
         }  
   
5760          /*  Macintosh (PPC):  */          /*  Macintosh (PPC):  */
5761          me = machine_entry_new("Macintosh (PPC)", ARCH_PPC,          me = machine_entry_new("Macintosh (PPC)", ARCH_PPC,
5762              MACHINE_MACPPC, 1, 2);              MACHINE_MACPPC, 1, 2);
# Line 4877  void machine_init(void) Line 5771  void machine_init(void)
5771                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5772          }          }
5773    
5774            /*  Iyonix:  */
5775            me = machine_entry_new("Iyonix", ARCH_ARM,
5776                MACHINE_IYONIX, 1, 0);
5777            me->aliases[0] = "iyonix";
5778            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5779                    me->next = first_machine_entry; first_machine_entry = me;
5780            }
5781    
5782            /*  Intel IQ80321 (ARM):  */
5783            me = machine_entry_new("Intel IQ80321 (ARM)", ARCH_ARM,
5784                MACHINE_IQ80321, 1, 0);
5785            me->aliases[0] = "iq80321";
5786            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5787                    me->next = first_machine_entry; first_machine_entry = me;
5788            }
5789    
5790            /*  HPCarm:  */
5791            me = machine_entry_new("Handheld SH (HPCsh)",
5792                ARCH_SH, MACHINE_HPCSH, 1, 2);
5793            me->aliases[0] = "hpcsh";
5794            me->subtype[0] = machine_entry_subtype_new("Jornada 680",
5795                MACHINE_HPCSH_JORNADA680, 1);
5796            me->subtype[0]->aliases[0] = "jornada680";
5797            me->subtype[1] = machine_entry_subtype_new(
5798                "Jornada 690", MACHINE_HPCSH_JORNADA690, 1);
5799            me->subtype[1]->aliases[0] = "jornada690";
5800            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5801                    me->next = first_machine_entry; first_machine_entry = me;
5802            }
5803    
5804          /*  HPCmips:  */          /*  HPCmips:  */
5805          me = machine_entry_new("Handheld MIPS (HPC)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
5806              ARCH_MIPS, MACHINE_HPCMIPS, 2, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
5807          me->aliases[0] = "hpcmips";          me->aliases[0] = "hpcmips";
         me->aliases[1] = "hpc";  
5808          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
5809              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);
5810          me->subtype[0]->aliases[0] = "be-300";          me->subtype[0]->aliases[0] = "be-300";
# Line 4914  void machine_init(void) Line 5837  void machine_init(void)
5837                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5838          }          }
5839    
5840            /*  HPCarm:  */
5841            me = machine_entry_new("Handheld ARM (HPCarm)",
5842                ARCH_ARM, MACHINE_HPCARM, 1, 2);
5843            me->aliases[0] = "hpcarm";
5844            me->subtype[0] = machine_entry_subtype_new("Ipaq",
5845                MACHINE_HPCARM_IPAQ, 1);
5846            me->subtype[0]->aliases[0] = "ipaq";
5847            me->subtype[1] = machine_entry_subtype_new(
5848                "Jornada 720", MACHINE_HPCARM_JORNADA720, 1);
5849            me->subtype[1]->aliases[0] = "jornada720";
5850            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5851                    me->next = first_machine_entry; first_machine_entry = me;
5852            }
5853    
5854          /*  Generic "bare" X86 machine:  */          /*  Generic "bare" X86 machine:  */
5855          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
5856              MACHINE_BAREX86, 1, 0);              MACHINE_BAREX86, 1, 0);
# Line 4922  void machine_init(void) Line 5859  void machine_init(void)
5859                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5860          }          }
5861    
         /*  Generic "bare" URISC machine:  */  
         me = machine_entry_new("Generic \"bare\" URISC machine", ARCH_URISC,  
             MACHINE_BAREURISC, 1, 0);  
         me->aliases[0] = "bareurisc";  
         if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {  
                 me->next = first_machine_entry; first_machine_entry = me;  
         }  
   
5862          /*  Generic "bare" SPARC machine:  */          /*  Generic "bare" SPARC machine:  */
5863          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,
5864              MACHINE_BARESPARC, 1, 0);              MACHINE_BARESPARC, 1, 0);
# Line 4938  void machine_init(void) Line 5867  void machine_init(void)
5867                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5868          }          }
5869    
5870            /*  Generic "bare" SH machine:  */
5871            me = machine_entry_new("Generic \"bare\" SH machine", ARCH_SH,
5872                MACHINE_BARESH, 1, 0);
5873            me->aliases[0] = "baresh";
5874            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5875                    me->next = first_machine_entry; first_machine_entry = me;
5876            }
5877    
5878          /*  Generic "bare" PPC machine:  */          /*  Generic "bare" PPC machine:  */
5879          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
5880              MACHINE_BAREPPC, 1, 0);              MACHINE_BAREPPC, 1, 0);
# Line 4954  void machine_init(void) Line 5891  void machine_init(void)
5891                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5892          }          }
5893    
5894            /*  Generic "bare" M68K machine:  */
5895            me = machine_entry_new("Generic \"bare\" M68K machine", ARCH_M68K,
5896                MACHINE_BAREM68K, 1, 0);
5897            me->aliases[0] = "barem68k";
5898            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
5899                    me->next = first_machine_entry; first_machine_entry = me;
5900            }
5901    
5902            /*  Generic "bare" IA64 machine:  */
5903            me = machine_entry_new("Generic \"bare\" IA64 machine", ARCH_IA64,
5904                MACHINE_BAREIA64, 1, 0);
5905            me->aliases[0] = "bareia64";
5906            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
5907                    me->next = first_machine_entry; first_machine_entry = me;
5908            }
5909    
5910            /*  Generic "bare" i960 machine:  */
5911            me = machine_entry_new("Generic \"bare\" i960 machine", ARCH_I960,
5912                MACHINE_BAREI960, 1, 0);
5913            me->aliases[0] = "barei960";
5914            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5915                    me->next = first_machine_entry; first_machine_entry = me;
5916            }
5917    
5918          /*  Generic "bare" HPPA machine:  */          /*  Generic "bare" HPPA machine:  */
5919          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
5920              MACHINE_BAREHPPA, 1, 0);              MACHINE_BAREHPPA, 1, 0);
# Line 4962  void machine_init(void) Line 5923  void machine_init(void)
5923                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5924          }          }
5925    
5926            /*  Generic "bare" Atmel AVR machine:  */
5927            me = machine_entry_new("Generic \"bare\" Atmel AVR machine", ARCH_AVR,
5928                MACHINE_BAREAVR, 1, 0);
5929            me->aliases[0] = "bareavr";
5930            if (cpu_family_ptr_by_number(ARCH_AVR) != NULL) {
5931                    me->next = first_machine_entry; first_machine_entry = me;
5932            }
5933    
5934          /*  Generic "bare" ARM machine:  */          /*  Generic "bare" ARM machine:  */
5935          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
5936              MACHINE_BAREARM, 1, 0);              MACHINE_BAREARM, 1, 0);
# Line 4978  void machine_init(void) Line 5947  void machine_init(void)
5947                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5948          }          }
5949    
5950            /*  Evaluation Boards (MALTA etc):  */
5951            me = machine_entry_new("Evaluation boards (evbmips)", ARCH_MIPS,
5952                MACHINE_EVBMIPS, 1, 3);
5953            me->aliases[0] = "evbmips";
5954            me->subtype[0] = machine_entry_subtype_new("Malta",
5955                MACHINE_EVBMIPS_MALTA, 1);
5956            me->subtype[0]->aliases[0] = "malta";
5957            me->subtype[1] = machine_entry_subtype_new("Malta (Big-Endian)",
5958                MACHINE_EVBMIPS_MALTA_BE, 1);
5959            me->subtype[1]->aliases[0] = "maltabe";
5960            me->subtype[2] = machine_entry_subtype_new("PB1000",
5961                MACHINE_EVBMIPS_PB1000, 1);
5962            me->subtype[2]->aliases[0] = "pb1000";
5963            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5964                    me->next = first_machine_entry; first_machine_entry = me;
5965            }
5966    
5967            /*  Digital DNARD ("Shark"):  */
5968            me = machine_entry_new("Digital DNARD (\"Shark\")", ARCH_ARM,
5969                MACHINE_SHARK, 2, 0);
5970            me->aliases[0] = "shark";
5971            me->aliases[1] = "dnard";
5972            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5973                    me->next = first_machine_entry; first_machine_entry = me;
5974            }
5975    
5976          /*  DECstation:  */          /*  DECstation:  */
5977          me = machine_entry_new("DECstation/DECsystem",          me = machine_entry_new("DECstation/DECsystem",
5978              ARCH_MIPS, MACHINE_DEC, 3, 9);              ARCH_MIPS, MACHINE_DEC, 3, 9);
# Line 5045  void machine_init(void) Line 6040  void machine_init(void)
6040                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6041          }          }
6042    
6043            /*  CATS (ARM) evaluation board:  */
6044            me = machine_entry_new("CATS evaluation board (ARM)", ARCH_ARM,
6045                MACHINE_CATS, 1, 0);
6046            me->aliases[0] = "cats";
6047            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6048                    me->next = first_machine_entry; first_machine_entry = me;
6049            }
6050    
6051          /*  BeBox: (NetBSD/bebox)  */          /*  BeBox: (NetBSD/bebox)  */
6052          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
6053          me->aliases[0] = "bebox";          me->aliases[0] = "bebox";
# Line 5109  void machine_init(void) Line 6112  void machine_init(void)
6112          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
6113                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6114          }          }
6115    
6116            /*  Alpha:  */
6117            me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6118            me->aliases[0] = "alpha";
6119            me->subtype[0] = machine_entry_subtype_new(
6120                "DEC 3000/300", ST_DEC_3000_300, 1);
6121            me->subtype[0]->aliases[0] = "3000/300";
6122            me->subtype[1] = machine_entry_subtype_new(
6123                "EB164", ST_EB164, 1);
6124            me->subtype[1]->aliases[0] = "eb164";
6125            if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
6126                    me->next = first_machine_entry; first_machine_entry = me;
6127            }
6128  }  }
6129    

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

  ViewVC Help
Powered by ViewVC 1.1.26