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

Diff of /trunk/src/machine.c

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

revision 12 by dpavlin, Mon Oct 8 16:18:38 2007 UTC revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: machine.c,v 1.515 2005/08/16 09:16:26 debug Exp $   *  $Id: machine.c,v 1.611 2005/11/23 23:31:34 debug Exp $
29   *   *
30   *  Emulation of specific machines.   *  Emulation of specific machines.
31   *   *
# Line 51  Line 51 
51  #include <unistd.h>  #include <unistd.h>
52    
53  #include "arcbios.h"  #include "arcbios.h"
54    #include "bus_isa.h"
55  #include "bus_pci.h"  #include "bus_pci.h"
56  #include "cpu.h"  #include "cpu.h"
57  #include "device.h"  #include "device.h"
# Line 67  Line 68 
68  /*  For Alpha emulation:  */  /*  For Alpha emulation:  */
69  #include "alpha_rpb.h"  #include "alpha_rpb.h"
70    
71    /*  For CATS emulation:  */
72    #include "cyclone_boot.h"
73    
74  /*  For SGI and ARC emulation:  */  /*  For SGI and ARC emulation:  */
75  #include "sgi_arcbios.h"  #include "sgi_arcbios.h"
76  #include "crimereg.h"  #include "crimereg.h"
# Line 162  struct machine *machine_new(char *name, Line 166  struct machine *machine_new(char *name,
166          m->boot_string_argument = NULL;          m->boot_string_argument = NULL;
167          m->automatic_clock_adjustment = 1;          m->automatic_clock_adjustment = 1;
168          m->x11_scaledown = 1;          m->x11_scaledown = 1;
169            m->x11_scaleup = 1;
170          m->n_gfx_cards = 1;          m->n_gfx_cards = 1;
171          m->dbe_on_nonexistant_memaccess = 1;          m->dbe_on_nonexistant_memaccess = 1;
172          m->show_symbolic_register_names = 1;          m->show_symbolic_register_names = 1;
# Line 456  int store_64bit_word(struct cpu *cpu, ui Line 461  int store_64bit_word(struct cpu *cpu, ui
461  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)
462  {  {
463          unsigned char data[4];          unsigned char data[4];
464          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
465                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
466          data[0] = (data32 >> 24) & 255;          data[0] = (data32 >> 24) & 255;
467          data[1] = (data32 >> 16) & 255;          data[1] = (data32 >> 16) & 255;
# Line 481  int store_32bit_word(struct cpu *cpu, ui Line 486  int store_32bit_word(struct cpu *cpu, ui
486  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)
487  {  {
488          unsigned char data[2];          unsigned char data[2];
489          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
490                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
491          data[0] = (data16 >> 8) & 255;          data[0] = (data16 >> 8) & 255;
492          data[1] = (data16) & 255;          data[1] = (data16) & 255;
# Line 502  void store_buf(struct cpu *cpu, uint64_t Line 507  void store_buf(struct cpu *cpu, uint64_t
507  {  {
508          int psize = 1024;       /*  1024 256 64 16 4 1  */          int psize = 1024;       /*  1024 256 64 16 4 1  */
509    
510          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
511                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
512    
513          while (len != 0) {          while (len != 0) {
# Line 555  uint32_t load_32bit_word(struct cpu *cpu Line 560  uint32_t load_32bit_word(struct cpu *cpu
560  {  {
561          unsigned char data[4];          unsigned char data[4];
562    
563          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
564                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
565          cpu->memory_rw(cpu, cpu->mem,          cpu->memory_rw(cpu, cpu->mem,
566              addr, data, sizeof(data), MEM_READ, CACHE_DATA);              addr, data, sizeof(data), MEM_READ, CACHE_DATA);
# Line 579  uint16_t load_16bit_word(struct cpu *cpu Line 584  uint16_t load_16bit_word(struct cpu *cpu
584  {  {
585          unsigned char data[2];          unsigned char data[2];
586    
587          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
588                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
589          cpu->memory_rw(cpu, cpu->mem,          cpu->memory_rw(cpu, cpu->mem,
590              addr, data, sizeof(data), MEM_READ, CACHE_DATA);              addr, data, sizeof(data), MEM_READ, CACHE_DATA);
# Line 1290  void au1x00_interrupt(struct machine *m, Line 1295  void au1x00_interrupt(struct machine *m,
1295    
1296    
1297  /*  /*
1298   *  Malta (evbmips) interrupts:   *  CPC700 interrupt routine:
1299   *   *
1300   *  ISA interrupts.   *  irq_nr should be 0..31. (32 means reassertion.)
  *  (irq_nr = 16+8 can be used to just reassert/deassert interrupts.)  
1301   */   */
1302  void malta_interrupt(struct machine *m, struct cpu *cpu, int irq_nr,  void cpc700_interrupt(struct machine *m, struct cpu *cpu,
1303          int assrt)          int irq_nr, int assrt)
1304  {  {
1305          int mask;          if (irq_nr < 32) {
1306                    uint32_t mask = 1 << (irq_nr & 31);
         irq_nr -= 8;  
         mask = 1 << (irq_nr & 7);  
   
         if (irq_nr < 8) {  
                 if (assrt)  
                         m->md_int.isa_pic_data.pic1->irr |= mask;  
                 else  
                         m->md_int.isa_pic_data.pic1->irr &= ~mask;  
         } else if (irq_nr < 16) {  
1307                  if (assrt)                  if (assrt)
1308                          m->md_int.isa_pic_data.pic2->irr |= mask;                          m->md_int.cpc700_data->sr |= mask;
1309                  else                  else
1310                          m->md_int.isa_pic_data.pic2->irr &= ~mask;                          m->md_int.cpc700_data->sr &= ~mask;
1311          }          }
1312    
1313          /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */          if ((m->md_int.cpc700_data->sr & m->md_int.cpc700_data->er) != 0)
1314          /*  (TODO: don't hardcode this here)  */                  cpu_interrupt(cpu, 65);
         if (m->md_int.isa_pic_data.pic2->irr &  
             ~m->md_int.isa_pic_data.pic2->ier)  
                 m->md_int.isa_pic_data.pic1->irr |= 0x04;  
         else  
                 m->md_int.isa_pic_data.pic1->irr &= ~0x04;  
   
         /*  Now, PIC1:  */  
         if (m->md_int.isa_pic_data.pic1->irr &  
             ~m->md_int.isa_pic_data.pic1->ier)  
                 cpu_interrupt(cpu, 2);  
1315          else          else
1316                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 65);
   
         /*  printf("MALTA: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "  
             "ier=0x%02x\n", m->md_int.isa_pic_data.pic1->irr,  
             m->md_int.isa_pic_data.pic1->ier,  
             m->md_int.isa_pic_data.pic2->irr,  
             m->md_int.isa_pic_data.pic2->ier);  */  
1317  }  }
1318    
1319    
1320  /*  /*
1321   *  Cobalt interrupts:   *  Interrupt function for Cobalt, evbmips (Malta), and Algor.
1322   *   *
1323   *  (irq_nr = 8 + 16 can be used to just reassert/deassert interrupts.)   *  (irq_nr = 8 + 16 can be used to just reassert/deassert interrupts.)
1324   */   */
1325  void cobalt_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)  void isa8_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
1326  {  {
1327          int mask;          int mask, x;
1328            int old_isa_assert, new_isa_assert;
1329    
1330            old_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1331    
1332          irq_nr -= 8;          irq_nr -= 8;
1333          mask = 1 << (irq_nr & 7);          mask = 1 << (irq_nr & 7);
1334    
1335          if (irq_nr < 8) {          if (irq_nr < 8) {
1336                  if (assrt)                  if (assrt)
1337                          m->md_int.isa_pic_data.pic1->irr |= mask;                          m->isa_pic_data.pic1->irr |= mask;
1338                  else                  else
1339                          m->md_int.isa_pic_data.pic1->irr &= ~mask;                          m->isa_pic_data.pic1->irr &= ~mask;
1340          } else if (irq_nr < 16) {          } else if (irq_nr < 16) {
1341                  if (assrt)                  if (assrt)
1342                          m->md_int.isa_pic_data.pic2->irr |= mask;                          m->isa_pic_data.pic2->irr |= mask;
1343                  else                  else
1344                          m->md_int.isa_pic_data.pic2->irr &= ~mask;                          m->isa_pic_data.pic2->irr &= ~mask;
1345          }          }
1346    
1347          /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */          /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1348          /*  (TODO: don't hardcode this here)  */          /*  (TODO: don't hardcode this here)  */
1349          if (m->md_int.isa_pic_data.pic2->irr &          if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1350              ~m->md_int.isa_pic_data.pic2->ier)                  m->isa_pic_data.pic1->irr |= 0x04;
                 m->md_int.isa_pic_data.pic1->irr |= 0x04;  
1351          else          else
1352                  m->md_int.isa_pic_data.pic1->irr &= ~0x04;                  m->isa_pic_data.pic1->irr &= ~0x04;
1353    
1354          /*  Now, PIC1:  */          /*  Now, PIC1:  */
1355          if (m->md_int.isa_pic_data.pic1->irr &          new_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1356              ~m->md_int.isa_pic_data.pic1->ier)          if (old_isa_assert != new_isa_assert) {
1357                  cpu_interrupt(cpu, 6);                  for (x=0; x<16; x++) {
1358          else                          if (x == 2)
1359                  cpu_interrupt_ack(cpu, 6);                                  continue;
1360                            if (x < 8 && (m->isa_pic_data.pic1->irr &
1361                                ~m->isa_pic_data.pic1->ier & (1 << x)))
1362                                    break;
1363                            if (x >= 8 && (m->isa_pic_data.pic2->irr &
1364                                ~m->isa_pic_data.pic2->ier & (1 << (x&7))))
1365                                    break;
1366                    }
1367                    m->isa_pic_data.last_int = x;
1368            }
1369    
1370          /*  printf("COBALT: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "          if (m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier)
1371              "ier=0x%02x\n", m->md_int.isa_pic_data.pic1->irr,                  cpu_interrupt(cpu, m->isa_pic_data.native_irq);
1372              m->md_int.isa_pic_data.pic1->ier,          else
1373              m->md_int.isa_pic_data.pic2->irr,                  cpu_interrupt_ack(cpu, m->isa_pic_data.native_irq);
             m->md_int.isa_pic_data.pic2->ier);  */  
1374  }  }
1375    
1376    
# Line 1396  void x86_pc_interrupt(struct machine *m, Line 1385  void x86_pc_interrupt(struct machine *m,
1385    
1386          if (irq_nr < 8) {          if (irq_nr < 8) {
1387                  if (assrt)                  if (assrt)
1388                          m->md.pc.pic1->irr |= mask;                          m->isa_pic_data.pic1->irr |= mask;
1389                  else                  else
1390                          m->md.pc.pic1->irr &= ~mask;                          m->isa_pic_data.pic1->irr &= ~mask;
1391          } else if (irq_nr < 16) {          } else if (irq_nr < 16) {
1392                  if (m->md.pc.pic2 == NULL) {                  if (m->isa_pic_data.pic2 == NULL) {
1393                          fatal("x86_pc_interrupt(): pic2 used (irq_nr = %i), "                          fatal("x86_pc_interrupt(): pic2 used (irq_nr = %i), "
1394                              "but we are emulating an XT?\n", irq_nr);                              "but we are emulating an XT?\n", irq_nr);
1395                          return;                          return;
1396                  }                  }
1397                  if (assrt)                  if (assrt)
1398                          m->md.pc.pic2->irr |= mask;                          m->isa_pic_data.pic2->irr |= mask;
1399                  else                  else
1400                          m->md.pc.pic2->irr &= ~mask;                          m->isa_pic_data.pic2->irr &= ~mask;
1401          }          }
1402    
1403          if (m->md.pc.pic2 != NULL) {          if (m->isa_pic_data.pic2 != NULL) {
1404                  /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */                  /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1405                  /*  (TODO: don't hardcode this here)  */                  /*  (TODO: don't hardcode this here)  */
1406                  if (m->md.pc.pic2->irr & ~m->md.pc.pic2->ier)                  if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1407                          m->md.pc.pic1->irr |= 0x04;                          m->isa_pic_data.pic1->irr |= 0x04;
1408                  else                  else
1409                          m->md.pc.pic1->irr &= ~0x04;                          m->isa_pic_data.pic1->irr &= ~0x04;
1410          }          }
1411    
1412          /*  Now, PIC1:  */          /*  Now, PIC1:  */
1413          if (m->md.pc.pic1->irr & ~m->md.pc.pic1->ier)          if (m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier)
1414                  cpu->cd.x86.interrupt_asserted = 1;                  cpu->cd.x86.interrupt_asserted = 1;
1415          else          else
1416                  cpu->cd.x86.interrupt_asserted = 0;                  cpu->cd.x86.interrupt_asserted = 0;
1417  }  }
1418    
1419    
1420    /*
1421     *  "Generic" ISA interrupt management, 32 native interrupts, 16 ISA
1422     *  interrupts.  So far: Footbridge (CATS, NetWinder), BeBox, and PReP.
1423     *
1424     *  0..31  = footbridge interrupt
1425     *  32..47 = ISA interrupts
1426     *  48     = ISA reassert
1427     *  64     = reassert (non-ISA)
1428     */
1429    void isa32_interrupt(struct machine *m, struct cpu *cpu, int irq_nr,
1430            int assrt)
1431    {
1432            uint32_t mask = 1 << (irq_nr & 31);
1433            int old_isa_assert, new_isa_assert;
1434    
1435            old_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1436    
1437            if (irq_nr >= 32 && irq_nr < 32 + 8) {
1438                    int mm = 1 << (irq_nr & 7);
1439                    if (assrt)
1440                            m->isa_pic_data.pic1->irr |= mm;
1441                    else
1442                            m->isa_pic_data.pic1->irr &= ~mm;
1443            } else if (irq_nr >= 32+8 && irq_nr < 32+16) {
1444                    int mm = 1 << (irq_nr & 7);
1445                    if (assrt)
1446                            m->isa_pic_data.pic2->irr |= mm;
1447                    else
1448                            m->isa_pic_data.pic2->irr &= ~mm;
1449            }
1450    
1451            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1452            /*  (TODO: don't hardcode this here)  */
1453            if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1454                    m->isa_pic_data.pic1->irr |= 0x04;
1455            else
1456                    m->isa_pic_data.pic1->irr &= ~0x04;
1457    
1458            /*  Now, PIC1:  */
1459            new_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1460            if (old_isa_assert != new_isa_assert || irq_nr == 48) {
1461                    if (new_isa_assert) {
1462                            int x;
1463                            for (x=0; x<16; x++) {
1464                                    if (x == 2)
1465                                            continue;
1466                                    if (x < 8 && (m->isa_pic_data.pic1->irr &
1467                                        ~m->isa_pic_data.pic1->ier & (1 << x)))
1468                                            break;
1469                                    if (x >= 8 && (m->isa_pic_data.pic2->irr &
1470                                        ~m->isa_pic_data.pic2->ier & (1 << (x&7))))
1471                                            break;
1472                            }
1473                            m->isa_pic_data.last_int = x;
1474                            cpu_interrupt(cpu, m->isa_pic_data.native_irq);
1475                    } else
1476                            cpu_interrupt_ack(cpu, m->isa_pic_data.native_irq);
1477                    return;
1478            }
1479    
1480            switch (m->machine_type) {
1481            case MACHINE_CATS:
1482            case MACHINE_NETWINDER:
1483                    if (irq_nr < 32) {
1484                            if (assrt)
1485                                    m->md_int.footbridge_data->irq_status |= mask;
1486                            else
1487                                    m->md_int.footbridge_data->irq_status &= ~mask;
1488                    }
1489                    if (m->md_int.footbridge_data->irq_status &
1490                        m->md_int.footbridge_data->irq_enable)
1491                            cpu_interrupt(cpu, 65);
1492                    else
1493                            cpu_interrupt_ack(cpu, 65);
1494                    break;
1495            case MACHINE_BEBOX:
1496                    if (irq_nr < 32) {
1497                            if (assrt)
1498                                    m->md_int.bebox_data->int_status |= mask;
1499                            else
1500                                    m->md_int.bebox_data->int_status &= ~mask;
1501                    }
1502                    if (m->md_int.bebox_data->int_status &
1503                        m->md_int.bebox_data->cpu0_int_mask)
1504                            cpu_interrupt(m->cpus[0], 65);
1505                    else
1506                            cpu_interrupt_ack(m->cpus[0], 65);
1507                    if (m->ncpus > 1 &&
1508                        m->md_int.bebox_data->int_status &
1509                        m->md_int.bebox_data->cpu1_int_mask)
1510                            cpu_interrupt(m->cpus[1], 65);
1511                    else
1512                            cpu_interrupt_ack(m->cpus[1], 65);
1513                    break;
1514            case MACHINE_PREP:
1515                    if (irq_nr < 32) {
1516                            if (assrt)
1517                                    m->md_int.prep_data->int_status |= mask;
1518                            else
1519                                    m->md_int.prep_data->int_status &= ~mask;
1520                    }
1521                    if (m->md_int.prep_data->int_status & 2)
1522                            cpu_interrupt(cpu, 65);
1523                    else
1524                            cpu_interrupt_ack(cpu, 65);
1525                    break;
1526            }
1527    }
1528    
1529    
1530  /****************************************************************************  /****************************************************************************
1531   *                                                                          *   *                                                                          *
1532   *                  Machine dependant Initialization routines               *   *                  Machine dependant Initialization routines               *
# Line 1463  void machine_setup(struct machine *machi Line 1562  void machine_setup(struct machine *machi
1562                  struct btinfo_symtab c;                  struct btinfo_symtab c;
1563          } xx;          } xx;
1564          struct hpc_bootinfo hpc_bootinfo;          struct hpc_bootinfo hpc_bootinfo;
1565          uint64_t hpcmips_fb_addr = 0;          int hpc_platid_flags = 0, hpc_platid_cpu_submodel = 0,
1566          int hpcmips_fb_bits = 0, hpcmips_fb_encoding = 0;              hpc_platid_cpu_model = 0, hpc_platid_cpu_series = 0,
1567          int hpcmips_fb_xsize = 0;              hpc_platid_cpu_arch = 0,
1568          int hpcmips_fb_ysize = 0;              hpc_platid_submodel = 0, hpc_platid_model = 0,
1569          int hpcmips_fb_xsize_mem = 0;              hpc_platid_series = 0, hpc_platid_vendor = 0;
1570          int hpcmips_fb_ysize_mem = 0;          uint64_t hpc_fb_addr = 0;
1571            int hpc_fb_bits = 0, hpc_fb_encoding = 0;
1572            int hpc_fb_xsize = 0;
1573            int hpc_fb_ysize = 0;
1574            int hpc_fb_xsize_mem = 0;
1575            int hpc_fb_ysize_mem = 0;
1576    
1577          /*  ARCBIOS stuff:  */          /*  ARCBIOS stuff:  */
1578          uint64_t sgi_ram_offset = 0;          uint64_t sgi_ram_offset = 0;
# Line 1484  void machine_setup(struct machine *machi Line 1588  void machine_setup(struct machine *machi
1588          char *init_bootpath;          char *init_bootpath;
1589    
1590          /*  PCI stuff:  */          /*  PCI stuff:  */
1591          struct pci_data *pci_data;          struct pci_data *pci_data = NULL;
1592    
1593          /*  Framebuffer stuff:  */          /*  Framebuffer stuff:  */
1594          struct vfb_data *fb;          struct vfb_data *fb = NULL;
1595    
1596          /*  Abreviation:  :-)  */          /*  Abreviation:  :-)  */
1597          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];
# Line 1504  void machine_setup(struct machine *machi Line 1608  void machine_setup(struct machine *machi
1608                  case MACHINE_ARC:                  case MACHINE_ARC:
1609                          machine->boot_string_argument = "-aN";                          machine->boot_string_argument = "-aN";
1610                          break;                          break;
1611                    case MACHINE_CATS:
1612                            machine->boot_string_argument = "-A";
1613                            break;
1614                  case MACHINE_DEC:                  case MACHINE_DEC:
1615                          machine->boot_string_argument = "-a";                          machine->boot_string_argument = "-a";
1616                          break;                          break;
# Line 2053  void machine_setup(struct machine *machi Line 2160  void machine_setup(struct machine *machi
2160    
2161                  /*                  /*
2162                   *  Most OSes on DECstation use physical addresses below                   *  Most OSes on DECstation use physical addresses below
2163                   *  0x20000000, but OSF/1 seems to use 0xbe...... as if it was                   *  0x20000000, but both OSF/1 and Sprite use 0xbe...... as if
2164                   *  0x1e......, so we need this hack:                   *  it was 0x1e......, so we need this hack:
2165                   */                   */
2166                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);                  dev_ram_init(machine, 0xa0000000, 0x20000000,
2167                        DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2168    
2169                  /*  DECstation PROM stuff:  (TODO: endianness)  */                  if (machine->prom_emulation) {
2170                  for (i=0; i<100; i++)                          /*  DECstation PROM stuff:  (TODO: endianness)  */
2171                          store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,                          for (i=0; i<100; i++)
2172                              DEC_PROM_EMULATION + i*8);                                  store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
2173                                        DEC_PROM_EMULATION + i*8);
2174                  /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */  
2175                  for (i=0; i<100; i++) {                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2176                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,                          for (i=0; i<100; i++) {
2177                              0x03e00008);        /*  return  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2178                          store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,                                      0x03e00008);        /*  return  */
2179                              0x00000000);        /*  nop  */                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2180                  }                                      0x00000000);        /*  nop  */
2181                            }
2182    
2183                  /*                          /*
2184                   *  According to dec_prom.h from NetBSD:                           *  According to dec_prom.h from NetBSD:
2185                   *                           *
2186                   *  "Programs loaded by the new PROMs pass the following arguments:                           *  "Programs loaded by the new PROMs pass the following arguments:
2187                   *      a0      argc                           *      a0      argc
2188                   *      a1      argv                           *      a1      argv
2189                   *      a2      DEC_PROM_MAGIC                           *      a2      DEC_PROM_MAGIC
2190                   *      a3      The callback vector defined below"                           *      a3      The callback vector defined below"
2191                   *                           *
2192                   *  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
2193                   *  loaded.                           *  loaded.
2194                   */                           */
2195    
2196                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2197                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2198                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2199                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2200    
2201                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2202                      BOOTINFO_MAGIC);                              BOOTINFO_MAGIC);
2203                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2204                      BOOTINFO_ADDR);                              BOOTINFO_ADDR);
2205    
2206                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2207                      (DEC_PROM_INITIAL_ARGV + 0x10));                              (DEC_PROM_INITIAL_ARGV + 0x10));
2208                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2209                      (DEC_PROM_INITIAL_ARGV + 0x70));                              (DEC_PROM_INITIAL_ARGV + 0x70));
2210                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2211                      (DEC_PROM_INITIAL_ARGV + 0xe0));                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2212                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2213    
2214                  /*                          /*
2215                   *  NetBSD and Ultrix expect the boot args to be like this:                           *  NetBSD and Ultrix expect the boot args to be like this:
2216                   *                           *
2217                   *      "boot" "bootdev" [args?]                           *      "boot" "bootdev" [args?]
2218                   *                           *
2219                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                           *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2220                   *  3100/2100 (although that crashes Ultrix :-/), and                           *  3100/2100 (although that crashes Ultrix :-/), and
2221                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                           *  "5/rz0a/netbsd" for all others.  The number '5' is the
2222                   *  slot number of the boot device.                           *  slot number of the boot device.
2223                   *                           *
2224                   *  'rz' for disks, 'tz' for tapes.                           *  'rz' for disks, 'tz' for tapes.
2225                   *                           *
2226                   *  TODO:  Make this nicer.                           *  TODO:  Make this nicer.
2227                   */                           */
2228                  {                          {
2229                          char bootpath[200];                          char bootpath[200];
   
2230  #if 0  #if 0
2231                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
2232                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
# Line 2140  void machine_setup(struct machine *machi Line 2248  void machine_setup(struct machine *machi
2248                          }                          }
2249    
2250                          init_bootpath = bootpath;                          init_bootpath = bootpath;
2251                  }                          }
2252    
2253                  bootarg = malloc(BOOTARG_BUFLEN);                          bootarg = malloc(BOOTARG_BUFLEN);
2254                  if (bootarg == NULL) {                          if (bootarg == NULL) {
2255                          fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2256                          exit(1);                                  exit(1);
2257                  }                          }
2258                  strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);                          strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2259                  if (strlcat(bootarg, machine->boot_kernel_filename,                          if (strlcat(bootarg, machine->boot_kernel_filename,
2260                      BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {                              BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2261                          fprintf(stderr, "bootarg truncated?\n");                                  fprintf(stderr, "bootarg truncated?\n");
2262                          exit(1);                                  exit(1);
2263                  }                          }
2264    
2265                  bootstr = "boot";                          bootstr = "boot";
2266    
2267                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2268                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2269                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2270                      machine->boot_string_argument);                              machine->boot_string_argument);
2271    
2272                  /*  Decrease the nr of args, if there are no args :-)  */                          /*  Decrease the nr of args, if there are no args :-)  */
2273                  if (machine->boot_string_argument == NULL ||                          if (machine->boot_string_argument == NULL ||
2274                      machine->boot_string_argument[0] == '\0')                              machine->boot_string_argument[0] == '\0')
2275                          cpu->cd.mips.gpr[MIPS_GPR_A0] --;                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2276    
2277                  if (machine->boot_string_argument[0] != '\0') {                          if (machine->boot_string_argument[0] != '\0') {
2278                          strlcat(bootarg, " ", BOOTARG_BUFLEN);                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2279                          if (strlcat(bootarg, machine->boot_string_argument,                                  if (strlcat(bootarg, machine->boot_string_argument,
2280                              BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2281                                  fprintf(stderr, "bootstr truncated?\n");                                          fprintf(stderr, "bootstr truncated?\n");
2282                                  exit(1);                                          exit(1);
2283                                    }
2284                          }                          }
                 }  
2285    
2286                  xx.a.common.next = (char *)&xx.b - (char *)&xx;                          xx.a.common.next = (char *)&xx.b - (char *)&xx;
2287                  xx.a.common.type = BTINFO_MAGIC;                          xx.a.common.type = BTINFO_MAGIC;
2288                  xx.a.magic = BOOTINFO_MAGIC;                          xx.a.magic = BOOTINFO_MAGIC;
2289    
2290                  xx.b.common.next = (char *)&xx.c - (char *)&xx.b;                          xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2291                  xx.b.common.type = BTINFO_BOOTPATH;                          xx.b.common.type = BTINFO_BOOTPATH;
2292                  strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));                          strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2293    
2294                  xx.c.common.next = 0;                          xx.c.common.next = 0;
2295                  xx.c.common.type = BTINFO_SYMTAB;                          xx.c.common.type = BTINFO_SYMTAB;
2296                  xx.c.nsym = 0;                          xx.c.nsym = 0;
2297                  xx.c.ssym = 0;                          xx.c.ssym = 0;
2298                  xx.c.esym = machine->file_loaded_end_addr;                          xx.c.esym = machine->file_loaded_end_addr;
2299    
2300                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
2301    
2302                  /*                          /*
2303                   *  The system's memmap:  (memmap is a global variable, in                           *  The system's memmap:  (memmap is a global variable, in
2304                   *  dec_prom.h)                           *  dec_prom.h)
2305                   */                           */
2306                  store_32bit_word_in_host(cpu,                          store_32bit_word_in_host(cpu,
2307                      (unsigned char *)&memmap.pagesize, 4096);                              (unsigned char *)&memmap.pagesize, 4096);
2308                  {                          {
2309                          unsigned int i;                                  unsigned int i;
2310                          for (i=0; i<sizeof(memmap.bitmap); i++)                                  for (i=0; i<sizeof(memmap.bitmap); i++)
2311                                  memmap.bitmap[i] = ((int)i * 4096*8 <                                          memmap.bitmap[i] = ((int)i * 4096*8 <
2312                                      1048576*machine->physical_ram_in_mb)?                                              1048576*machine->physical_ram_in_mb)?
2313                                      0xff : 0x00;                                              0xff : 0x00;
2314                  }                          }
2315                  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);  
2316    
2317                  /*                          /*  Environment variables:  */
2318                   *  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);  
                 }  
   
                 /*  These are needed for Sprite to boot:  */  
                 {  
                         char tmps[500];  
   
                         snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);  
                         tmps[sizeof(tmps)-1] = '\0';  
                         add_environment_string(cpu, tmps, &addr);  
   
                         snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((  
                             DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))  
                             & 0xffffffffULL));  
                         tmps[sizeof(tmps)-1] = '\0';  
                         add_environment_string(cpu, tmps, &addr);  
   
                         snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",  
                             machine->physical_ram_in_mb * 1048576 / 4096 / 8);  
                         tmps[sizeof(tmps)-1] = '\0';  
                         add_environment_string(cpu, tmps, &addr);  
                 }  
   
                 add_environment_string(cpu, "scsiid0=7", &addr);  
                 add_environment_string(cpu, "bootmode=a", &addr);  
                 add_environment_string(cpu, "testaction=q", &addr);  
                 add_environment_string(cpu, "haltaction=h", &addr);  
                 add_environment_string(cpu, "more=24", &addr);  
   
                 /*  Used in at least Ultrix on the 5100:  */  
                 add_environment_string(cpu, "scsiid=7", &addr);  
                 add_environment_string(cpu, "baud0=9600", &addr);  
                 add_environment_string(cpu, "baud1=9600", &addr);  
                 add_environment_string(cpu, "baud2=9600", &addr);  
                 add_environment_string(cpu, "baud3=9600", &addr);  
                 add_environment_string(cpu, "iooption=0x1", &addr);  
2319    
2320                  /*  The end:  */                          if (machine->use_x11 && machine->n_gfx_cards > 0)
2321                  add_environment_string(cpu, "", &addr);                                  /*  (0,3)  Keyboard and Framebuffer  */
2322                                    add_environment_string(cpu, framebuffer_console_name, &addr);
2323                            else
2324                                    /*  Serial console  */
2325                                    add_environment_string(cpu, serial_console_name, &addr);
2326    
2327                            /*
2328                             *  The KN5800 (SMP system) uses a CCA (console communications
2329                             *  area):  (See VAX 6000 documentation for details.)
2330                             */
2331                            {
2332                                    char tmps[300];
2333                                    snprintf(tmps, sizeof(tmps), "cca=%x",
2334                                        (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2335                                    add_environment_string(cpu, tmps, &addr);
2336                            }
2337    
2338                            /*  These are needed for Sprite to boot:  */
2339                            {
2340                                    char tmps[500];
2341    
2342                                    snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2343                                    tmps[sizeof(tmps)-1] = '\0';
2344                                    add_environment_string(cpu, tmps, &addr);
2345    
2346                                    snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2347                                        DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2348                                        & 0xffffffffULL));
2349                                    tmps[sizeof(tmps)-1] = '\0';
2350                                    add_environment_string(cpu, tmps, &addr);
2351    
2352                                    snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2353                                        machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2354                                    tmps[sizeof(tmps)-1] = '\0';
2355                                    add_environment_string(cpu, tmps, &addr);
2356                            }
2357    
2358                            add_environment_string(cpu, "scsiid0=7", &addr);
2359                            add_environment_string(cpu, "bootmode=a", &addr);
2360                            add_environment_string(cpu, "testaction=q", &addr);
2361                            add_environment_string(cpu, "haltaction=h", &addr);
2362                            add_environment_string(cpu, "more=24", &addr);
2363    
2364                            /*  Used in at least Ultrix on the 5100:  */
2365                            add_environment_string(cpu, "scsiid=7", &addr);
2366                            add_environment_string(cpu, "baud0=9600", &addr);
2367                            add_environment_string(cpu, "baud1=9600", &addr);
2368                            add_environment_string(cpu, "baud2=9600", &addr);
2369                            add_environment_string(cpu, "baud3=9600", &addr);
2370                            add_environment_string(cpu, "iooption=0x1", &addr);
2371    
2372                            /*  The end:  */
2373                            add_environment_string(cpu, "", &addr);
2374                    }
2375    
2376                  break;                  break;
2377    
# Line 2285  void machine_setup(struct machine *machi Line 2394  void machine_setup(struct machine *machi
2394    
2395                  /*  ISA interrupt controllers:  */                  /*  ISA interrupt controllers:  */
2396                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2397                  machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2398                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2399                  machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);                  machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2400                  machine->md_interrupt = cobalt_interrupt;                  machine->md_interrupt = isa8_interrupt;
2401                    machine->isa_pic_data.native_irq = 6;
2402    
2403                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);
2404    
2405                  machine->main_console_handle = (size_t)                  machine->main_console_handle = (size_t)
2406                      device_add(machine, "ns16550 irq=5 addr=0x1c800000 name2=tty0 in_use=1");                      device_add(machine, "ns16550 irq=5 addr=0x1c800000 name2=tty0 in_use=1");
2407    
2408                    /*  TODO: bus_isa() ?  */
2409    
2410  #if 0  #if 0
2411                  device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0");                  device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0");
2412  #endif  #endif
# Line 2312  void machine_setup(struct machine *machi Line 2424  void machine_setup(struct machine *machi
2424                   *  The PCI controller interrupts at ISA interrupt 9.                   *  The PCI controller interrupts at ISA interrupt 9.
2425                   */                   */
2426                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 8 + 9, 11);                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 8 + 9, 11);
2427                  /*  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, "dec21143");
2428                  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, "symbios_860");   PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860  */
2429                  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, "vt82c586_isa");
2430                  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, "vt82c586_ide");
2431                  /*  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, "dec21143");  */
2432    
2433                  /*                  if (machine->prom_emulation) {
2434                   *  NetBSD/cobalt expects memsize in a0, but it seems that what                          /*
2435                   *  it really wants is the end of memory + 0x80000000.                           *  NetBSD/cobalt expects memsize in a0, but it seems that what
2436                   *                           *  it really wants is the end of memory + 0x80000000.
2437                   *  The bootstring is stored 512 bytes before the end of                           *
2438                   *  physical ram.                           *  The bootstring is stored 512 bytes before the end of
2439                   */                           *  physical ram.
2440                  cpu->cd.mips.gpr[MIPS_GPR_A0] =                           */
2441                      machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A0] =
2442                  bootstr = "root=/dev/hda1 ro";                              machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2443                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                          bootstr = "root=/dev/hda1 ro";
2444                  /*  TODO: bootarg, and/or automagic boot device detection  */                          /*  bootstr = "nfsroot=/usr/cobalt/";  */
2445                  store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);                          /*  TODO: bootarg, and/or automagic boot device detection  */
2446                            store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);
2447                    }
2448                  break;                  break;
2449    
2450          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
2451                  cpu->byte_order = EMUL_LITTLE_ENDIAN;                  cpu->byte_order = EMUL_LITTLE_ENDIAN;
2452                  memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));                  memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));
                 /*  TODO:  set platid from netbsd/usr/src/sys/arch/hpc/include/platid*  */  
                 /*  
                 #define PLATID_FLAGS_SHIFT              0  
                 #define PLATID_CPU_SUBMODEL_SHIFT       8  
                 #define PLATID_CPU_MODEL_SHIFT          14  
                 #define PLATID_CPU_SERIES_SHIFT         20  
                 #define PLATID_CPU_ARCH_SHIFT           26  
   
                 #define PLATID_SUBMODEL_SHIFT           0  
                 #define PLATID_MODEL_SHIFT              8  
                 #define PLATID_SERIES_SHIFT             16  
                 #define PLATID_VENDOR_SHIFT             22  
                 */  
   
2453                  /*                  /*
2454                  NOTE: See http://forums.projectmayo.com/viewtopic.php?topic=2743&forum=23                  NOTE: See http://forums.projectmayo.com/viewtopic.php?topic=2743&forum=23
2455                  for info on framebuffer addresses.                  for info on framebuffer addresses.
# Line 2359  void machine_setup(struct machine *machi Line 2459  void machine_setup(struct machine *machi
2459                  case MACHINE_HPCMIPS_CASIO_BE300:                  case MACHINE_HPCMIPS_CASIO_BE300:
2460                          /*  166MHz VR4131  */                          /*  166MHz VR4131  */
2461                          machine->machine_name = "Casio Cassiopeia BE-300";                          machine->machine_name = "Casio Cassiopeia BE-300";
2462                          hpcmips_fb_addr = 0x0a200000;                          hpc_fb_addr = 0x0a200000;
2463                          hpcmips_fb_xsize = 240;                          hpc_fb_xsize = 240;
2464                          hpcmips_fb_ysize = 320;                          hpc_fb_ysize = 320;
2465                          hpcmips_fb_xsize_mem = 256;                          hpc_fb_xsize_mem = 256;
2466                          hpcmips_fb_ysize_mem = 320;                          hpc_fb_ysize_mem = 320;
2467                          hpcmips_fb_bits = 15;                          hpc_fb_bits = 15;
2468                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2469    
2470                          /*  TODO: irq?  */                          /*  TODO: irq?  */
2471                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
# Line 2374  void machine_setup(struct machine *machi Line 2474  void machine_setup(struct machine *machi
2474                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);
2475                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2476    
2477                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2478                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2479                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2480                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 6;    /*  VR4131  */
2481                              + (6 <<  8)         /*  6 = VR4131  */                          hpc_platid_vendor = 3;          /*  Casio  */
2482                              );                          hpc_platid_series = 1;          /*  CASSIOPEIAE  */
2483                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  EXXX  */
2484                                (3 << 22)         /*  22: vendor  3=casio */                          hpc_platid_submodel = 3;        /*  E500  */
                             + (1 << 16)         /*  16: series  1=CASSIOPEIAE*/  
                             + (2 <<  8)         /*   8: model   2=EXXX*/  
                             + (3)               /*   0: submodel 3=E500 */  
                             );  
2485                          /*  TODO: Don't use model number for E500, it's a BE300!  */                          /*  TODO: Don't use model number for E500, it's a BE300!  */
2486                          break;                          break;
2487                  case MACHINE_HPCMIPS_CASIO_E105:                  case MACHINE_HPCMIPS_CASIO_E105:
2488                          /*  131MHz VR4121  */                          /*  131MHz VR4121  */
2489                          machine->machine_name = "Casio Cassiopeia E-105";                          machine->machine_name = "Casio Cassiopeia E-105";
2490                          hpcmips_fb_addr = 0x0a200000;   /*  TODO?  */                          hpc_fb_addr = 0x0a200000;       /*  TODO?  */
2491                          hpcmips_fb_xsize = 240;                          hpc_fb_xsize = 240;
2492                          hpcmips_fb_ysize = 320;                          hpc_fb_ysize = 320;
2493                          hpcmips_fb_xsize_mem = 256;                          hpc_fb_xsize_mem = 256;
2494                          hpcmips_fb_ysize_mem = 320;                          hpc_fb_ysize_mem = 320;
2495                          hpcmips_fb_bits = 16;                          hpc_fb_bits = 16;
2496                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2497    
2498                          /*  TODO: irq?  */                          /*  TODO: irq?  */
2499                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
# Line 2406  void machine_setup(struct machine *machi Line 2502  void machine_setup(struct machine *machi
2502                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2503                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2504    
2505                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2506                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2507                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2508                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2509                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 3;          /*  Casio  */
2510                              );                          hpc_platid_series = 1;          /*  CASSIOPEIAE  */
2511                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  EXXX  */
2512                                (3 << 22)         /*  22: vendor  3=casio */                          hpc_platid_submodel = 2;        /*  E105  */
                             + (1 << 16)         /*  16: series  1=CASSIOPEIAE*/  
                             + (2 <<  8)         /*   8: model   2=EXXX*/  
                             + (2)               /*   0: submodel 2=E105  */  
                             );  
2513                          break;                          break;
2514                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:
2515                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2516                          machine->machine_name = "NEC MobilePro 770";                          machine->machine_name = "NEC MobilePro 770";
2517                          /*  TODO:  */                          hpc_fb_addr = 0xa000000;
2518                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_xsize = 640;
2519                          hpcmips_fb_xsize = 640;                          hpc_fb_ysize = 240;
2520                          hpcmips_fb_ysize = 240;                          hpc_fb_xsize_mem = 800;
2521                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 240;
2522                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_bits = 16;
2523                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2524    
2525                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2526                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2527    
2528                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2529                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2530                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2531                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2532                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2533                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2534                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  MCR 5XX  */
2535                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 4;        /*  MCR 520A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (2 <<  8)         /*   8: model   2="MCR 5XX" */  
                             + (4)               /*   0: submodel 4="MCR 520A" */  
                             );  
2536                          break;                          break;
2537                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:
2538                          /*  166 (or 168) MHz VR4121  */                          /*  166 (or 168) MHz VR4121  */
2539                          machine->machine_name = "NEC MobilePro 780";                          machine->machine_name = "NEC MobilePro 780";
2540                          /*  TODO:  */                          hpc_fb_addr = 0xa180100;
2541                          hpcmips_fb_addr = 0xa180100;                          hpc_fb_xsize = 640;
2542                          hpcmips_fb_xsize = 640;                          hpc_fb_ysize = 240;
2543                          hpcmips_fb_ysize = 240;                          hpc_fb_xsize_mem = 640;
2544                          hpcmips_fb_xsize_mem = 640;                          hpc_fb_ysize_mem = 240;
2545                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_bits = 16;
2546                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2547    
2548                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2549                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2550    
2551                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2552                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2553                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2554                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2555                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2556                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2557                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  MCR 5XX  */
2558                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 8;        /*  MCR 530A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (2 <<  8)         /*   8: model   2="MCR 5XX" */  
                             + (8)               /*   0: submodel 8="MCR 530A" */  
                             );  
2559                          break;                          break;
2560                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:
2561                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2562                          machine->machine_name = "NEC MobilePro 800";                          machine->machine_name = "NEC MobilePro 800";
2563                          /*  TODO:  */                          hpc_fb_addr = 0xa000000;
2564                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_xsize = 800;
2565                          hpcmips_fb_xsize = 800;                          hpc_fb_ysize = 600;
2566                          hpcmips_fb_ysize = 600;                          hpc_fb_xsize_mem = 800;
2567                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 600;
2568                          hpcmips_fb_ysize_mem = 600;                          hpc_fb_bits = 16;
2569                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2570    
2571                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2572                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2573    
2574                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2575                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2576                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2577                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2578                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2579                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2580                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 3;           /*  MCR 7XX  */
2581                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 2;        /*  MCR 700A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (3 <<  8)         /*   8: model   3="MCR 7XX" */  
                             + (2)               /*   0: submodel 2="MCR 700A" */  
                             );  
2582                          break;                          break;
2583                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:
2584                          /*  168 MHz VR4121  */                          /*  168 MHz VR4121  */
2585                          machine->machine_name = "NEC MobilePro 880";                          machine->machine_name = "NEC MobilePro 880";
2586                          /*  TODO:  */                          hpc_fb_addr = 0xa0ea600;
2587                          hpcmips_fb_addr = 0xa0ea600;                          hpc_fb_xsize = 800;
2588                          hpcmips_fb_xsize = 800;                          hpc_fb_ysize = 600;
2589                          hpcmips_fb_ysize = 600;                          hpc_fb_xsize_mem = 800;
2590                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 600;
2591                          hpcmips_fb_ysize_mem = 600;                          hpc_fb_bits = 16;
2592                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2593    
2594                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2595                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2596    
2597                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2598                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2599                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2600                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2601                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2602                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2603                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 3;           /*  MCR 7XX  */
2604                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 4;        /*  MCR 730A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (3 <<  8)         /*   8: model   3="MCR 7XX" */  
                             + (4)               /*   0: submodel 4="MCR 730A" */  
                             );  
2605                          break;                          break;
2606                  case MACHINE_HPCMIPS_AGENDA_VR3:                  case MACHINE_HPCMIPS_AGENDA_VR3:
2607                          /*  66 MHz VR4181  */                          /*  66 MHz VR4181  */
2608                          machine->machine_name = "Agenda VR3";                          machine->machine_name = "Agenda VR3";
2609                          /*  TODO:  */                          /*  TODO:  */
2610                          hpcmips_fb_addr = 0x1000;                          hpc_fb_addr = 0x1000;
2611                          hpcmips_fb_xsize = 160;                          hpc_fb_xsize = 160;
2612                          hpcmips_fb_ysize = 240;                          hpc_fb_ysize = 240;
2613                          hpcmips_fb_xsize_mem = 160;                          hpc_fb_xsize_mem = 160;
2614                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_ysize_mem = 240;
2615                          hpcmips_fb_bits = 4;                          hpc_fb_bits = 4;
2616                          hpcmips_fb_encoding = BIFB_D4_M2L_F;                          hpc_fb_encoding = BIFB_D4_M2L_F;
2617    
2618                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4181);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4181);
2619                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
# Line 2557  void machine_setup(struct machine *machi Line 2629  void machine_setup(struct machine *machi
2629                                          machine->main_console_handle = x;                                          machine->main_console_handle = x;
2630                          }                          }
2631    
2632                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2633                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2634                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2635                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 4;    /*  VR4181  */
2636                              + (4 <<  8)         /*  4 = VR4181  */                          hpc_platid_vendor = 15;         /*  Agenda  */
2637                              );                          hpc_platid_series = 1;          /*  VR  */
2638                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 1;           /*  VR3  */
2639                                (15 << 22)        /*  22: vendor  15=Agenda  */                          hpc_platid_submodel = 0;        /*  -  */
                             + (1 << 16)         /*  16: series  2=VR */  
                             + (1 <<  8)         /*   8: model   1=VR3  */  
                             + (0)               /*   0: submodel 0="VR3" */  
                             );  
2640    
2641                          dev_ram_init(mem, 0x0f000000, 0x01000000, DEV_RAM_MIRROR, 0x0);                          dev_ram_init(machine, 0x0f000000, 0x01000000,
2642                                DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2643                          break;                          break;
2644                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:
2645                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2646                          machine->machine_name = "IBM Workpad Z50";                          machine->machine_name = "IBM Workpad Z50";
2647                          /*  TODO:  */                          /*  TODO:  */
2648                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_addr = 0xa000000;
2649                          hpcmips_fb_xsize = 640;                          hpc_fb_xsize = 640;
2650                          hpcmips_fb_ysize = 480;                          hpc_fb_ysize = 480;
2651                          hpcmips_fb_xsize_mem = 640;                          hpc_fb_xsize_mem = 640;
2652                          hpcmips_fb_ysize_mem = 480;                          hpc_fb_ysize_mem = 480;
2653                          hpcmips_fb_bits = 16;                          hpc_fb_bits = 16;
2654                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2655    
2656                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2657                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2658    
2659                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2660                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2661                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2662                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2663                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 9;          /*  IBM  */
2664                              );                          hpc_platid_series = 1;          /*  WorkPad  */
2665                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 1;           /*  Z50  */
2666                                (9 << 22)         /*  22: vendor  9=IBM  */                          hpc_platid_submodel = 0;        /*  0  */
                             + (1 << 16)         /*  16: series  1=WorkPad */  
                             + (1 <<  8)         /*   8: model   1=Z50  */  
                             + (0)               /*   0: submodel 0 */  
                             );  
2667                          break;                          break;
2668                  default:                  default:
2669                          printf("Unimplemented hpcmips machine number.\n");                          printf("Unimplemented hpcmips machine number.\n");
2670                          exit(1);                          exit(1);
2671                  }                  }
2672    
2673                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2674                          (hpc_platid_cpu_arch << 26) + (hpc_platid_cpu_series << 20)
2675                        + (hpc_platid_cpu_model << 14) + (hpc_platid_cpu_submodel <<  8)
2676                        + hpc_platid_flags);
2677                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2678                          (hpc_platid_vendor << 22) + (hpc_platid_series << 16)
2679                        + (hpc_platid_model <<  8) + hpc_platid_submodel);
2680    
2681                  if (machine->use_x11)                  if (machine->use_x11)
2682                          machine->main_console_handle =                          machine->main_console_handle =
2683                              machine->md_int.vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
2684    
2685                  /*  NetBSD/hpcmips and possibly others expects the following:  */                  if (machine->prom_emulation) {
2686                            /*  NetBSD/hpcmips and possibly others expects the following:  */
                 cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */  
                 cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576  
                     + 0xffffffff80000000ULL - 512;      /*  argv  */  
                 cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576  
                     + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */  
   
                 bootstr = machine->boot_kernel_filename;  
                 store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16);  
                 store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);  
                 store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);  
   
                 /*  Special case for the Agenda VR3:  */  
                 if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {  
                         const int tmplen = 1000;  
                         char *tmp = malloc(tmplen);  
   
                         cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */  
   
                         store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);  
                         store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);  
2687    
2688                          snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2689                              "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");                          cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2690                          tmp[tmplen-1] = '\0';                              + 0xffffffff80000000ULL - 512;      /*  argv  */
2691                            cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2692                                + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */
2693    
2694                            bootstr = machine->boot_kernel_filename;
2695                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512,
2696                                0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2697                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2698                            store_string(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2699    
2700                            /*  Special case for the Agenda VR3:  */
2701                            if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2702                                    const int tmplen = 1000;
2703                                    char *tmp = malloc(tmplen);
2704    
2705                                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */
2706    
2707                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2708                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2709    
2710                                    snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2711                                        "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2712                                    tmp[tmplen-1] = '\0';
2713    
2714                          if (!machine->use_x11)                                  if (!machine->use_x11)
2715                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2716                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2717    
2718                          if (machine->boot_string_argument[0])                                  if (machine->boot_string_argument[0])
2719                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2720                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2721    
2722                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
2723    
2724                          bootarg = tmp;                                  bootarg = tmp;
2725                  } else if (machine->boot_string_argument[0]) {                          } else if (machine->boot_string_argument[0]) {
2726                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */                                  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2727    
2728                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2729                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2730    
2731                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2732                              machine->boot_string_argument);                                      machine->boot_string_argument);
2733    
2734                          bootarg = machine->boot_string_argument;                                  bootarg = machine->boot_string_argument;
2735                  }                          }
2736    
2737                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2738                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2739                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpc_fb_addr);
2740                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpc_fb_xsize_mem * (((hpc_fb_bits-1)|7)+1) / 8);
2741                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpc_fb_xsize);
2742                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpc_fb_ysize);
2743                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpc_fb_encoding);
2744                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */
2745    
2746                  /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);                          /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);
2747                      printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */                              printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */
2748                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2749                  store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));                          store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2750                    }
2751                  if (hpcmips_fb_addr != 0) {  
2752                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,                  if (hpc_fb_addr != 0) {
2753                              hpcmips_fb_xsize, hpcmips_fb_ysize,                          dev_fb_init(machine, mem, hpc_fb_addr, VFB_HPC,
2754                              hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,                              hpc_fb_xsize, hpc_fb_ysize,
2755                              hpcmips_fb_bits, "HPCmips");                              hpc_fb_xsize_mem, hpc_fb_ysize_mem,
2756                                hpc_fb_bits, machine->machine_name);
2757    
2758                          /*  NetBSD/hpcmips uses framebuffer at physical                          /*  NetBSD/hpcmips uses framebuffer at physical
2759                              address 0x8.......:  */                              address 0x8.......:  */
2760                          dev_ram_init(mem, 0x80000000, 0x20000000,                          dev_ram_init(machine, 0x80000000, 0x20000000,
2761                              DEV_RAM_MIRROR, 0x0);                              DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2762                  }                  }
2763    
2764                  break;                  break;
# Line 2710  void machine_setup(struct machine *machi Line 2786  void machine_setup(struct machine *machi
2786                  machine->md_int.ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);                  machine->md_int.ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);
2787                  device_add(machine, "ps2_gs addr=0x12000000");                  device_add(machine, "ps2_gs addr=0x12000000");
2788                  device_add(machine, "ps2_ether addr=0x14001000");                  device_add(machine, "ps2_ether addr=0x14001000");
2789                  dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0);     /*  TODO: how much?  */                  dev_ram_init(machine, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0); /*  TODO: how much?  */
2790                  /*  irq = 8 + 32 + 1 (SBUS/USB)  */                  /*  irq = 8 + 32 + 1 (SBUS/USB)  */
2791                  device_add(machine, "ohci addr=0x1f801600 irq=41");                  device_add(machine, "ohci addr=0x1f801600 irq=41");
2792    
2793                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2794    
                 add_symbol_name(&machine->symbol_context,  
                     PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);  
                 store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);  
                 store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);  
   
2795                  /*  Set the Harddisk controller present flag, if either                  /*  Set the Harddisk controller present flag, if either
2796                      disk 0 or 1 is present:  */                      disk 0 or 1 is present:  */
2797                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2798                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2799                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                          if (machine->prom_emulation)
2800                                    store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2801                          dev_ps2_spd_init(machine, mem, 0x14000000);                          dev_ps2_spd_init(machine, mem, 0x14000000);
2802                  }                  }
2803    
2804                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                  if (machine->prom_emulation) {
                 {  
2805                          int tmplen = 1000;                          int tmplen = 1000;
2806                          char *tmp = malloc(tmplen);                          char *tmp = malloc(tmplen);
2807                            time_t timet;
2808                            struct tm *tm_ptr;
2809    
2810                            add_symbol_name(&machine->symbol_context,
2811                                PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2812                            store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2813                            store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2814    
2815                            store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2816                          if (tmp == NULL) {                          if (tmp == NULL) {
2817                                  fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2818                                  exit(1);                                  exit(1);
# Line 2747  void machine_setup(struct machine *machi Line 2827  void machine_setup(struct machine *machi
2827    
2828                          bootstr = tmp;                          bootstr = tmp;
2829                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
                 }  
2830    
2831                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
                 {  
                         time_t timet;  
                         struct tm *tmp;  
2832    
2833                          /*  RTC data given by the BIOS:  */                          /*  RTC data given by the BIOS:  */
2834                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */
2835                          tmp = gmtime(&timet);                          tm_ptr = gmtime(&timet);
2836                          /*  TODO:  are these 0- or 1-based?  */                          /*  TODO:  are these 0- or 1-based?  */
2837                          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));
2838                          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));
2839                          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));
2840                          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));
2841                          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));
2842                          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));
                 }  
2843    
2844                  /*  "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.  */
2845                  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);
2846                    }
2847    
2848                  break;                  break;
2849    
# Line 2797  void machine_setup(struct machine *machi Line 2873  void machine_setup(struct machine *machi
2873                          /*  Special cases for IP20,22,24,26 memory offset:  */                          /*  Special cases for IP20,22,24,26 memory offset:  */
2874                          if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||                          if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||
2875                              machine->machine_subtype == 24 || machine->machine_subtype == 26) {                              machine->machine_subtype == 24 || machine->machine_subtype == 26) {
2876                                  dev_ram_init(mem, 0x00000000, 0x10000, DEV_RAM_MIRROR, sgi_ram_offset);                                  dev_ram_init(machine, 0x00000000, 0x10000, DEV_RAM_MIRROR
2877                                  dev_ram_init(mem, 0x00050000, sgi_ram_offset-0x50000, DEV_RAM_MIRROR, sgi_ram_offset + 0x50000);                                      | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
2878                                    dev_ram_init(machine, 0x00050000, sgi_ram_offset-0x50000,
2879                                        DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset + 0x50000);
2880                          }                          }
2881    
2882                          /*  Special cases for IP28,30 memory offset:  */                          /*  Special cases for IP28,30 memory offset:  */
2883                          if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {                          if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {
2884                                  /*  TODO: length below should maybe not be 128MB?  */                                  /*  TODO: length below should maybe not be 128MB?  */
2885                                  dev_ram_init(mem, 0x00000000, 128*1048576, DEV_RAM_MIRROR, sgi_ram_offset);                                  dev_ram_init(machine, 0x00000000, 128*1048576, DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
2886                          }                          }
2887                  } else {                  } else {
2888                          cpu->byte_order = EMUL_LITTLE_ENDIAN;                          cpu->byte_order = EMUL_LITTLE_ENDIAN;
# Line 2815  void machine_setup(struct machine *machi Line 2893  void machine_setup(struct machine *machi
2893                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2894                          /*  TODO:  Other SGI machine types?  */                          /*  TODO:  Other SGI machine types?  */
2895                          switch (machine->machine_subtype) {                          switch (machine->machine_subtype) {
2896                            case 10:
2897                                    strlcat(machine->machine_name, " (4D/25)", MACHINE_NAME_MAXBUF);
2898                                    /*  TODO  */
2899                                    break;
2900                          case 12:                          case 12:
2901                                  strlcat(machine->machine_name,                                  strlcat(machine->machine_name,
2902                                      " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);                                      " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);
# Line 2916  void machine_setup(struct machine *machi Line 2998  void machine_setup(struct machine *machi
2998    
2999  /*  /*
3000  Why is this here? TODO  Why is this here? TODO
3001                                  dev_ram_init(mem, 0x88000000ULL,                                  dev_ram_init(machine, 0x88000000ULL,
3002                                      128 * 1048576, DEV_RAM_MIRROR, 0x08000000);                                      128 * 1048576, DEV_RAM_MIRROR, 0x08000000);
3003  */  */
3004                                  machine->md_interrupt = sgi_ip22_interrupt;                                  machine->md_interrupt = sgi_ip22_interrupt;
# Line 3043  Why is this here? TODO Line 3125  Why is this here? TODO
3125                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);
3126                                  machine->md_interrupt = sgi_ip30_interrupt;                                  machine->md_interrupt = sgi_ip30_interrupt;
3127    
3128                                  dev_ram_init(mem,    0xa0000000ULL,                                  dev_ram_init(machine,    0xa0000000ULL,
3129                                      128 * 1048576, DEV_RAM_MIRROR, 0x00000000);                                      128 * 1048576, DEV_RAM_MIRROR
3130                                        | DEV_RAM_MIGHT_POINT_TO_DEVICES,
3131                                        0x00000000);
3132    
3133                                  dev_ram_init(mem,    0x80000000ULL,                                  dev_ram_init(machine,    0x80000000ULL,
3134                                      32 * 1048576, DEV_RAM_RAM, 0x00000000);                                      32 * 1048576, DEV_RAM_RAM, 0x00000000);
3135    
3136                                  /*                                  /*
# Line 3078  Why is this here? TODO Line 3162  Why is this here? TODO
3162                                      " (O2)", MACHINE_NAME_MAXBUF);                                      " (O2)", MACHINE_NAME_MAXBUF);
3163    
3164                                  /*  TODO:  Find out where the physical ram is actually located.  */                                  /*  TODO:  Find out where the physical ram is actually located.  */
3165                                  dev_ram_init(mem, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(machine, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
3166                                  dev_ram_init(mem, 0x10000000ULL,           256, DEV_RAM_MIRROR, 0x00000000);                                  dev_ram_init(machine, 0x10000000ULL,           256, DEV_RAM_MIRROR, 0x00000000);
3167                                  dev_ram_init(mem, 0x11ffff00ULL,           256, DEV_RAM_MIRROR, 0x01ffff00);                                  dev_ram_init(machine, 0x11ffff00ULL,           256, DEV_RAM_MIRROR, 0x01ffff00);
3168                                  dev_ram_init(mem, 0x12000000ULL,           256, DEV_RAM_MIRROR, 0x02000000);                                  dev_ram_init(machine, 0x12000000ULL,           256, DEV_RAM_MIRROR, 0x02000000);
3169                                  dev_ram_init(mem, 0x17ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(machine, 0x17ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
3170                                  dev_ram_init(mem, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);                                  dev_ram_init(machine, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);
3171                                  dev_ram_init(mem, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);                                  dev_ram_init(machine, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);
3172    
3173                                  machine->md_int.ip32.crime_data = dev_crime_init(machine, mem, 0x14000000, 2, machine->use_x11);        /*  crime0  */                                  machine->md_int.ip32.crime_data = dev_crime_init(machine, mem, 0x14000000, 2, machine->use_x11);        /*  crime0  */
3174                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */
# Line 3130  Why is this here? TODO Line 3214  Why is this here? TODO
3214                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
3215                                   */                                   */
3216    
 #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  
   
3217                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3218                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3219                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
# Line 3158  Why is this here? TODO Line 3235  Why is this here? TODO
3235                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",
3236                                      (1<<26) + MACE_PERIPH_SERIAL, 0);                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3237                                  device_add(machine, tmpstr);                                  device_add(machine, tmpstr);
3238  #if 0  
3239                                  if (machine->use_x11)                                  machine->main_console_handle = j;
3240    
3241                                    /*  TODO: Once this works, it should be enabled
3242                                        always, not just when using X!  */
3243                                    if (machine->use_x11) {
3244                                            i = dev_pckbc_init(machine, mem, 0x1f320000,
3245                                                PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
3246                                                0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
3247                                                    /*  keyb+mouse (mace irq numbers)  */
3248                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3249                                  else                                  }
 #endif  
                                         machine->main_console_handle = j;  
3250    
3251                                  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  */
3252                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");
# Line 3177  Why is this here? TODO Line 3260  Why is this here? TODO
3260                                   */                                   */
3261    
3262                                  pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE);  /*  macepci0  */                                  pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE);  /*  macepci0  */
3263                                  /*  bus_pci_add(machine, pci_data, mem, 0, 0, 0, pci_ne2000_init, pci_ne2000_rr);  TODO  */                                  /*  bus_pci_add(machine, pci_data, mem, 0, 0, 0, "ne2000");  TODO  */
3264    
3265                                  /*  TODO: make this nicer  */                                  /*  TODO: make this nicer  */
3266                                  if (diskimage_exist(machine, 0, DISKIMAGE_SCSI) ||                                  if (diskimage_exist(machine, 0, DISKIMAGE_SCSI) ||
# Line 3188  Why is this here? TODO Line 3271  Why is this here? TODO
3271                                      diskimage_exist(machine, 5, DISKIMAGE_SCSI) ||                                      diskimage_exist(machine, 5, DISKIMAGE_SCSI) ||
3272                                      diskimage_exist(machine, 6, DISKIMAGE_SCSI) ||                                      diskimage_exist(machine, 6, DISKIMAGE_SCSI) ||
3273                                      diskimage_exist(machine, 7, DISKIMAGE_SCSI))                                      diskimage_exist(machine, 7, DISKIMAGE_SCSI))
3274                                          bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr);                                          bus_pci_add(machine, pci_data, mem, 0, 1, 0, "ahc");
3275    
3276                                  /*  TODO: second ahc  */                                  /*  TODO: second ahc  */
3277                                  /*  bus_pci_add(machine, pci_data, mem, 0, 2, 0, pci_ahc_init, pci_ahc_rr);  */                                  /*  bus_pci_add(machine, pci_data, mem, 0, 2, 0, "ahc");  */
3278    
3279                                  break;                                  break;
3280                          case 35:                          case 35:
# Line 3273  Why is this here? TODO Line 3356  Why is this here? TODO
3356                                  case MACHINE_ARC_NEC_RD94:                                  case MACHINE_ARC_NEC_RD94:
3357                                  case MACHINE_ARC_NEC_R94:                                  case MACHINE_ARC_NEC_R94:
3358                                          /*  PCI devices:  (NOTE: bus must be 0, device must be 3, 4, or 5, for NetBSD to accept interrupts)  */                                          /*  PCI devices:  (NOTE: bus must be 0, device must be 3, 4, or 5, for NetBSD to accept interrupts)  */
3359                                          bus_pci_add(machine, pci_data, mem, 0, 3, 0, pci_dec21030_init, pci_dec21030_rr);       /*  tga graphics  */                                          bus_pci_add(machine, pci_data, mem, 0, 3, 0, "dec21030");       /*  tga graphics  */
3360                                          break;                                          break;
3361                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3362                                          dev_fb_init(machine, mem, 0x100e00000ULL,                                          dev_fb_init(machine, mem, 0x100e00000ULL,
# Line 3396  Why is this here? TODO Line 3479  Why is this here? TODO
3479                                          break;                                          break;
3480                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3481                                          /*  PROM mirror?  */                                          /*  PROM mirror?  */
3482                                          dev_ram_init(mem, 0xfff00000, 0x100000,                                          dev_ram_init(machine, 0xfff00000, 0x100000,
3483                                              DEV_RAM_MIRROR, 0x1fc00000);                                              DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x1fc00000);
3484    
3485                                          /*  VXL. TODO  */                                          /*  VXL. TODO  */
3486                                          /*  control at 0x60100000?  */                                          /*  control at 0x60100000?  */
# Line 3422  Why is this here? TODO Line 3505  Why is this here? TODO
3505    
3506  #if 0  #if 0
3507  Not yet.  Not yet.
3508                                  dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);                                  /*  irq = 8+16 + 14  */
3509                                    device_add(machine, "wdc addr=0x900001f0, irq=38");
3510  #endif  #endif
3511    
3512                                  break;                                  break;
# Line 3489  Not yet. Line 3573  Not yet.
3573                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3574    
3575  #if 0  #if 0
3576                                  dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);                                  /*  TODO: irq, etc  */
3577                                  dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);                                  device_add(machine, "wdc addr=0x9000001f0, irq=0");
3578                                    device_add(machine, "wdc addr=0x900000170, irq=0");
3579  #endif  #endif
3580                                  /*  PC kbd  */                                  /*  PC kbd  */
3581                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,
# Line 3524  Not yet. Line 3609  Not yet.
3609                   *  point.                   *  point.
3610                   */                   */
3611    
3612                  if (machine->prom_emulation)                  if (machine->prom_emulation) {
3613                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),
3614                              sgi_ram_offset);                              sgi_ram_offset);
                 else  
                         goto no_arc_prom_emulation;     /*  TODO: ugly  */  
3615    
3616                  /*                          /*
3617                   *  TODO: How to build the component tree intermixed with                           *  TODO: How to build the component tree intermixed with
3618                   *  the rest of device initialization?                           *  the rest of device initialization?
3619                   */                           */
   
                 /*  
                  *  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';  
3620    
3621                  if (bootdev_id < 0 || machine->force_netboot) {                          /*
3622                          snprintf(init_bootpath, 400, "tftp()");                           *  Boot string in ARC format:
3623                  } else {                           *
3624                          /*  TODO: Make this nicer.  */                           *  TODO: How about floppies? multi()disk()fdisk()
3625                          if (machine->machine_type == MACHINE_SGI) {                           *        Is tftp() good for netbooting?
3626                                  if (machine->machine_subtype == 30)                           */
3627                                          strlcat(init_bootpath, "xio(0)pci(15)",                          init_bootpath = malloc(500);
3628                                              MACHINE_NAME_MAXBUF);                          if (init_bootpath == NULL) {
3629                                  if (machine->machine_subtype == 32)                                  fprintf(stderr, "out of mem, bootpath\n");
3630                                          strlcat(init_bootpath, "pci(0)",                                  exit(1);
                                             MACHINE_NAME_MAXBUF);  
3631                          }                          }
3632                            init_bootpath[0] = '\0';
3633    
3634                          if (diskimage_is_a_cdrom(machine, bootdev_id,                          if (bootdev_id < 0 || machine->force_netboot) {
3635                              bootdev_type))                                  snprintf(init_bootpath, 400, "tftp()");
3636                                  snprintf(init_bootpath + strlen(init_bootpath),                          } else {
3637                                      400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);                                  /*  TODO: Make this nicer.  */
3638                          else                                  if (machine->machine_type == MACHINE_SGI) {
3639                                  snprintf(init_bootpath + strlen(init_bootpath),                                          if (machine->machine_subtype == 30)
3640                                      400,"scsi(0)disk(%i)rdisk(0)partition(1)",                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3641                                      bootdev_id);                                                      MACHINE_NAME_MAXBUF);
3642                  }                                          if (machine->machine_subtype == 32)
3643                                                    strlcat(init_bootpath, "pci(0)",
3644                                                        MACHINE_NAME_MAXBUF);
3645                                    }
3646    
3647                  if (machine->machine_type == MACHINE_ARC)                                  if (diskimage_is_a_cdrom(machine, bootdev_id,
3648                          strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);                                      bootdev_type))
3649                                            snprintf(init_bootpath + strlen(init_bootpath),
3650                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3651                                    else
3652                                            snprintf(init_bootpath + strlen(init_bootpath),
3653                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3654                                                bootdev_id);
3655                            }
3656    
3657                  bootstr = malloc(BOOTSTR_BUFLEN);                          if (machine->machine_type == MACHINE_ARC)
3658                  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);  
                 }  
3659    
3660                  /*  Boot args., eg "-a"  */                          bootstr = malloc(BOOTSTR_BUFLEN);
3661                  bootarg = machine->boot_string_argument;                          if (bootstr == NULL) {
3662                                    fprintf(stderr, "out of memory\n");
3663                                    exit(1);
3664                            }
3665                            strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3666                            if (strlcat(bootstr, machine->boot_kernel_filename,
3667                                BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3668                                    fprintf(stderr, "boot string too long?\n");
3669                                    exit(1);
3670                            }
3671    
3672                            /*  Boot args., eg "-a"  */
3673                            bootarg = machine->boot_string_argument;
3674    
3675                  /*  argc, argv, envp in a0, a1, a2:  */                          /*  argc, argv, envp in a0, a1, a2:  */
3676                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */
3677    
3678                  /*  TODO:  not needed?  */                          /*  TODO:  not needed?  */
3679                  cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3680                      (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3681    
3682                  /*  Set up argc/argv:  */                          /*  Set up argc/argv:  */
3683                  addr = ARC_ENV_STRINGS;                          addr = ARC_ENV_STRINGS;
3684                  addr2 = ARC_ARGV_START;                          addr2 = ARC_ARGV_START;
3685                  cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
   
                 /*  bootstr:  */  
                 store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                 add_environment_string(cpu, bootstr, &addr);  
                 cpu->cd.mips.gpr[MIPS_GPR_A0] ++;  
3686    
3687                  /*  bootarg:  */                          /*  bootstr:  */
                 if (bootarg[0] != '\0') {  
3688                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3689                          add_environment_string(cpu, bootarg, &addr);                          add_environment_string(cpu, bootstr, &addr);
3690                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                 }  
3691    
3692                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                          /*  bootarg:  */
3693                            if (bootarg[0] != '\0') {
3694                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3695                                    add_environment_string(cpu, bootarg, &addr);
3696                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3697                            }
3698    
3699                  /*                          cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
3700                   *  Add environment variables.  For each variable, add it  
3701                   *  as a string using add_environment_string(), and add a                          /*
3702                   *  pointer to it to the ARC_ENV_POINTERS array.                           *  Add environment variables.  For each variable, add it
3703                   */                           *  as a string using add_environment_string(), and add a
3704                  if (machine->use_x11) {                           *  pointer to it to the ARC_ENV_POINTERS array.
3705                          if (machine->machine_type == MACHINE_ARC) {                           */
3706                            if (machine->use_x11) {
3707                                    if (machine->machine_type == MACHINE_ARC) {
3708                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3709                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3710                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3711                                            add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3712                                    } else {
3713                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3714                                            add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3715                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3716                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3717    
3718                                            /*  g for graphical mode. G for graphical mode
3719                                                with SGI logo visible on Irix?  */
3720                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3721                                            add_environment_string(cpu, "console=g", &addr);
3722                                    }
3723                            } else {
3724                                    if (machine->machine_type == MACHINE_ARC) {
3725                                            /*  TODO: serial console for ARC?  */
3726                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3727                                            add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3728                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3729                                            add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3730                                    } else {
3731                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3732                                            add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3733                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3734                                            add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3735    
3736                                            /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3737                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3738                                            add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
3739                                    }
3740                            }
3741    
3742                            if (machine->machine_type == MACHINE_SGI) {
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, "CONSOLEIN=multi()key()keyboard()console()", &addr);                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3745                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3746                                  add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "diskless=0", &addr);
                         } else {  
3747                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3748                                  add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);                                  add_environment_string(cpu, "volume=80", &addr);
3749                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3750                                  add_environment_string(cpu, "ConsoleOut=video()", &addr);                                  add_environment_string(cpu, "sgilogo=y", &addr);
3751    
                                 /*  g for graphical mode. G for graphical mode  
                                     with SGI logo visible on Irix?  */  
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=g", &addr);                                  add_environment_string(cpu, "monitor=h", &addr);
                         }  
                 } else {  
                         if (machine->machine_type == MACHINE_ARC) {  
                                 /*  TODO: serial console for ARC?  */  
3754                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3755                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "TimeZone=GMT", &addr);
3756                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3757                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "nogfxkbd=1", &addr);
3758                          } else {  
3759                                    /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */
3760    
3761                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3762                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);
3763                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3764                                  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?  */  
3765                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3766                                  add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */                                  add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
3767                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3768                  }                                  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);  
3769    
3770                          /*  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));
3771                                    add_environment_string(cpu, "rbaud=9600", &addr);
3772                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3773                                    add_environment_string(cpu, "rebound=y", &addr);
3774                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3775                                    add_environment_string(cpu, "crt_option=1", &addr);
3776                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3777                                    add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
3778    
3779                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3780                          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);  
3781    
3782                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3783                          add_environment_string(cpu, "rbaud=9600", &addr);                                  add_environment_string(cpu, "cpufreq=3", &addr);
3784                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3785                          add_environment_string(cpu, "rebound=y", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
3786                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3787                          add_environment_string(cpu, "crt_option=1", &addr);                                  add_environment_string(cpu, eaddr_string, &addr);
3788                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3789                          add_environment_string(cpu, "netaddr=10.0.0.1", &addr);                                  add_environment_string(cpu, "verbose=istrue", &addr);
3790                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3791                                    add_environment_string(cpu, "showconfig=istrue", &addr);
3792                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3793                                    add_environment_string(cpu, "diagmode=v", &addr);
3794                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3795                                    add_environment_string(cpu, "kernname=unix", &addr);
3796                            } else {
3797                                    char *tmp;
3798                                    size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3799                                    tmp = malloc(mlen);
3800                                    snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3801                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3802                                    add_environment_string(cpu, tmp, &addr);
3803    
3804                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3805                          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);
3806    
3807                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3808                          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);
3809                          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);  
3810    
3811                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  End the environment strings with an empty zero-terminated
3812                          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.  */
3813                            add_environment_string(cpu, "", &addr); /*  the end  */
3814                            store_pointer_and_advance(cpu, &addr2,
3815                                0, arc_wordlen==sizeof(uint64_t));
3816    
3817                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  Return address:  (0x20 = ReturnFromMain())  */
3818                          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;
3819                  }                  }
3820    
                 /*  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;  
   
3821                  break;                  break;
3822    
3823          case MACHINE_MESHCUBE:          case MACHINE_MESHCUBE:
# Line 3765  no_arc_prom_emulation:         /*  TODO: ugly, Line 3847  no_arc_prom_emulation:         /*  TODO: ugly,
3847    
3848                  device_add(machine, "random addr=0x1017fffc len=4");                  device_add(machine, "random addr=0x1017fffc len=4");
3849    
3850                  /*                  if (machine->prom_emulation) {
3851                   *  TODO:  A Linux kernel wants "memsize" from somewhere... I                          /*
3852                   *  haven't found any docs on how it is used though.                           *  TODO:  A Linux kernel wants "memsize" from somewhere... I
3853                   */                           *  haven't found any docs on how it is used though.
3854                             */
3855                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
3856                  cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
3857                  store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
3858                      0xa0002000ULL);                              0xa0002000ULL);
3859                  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");  
3860    
3861                            cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
3862                            store_string(cpu, 0xa0002000ULL, "hello=world\n");
3863                    }
3864                  break;                  break;
3865    
3866          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
3867                  machine->machine_name = "NetGear WG602";                  machine->machine_name = "NetGear WG602v1";
3868    
3869                  if (machine->use_x11)                  if (machine->use_x11)
3870                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
3871                  if (machine->physical_ram_in_mb != 16)                  if (machine->physical_ram_in_mb != 16)
3872                          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");
3873    
3874                  /*                  /*
3875                   *  Lots of info about the IDT 79RC 32334                   *  Lots of info about the IDT 79RC 32334
# Line 3820  no_arc_prom_emulation:         /*  TODO: ugly, Line 3902  no_arc_prom_emulation:         /*  TODO: ugly,
3902                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
3903                  machine->machine_name = "Sony NeWS (NET WORK STATION)";                  machine->machine_name = "Sony NeWS (NET WORK STATION)";
3904    
3905                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3906                  {                          /*  This is just a test.  TODO  */
3907                          int i;                          int i;
3908                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
3909                                  cpu->cd.mips.gpr[i] =                                  cpu->cd.mips.gpr[i] =
# Line 3848  no_arc_prom_emulation:         /*  TODO: ugly, Line 3930  no_arc_prom_emulation:         /*  TODO: ugly,
3930                                  cpu->byte_order = EMUL_BIG_ENDIAN;                                  cpu->byte_order = EMUL_BIG_ENDIAN;
3931                          }                          }
3932    
3933                          /*  ISA interrupt controllers:  */                          machine->md_interrupt = isa8_interrupt;
3934                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");                          machine->isa_pic_data.native_irq = 2;
3935                          machine->md_int.isa_pic_data.pic1 = device_add(machine, tmpstr);  
3936                          snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");                          bus_isa(machine, 0, 0x18000000, 0x10000000, 8, 24);
                         machine->md_int.isa_pic_data.pic2 = device_add(machine, tmpstr);  
                         machine->md_interrupt = malta_interrupt;  
   
                         dev_mc146818_init(machine, mem, 0x18000070, 8 + 8, MC146818_PC_CMOS, 1);  
   
                         machine->main_console_handle = (size_t)  
                             device_add(machine, "ns16550 irq=12 addr=0x180003f8 name2=tty0");  
                         device_add(machine, "ns16550 irq=11 addr=0x180002f8 name2=tty1");  
3937    
3938                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x name2=tty2", MALTA_CBUSUART);                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x name2=tty2", MALTA_CBUSUART);
3939                          device_add(machine, tmpstr);                          device_add(machine, tmpstr);
3940                          /*  TODO: Irqs  */  
3941                          pci_data = dev_gt_init(machine, mem, 0x1be00000, 8+9, 8+9, 120);                          pci_data = dev_gt_init(machine, mem, 0x1be00000, 8+9, 8+9, 120);
3942    
3943                          /*  TODO: Haha, this is bogus. Just a cut&paste                          if (machine->use_x11) {
3944                              from the Cobalt emulation above.  */                                  if (strlen(machine->boot_string_argument) < 3)
3945                          bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);                                          fatal("WARNING: remember to use  -o 'console=tty0'  "
3946                          bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);                                              "if you are emulating Linux. (Not needed for NetBSD.)\n");
3947                                    bus_pci_add(machine, pci_data, mem, 0xc0, 8, 0, "s3_virge");
3948                            }
3949    
3950                            bus_pci_add(machine, pci_data, mem, 0,  9, 0, "i82371ab_isa");
3951                            bus_pci_add(machine, pci_data, mem, 0,  9, 1, "i82371ab_ide");
3952    
3953                          device_add(machine, "malta_lcd addr=0x1f000400");                          device_add(machine, "malta_lcd addr=0x1f000400");
3954                          break;                          break;
# Line 3887  no_arc_prom_emulation:         /*  TODO: ugly, Line 3966  no_arc_prom_emulation:         /*  TODO: ugly,
3966                  }                  }
3967    
3968                  if (machine->prom_emulation) {                  if (machine->prom_emulation) {
                         /*  This is just a test.  TODO  */  
                         for (i=0; i<32; i++)  
                                 cpu->cd.mips.gpr[i] =  
                                     0x01230000 + (i << 8) + 0x55;  
   
3969                          /*  NetBSD/evbmips wants these: (at least for Malta)  */                          /*  NetBSD/evbmips wants these: (at least for Malta)  */
3970    
3971                          /*  a0 = argc  */                          /*  a0 = argc  */
# Line 3970  no_arc_prom_emulation:         /*  TODO: ugly, Line 4044  no_arc_prom_emulation:         /*  TODO: ugly,
4044                              "------------------------------------------\n");                              "------------------------------------------\n");
4045    
4046                  /*  480 x 272 pixels framebuffer (512 bytes per line)  */                  /*  480 x 272 pixels framebuffer (512 bytes per line)  */
4047                  fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPCMIPS,                  fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPC,
4048                      480,272, 512,1088, -15, "Playstation Portable");                      480,272, 512,1088, -15, "Playstation Portable");
4049    
4050                  /*                  /*
# Line 3992  no_arc_prom_emulation:         /*  TODO: ugly, Line 4066  no_arc_prom_emulation:         /*  TODO: ugly,
4066                  cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;                  cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;
4067    
4068                  break;                  break;
4069    
4070            case MACHINE_ALGOR:
4071                    switch (machine->machine_subtype) {
4072                    case MACHINE_ALGOR_P4032:
4073                            machine->machine_name = "\"Algor\" P4032";
4074                            break;
4075                    case MACHINE_ALGOR_P5064:
4076                            machine->machine_name = "\"Algor\" P5064";
4077                            break;
4078                    default:fatal("Unimplemented Algor machine.\n");
4079                            exit(1);
4080                    }
4081    
4082                    machine->md_interrupt = isa8_interrupt;
4083                    machine->isa_pic_data.native_irq = 6;
4084    
4085                    /*  TODO: correct isa irq? 6 is just a bogus guess  */
4086    
4087                    bus_isa(machine, 0, 0x1d000000, 0xc0000000, 8, 24);
4088    
4089                    if (machine->prom_emulation) {
4090                            /*  NetBSD/algor wants these:  */
4091    
4092                            /*  a0 = argc  */
4093                            cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
4094    
4095                            /*  a1 = argv  */
4096                            cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
4097                            store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
4098                            store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
4099                            store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
4100    
4101                            bootstr = strdup(machine->boot_kernel_filename);
4102                            bootarg = strdup(machine->boot_string_argument);
4103                            store_string(cpu, (int32_t)0x9fc01040, bootstr);
4104                            store_string(cpu, (int32_t)0x9fc01200, bootarg);
4105    
4106                            /*  a2 = (yamon_env_var *)envp  */
4107                            cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
4108                            {
4109                                    char tmps[50];
4110    
4111                                    store_32bit_word(cpu, (int32_t)0x9fc01800, 0x9fc01900);
4112                                    store_32bit_word(cpu, (int32_t)0x9fc01804, 0x9fc01a00);
4113                                    store_32bit_word(cpu, (int32_t)0x9fc01808, 0);
4114    
4115                                    snprintf(tmps, sizeof(tmps), "memsize=0x%08x",
4116                                        machine->physical_ram_in_mb * 1048576);
4117                                    store_string(cpu, (int)0x9fc01900, tmps);
4118                                    store_string(cpu, (int)0x9fc01a00, "ethaddr=10:20:30:30:20:10");
4119                            }
4120                    }
4121                    break;
4122  #endif  /*  ENABLE_MIPS  */  #endif  /*  ENABLE_MIPS  */
4123    
4124  #ifdef ENABLE_PPC  #ifdef ENABLE_PPC
# Line 4039  no_arc_prom_emulation:         /*  TODO: ugly, Line 4166  no_arc_prom_emulation:         /*  TODO: ugly,
4166                   */                   */
4167                  machine->machine_name = "Walnut evaluation board";                  machine->machine_name = "Walnut evaluation board";
4168    
4169                    /*  "OpenBIOS" entrypoint (?):  */
4170                    dev_ram_init(machine, 0xfffe0b50, 8, DEV_RAM_RAM, 0);
4171                    store_32bit_word(cpu, 0xfffe0b50, 0xfffe0b54);
4172                    store_32bit_word(cpu, 0xfffe0b54, 0x4e800020);  /*  blr  */
4173    
4174                  break;                  break;
4175    
4176          case MACHINE_PMPPC:          case MACHINE_PMPPC:
# Line 4046  no_arc_prom_emulation:         /*  TODO: ugly, Line 4178  no_arc_prom_emulation:         /*  TODO: ugly,
4178                   *  NetBSD/pmppc (http://www.netbsd.org/Ports/pmppc/)                   *  NetBSD/pmppc (http://www.netbsd.org/Ports/pmppc/)
4179                   */                   */
4180                  machine->machine_name = "Artesyn's PM/PPC board";                  machine->machine_name = "Artesyn's PM/PPC board";
4181                    machine->emulated_hz = 10000000;
4182    
4183                  dev_pmppc_init(mem);                  dev_pmppc_init(mem);
4184    
4185                  /*  com0 = 0xff600300, com1 = 0xff600400  */                  machine->md_int.cpc700_data = dev_cpc700_init(machine, mem);
4186                    machine->md_interrupt = cpc700_interrupt;
4187    
4188                    /*  RTC at "ext int 5" = "int 25" in IBM jargon, int
4189                        31-25 = 6 for the rest of us.  */
4190                    dev_mc146818_init(machine, mem, 0x7ff00000, 31-25, MC146818_PMPPC, 1);
4191    
4192                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0xff600300 name2=tty0");                  bus_pci_add(machine, machine->md_int.cpc700_data->pci_data,
4193                  device_add(machine, "ns16550 irq=0 addr=0xff600400 in_use=0 name2=tty1");                      mem, 0, 8, 0, "dec21143");
4194    
4195                  break;                  break;
4196    
# Line 4062  no_arc_prom_emulation:         /*  TODO: ugly, Line 4200  no_arc_prom_emulation:         /*  TODO: ugly,
4200                   */                   */
4201                  machine->machine_name = "Motorola Sandpoint";                  machine->machine_name = "Motorola Sandpoint";
4202    
4203                  {                  /*  r4 should point to first free byte after the loaded kernel:  */
4204                          int i;                  cpu->cd.ppc.gpr[4] = 6 * 1048576;
                         for (i=0; i<32; i++)  
                                 cpu->cd.ppc.gpr[i] =  
                                     0x12340000 + (i << 8) + 0x55;  
                 }  
4205    
4206                  break;                  break;
4207    
# Line 4077  no_arc_prom_emulation:         /*  TODO: ugly, Line 4211  no_arc_prom_emulation:         /*  TODO: ugly,
4211                   */                   */
4212                  machine->machine_name = "BeBox";                  machine->machine_name = "BeBox";
4213    
4214                  device_add(machine, "bebox");                  machine->md_int.bebox_data = device_add(machine, "bebox");
4215                    machine->isa_pic_data.native_irq = 5;
4216                    machine->md_interrupt = isa32_interrupt;
4217    
4218                  machine->main_console_handle = (size_t)                  pci_data = dev_eagle_init(machine, mem,
4219                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");                      32 /*  isa irq base */, 0 /*  pci irq: TODO */);
                 device_add(machine, "ns16550 irq=0 addr=0x800002f8 name2=tty1 in_use=0");  
4220    
4221                  if (machine->use_x11)                  bus_isa(machine, BUS_ISA_IDE0 | BUS_ISA_VGA,
4222                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,                      0x80000000, 0xc0000000, 32, 48);
                             machine->machine_name);  
4223    
4224                  store_32bit_word(cpu, 0x3010,                  if (machine->prom_emulation) {
4225                      machine->physical_ram_in_mb * 1048576);                          /*  According to the docs, and also used by NetBSD:  */
4226                            store_32bit_word(cpu, 0x3010, machine->physical_ram_in_mb * 1048576);
4227    
4228                  /*  TODO: List of stuff, see http://www.beatjapan.org/                          /*  Used by Linux:  */
4229                      mirror/www.be.com/aboutbe/benewsletter/                          store_32bit_word(cpu, 0x32f8, machine->physical_ram_in_mb * 1048576);
                     Issue27.html#Cookbook  for the details.  */  
                 store_32bit_word(cpu, 0x301c, 0);  
   
                 /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,  
                     r5 = args, r6 = ptr to bootinfo?  */  
                 cpu->cd.ppc.gpr[3] = 0x3100;  
                 cpu->cd.ppc.gpr[4] = 0x200000;  
                 cpu->cd.ppc.gpr[5] = 0x2000;  
                 store_string(cpu, cpu->cd.ppc.gpr[5], "-a");  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x100;  
   
                 /*  See NetBSD's bebox/include/bootinfo.h for details  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,  
                     machine->physical_ram_in_mb * 1048576);  
   
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */  
                 store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,  
                     machine->use_x11? "vga" : "com", 4);  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */  
   
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);  
4230    
4231                            /*  TODO: List of stuff, see http://www.beatjapan.org/
4232                                mirror/www.be.com/aboutbe/benewsletter/
4233                                Issue27.html#Cookbook  for the details.  */
4234                            store_32bit_word(cpu, 0x301c, 0);
4235    
4236                            /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4237                                r5 = args, r6 = ptr to bootinfo?  */
4238                            cpu->cd.ppc.gpr[3] = 0x3100;
4239                            cpu->cd.ppc.gpr[4] = 0x400000;
4240                            cpu->cd.ppc.gpr[5] = 0x2000;
4241                            store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4242                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4243    
4244                            /*  See NetBSD's bebox/include/bootinfo.h for details  */
4245                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */
4246                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4247                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4248                                machine->physical_ram_in_mb * 1048576);
4249    
4250                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */
4251                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4252                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4253                                machine->use_x11? "vga" : "com", 4);
4254                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4255                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4256    
4257                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4258                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */
4259                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4260                    }
4261                  break;                  break;
4262    
4263          case MACHINE_PREP:          case MACHINE_PREP:
# Line 4128  no_arc_prom_emulation:         /*  TODO: ugly, Line 4265  no_arc_prom_emulation:         /*  TODO: ugly,
4265                   *  NetBSD/prep (http://www.netbsd.org/Ports/prep/)                   *  NetBSD/prep (http://www.netbsd.org/Ports/prep/)
4266                   */                   */
4267                  machine->machine_name = "PowerPC Reference Platform";                  machine->machine_name = "PowerPC Reference Platform";
4268                    machine->emulated_hz = 20000000;
4269    
4270                  {                  machine->md_int.bebox_data = device_add(machine, "prep");
4271                          int i;                  machine->isa_pic_data.native_irq = 1;   /*  Semi-bogus  */
4272                          for (i=0; i<32; i++)                  machine->md_interrupt = isa32_interrupt;
4273                                  cpu->cd.ppc.gpr[i] =  
4274                                      0x12340000 + (i << 8) + 0x55;                  pci_data = dev_eagle_init(machine, mem,
4275                  }                      32 /*  isa irq base */, 0 /*  pci irq: TODO */);
4276    
4277                    bus_isa(machine, BUS_ISA_IDE0 | BUS_ISA_IDE1,
4278                        0x80000000, 0xc0000000, 32, 48);
4279    
4280                  /*  Linux on PReP has 0xdeadc0de at address 0? (See                  bus_pci_add(machine, pci_data, mem, 0, 13, 0, "dec21143");
                     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;  
4281    
4282                    if (machine->use_x11)
4283                            bus_pci_add(machine, pci_data, mem, 0, 14, 0, "s3_virge");
4284    
4285                    if (machine->prom_emulation) {
4286                            /*  Linux on PReP has 0xdeadc0de at address 0? (See
4287                                http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */
4288                            store_32bit_word(cpu, 0, 0xdeadc0de);
4289    
4290                            /*  r4 should point to first free byte after the loaded kernel:  */
4291                            cpu->cd.ppc.gpr[4] = 6 * 1048576;
4292    
4293                            /*
4294                             *  r6 should point to bootinfo.
4295                             *  (See NetBSD's prep/include/bootinfo.h for details.)
4296                             */
4297                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x8000;
4298    
4299                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 0, 12);  /*  next  */
4300                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 4, 2);  /*  type: clock  */
4301                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+ 8, machine->emulated_hz);
4302    
4303                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+12, 20);  /*  next  */
4304                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+16, 1);  /*  type: console  */
4305                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4306                                machine->use_x11? "vga" : "com", 4);
4307                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+24, 0x3f8);  /*  addr  */
4308                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+28, 9600);  /*  speed  */
4309    
4310                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+32, 0);  /*  next  */
4311                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+36, 0);  /*  type: residual  */
4312                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+40,    /*  addr of data  */
4313                                cpu->cd.ppc.gpr[6] + 0x100);
4314    
4315                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+0x100, 0x200);  /*  TODO: residual  */
4316                            /*  store_string(cpu, cpu->cd.ppc.gpr[6]+0x100+0x8, "IBM PPS Model 7248 (E)");  */
4317                            store_string(cpu, cpu->cd.ppc.gpr[6]+0x100+0x8, "IBM PPS Model 6050/6070 (E)");
4318    
4319                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6]+0x100+0x1f8, machine->physical_ram_in_mb * 1048576);  /*  memsize  */
4320                    }
4321                  break;                  break;
4322    
4323          case MACHINE_MACPPC:          case MACHINE_MACPPC:
# Line 4153  no_arc_prom_emulation:         /*  TODO: ugly, Line 4327  no_arc_prom_emulation:         /*  TODO: ugly,
4327                   */                   */
4328                  machine->machine_name = "Macintosh (PPC)";                  machine->machine_name = "Macintosh (PPC)";
4329    
4330                  /*  r5 = OpenFirmware entry point  */                  if (machine->prom_emulation) {
4331                  cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;                          uint64_t b = 8 * 1048576, a = b - 0x800;
4332                            int i;
4333                            /*
4334                             *  r3 = pointer to boot_args (for the Mach kernel).
4335                             *  See http://darwinsource.opendarwin.org/10.3/
4336                             *  BootX-59/bootx.tproj/include.subproj/boot_args.h
4337                             *  for more info.
4338                             */
4339                            cpu->cd.ppc.gpr[3] = a;
4340                            store_16bit_word(cpu, a + 0x0000, 1);   /*  revision  */
4341                            store_16bit_word(cpu, a + 0x0002, 2);   /*  version  */
4342                            store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
4343                            /*  26 dram banks; "long base; long size"  */
4344                            store_32bit_word(cpu, a + 0x0104, 0);   /*  base  */
4345                            store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
4346                                * 256);             /*  size (in pages)  */
4347                            for (i=8; i<26*8; i+= 4)
4348                                    store_32bit_word(cpu, a + 0x0104 + i, 0);
4349                            a += (0x104 + 26 * 8);
4350                            /*  Video info:  */
4351                            store_32bit_word(cpu, a+0, 0xd0000000); /*  video base  */
4352                            store_32bit_word(cpu, a+4, 0);          /*  display code (?)  */
4353                            store_32bit_word(cpu, a+8, 800);        /*  bytes per pixel row  */
4354                            store_32bit_word(cpu, a+12, 800);       /*  width  */
4355                            store_32bit_word(cpu, a+16, 600);       /*  height  */
4356                            store_32bit_word(cpu, a+20, 8);         /*  pixel depth  */
4357                            a += 24;
4358                            store_32bit_word(cpu, a+0, 127);        /*  gestalt number (TODO)  */
4359                            store_32bit_word(cpu, a+4, 0);          /*  device tree pointer (TODO)  */
4360                            store_32bit_word(cpu, a+8, 0);          /*  device tree length  */
4361                            store_32bit_word(cpu, a+12, b);         /*  last address of kernel data area  */
4362    
4363                            /*  r4 = "MOSX" (0x4D4F5358)  */
4364                            cpu->cd.ppc.gpr[4] = 0x4D4F5358;
4365    
4366                            /*
4367                             *  r5 = OpenFirmware entry point.  NOTE: See
4368                             *  cpu_ppc.c for the rest of this semi-ugly hack.
4369                             */
4370                            dev_ram_init(machine, cpu->cd.ppc.of_emul_addr,
4371                                0x1000, DEV_RAM_RAM, 0x0);
4372                            store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
4373                                0x44ee0002);
4374                            cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4375                    }
4376                  break;                  break;
4377    
4378          case MACHINE_DB64360:          case MACHINE_DB64360:
4379                  /*  For playing with PMON2000 for PPC:  */                  /*  For playing with PMON2000 for PPC:  */
4380                  machine->machine_name = "DB64360";                  machine->machine_name = "DB64360";
4381    
4382                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0x1d000020");                  machine->main_console_handle = (size_t)device_add(machine,
4383                        "ns16550 irq=0 addr=0x1d000020 addr_mult=4");
4384    
4385                  {                  if (machine->prom_emulation) {
4386                          int i;                          int i;
4387                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
4388                                  cpu->cd.ppc.gpr[i] =                                  cpu->cd.ppc.gpr[i] =
# Line 4174  no_arc_prom_emulation:         /*  TODO: ugly, Line 4392  no_arc_prom_emulation:         /*  TODO: ugly,
4392                  break;                  break;
4393  #endif  /*  ENABLE_PPC  */  #endif  /*  ENABLE_PPC  */
4394    
4395    #ifdef ENABLE_SH
4396            case MACHINE_BARESH:
4397                    /*  A bare SH machine, with no devices.  */
4398                    machine->machine_name = "\"Bare\" SH machine";
4399                    break;
4400    
4401            case MACHINE_TESTSH:
4402                    machine->machine_name = "SH test machine";
4403    
4404                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4405                        (long long)DEV_CONS_ADDRESS);
4406                    cons_data = device_add(machine, tmpstr);
4407                    machine->main_console_handle = cons_data->console_handle;
4408    
4409                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4410                        (long long)DEV_MP_ADDRESS);
4411                    device_add(machine, tmpstr);
4412    
4413                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4414                        640,480, 640,480, 24, "testsh generic");
4415    
4416                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4417                        (long long)DEV_DISK_ADDRESS);
4418                    device_add(machine, tmpstr);
4419    
4420                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4421                        (long long)DEV_ETHER_ADDRESS);
4422                    device_add(machine, tmpstr);
4423    
4424                    break;
4425    
4426            case MACHINE_HPCSH:
4427                    /*  Handheld SH-based machines:  */
4428                    machine->machine_name = "HPCsh";
4429    
4430                    /*  TODO  */
4431    
4432                    break;
4433    #endif  /*  ENABLE_SH  */
4434    
4435    #ifdef ENABLE_HPPA
4436            case MACHINE_BAREHPPA:
4437                    /*  A bare HPPA machine, with no devices.  */
4438                    machine->machine_name = "\"Bare\" HPPA machine";
4439                    break;
4440    
4441            case MACHINE_TESTHPPA:
4442                    machine->machine_name = "HPPA test machine";
4443    
4444                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4445                        (long long)DEV_CONS_ADDRESS);
4446                    cons_data = device_add(machine, tmpstr);
4447                    machine->main_console_handle = cons_data->console_handle;
4448    
4449                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4450                        (long long)DEV_MP_ADDRESS);
4451                    device_add(machine, tmpstr);
4452    
4453                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4454                        640,480, 640,480, 24, "testhppa generic");
4455    
4456                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4457                        (long long)DEV_DISK_ADDRESS);
4458                    device_add(machine, tmpstr);
4459    
4460                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4461                        (long long)DEV_ETHER_ADDRESS);
4462                    device_add(machine, tmpstr);
4463    
4464                    break;
4465    #endif  /*  ENABLE_HPPA  */
4466    
4467    #ifdef ENABLE_I960
4468            case MACHINE_BAREI960:
4469                    /*  A bare I960 machine, with no devices.  */
4470                    machine->machine_name = "\"Bare\" i960 machine";
4471                    break;
4472    
4473            case MACHINE_TESTI960:
4474                    machine->machine_name = "i960 test machine";
4475    
4476                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4477                        (long long)DEV_CONS_ADDRESS);
4478                    cons_data = device_add(machine, tmpstr);
4479                    machine->main_console_handle = cons_data->console_handle;
4480    
4481                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4482                        (long long)DEV_MP_ADDRESS);
4483                    device_add(machine, tmpstr);
4484    
4485                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4486                        640,480, 640,480, 24, "testi960 generic");
4487    
4488                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4489                        (long long)DEV_DISK_ADDRESS);
4490                    device_add(machine, tmpstr);
4491    
4492                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4493                        (long long)DEV_ETHER_ADDRESS);
4494                    device_add(machine, tmpstr);
4495    
4496                    break;
4497    #endif  /*  ENABLE_I960  */
4498    
4499  #ifdef ENABLE_SPARC  #ifdef ENABLE_SPARC
4500          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
4501                  /*  A bare SPARC machine, with no devices.  */                  /*  A bare SPARC machine, with no devices.  */
# Line 4245  no_arc_prom_emulation:         /*  TODO: ugly, Line 4567  no_arc_prom_emulation:         /*  TODO: ugly,
4567                  break;                  break;
4568    
4569          case MACHINE_ALPHA:          case MACHINE_ALPHA:
                 /*  TODO:  Most of these... They are used by NetBSD/alpha:  */  
                 /*  a0 = First free Page Frame Number  */  
                 /*  a1 = PFN of current Level 1 page table  */  
                 /*  a2 = Bootinfo magic  */  
                 /*  a3 = Bootinfo pointer  */  
                 /*  a4 = Bootinfo version  */  
                 cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;  
                 cpu->cd.alpha.r[ALPHA_A1] = 0;  
                 cpu->cd.alpha.r[ALPHA_A2] = 0;  
                 cpu->cd.alpha.r[ALPHA_A3] = 0;  
                 cpu->cd.alpha.r[ALPHA_A4] = 0;  
   
4570                  if (machine->prom_emulation) {                  if (machine->prom_emulation) {
4571                          struct rpb rpb;                          struct rpb rpb;
4572                          struct crb crb;                          struct crb crb;
4573                          struct ctb ctb;                          struct ctb ctb;
4574    
4575                            /*  TODO:  Most of these... They are used by NetBSD/alpha:  */
4576                            /*  a0 = First free Page Frame Number  */
4577                            /*  a1 = PFN of current Level 1 page table  */
4578                            /*  a2 = Bootinfo magic  */
4579                            /*  a3 = Bootinfo pointer  */
4580                            /*  a4 = Bootinfo version  */
4581                            cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
4582                            cpu->cd.alpha.r[ALPHA_A1] = 0;
4583                            cpu->cd.alpha.r[ALPHA_A2] = 0;
4584                            cpu->cd.alpha.r[ALPHA_A3] = 0;
4585                            cpu->cd.alpha.r[ALPHA_A4] = 0;
4586    
4587                          /*  HWRPB: Hardware Restart Parameter Block  */                          /*  HWRPB: Hardware Restart Parameter Block  */
4588                          memset(&rpb, 0, sizeof(struct rpb));                          memset(&rpb, 0, sizeof(struct rpb));
4589                          store_64bit_word_in_host(cpu, (unsigned char *)                          store_64bit_word_in_host(cpu, (unsigned char *)
# Line 4306  no_arc_prom_emulation:         /*  TODO: ugly, Line 4628  no_arc_prom_emulation:         /*  TODO: ugly,
4628                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
4629                  case ST_DEC_3000_300:                  case ST_DEC_3000_300:
4630                          machine->machine_name = "DEC 3000/300";                          machine->machine_name = "DEC 3000/300";
4631                            machine->main_console_handle =
4632                                dev_zs_init(machine, mem, 0x1b0200000ULL,
4633                                0, 4, "serial zs"); /*  serial? netbsd?  */
4634                            break;
4635                    case ST_EB164:
4636                            machine->machine_name = "EB164";
4637                          break;                          break;
4638                  default:fatal("Unimplemented Alpha machine type %i\n",                  default:fatal("Unimplemented Alpha machine type %i\n",
4639                              machine->machine_subtype);                              machine->machine_subtype);
# Line 4353  no_arc_prom_emulation:         /*  TODO: ugly, Line 4681  no_arc_prom_emulation:         /*  TODO: ugly,
4681                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,                  store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4682                      0xeafffffe);                      0xeafffffe);
4683                  break;                  break;
4684    
4685            case MACHINE_CATS:
4686                    machine->machine_name = "CATS evaluation board";
4687    
4688                    if (machine->emulated_hz == 0)
4689                            machine->emulated_hz = 50000000;
4690    
4691                    if (machine->physical_ram_in_mb > 256)
4692                            fprintf(stderr, "WARNING! Real CATS machines cannot"
4693                                " have more than 256 MB RAM. Continuing anyway.\n");
4694    
4695                    machine->md_int.footbridge_data =
4696                        device_add(machine, "footbridge addr=0x42000000");
4697                    machine->md_interrupt = isa32_interrupt;
4698                    machine->isa_pic_data.native_irq = 10;
4699    
4700                    /*
4701                     *  DC21285_ROM_BASE (0x41000000): "reboot" code. Works
4702                     *  with NetBSD.
4703                     */
4704                    dev_ram_init(machine, 0x41000000, 12, DEV_RAM_RAM, 0);
4705                    store_32bit_word(cpu, 0x41000008ULL, 0xef8c64ebUL);
4706    
4707                    /*  OpenBSD reboot needs 0xf??????? to be mapped to phys.:  */
4708                    dev_ram_init(machine, 0xf0000000, 0x1000000,
4709                        DEV_RAM_MIRROR, 0x0);
4710    
4711                    /*  NetBSD and OpenBSD clean their caches here:  */
4712                    dev_ram_init(machine, 0x50000000, 0x4000, DEV_RAM_RAM, 0);
4713    
4714                    /*  Interrupt ack space?  */
4715                    dev_ram_init(machine, 0x80000000, 0x1000, DEV_RAM_RAM, 0);
4716    
4717                    bus_isa(machine, BUS_ISA_PCKBC_FORCE_USE | BUS_ISA_PCKBC_NONPCSTYLE,
4718                        0x7c000000, 0x80000000, 32, 48);
4719    
4720                    bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4721                        mem, 0xc0, 8, 0, "s3_virge");
4722    
4723                    if (machine->prom_emulation) {
4724                            struct ebsaboot ebsaboot;
4725                            char bs[300];
4726                            int boot_id = bootdev_id >= 0? bootdev_id : 0;
4727    
4728                            cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
4729                                7 * 1048576 - 0x1000;
4730    
4731                            memset(&ebsaboot, 0, sizeof(struct ebsaboot));
4732                            store_32bit_word_in_host(cpu, (unsigned char *)
4733                                &(ebsaboot.bt_magic), BT_MAGIC_NUMBER_CATS);
4734                            store_32bit_word_in_host(cpu, (unsigned char *)
4735                                &(ebsaboot.bt_vargp), 0);
4736                            store_32bit_word_in_host(cpu, (unsigned char *)
4737                                &(ebsaboot.bt_pargp), 0);
4738                            store_32bit_word_in_host(cpu, (unsigned char *)
4739                                &(ebsaboot.bt_args), cpu->cd.arm.r[0]
4740                                + sizeof(struct ebsaboot));
4741                            store_32bit_word_in_host(cpu, (unsigned char *)
4742                                &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
4743                            store_32bit_word_in_host(cpu, (unsigned char *)
4744                                &(ebsaboot.bt_memstart), 0);
4745                            store_32bit_word_in_host(cpu, (unsigned char *)
4746                                &(ebsaboot.bt_memend),
4747                                machine->physical_ram_in_mb * 1048576);
4748                            store_32bit_word_in_host(cpu, (unsigned char *)
4749                                &(ebsaboot.bt_memavail), 7 * 1048576);
4750                            store_32bit_word_in_host(cpu, (unsigned char *)
4751                                &(ebsaboot.bt_fclk), 50 * 1000000);
4752                            store_32bit_word_in_host(cpu, (unsigned char *)
4753                                &(ebsaboot.bt_pciclk), 66 * 1000000);
4754                            /*  TODO: bt_vers  */
4755                            /*  TODO: bt_features  */
4756    
4757                            store_buf(cpu, cpu->cd.arm.r[0],
4758                                (char *)&ebsaboot, sizeof(struct ebsaboot));
4759    
4760                            snprintf(bs, sizeof(bs), "(hd%i)%s root=/dev/wd%i%s%s",
4761                                boot_id, machine->boot_kernel_filename, boot_id,
4762                                (machine->boot_string_argument[0])? " " : "",
4763                                machine->boot_string_argument);
4764    
4765                            store_string(cpu, cpu->cd.arm.r[0] +
4766                                sizeof(struct ebsaboot), bs);
4767    
4768                            arm_setup_initial_translation_table(cpu,
4769                                7 * 1048576 - 32768);
4770                    }
4771                    break;
4772    
4773            case MACHINE_HPCARM:
4774                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
4775                    memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));
4776                    switch (machine->machine_subtype) {
4777                    case MACHINE_HPCARM_IPAQ:
4778                            /*  SA-1110 206MHz  */
4779                            machine->machine_name = "Compaq iPAQ H3600";
4780                            hpc_fb_addr = 0x48200000;       /*  TODO  */
4781                            hpc_fb_xsize = 240;
4782                            hpc_fb_ysize = 320;
4783                            hpc_fb_xsize_mem = 256;
4784                            hpc_fb_ysize_mem = 320;
4785                            hpc_fb_bits = 15;
4786                            hpc_fb_encoding = BIFB_D16_0000;
4787                            hpc_platid_cpu_arch = 3;        /*  ARM  */
4788                            hpc_platid_cpu_series = 1;      /*  StrongARM  */
4789                            hpc_platid_cpu_model = 2;       /*  SA-1110  */
4790                            hpc_platid_cpu_submodel = 0;
4791                            hpc_platid_vendor = 7;          /*  Compaq  */
4792                            hpc_platid_series = 4;          /*  IPAQ  */
4793                            hpc_platid_model = 2;           /*  H36xx  */
4794                            hpc_platid_submodel = 1;        /*  H3600  */
4795                            break;
4796                    case MACHINE_HPCARM_JORNADA720:
4797                            /*  SA-1110 206MHz  */
4798                            machine->machine_name = "Jornada 720";
4799                            hpc_fb_addr = 0x48200000;
4800                            hpc_fb_xsize = 640;
4801                            hpc_fb_ysize = 240;
4802                            hpc_fb_xsize_mem = 640;
4803                            hpc_fb_ysize_mem = 240;
4804                            hpc_fb_bits = 16;
4805                            hpc_fb_encoding = BIFB_D16_0000;
4806                            hpc_platid_cpu_arch = 3;        /*  ARM  */
4807                            hpc_platid_cpu_series = 1;      /*  StrongARM  */
4808                            hpc_platid_cpu_model = 2;       /*  SA-1110  */
4809                            hpc_platid_cpu_submodel = 0;
4810                            hpc_platid_vendor = 11;         /*  HP  */
4811                            hpc_platid_series = 2;          /*  Jornada  */
4812                            hpc_platid_model = 2;           /*  7xx  */
4813                            hpc_platid_submodel = 1;        /*  720  */
4814                            break;
4815                    default:
4816                            printf("Unimplemented hpcarm machine number.\n");
4817                            exit(1);
4818                    }
4819    
4820                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
4821                          (hpc_platid_cpu_arch << 26) + (hpc_platid_cpu_series << 20)
4822                        + (hpc_platid_cpu_model << 14) + (hpc_platid_cpu_submodel <<  8)
4823                        + hpc_platid_flags);
4824                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
4825                          (hpc_platid_vendor << 22) + (hpc_platid_series << 16)
4826                        + (hpc_platid_model <<  8) + hpc_platid_submodel);
4827    
4828                    if (machine->prom_emulation) {
4829                            /*  NetBSD/hpcarm and possibly others expects the following:  */
4830    
4831                            cpu->cd.arm.r[0] = 1;   /*  argc  */
4832                            cpu->cd.arm.r[1] = machine->physical_ram_in_mb * 1048576 - 512; /*  argv  */
4833                            cpu->cd.arm.r[2] = machine->physical_ram_in_mb * 1048576 - 256; /*  ptr to hpc_bootinfo  */
4834    
4835                            bootstr = machine->boot_kernel_filename;
4836                            store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512,
4837                                machine->physical_ram_in_mb * 1048576 - 512 + 16);
4838                            store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
4839                            store_string(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
4840    
4841                            if (machine->boot_string_argument[0]) {
4842                                    cpu->cd.arm.r[0] ++;    /*  argc  */
4843    
4844                                    store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 4, machine->physical_ram_in_mb * 1048576 - 512 + 64);
4845                                    store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
4846    
4847                                    store_string(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 64,
4848                                        machine->boot_string_argument);
4849    
4850                                    bootarg = machine->boot_string_argument;
4851                            }
4852    
4853                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
4854                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
4855                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, hpc_fb_addr);
4856                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpc_fb_xsize_mem * (((hpc_fb_bits-1)|7)+1) / 8);
4857                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpc_fb_xsize);
4858                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpc_fb_ysize);
4859                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpc_fb_encoding);
4860                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse,
4861                                machine->use_x11? BI_CNUSE_BUILTIN : BI_CNUSE_SERIAL);
4862    
4863                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
4864                            store_buf(cpu, machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
4865    
4866                            /*
4867                             *  TODO: ugly hack, only works with small NetBSD
4868                             *        kernels!
4869                             */
4870                            cpu->cd.arm.r[ARM_SP] = 0xc02c0000;
4871                    }
4872    
4873                    /*  Physical RAM at 0xc0000000:  */
4874                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4875                        DEV_RAM_MIRROR, 0x0);
4876    
4877                    /*  Cache flush region:  */
4878                    dev_ram_init(machine, 0xe0000000, 0x10000, DEV_RAM_RAM, 0x0);
4879    
4880                    if (hpc_fb_addr != 0) {
4881                            dev_fb_init(machine, mem, hpc_fb_addr, VFB_HPC,
4882                                hpc_fb_xsize, hpc_fb_ysize,
4883                                hpc_fb_xsize_mem, hpc_fb_ysize_mem,
4884                                hpc_fb_bits, machine->machine_name);
4885                    }
4886                    break;
4887    
4888            case MACHINE_ZAURUS:
4889                    machine->machine_name = "Zaurus";
4890                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4891                        DEV_RAM_MIRROR, 0x0);
4892                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4893                        DEV_RAM_MIRROR, 0x0);
4894    
4895                    /*  TODO: replace this with the correct device  */
4896                    dev_ram_init(machine, 0x40d00000, 0x1000, DEV_RAM_RAM, 0);
4897    
4898                    device_add(machine, "ns16550 irq=0 addr=0x40100000 addr_mult=4");
4899                    device_add(machine, "ns16550 irq=0 addr=0xfd400000 addr_mult=4");
4900    
4901                    /*  TODO  */
4902                    if (machine->prom_emulation) {
4903                            arm_setup_initial_translation_table(cpu, 0x4000);
4904                    }
4905                    break;
4906    
4907            case MACHINE_NETWINDER:
4908                    machine->machine_name = "NetWinder";
4909    
4910                    if (machine->physical_ram_in_mb > 256)
4911                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4912                                " have more than 256 MB RAM. Continuing anyway.\n");
4913    
4914                    machine->md_int.footbridge_data =
4915                        device_add(machine, "footbridge addr=0x42000000");
4916                    machine->md_interrupt = isa32_interrupt;
4917                    machine->isa_pic_data.native_irq = 11;
4918    
4919                    bus_isa(machine, 0, 0x7c000000, 0x80000000, 32, 48);
4920    #if 0
4921                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4922                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4923                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4924                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4925    
4926                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4927                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4928    
4929                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4930                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4931                                32 + 1, 32 + 12, machine->use_x11, 0);
4932                            machine->main_console_handle = j;
4933    #endif
4934                    if (machine->use_x11) {
4935                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4936                                mem, 0xc0, 8, 0, "igsfb");
4937                    }
4938    
4939                    if (machine->prom_emulation) {
4940                            arm_setup_initial_translation_table(cpu, 0x4000);
4941                    }
4942                    break;
4943    
4944            case MACHINE_SHARK:
4945                    machine->machine_name = "Digital DNARD (\"Shark\")";
4946                    if (machine->prom_emulation) {
4947                            arm_setup_initial_translation_table(cpu,
4948                                machine->physical_ram_in_mb * 1048576 - 65536);
4949    
4950                            /*
4951                             *  r0 = OpenFirmware entry point.  NOTE: See
4952                             *  cpu_arm.c for the rest of this semi-ugly hack.
4953                             */
4954                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4955                    }
4956                    break;
4957    
4958            case MACHINE_IQ80321:
4959                    /*
4960                     *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4961                     *  for more details about the memory map.
4962                     */
4963                    machine->machine_name = "Intel IQ80321 (ARM)";
4964                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4965                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4966                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4967    
4968                    /*  Used by "Redboot":  */
4969                    dev_ram_init(machine, 0xa800024, 4, DEV_RAM_RAM, 0);
4970                    store_32bit_word(cpu, 0xa800024, 0x7fff);
4971                    device_add(machine, "ns16550 irq=0 addr=0x0d800000 addr_mult=4");
4972                    device_add(machine, "ns16550 irq=0 addr=0x0d800020 addr_mult=4");
4973    
4974                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
4975                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4976                        DEV_RAM_MIRROR, 0x0);
4977                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4978                        DEV_RAM_MIRROR, 0x0);
4979    
4980                    /*  0xe0000000 and 0xff000000 = cache flush regions  */
4981                    dev_ram_init(machine, 0xe0000000, 0x100000, DEV_RAM_RAM, 0x0);
4982                    dev_ram_init(machine, 0xff000000, 0x100000, DEV_RAM_RAM, 0x0);
4983    
4984                    device_add(machine, "i80321 addr=0xffffe000");
4985    
4986                    if (machine->prom_emulation) {
4987                            arm_setup_initial_translation_table(cpu, 0x4000);
4988                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
4989                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
4990                            arm_translation_table_set_l1(cpu, 0xe0000000, 0xe0000000);
4991                            arm_translation_table_set_l1(cpu, 0xf0000000, 0xf0000000);
4992                    }
4993                    break;
4994    
4995            case MACHINE_IYONIX:
4996                    machine->machine_name = "Iyonix";
4997                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4998                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4999    
5000                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
5001                    device_add(machine, "ns16550 irq=0 addr=0x900003f8");
5002                    device_add(machine, "ns16550 irq=0 addr=0x900002f8");
5003    
5004                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
5005                    dev_ram_init(machine, 0xa0000000, 0x20000000,
5006                        DEV_RAM_MIRROR, 0x0);
5007                    dev_ram_init(machine, 0xc0000000, 0x20000000,
5008                        DEV_RAM_MIRROR, 0x0);
5009                    dev_ram_init(machine, 0xf0000000, 0x08000000,
5010                        DEV_RAM_MIRROR, 0x0);
5011    
5012                    device_add(machine, "i80321 addr=0xffffe000");
5013    
5014                    if (machine->prom_emulation) {
5015                            arm_setup_initial_translation_table(cpu,
5016                                machine->physical_ram_in_mb * 1048576 - 65536);
5017                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
5018                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
5019                            arm_translation_table_set_l1_b(cpu, 0xff000000, 0xff000000);
5020                    }
5021                    break;
5022  #endif  /*  ENABLE_ARM  */  #endif  /*  ENABLE_ARM  */
5023    
5024    #ifdef ENABLE_AVR
5025            case MACHINE_BAREAVR:
5026                    /*  A bare Atmel AVR machine, with no devices.  */
5027                    machine->machine_name = "\"Bare\" Atmel AVR machine";
5028                    break;
5029    #endif  /*  ENABLE_AVR  */
5030    
5031  #ifdef ENABLE_IA64  #ifdef ENABLE_IA64
5032          case MACHINE_BAREIA64:          case MACHINE_BAREIA64:
5033                  machine->machine_name = "\"Bare\" IA64 machine";                  machine->machine_name = "\"Bare\" IA64 machine";
# Line 4428  no_arc_prom_emulation:         /*  TODO: ugly, Line 5101  no_arc_prom_emulation:         /*  TODO: ugly,
5101                  else                  else
5102                          machine->machine_name = "Generic x86 PC";                          machine->machine_name = "Generic x86 PC";
5103    
                 /*  Interrupt controllers:  */  
                 snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",  
                     (long long)(X86_IO_BASE + 0x20));  
                 machine->md.pc.pic1 = device_add(machine, tmpstr);  
                 if (machine->machine_subtype != MACHINE_X86_XT) {  
                         snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",  
                             (long long)(X86_IO_BASE + 0xa0));  
                         machine->md.pc.pic2 = device_add(machine, tmpstr);  
                 }  
   
5104                  machine->md_interrupt = x86_pc_interrupt;                  machine->md_interrupt = x86_pc_interrupt;
5105    
5106                  /*  Timer:  */                  bus_isa(machine, BUS_ISA_IDE0 | BUS_ISA_IDE1 | BUS_ISA_VGA |
5107                  snprintf(tmpstr, sizeof(tmpstr), "8253 addr=0x%llx irq=0",                      BUS_ISA_PCKBC_FORCE_USE |
5108                      (long long)(X86_IO_BASE + 0x40));                      (machine->machine_subtype == MACHINE_X86_XT?
5109                  device_add(machine, tmpstr);                      BUS_ISA_NO_SECOND_PIC : 0) | BUS_ISA_FDC,
5110                        X86_IO_BASE, 0x00000000, 0, 16);
                 snprintf(tmpstr, sizeof(tmpstr), "pccmos addr=0x%llx",  
                     (long long)(X86_IO_BASE + 0x70));  
                 device_add(machine, tmpstr);  
   
                 /*  TODO: IRQ when emulating a PC XT?  */  
   
                 /*  IDE controllers:  */  
                 if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||  
                     diskimage_exist(machine, 1, DISKIMAGE_IDE))  
                         dev_wdc_init(machine, mem, X86_IO_BASE + 0x1f0, 14, 0);  
                 if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||  
                     diskimage_exist(machine, 3, DISKIMAGE_IDE))  
                         dev_wdc_init(machine, mem, X86_IO_BASE + 0x170, 15, 2);  
   
                 /*  Floppy controller at irq 6  */  
                 snprintf(tmpstr, sizeof(tmpstr), "fdc addr=0x%llx irq=6",  
                     (long long)(X86_IO_BASE + 0x3f0));  
                 device_add(machine, tmpstr);  
   
                 /*  TODO: sound blaster (eventually) at irq 7?  */  
   
                 /*  TODO: parallel port  */  
   
                 /*  Serial ports:  (TODO: 8250 for PC XT?)  */  
   
                 snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%llx name2=com1 in_use=0",  
                     (long long)X86_IO_BASE + 0x3f8);  
                 device_add(machine, tmpstr);  
                 snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x%llx name2=com2 in_use=0",  
                     (long long)X86_IO_BASE + 0x2f8);  
                 device_add(machine, tmpstr);  
   
                 /*  VGA + keyboard:  */  
                 dev_vga_init(machine, mem, 0xa0000ULL, X86_IO_BASE + 0x3c0,  
                     "Generic x86 PC");  
                 machine->main_console_handle = dev_pckbc_init(machine,  
                     mem, X86_IO_BASE + 0x60, PCKBC_8042, 1, 12, 1, 1);  
5111    
5112                  if (machine->prom_emulation)                  if (machine->prom_emulation)
5113                          pc_bios_init(cpu);                          pc_bios_init(cpu);
# Line 4508  no_arc_prom_emulation:         /*  TODO: ugly, Line 5134  no_arc_prom_emulation:         /*  TODO: ugly,
5134                  debug(" (%.2f MHz)", (float)machine->emulated_hz / 1000000);                  debug(" (%.2f MHz)", (float)machine->emulated_hz / 1000000);
5135          debug("\n");          debug("\n");
5136    
5137            /*  Default fake speed: 5 MHz  */
5138          if (machine->emulated_hz < 1)          if (machine->emulated_hz < 1)
5139                  machine->emulated_hz = 1000000;                  machine->emulated_hz = 5000000;
5140    
5141          if (bootstr != NULL) {          if (bootstr != NULL) {
5142                  debug("bootstring%s: %s", (bootarg!=NULL &&                  debug("bootstring%s: %s", (bootarg!=NULL &&
# Line 4597  void machine_memsize_fix(struct machine Line 5224  void machine_memsize_fix(struct machine
5224                          }                          }
5225                          break;                          break;
5226                  case MACHINE_ALPHA:                  case MACHINE_ALPHA:
                         m->physical_ram_in_mb = 64;  
                         break;  
5227                  case MACHINE_BEBOX:                  case MACHINE_BEBOX:
5228                    case MACHINE_PREP:
5229                    case MACHINE_CATS:
5230                    case MACHINE_ZAURUS:
5231                          m->physical_ram_in_mb = 64;                          m->physical_ram_in_mb = 64;
5232                          break;                          break;
5233                    case MACHINE_HPCARM:
5234                            m->physical_ram_in_mb = 32;
5235                            break;
5236                    case MACHINE_NETWINDER:
5237                            m->physical_ram_in_mb = 16;
5238                            break;
5239                  case MACHINE_X86:                  case MACHINE_X86:
5240                          if (m->machine_subtype == MACHINE_X86_XT)                          if (m->machine_subtype == MACHINE_X86_XT)
5241                                  m->physical_ram_in_mb = 1;                                  m->physical_ram_in_mb = 1;
# Line 4753  void machine_default_cputype(struct mach Line 5387  void machine_default_cputype(struct mach
5387          case MACHINE_PSP:          case MACHINE_PSP:
5388                  m->cpu_name = strdup("Allegrex");                  m->cpu_name = strdup("Allegrex");
5389                  break;                  break;
5390            case MACHINE_ALGOR:
5391                    m->cpu_name = strdup("RM5200");
5392                    break;
5393    
5394          /*  PowerPC:  */          /*  PowerPC:  */
5395          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
# Line 4781  void machine_default_cputype(struct mach Line 5418  void machine_default_cputype(struct mach
5418                  m->cpu_name = strdup("PPC603e");                  m->cpu_name = strdup("PPC603e");
5419                  break;                  break;
5420          case MACHINE_PREP:          case MACHINE_PREP:
5421                  /*  For NetBSD/prep. TODO  */                  /*  For NetBSD/prep. TODO: Differs between models!  */
5422                  m->cpu_name = strdup("PPC603e");                  m->cpu_name = strdup("PPC604");
5423                  break;                  break;
5424          case MACHINE_MACPPC:          case MACHINE_MACPPC:
5425                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5426                  case MACHINE_MACPPC_G4:                  case MACHINE_MACPPC_G4:
5427                          m->cpu_name = strdup("G4e");                          m->cpu_name = strdup("PPC750");
5428                          break;                          break;
5429                  case MACHINE_MACPPC_G5:                  case MACHINE_MACPPC_G5:
5430                          m->cpu_name = strdup("PPC970");                          m->cpu_name = strdup("PPC970");
# Line 4798  void machine_default_cputype(struct mach Line 5435  void machine_default_cputype(struct mach
5435                  m->cpu_name = strdup("PPC750");                  m->cpu_name = strdup("PPC750");
5436                  break;                  break;
5437    
5438            /*  SH:  */
5439            case MACHINE_BARESH:
5440            case MACHINE_TESTSH:
5441            case MACHINE_HPCSH:
5442                    m->cpu_name = strdup("SH");
5443                    break;
5444    
5445            /*  HPPA:  */
5446            case MACHINE_BAREHPPA:
5447            case MACHINE_TESTHPPA:
5448                    m->cpu_name = strdup("HPPA");
5449                    break;
5450    
5451            /*  i960:  */
5452            case MACHINE_BAREI960:
5453            case MACHINE_TESTI960:
5454                    m->cpu_name = strdup("i960");
5455                    break;
5456    
5457          /*  SPARC:  */          /*  SPARC:  */
5458          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
5459          case MACHINE_TESTSPARC:          case MACHINE_TESTSPARC:
# Line 4815  void machine_default_cputype(struct mach Line 5471  void machine_default_cputype(struct mach
5471          /*  ARM:  */          /*  ARM:  */
5472          case MACHINE_BAREARM:          case MACHINE_BAREARM:
5473          case MACHINE_TESTARM:          case MACHINE_TESTARM:
5474                  m->cpu_name = strdup("ARM");          case MACHINE_HPCARM:
5475                    m->cpu_name = strdup("SA1110");
5476                    break;
5477            case MACHINE_IQ80321:
5478            case MACHINE_IYONIX:
5479                    m->cpu_name = strdup("80321_600_B0");
5480                    break;
5481            case MACHINE_CATS:
5482            case MACHINE_NETWINDER:
5483            case MACHINE_SHARK:
5484                    m->cpu_name = strdup("SA110");
5485                    break;
5486            case MACHINE_ZAURUS:
5487                    m->cpu_name = strdup("PXA210");
5488                    break;
5489    
5490            /*  AVR:  */
5491            case MACHINE_BAREAVR:
5492                    m->cpu_name = strdup("AVR");
5493                  break;                  break;
5494    
5495          /*  IA64:  */          /*  IA64:  */
# Line 4908  void machine_dumpinfo(struct machine *m) Line 5582  void machine_dumpinfo(struct machine *m)
5582                  debug("Using X11");                  debug("Using X11");
5583                  if (m->x11_scaledown > 1)                  if (m->x11_scaledown > 1)
5584                          debug(", scaledown %i", m->x11_scaledown);                          debug(", scaledown %i", m->x11_scaledown);
5585                    if (m->x11_scaleup > 1)
5586                            debug(", scaleup %i", m->x11_scaleup);
5587                  if (m->x11_n_display_names > 0) {                  if (m->x11_n_display_names > 0) {
5588                          for (i=0; i<m->x11_n_display_names; i++) {                          for (i=0; i<m->x11_n_display_names; i++) {
5589                                  debug(i? ", " : " (");                                  debug(i? ", " : " (");
# Line 5063  void machine_list_available_types_and_cp Line 5739  void machine_list_available_types_and_cp
5739          debug_indentation(-iadd);          debug_indentation(-iadd);
5740    
5741          debug("\nMost of the machine types are bogus too. Please read the "          debug("\nMost of the machine types are bogus too. Please read the "
5742              "GXemul\ndocumentation for information about which machine"              "GXemul documentation\nfor information about which machine types "
5743              " types that actually\nwork. Use the alias when selecting a "                "that actually work. Use the alias\nwhen selecting a machine type "
5744              "machine type or subtype, not the\nreal name.\n");              "or subtype, not the real name.\n");
5745    
5746          debug("\n");          debug("\n");
5747    
# Line 5090  void machine_init(void) Line 5766  void machine_init(void)
5766           *  entries will appear in normal order when listed.  :-)           *  entries will appear in normal order when listed.  :-)
5767           */           */
5768    
5769            /*  Zaurus:  */
5770            me = machine_entry_new("Zaurus (ARM)",
5771                ARCH_ARM, MACHINE_ZAURUS, 1, 0);
5772            me->aliases[0] = "zaurus";
5773            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5774                    me->next = first_machine_entry; first_machine_entry = me;
5775            }
5776    
5777          /*  X86 machine:  */          /*  X86 machine:  */
5778          me = machine_entry_new("x86-based PC", ARCH_X86,          me = machine_entry_new("x86-based PC", ARCH_X86,
5779              MACHINE_X86, 2, 2);              MACHINE_X86, 2, 2);
5780          me->aliases[0] = "pc";          me->aliases[0] = "pc";
5781          me->aliases[1] = "x86";          me->aliases[1] = "x86";
5782          me->subtype[0] = machine_entry_subtype_new("Generic PC",          me->subtype[0] = machine_entry_subtype_new("Generic PC",
5783              MACHINE_X86_GENERIC, 1);              MACHINE_X86_GENERIC, 2);
5784          me->subtype[0]->aliases[0] = "generic";          me->subtype[0]->aliases[0] = "pc";
5785            me->subtype[0]->aliases[1] = "generic";
5786          me->subtype[1] = machine_entry_subtype_new("PC XT", MACHINE_X86_XT, 1);          me->subtype[1] = machine_entry_subtype_new("PC XT", MACHINE_X86_XT, 1);
5787          me->subtype[1]->aliases[0] = "xt";          me->subtype[1]->aliases[0] = "xt";
5788          if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {          if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {
# Line 5121  void machine_init(void) Line 5806  void machine_init(void)
5806                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5807          }          }
5808    
5809            /*  Test-machine for SH:  */
5810            me = machine_entry_new("Test-machine for SH", ARCH_SH,
5811                MACHINE_TESTSH, 1, 0);
5812            me->aliases[0] = "testsh";
5813            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5814                    me->next = first_machine_entry; first_machine_entry = me;
5815            }
5816    
5817          /*  Test-machine for PPC:  */          /*  Test-machine for PPC:  */
5818          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,          me = machine_entry_new("Test-machine for PPC", ARCH_PPC,
5819              MACHINE_TESTPPC, 1, 0);              MACHINE_TESTPPC, 1, 0);
# Line 5153  void machine_init(void) Line 5846  void machine_init(void)
5846                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5847          }          }
5848    
5849            /*  Test-machine for i960:  */
5850            me = machine_entry_new("Test-machine for i960", ARCH_I960,
5851                MACHINE_TESTI960, 1, 0);
5852            me->aliases[0] = "testi960";
5853            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5854                    me->next = first_machine_entry; first_machine_entry = me;
5855            }
5856    
5857            /*  Test-machine for HPPA:  */
5858            me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5859                MACHINE_TESTHPPA, 1, 0);
5860            me->aliases[0] = "testhppa";
5861            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
5862                    me->next = first_machine_entry; first_machine_entry = me;
5863            }
5864    
5865          /*  Test-machine for ARM:  */          /*  Test-machine for ARM:  */
5866          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,          me = machine_entry_new("Test-machine for ARM", ARCH_ARM,
5867              MACHINE_TESTARM, 1, 0);              MACHINE_TESTARM, 1, 0);
# Line 5243  void machine_init(void) Line 5952  void machine_init(void)
5952                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5953          }          }
5954    
5955            /*  NetWinder:  */
5956            me = machine_entry_new("NetWinder", ARCH_ARM, MACHINE_NETWINDER, 1, 0);
5957            me->aliases[0] = "netwinder";
5958            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5959                    me->next = first_machine_entry; first_machine_entry = me;
5960            }
5961    
5962          /*  NetGear:  */          /*  NetGear:  */
5963          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602v1", ARCH_MIPS,
5964              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);
5965          me->aliases[0] = "netgear";          me->aliases[0] = "netgear";
5966          me->aliases[1] = "wg602";          me->aliases[1] = "wg602v1";
5967          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5968                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5969          }          }
# Line 5281  void machine_init(void) Line 5997  void machine_init(void)
5997                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5998          }          }
5999    
6000            /*  Iyonix:  */
6001            me = machine_entry_new("Iyonix", ARCH_ARM,
6002                MACHINE_IYONIX, 1, 0);
6003            me->aliases[0] = "iyonix";
6004            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6005                    me->next = first_machine_entry; first_machine_entry = me;
6006            }
6007    
6008            /*  Intel IQ80321 (ARM):  */
6009            me = machine_entry_new("Intel IQ80321 (ARM)", ARCH_ARM,
6010                MACHINE_IQ80321, 1, 0);
6011            me->aliases[0] = "iq80321";
6012            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6013                    me->next = first_machine_entry; first_machine_entry = me;
6014            }
6015    
6016            /*  HPCarm:  */
6017            me = machine_entry_new("Handheld SH (HPCsh)",
6018                ARCH_SH, MACHINE_HPCSH, 1, 2);
6019            me->aliases[0] = "hpcsh";
6020            me->subtype[0] = machine_entry_subtype_new("Jornada 680",
6021                MACHINE_HPCSH_JORNADA680, 1);
6022            me->subtype[0]->aliases[0] = "jornada680";
6023            me->subtype[1] = machine_entry_subtype_new(
6024                "Jornada 690", MACHINE_HPCSH_JORNADA690, 1);
6025            me->subtype[1]->aliases[0] = "jornada690";
6026            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
6027                    me->next = first_machine_entry; first_machine_entry = me;
6028            }
6029    
6030          /*  HPCmips:  */          /*  HPCmips:  */
6031          me = machine_entry_new("Handheld MIPS (HPCmips)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
6032              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
# Line 5317  void machine_init(void) Line 6063  void machine_init(void)
6063                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6064          }          }
6065    
6066            /*  HPCarm:  */
6067            me = machine_entry_new("Handheld ARM (HPCarm)",
6068                ARCH_ARM, MACHINE_HPCARM, 1, 2);
6069            me->aliases[0] = "hpcarm";
6070            me->subtype[0] = machine_entry_subtype_new("Ipaq",
6071                MACHINE_HPCARM_IPAQ, 1);
6072            me->subtype[0]->aliases[0] = "ipaq";
6073            me->subtype[1] = machine_entry_subtype_new(
6074                "Jornada 720", MACHINE_HPCARM_JORNADA720, 1);
6075            me->subtype[1]->aliases[0] = "jornada720";
6076            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6077                    me->next = first_machine_entry; first_machine_entry = me;
6078            }
6079    
6080          /*  Generic "bare" X86 machine:  */          /*  Generic "bare" X86 machine:  */
6081          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
6082              MACHINE_BAREX86, 1, 0);              MACHINE_BAREX86, 1, 0);
# Line 5333  void machine_init(void) Line 6093  void machine_init(void)
6093                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6094          }          }
6095    
6096            /*  Generic "bare" SH machine:  */
6097            me = machine_entry_new("Generic \"bare\" SH machine", ARCH_SH,
6098                MACHINE_BARESH, 1, 0);
6099            me->aliases[0] = "baresh";
6100            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
6101                    me->next = first_machine_entry; first_machine_entry = me;
6102            }
6103    
6104          /*  Generic "bare" PPC machine:  */          /*  Generic "bare" PPC machine:  */
6105          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
6106              MACHINE_BAREPPC, 1, 0);              MACHINE_BAREPPC, 1, 0);
# Line 5365  void machine_init(void) Line 6133  void machine_init(void)
6133                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6134          }          }
6135    
6136            /*  Generic "bare" i960 machine:  */
6137            me = machine_entry_new("Generic \"bare\" i960 machine", ARCH_I960,
6138                MACHINE_BAREI960, 1, 0);
6139            me->aliases[0] = "barei960";
6140            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
6141                    me->next = first_machine_entry; first_machine_entry = me;
6142            }
6143    
6144            /*  Generic "bare" HPPA machine:  */
6145            me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
6146                MACHINE_BAREHPPA, 1, 0);
6147            me->aliases[0] = "barehppa";
6148            if (cpu_family_ptr_by_number(ARCH_HPPA) != NULL) {
6149                    me->next = first_machine_entry; first_machine_entry = me;
6150            }
6151    
6152            /*  Generic "bare" Atmel AVR machine:  */
6153            me = machine_entry_new("Generic \"bare\" Atmel AVR machine", ARCH_AVR,
6154                MACHINE_BAREAVR, 1, 0);
6155            me->aliases[0] = "bareavr";
6156            if (cpu_family_ptr_by_number(ARCH_AVR) != NULL) {
6157                    me->next = first_machine_entry; first_machine_entry = me;
6158            }
6159    
6160          /*  Generic "bare" ARM machine:  */          /*  Generic "bare" ARM machine:  */
6161          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,          me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
6162              MACHINE_BAREARM, 1, 0);              MACHINE_BAREARM, 1, 0);
# Line 5398  void machine_init(void) Line 6190  void machine_init(void)
6190                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6191          }          }
6192    
6193            /*  Digital DNARD ("Shark"):  */
6194            me = machine_entry_new("Digital DNARD (\"Shark\")", ARCH_ARM,
6195                MACHINE_SHARK, 2, 0);
6196            me->aliases[0] = "shark";
6197            me->aliases[1] = "dnard";
6198            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6199                    me->next = first_machine_entry; first_machine_entry = me;
6200            }
6201    
6202          /*  DECstation:  */          /*  DECstation:  */
6203          me = machine_entry_new("DECstation/DECsystem",          me = machine_entry_new("DECstation/DECsystem",
6204              ARCH_MIPS, MACHINE_DEC, 3, 9);              ARCH_MIPS, MACHINE_DEC, 3, 9);
# Line 5465  void machine_init(void) Line 6266  void machine_init(void)
6266                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6267          }          }
6268    
6269            /*  CATS (ARM) evaluation board:  */
6270            me = machine_entry_new("CATS evaluation board (ARM)", ARCH_ARM,
6271                MACHINE_CATS, 1, 0);
6272            me->aliases[0] = "cats";
6273            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6274                    me->next = first_machine_entry; first_machine_entry = me;
6275            }
6276    
6277          /*  BeBox: (NetBSD/bebox)  */          /*  BeBox: (NetBSD/bebox)  */
6278          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
6279          me->aliases[0] = "bebox";          me->aliases[0] = "bebox";
# Line 5531  void machine_init(void) Line 6340  void machine_init(void)
6340          }          }
6341    
6342          /*  Alpha:  */          /*  Alpha:  */
6343          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 1);          me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6344          me->aliases[0] = "alpha";          me->aliases[0] = "alpha";
6345          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
6346              "DEC 3000/300", ST_DEC_3000_300, 1);              "DEC 3000/300", ST_DEC_3000_300, 1);
6347          me->subtype[0]->aliases[0] = "3000/300";          me->subtype[0]->aliases[0] = "3000/300";
6348            me->subtype[1] = machine_entry_subtype_new(
6349                "EB164", ST_EB164, 1);
6350            me->subtype[1]->aliases[0] = "eb164";
6351          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {          if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
6352                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6353          }          }
6354    
6355            /*  Algor evaluation board:  */
6356            me = machine_entry_new("Algor", ARCH_MIPS, MACHINE_ALGOR, 1, 2);
6357            me->aliases[0] = "algor";
6358            me->subtype[0] = machine_entry_subtype_new("P4032",
6359                MACHINE_ALGOR_P4032, 1);
6360            me->subtype[0]->aliases[0] = "p4032";
6361            me->subtype[1] = machine_entry_subtype_new("P5064",
6362                MACHINE_ALGOR_P5064, 1);
6363            me->subtype[1]->aliases[0] = "p5064";
6364            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
6365                    me->next = first_machine_entry; first_machine_entry = me;
6366            }
6367  }  }
6368    

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

  ViewVC Help
Powered by ViewVC 1.1.26