/[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 6 by dpavlin, Mon Oct 8 16:18:11 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.452 2005/06/02 17:11:34 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"
 #include "cpu_mips.h"  
57  #include "device.h"  #include "device.h"
58  #include "devices.h"  #include "devices.h"
59  #include "diskimage.h"  #include "diskimage.h"
# Line 65  Line 65 
65  #include "net.h"  #include "net.h"
66  #include "symbol.h"  #include "symbol.h"
67    
68    /*  For Alpha emulation:  */
69    #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"
77    
78    /*  For evbmips emulation:  */
79    #include "maltareg.h"
80    
81  /*  For DECstation emulation:  */  /*  For DECstation emulation:  */
82  #include "dec_prom.h"  #include "dec_prom.h"
83  #include "dec_bootinfo.h"  #include "dec_bootinfo.h"
# Line 83  Line 92 
92  #include "hpc_bootinfo.h"  #include "hpc_bootinfo.h"
93  #include "vripreg.h"  #include "vripreg.h"
94    
95    #define BOOTSTR_BUFLEN          1000
96    #define BOOTARG_BUFLEN          2000
97    #define ETHERNET_STRING_MAXLEN  40
98    
99  struct machine_entry_subtype {  struct machine_entry_subtype {
100          int                     machine_subtype;/*  Old-style subtype  */          int                     machine_subtype;/*  Old-style subtype  */
# Line 137  struct machine *machine_new(char *name, Line 149  struct machine *machine_new(char *name,
149          m->name = strdup(name);          m->name = strdup(name);
150    
151          /*  Sane default values:  */          /*  Sane default values:  */
152          m->serial_nr = 0;          m->serial_nr = 1;
153          m->machine_type = MACHINE_NONE;          m->machine_type = MACHINE_NONE;
154          m->machine_subtype = MACHINE_NONE;          m->machine_subtype = MACHINE_NONE;
155    #ifdef BINTRANS
156          m->bintrans_enable = 1;          m->bintrans_enable = 1;
157            m->old_bintrans_enable = 1;
158    #endif
159            m->arch_pagesize = 4096;        /*  Should be overriden in
160                                                emul.c for other pagesizes.  */
161            m->dyntrans_alignment_check = 1;
162          m->prom_emulation = 1;          m->prom_emulation = 1;
163          m->speed_tricks = 1;          m->speed_tricks = 1;
164          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;
# Line 148  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 171  int machine_name_to_type(char *stype, ch Line 190  int machine_name_to_type(char *stype, ch
190          int *type, int *subtype, int *arch)          int *type, int *subtype, int *arch)
191  {  {
192          struct machine_entry *me;          struct machine_entry *me;
193          int i, j, k;          int i, j, k, nmatches = 0;
194    
195          *type = MACHINE_NONE;          *type = MACHINE_NONE;
196          *subtype = 0;          *subtype = 0;
197    
198            /*  Check stype, and optionally ssubtype:  */
199          me = first_machine_entry;          me = first_machine_entry;
200          while (me != NULL) {          while (me != NULL) {
201                  for (i=0; i<me->n_aliases; i++)                  for (i=0; i<me->n_aliases; i++)
# Line 210  int machine_name_to_type(char *stype, ch Line 230  int machine_name_to_type(char *stype, ch
230                  me = me->next;                  me = me->next;
231          }          }
232    
233          fatal("\nSorry, emulation \"%s\"", stype);          /*  Not found? Then just check ssubtype:  */
234          if (ssubtype != NULL && ssubtype[0] != '\0')          me = first_machine_entry;
235                  fatal(" (subtype \"%s\")", ssubtype);          while (me != NULL) {
236          fatal(" is unknown.\n");                  if (me->n_subtypes == 0) {
237          fatal("Use the -H command line option to get a list of available"                          me = me->next;
238              " types and subtypes.\n\n");                          continue;
239                    }
240    
241                    /*  Check for subtype:  */
242                    for (j=0; j<me->n_subtypes; j++)
243                            for (k=0; k<me->subtype[j]->n_aliases; k++)
244                                    if (strcasecmp(ssubtype, me->subtype[j]->
245                                        aliases[k]) == 0) {
246                                            *type = me->machine_type;
247                                            *arch = me->arch;
248                                            *subtype = me->subtype[j]->
249                                                machine_subtype;
250                                            nmatches ++;
251                                    }
252    
253                    me = me->next;
254            }
255    
256            switch (nmatches) {
257            case 0: fatal("\nSorry, emulation \"%s\"", stype);
258                    if (ssubtype != NULL && ssubtype[0] != '\0')
259                            fatal(" (subtype \"%s\")", ssubtype);
260                    fatal(" is unknown.\n");
261                    break;
262            case 1: return 1;
263            default:fatal("\nSorry, multiple matches for \"%s\"", stype);
264                    if (ssubtype != NULL && ssubtype[0] != '\0')
265                            fatal(" (subtype \"%s\")", ssubtype);
266                    fatal(".\n");
267            }
268    
269            *type = MACHINE_NONE;
270            *subtype = 0;
271    
272            fatal("Use the -H command line option to get a list of "
273                "available types and subtypes.\n\n");
274    
275          return 0;          return 0;
276  }  }
277    
# Line 337  void add_environment_string(struct cpu * Line 393  void add_environment_string(struct cpu *
393    
394    
395  /*  /*
396     *  add_environment_string_dual():
397     *
398     *  Add "dual" environment strings, one for the variable name and one for the
399     *  value, and update pointers afterwards.
400     */
401    void add_environment_string_dual(struct cpu *cpu,
402            uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2)
403    {
404            uint64_t ptr = *ptrp, addr = *addrp;
405    
406            store_32bit_word(cpu, ptr, addr);
407            ptr += sizeof(uint32_t);
408            if (addr != 0) {
409                    store_string(cpu, addr, s1);
410                    addr += strlen(s1) + 1;
411            }
412            store_32bit_word(cpu, ptr, addr);
413            ptr += sizeof(uint32_t);
414            if (addr != 0) {
415                    store_string(cpu, addr, s2);
416                    addr += strlen(s2) + 1;
417            }
418    
419            *ptrp = ptr;
420            *addrp = addr;
421    }
422    
423    
424    /*
425   *  store_64bit_word():   *  store_64bit_word():
426   *   *
427   *  Stores a 64-bit word in emulated RAM.  Byte order is taken into account.   *  Stores a 64-bit word in emulated RAM.  Byte order is taken into account.
# Line 376  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 401  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 422  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 475  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 499  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 1053  void sgi_ip32_interrupt(struct machine * Line 1138  void sgi_ip32_interrupt(struct machine *
1138           *  interrupt 2 should be asserted.           *  interrupt 2 should be asserted.
1139           *           *
1140           *  TODO:  how should all this be done nicely?           *  TODO:  how should all this be done nicely?
          *  
          *  TODO:  mace interrupt mask  
1141           */           */
1142    
1143          uint64_t crime_addr = CRIME_INTSTAT;          uint64_t crime_addr = CRIME_INTSTAT;
1144          uint64_t mace_addr = 0x14;          uint64_t mace_addr = 0x10;
1145          uint64_t crime_interrupts, crime_interrupts_mask, mace_interrupts;          uint64_t crime_interrupts, crime_interrupts_mask;
1146            uint64_t mace_interrupts, mace_interrupt_mask;
1147          unsigned int i;          unsigned int i;
1148          unsigned char x[8];          unsigned char x[8];
1149    
1150            /*  Read current MACE interrupt assertions:  */
1151            memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr,
1152                sizeof(uint64_t));
1153            mace_interrupts = 0;
1154            for (i=0; i<sizeof(uint64_t); i++) {
1155                    mace_interrupts <<= 8;
1156                    mace_interrupts |= x[i];
1157            }
1158    
1159            /*  Read current MACE interrupt mask:  */
1160            memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr + 8,
1161                sizeof(uint64_t));
1162            mace_interrupt_mask = 0;
1163            for (i=0; i<sizeof(uint64_t); i++) {
1164                    mace_interrupt_mask <<= 8;
1165                    mace_interrupt_mask |= x[i];
1166            }
1167    
1168          /*          /*
1169           *  This mapping of both MACE and CRIME interrupts into the same           *  This mapping of both MACE and CRIME interrupts into the same
1170           *  'int' is really ugly.           *  'int' is really ugly.
# Line 1074  void sgi_ip32_interrupt(struct machine * Line 1176  void sgi_ip32_interrupt(struct machine *
1176           *  TODO: fix.           *  TODO: fix.
1177           */           */
1178          if (irq_nr & MACE_PERIPH_SERIAL) {          if (irq_nr & MACE_PERIPH_SERIAL) {
                 /*  Read current MACE interrupt bits:  */  
                 memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr, sizeof(uint32_t));  
                 mace_interrupts = 0;  
                 for (i=0; i<sizeof(uint32_t); i++) {  
                         /*  SGI is big-endian...  */  
                         mace_interrupts <<= 8;  
                         mace_interrupts |= x[i];  
                 }  
   
1179                  if (assrt)                  if (assrt)
1180                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_SERIAL);                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_SERIAL);
1181                  else                  else
1182                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_SERIAL);                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_SERIAL);
1183    
                 /*  Write back MACE interrupt bits:  */  
                 for (i=0; i<4; i++)  
                         x[3-i] = mace_interrupts >> (i*8);  
                 memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint32_t));  
   
1184                  irq_nr = MACE_PERIPH_SERIAL;                  irq_nr = MACE_PERIPH_SERIAL;
1185                  if (mace_interrupts == 0)                  if ((mace_interrupts & mace_interrupt_mask) == 0)
1186                          assrt = 0;                          assrt = 0;
1187                  else                  else
1188                          assrt = 1;                          assrt = 1;
# Line 1102  void sgi_ip32_interrupt(struct machine * Line 1190  void sgi_ip32_interrupt(struct machine *
1190    
1191          /*  Hopefully _MISC and _SERIAL will not be both on at the same time.  */          /*  Hopefully _MISC and _SERIAL will not be both on at the same time.  */
1192          if (irq_nr & MACE_PERIPH_MISC) {          if (irq_nr & MACE_PERIPH_MISC) {
                 /*  Read current MACE interrupt bits:  */  
                 memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr, sizeof(uint32_t));  
                 mace_interrupts = 0;  
                 for (i=0; i<sizeof(uint32_t); i++) {  
                         /*  SGI is big-endian...  */  
                         mace_interrupts <<= 8;  
                         mace_interrupts |= x[i];  
                 }  
   
1193                  if (assrt)                  if (assrt)
1194                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_MISC);                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_MISC);
1195                  else                  else
1196                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_MISC);                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_MISC);
1197    
                 /*  Write back MACE interrupt bits:  */  
                 for (i=0; i<4; i++)  
                         x[3-i] = mace_interrupts >> (i*8);  
                 memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint32_t));  
   
1198                  irq_nr = MACE_PERIPH_MISC;                  irq_nr = MACE_PERIPH_MISC;
1199                  if (mace_interrupts == 0)                  if ((mace_interrupts & mace_interrupt_mask) == 0)
1200                          assrt = 0;                          assrt = 0;
1201                  else                  else
1202                          assrt = 1;                          assrt = 1;
1203          }          }
1204    
1205            /*  Write back MACE interrupt assertions:  */
1206            for (i=0; i<sizeof(uint64_t); i++)
1207                    x[7-i] = mace_interrupts >> (i*8);
1208            memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint64_t));
1209    
1210          /*  Read CRIME_INTSTAT:  */          /*  Read CRIME_INTSTAT:  */
1211          memcpy(x, m->md_int.ip32.crime_data->reg + crime_addr, sizeof(uint64_t));          memcpy(x, m->md_int.ip32.crime_data->reg + crime_addr,
1212                sizeof(uint64_t));
1213          crime_interrupts = 0;          crime_interrupts = 0;
1214          for (i=0; i<8; i++) {          for (i=0; i<sizeof(uint64_t); i++) {
                 /*  SGI is big-endian...  */  
1215                  crime_interrupts <<= 8;                  crime_interrupts <<= 8;
1216                  crime_interrupts |= x[i];                  crime_interrupts |= x[i];
1217          }          }
# Line 1143  void sgi_ip32_interrupt(struct machine * Line 1222  void sgi_ip32_interrupt(struct machine *
1222                  crime_interrupts &= ~irq_nr;                  crime_interrupts &= ~irq_nr;
1223    
1224          /*  Write back CRIME_INTSTAT:  */          /*  Write back CRIME_INTSTAT:  */
1225          for (i=0; i<8; i++)          for (i=0; i<sizeof(uint64_t); i++)
1226                  x[7-i] = crime_interrupts >> (i*8);                  x[7-i] = crime_interrupts >> (i*8);
1227          memcpy(m->md_int.ip32.crime_data->reg + crime_addr, x, sizeof(uint64_t));          memcpy(m->md_int.ip32.crime_data->reg + crime_addr, x,
1228                sizeof(uint64_t));
1229    
1230          /*  Read CRIME_INTMASK:  */          /*  Read CRIME_INTMASK:  */
1231          memcpy(x, m->md_int.ip32.crime_data->reg + CRIME_INTMASK, sizeof(uint64_t));          memcpy(x, m->md_int.ip32.crime_data->reg + CRIME_INTMASK,
1232                sizeof(uint64_t));
1233          crime_interrupts_mask = 0;          crime_interrupts_mask = 0;
1234          for (i=0; i<8; i++) {          for (i=0; i<sizeof(uint64_t); i++) {
1235                  crime_interrupts_mask <<= 8;                  crime_interrupts_mask <<= 8;
1236                  crime_interrupts_mask |= x[i];                  crime_interrupts_mask |= x[i];
1237          }          }
# Line 1160  void sgi_ip32_interrupt(struct machine * Line 1241  void sgi_ip32_interrupt(struct machine *
1241          else          else
1242                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1243    
1244          /*  printf("sgi_crime_machine_irq(%i,%i): new interrupts = 0x%08x\n", assrt, irq_nr, crime_interrupts);  */          /*  printf("sgi_crime_machine_irq(%i,%i): new interrupts = 0x%08x\n",
1245                assrt, irq_nr, crime_interrupts);  */
1246  }  }
1247    
1248    
# Line 1213  void au1x00_interrupt(struct machine *m, Line 1295  void au1x00_interrupt(struct machine *m,
1295    
1296    
1297  /*  /*
1298     *  CPC700 interrupt routine:
1299     *
1300     *  irq_nr should be 0..31. (32 means reassertion.)
1301     */
1302    void cpc700_interrupt(struct machine *m, struct cpu *cpu,
1303            int irq_nr, int assrt)
1304    {
1305            if (irq_nr < 32) {
1306                    uint32_t mask = 1 << (irq_nr & 31);
1307                    if (assrt)
1308                            m->md_int.cpc700_data->sr |= mask;
1309                    else
1310                            m->md_int.cpc700_data->sr &= ~mask;
1311            }
1312    
1313            if ((m->md_int.cpc700_data->sr & m->md_int.cpc700_data->er) != 0)
1314                    cpu_interrupt(cpu, 65);
1315            else
1316                    cpu_interrupt_ack(cpu, 65);
1317    }
1318    
1319    
1320    /*
1321     *  Interrupt function for Cobalt, evbmips (Malta), and Algor.
1322     *
1323     *  (irq_nr = 8 + 16 can be used to just reassert/deassert interrupts.)
1324     */
1325    void isa8_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
1326    {
1327            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;
1333            mask = 1 << (irq_nr & 7);
1334    
1335            if (irq_nr < 8) {
1336                    if (assrt)
1337                            m->isa_pic_data.pic1->irr |= mask;
1338                    else
1339                            m->isa_pic_data.pic1->irr &= ~mask;
1340            } else if (irq_nr < 16) {
1341                    if (assrt)
1342                            m->isa_pic_data.pic2->irr |= mask;
1343                    else
1344                            m->isa_pic_data.pic2->irr &= ~mask;
1345            }
1346    
1347            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1348            /*  (TODO: don't hardcode this here)  */
1349            if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1350                    m->isa_pic_data.pic1->irr |= 0x04;
1351            else
1352                    m->isa_pic_data.pic1->irr &= ~0x04;
1353    
1354            /*  Now, PIC1:  */
1355            new_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1356            if (old_isa_assert != new_isa_assert) {
1357                    for (x=0; x<16; x++) {
1358                            if (x == 2)
1359                                    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            if (m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier)
1371                    cpu_interrupt(cpu, m->isa_pic_data.native_irq);
1372            else
1373                    cpu_interrupt_ack(cpu, m->isa_pic_data.native_irq);
1374    }
1375    
1376    
1377    /*
1378   *  x86 (PC) interrupts:   *  x86 (PC) interrupts:
1379   *   *
1380   *  (irq_nr = 16 can be used to just reassert/deassert interrupts.)   *  (irq_nr = 16 can be used to just reassert/deassert interrupts.)
# Line 1223  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 1274  void machine_setup(struct machine *machi Line 1546  void machine_setup(struct machine *machi
1546          int i, j;          int i, j;
1547          struct memory *mem;          struct memory *mem;
1548          char tmpstr[1000];          char tmpstr[1000];
1549            struct cons_data *cons_data;
1550    
1551          /*  DECstation:  */          /*  DECstation:  */
1552          char *framebuffer_console_name, *serial_console_name;          char *framebuffer_console_name, *serial_console_name;
# Line 1289  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 1310  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 1330  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 1346  void machine_setup(struct machine *machi Line 1627  void machine_setup(struct machine *machi
1627                  printf("\nNo emulation type specified.\n");                  printf("\nNo emulation type specified.\n");
1628                  exit(1);                  exit(1);
1629    
1630    #ifdef ENABLE_MIPS
1631          case MACHINE_BAREMIPS:          case MACHINE_BAREMIPS:
1632                  /*                  /*
1633                   *  A "bare" MIPS test machine.                   *  A "bare" MIPS test machine.
# Line 1358  void machine_setup(struct machine *machi Line 1640  void machine_setup(struct machine *machi
1640    
1641          case MACHINE_TESTMIPS:          case MACHINE_TESTMIPS:
1642                  /*                  /*
1643                   *  A MIPS test machine (which happens to work with my                   *  A MIPS test machine (which happens to work with the
1644                   *  thesis work).                   *  code in my master's thesis).  :-)
1645                     *
1646                     *  IRQ map:
1647                     *      7       CPU counter
1648                     *      6       SMP IPIs
1649                     *      5       not used yet
1650                     *      4       not used yet
1651                     *      3       ethernet
1652                     *      2       serial console
1653                   */                   */
1654                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
1655                  machine->machine_name = "MIPS test machine";                  machine->machine_name = "MIPS test machine";
1656    
1657                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=2",
1658                      machine, mem, DEV_CONS_ADDRESS, "console", 2);                      (long long)DEV_CONS_ADDRESS);
1659                    cons_data = device_add(machine, tmpstr);
1660                    machine->main_console_handle = cons_data->console_handle;
1661    
1662                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
1663                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
1664                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
1665    
1666                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
1667                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testmips generic");
1668    
1669                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
1670                        (long long)DEV_DISK_ADDRESS);
1671                    device_add(machine, tmpstr);
1672    
1673                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=3",
1674                        (long long)DEV_ETHER_ADDRESS);
1675                    device_add(machine, tmpstr);
1676    
1677                  break;                  break;
1678    
1679          case MACHINE_DEC:          case MACHINE_DEC:
# Line 1414  void machine_setup(struct machine *machi Line 1715  void machine_setup(struct machine *machi
1715                           */                           */
1716                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,
1717                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,
1718                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01", 1);                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01");
1719                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);
1720                          dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag);                          dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag);
1721                          dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576);                          dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576);
# Line 1846  void machine_setup(struct machine *machi Line 2147  void machine_setup(struct machine *machi
2147                          dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576);                          dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576);
2148                          dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII);                          dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII);
2149    
2150                          snprintf(tmpstr, sizeof(tmpstr) - 1,                          snprintf(tmpstr, sizeof(tmpstr),
2151                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);
2152                          machine->md_int.kn230_csr = device_add(machine, tmpstr);                          machine->md_int.kn230_csr = device_add(machine, tmpstr);
2153    
# Line 1859  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                                  strcpy(bootpath, "rz(0,0,0)");                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
2233                          else                          else
2234  #endif  #endif
2235                                  strcpy(bootpath, "5/rz1/");                                  strlcpy(bootpath, "5/rz1/", sizeof(bootpath));
2236    
2237                          if (bootdev_id < 0 || machine->force_netboot) {                          if (bootdev_id < 0 || machine->force_netboot) {
2238                                  /*  tftp boot:  */                                  /*  tftp boot:  */
2239                                  strcpy(bootpath, "5/tftp/");                                  strlcpy(bootpath, "5/tftp/", sizeof(bootpath));
2240                                  bootpath[0] = '0' + boot_net_boardnumber;                                  bootpath[0] = '0' + boot_net_boardnumber;
2241                          } else {                          } else {
2242                                  /*  disk boot:  */                                  /*  disk boot:  */
# Line 1946  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(strlen(init_bootpath) +                          bootarg = malloc(BOOTARG_BUFLEN);
2254                      strlen(machine->boot_kernel_filename) + 1 +                          if (bootarg == NULL) {
2255                      strlen(machine->boot_string_argument) + 1);                                  fprintf(stderr, "out of memory\n");
2256                  strcpy(bootarg, init_bootpath);                                  exit(1);
2257                  strcat(bootarg, machine->boot_kernel_filename);                          }
2258                            strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2259                  bootstr = "boot";                          if (strlcat(bootarg, machine->boot_kernel_filename,
2260                                BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2261                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                                  fprintf(stderr, "bootarg truncated?\n");
2262                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                                  exit(1);
2263                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,                          }
                     machine->boot_string_argument);  
   
                 /*  Decrease the nr of args, if there are no args :-)  */  
                 if (machine->boot_string_argument == NULL ||  
                     machine->boot_string_argument[0] == '\0')  
                         cpu->cd.mips.gpr[MIPS_GPR_A0] --;  
   
                 if (machine->boot_string_argument[0] != '\0') {  
                         strcat(bootarg, " ");  
                         strcat(bootarg, machine->boot_string_argument);  
                 }  
   
                 xx.a.common.next = (char *)&xx.b - (char *)&xx;  
                 xx.a.common.type = BTINFO_MAGIC;  
                 xx.a.magic = BOOTINFO_MAGIC;  
   
                 xx.b.common.next = (char *)&xx.c - (char *)&xx.b;  
                 xx.b.common.type = BTINFO_BOOTPATH;  
                 strcpy(xx.b.bootpath, bootstr);  
   
                 xx.c.common.next = 0;  
                 xx.c.common.type = BTINFO_SYMTAB;  
                 xx.c.nsym = 0;  
                 xx.c.ssym = 0;  
                 xx.c.esym = machine->file_loaded_end_addr;  
2264    
2265                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          bootstr = "boot";
2266    
2267                  /*                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2268                   *  The system's memmap:  (memmap is a global variable, in                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2269                   *  dec_prom.h)                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2270                   */                              machine->boot_string_argument);
                 store_32bit_word_in_host(cpu,  
                     (unsigned char *)&memmap.pagesize, 4096);  
                 {  
                         unsigned int i;  
                         for (i=0; i<sizeof(memmap.bitmap); i++)  
                                 memmap.bitmap[i] = ((int)i * 4096*8 <  
                                     1048576*machine->physical_ram_in_mb)?  
                                     0xff : 0x00;  
                 }  
                 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);  
2271    
2272                  /*                          /*  Decrease the nr of args, if there are no args :-)  */
2273                   *  The KN5800 (SMP system) uses a CCA (console communications                          if (machine->boot_string_argument == NULL ||
2274                   *  area):  (See VAX 6000 documentation for details.)                              machine->boot_string_argument[0] == '\0')
2275                   */                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2276                  {  
2277                          char tmps[300];                          if (machine->boot_string_argument[0] != '\0') {
2278                          sprintf(tmps, "cca=%x",                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2279                              (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));                                  if (strlcat(bootarg, machine->boot_string_argument,
2280                          add_environment_string(cpu, tmps, &addr);                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2281                  }                                          fprintf(stderr, "bootstr truncated?\n");
2282                                            exit(1);
2283                  /*  These are needed for Sprite to boot:  */                                  }
2284                  {                          }
2285                          char tmps[300];  
2286                            xx.a.common.next = (char *)&xx.b - (char *)&xx;
2287                          sprintf(tmps, "boot=%s", bootarg);                          xx.a.common.type = BTINFO_MAGIC;
2288                          add_environment_string(cpu, tmps, &addr);                          xx.a.magic = BOOTINFO_MAGIC;
2289    
2290                          sprintf(tmps, "bitmap=0x%x", (uint32_t)((                          xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2291                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))                          xx.b.common.type = BTINFO_BOOTPATH;
2292                              & 0xffffffffULL));                          strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2293                          add_environment_string(cpu, tmps, &addr);  
2294                            xx.c.common.next = 0;
2295                          sprintf(tmps, "bitmaplen=0x%x",                          xx.c.common.type = BTINFO_SYMTAB;
2296                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                          xx.c.nsym = 0;
2297                          add_environment_string(cpu, tmps, &addr);                          xx.c.ssym = 0;
2298                  }                          xx.c.esym = machine->file_loaded_end_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);  
2299    
2300                  /*  The end:  */                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
2301                  add_environment_string(cpu, "", &addr);  
2302                            /*
2303                             *  The system's memmap:  (memmap is a global variable, in
2304                             *  dec_prom.h)
2305                             */
2306                            store_32bit_word_in_host(cpu,
2307                                (unsigned char *)&memmap.pagesize, 4096);
2308                            {
2309                                    unsigned int i;
2310                                    for (i=0; i<sizeof(memmap.bitmap); i++)
2311                                            memmap.bitmap[i] = ((int)i * 4096*8 <
2312                                                1048576*machine->physical_ram_in_mb)?
2313                                                0xff : 0x00;
2314                            }
2315                            store_buf(cpu, DEC_MEMMAP_ADDR, (char *)&memmap, sizeof(memmap));
2316    
2317                            /*  Environment variables:  */
2318                            addr = DEC_PROM_STRINGS;
2319    
2320                            if (machine->use_x11 && machine->n_gfx_cards > 0)
2321                                    /*  (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 2072  void machine_setup(struct machine *machi Line 2388  void machine_setup(struct machine *machi
2388                   *      4       Tulip 1                   *      4       Tulip 1
2389                   *      5       16550 UART (serial console)                   *      5       16550 UART (serial console)
2390                   *      6       VIA southbridge PIC                   *      6       VIA southbridge PIC
2391                   *      7       PCI                   *      7       PCI  (Note: Not used. The PCI controller
2392                     *              interrupts at ISA interrupt 9.)
2393                   */                   */
2394  /*              dev_XXX_init(cpu, mem, 0x10000000, machine->emulated_hz);       */  
2395                    /*  ISA interrupt controllers:  */
2396                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2397                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2398                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2399                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2400                    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 = dev_ns16550_init(machine, mem,                  machine->main_console_handle = (size_t)
2406                      0x1c800000, 5, 1, 1, "serial console");                      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                  dev_ns16550_init(machine, mem, 0x1f000010, 0, 1, 1,                  device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0");
                     "other serial console");  
2412  #endif  #endif
2413    
2414                  /*                  /*
# Line 2094  void machine_setup(struct machine *machi Line 2420  void machine_setup(struct machine *machi
2420                   *  pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37                   *  pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37
2421                   *  pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr                   *  pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr
2422                   *  tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1                   *  tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1
                  */  
                 pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 6); /*  7 for PCI, not 6?  */  
                 /*  bus_pci_add(machine, pci_data, mem, 0,  7, 0, pci_dec21143_init, pci_dec21143_rr);  */  
                 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,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);  
                 bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);  
                 /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr);  */  
   
                 /*  
                  *  NetBSD/cobalt expects memsize in a0, but it seems that what  
                  *  it really wants is the end of memory + 0x80000000.  
2423                   *                   *
2424                   *  The bootstring should be stored starting 512 bytes before end                   *  The PCI controller interrupts at ISA interrupt 9.
                  *  of physical ram.  
2425                   */                   */
2426                  cpu->cd.mips.gpr[MIPS_GPR_A0] = machine->physical_ram_in_mb * 1048576 + 0x80000000;                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 8 + 9, 11);
2427                  bootstr = "root=/dev/hda1 ro";                  bus_pci_add(machine, pci_data, mem, 0,  7, 0, "dec21143");
2428                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                  /*  bus_pci_add(machine, pci_data, mem, 0,  8, 0, "symbios_860");   PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860  */
2429                  store_string(cpu, 0xffffffff80000000ULL +                  bus_pci_add(machine, pci_data, mem, 0,  9, 0, "vt82c586_isa");
2430                      machine->physical_ram_in_mb * 1048576 - 512, bootstr);                  bus_pci_add(machine, pci_data, mem, 0,  9, 1, "vt82c586_ide");
2431                    /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, "dec21143");  */
2432    
2433                    if (machine->prom_emulation) {
2434                            /*
2435                             *  NetBSD/cobalt expects memsize in a0, but it seems that what
2436                             *  it really wants is the end of memory + 0x80000000.
2437                             *
2438                             *  The bootstring is stored 512 bytes before the end of
2439                             *  physical ram.
2440                             */
2441                            cpu->cd.mips.gpr[MIPS_GPR_A0] =
2442                                machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2443                            bootstr = "root=/dev/hda1 ro";
2444                            /*  bootstr = "nfsroot=/usr/cobalt/";  */
2445                            /*  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 2142  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                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2471                              machine, mem, 0xa008680, 0, 4,                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
2472                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2473    
2474                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 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                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2499                              machine, mem, 0xa008680, 0, 4,                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
2500                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2501    
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 2331  void machine_setup(struct machine *machi Line 2622  void machine_setup(struct machine *machi
2622                              VRIP_INTR_SIU (=9) here?  */                              VRIP_INTR_SIU (=9) here?  */
2623                          {                          {
2624                                  int x;                                  int x;
2625                                  x = dev_ns16550_init(machine, mem, 0x0c000010,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x0c000010", 8 + VRIP_INTR_SIU);
2626                                      8 + VRIP_INTR_SIU, 1, 1, "serial 0");                                  x = (size_t)device_add(machine, tmpstr);
2627    
2628                                  if (!machine->use_x11)                                  if (!machine->use_x11)
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 = "Agenda VR3";                          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  */  
2687    
2688                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2689                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                          cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2690                                + 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                          snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"                                  if (!machine->use_x11)
2715                              "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2716                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2717    
2718                          if (!machine->use_x11)                                  if (machine->boot_string_argument[0])
2719                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2720                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2721    
2722                          if (machine->boot_string_argument[0])                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
                                 snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);  
                         tmp[tmplen-1] = '\0';  
   
                         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", 0);                              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 2491  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);  
                 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);
2819                          }                          }
2820    
2821                          strcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60");                          strlcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60", tmplen);
2822    
2823                          if (machine->boot_string_argument[0])                          if (machine->boot_string_argument[0])
2824                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),
# Line 2528  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 2562  void machine_setup(struct machine *machi Line 2857  void machine_setup(struct machine *machi
2857                   *  detailed list of IP ("Inhouse Processor") model numbers.                   *  detailed list of IP ("Inhouse Processor") model numbers.
2858                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)
2859                   */                   */
2860                  machine->machine_name = malloc(500);                  machine->machine_name = malloc(MACHINE_NAME_MAXBUF);
2861                  if (machine->machine_name == NULL) {                  if (machine->machine_name == NULL) {
2862                          fprintf(stderr, "out of memory\n");                          fprintf(stderr, "out of memory\n");
2863                          exit(1);                          exit(1);
# Line 2570  void machine_setup(struct machine *machi Line 2865  void machine_setup(struct machine *machi
2865    
2866                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2867                          cpu->byte_order = EMUL_BIG_ENDIAN;                          cpu->byte_order = EMUL_BIG_ENDIAN;
2868                          sprintf(machine->machine_name, "SGI-IP%i", machine->machine_subtype);                          snprintf(machine->machine_name, MACHINE_NAME_MAXBUF,
2869                                "SGI-IP%i", machine->machine_subtype);
2870    
2871                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;
2872    
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;
2889                          sprintf(machine->machine_name, "ARC");                          snprintf(machine->machine_name,
2890                                MACHINE_NAME_MAXBUF, "ARC");
2891                  }                  }
2892    
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                                  strcat(machine->machine_name, " (Iris Indigo IP12)");                                  strlcat(machine->machine_name,
2902                                        " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);
2903    
2904                                  /*  TODO  */                                  /*  TODO  */
2905                                  /*  33 MHz R3000, according to http://www.irisindigo.com/  */                                  /*  33 MHz R3000, according to http://www.irisindigo.com/  */
# Line 2603  void machine_setup(struct machine *machi Line 2907  void machine_setup(struct machine *machi
2907    
2908                                  break;                                  break;
2909                          case 19:                          case 19:
2910                                  strcat(machine->machine_name, " (Everest IP19)");                                  strlcat(machine->machine_name,
2911                                        " (Everest IP19)", MACHINE_NAME_MAXBUF);
2912                                  machine->main_console_handle =                                  machine->main_console_handle =
2913                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */
2914                                  dev_scc_init(machine, mem, 0x10086000, 0, machine->use_x11, 0, 8);      /*  serial? irix?  */                                  dev_scc_init(machine, mem, 0x10086000, 0, machine->use_x11, 0, 8);      /*  serial? irix?  */
# Line 2623  void machine_setup(struct machine *machi Line 2928  void machine_setup(struct machine *machi
2928    
2929                                  break;                                  break;
2930                          case 20:                          case 20:
2931                                  strcat(machine->machine_name, " (Indigo)");                                  strlcat(machine->machine_name,
2932                                        " (Indigo)", MACHINE_NAME_MAXBUF);
2933    
2934                                  /*                                  /*
2935                                   *  Guesses based on NetBSD 2.0 beta, 20040606.                                   *  Guesses based on NetBSD 2.0 beta, 20040606.
# Line 2668  void machine_setup(struct machine *machi Line 2974  void machine_setup(struct machine *machi
2974    
2975                                  break;                                  break;
2976                          case 21:                          case 21:
2977                                  strcat(machine->machine_name, " (uknown SGI-IP21 ?)");  /*  TODO  */                                  strlcat(machine->machine_name,  /*  TODO  */
2978                                        " (uknown SGI-IP21 ?)", MACHINE_NAME_MAXBUF);
2979                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2980                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2981    
# Line 2678  void machine_setup(struct machine *machi Line 2985  void machine_setup(struct machine *machi
2985                          case 22:                          case 22:
2986                          case 24:                          case 24:
2987                                  if (machine->machine_subtype == 22) {                                  if (machine->machine_subtype == 22) {
2988                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Full-house)");                                          strlcat(machine->machine_name,
2989                                                " (Indy, Indigo2, Challenge S; Full-house)",
2990                                                MACHINE_NAME_MAXBUF);
2991                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);
2992                                  } else {                                  } else {
2993                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Guiness)");                                          strlcat(machine->machine_name,
2994                                                " (Indy, Indigo2, Challenge S; Guiness)",
2995                                                MACHINE_NAME_MAXBUF);
2996                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);
2997                                  }                                  }
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 2754  Why is this here? TODO Line 3065  Why is this here? TODO
3065                          case 25:                          case 25:
3066                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3067                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3068                                  strcat(machine->machine_name, " (Everest IP25)");                                  strlcat(machine->machine_name,
3069                                        " (Everest IP25)", MACHINE_NAME_MAXBUF);
3070    
3071                                   /*  serial? irix?  */                                   /*  serial? irix?  */
3072                                  dev_scc_init(machine, mem,                                  dev_scc_init(machine, mem,
# Line 2775  Why is this here? TODO Line 3087  Why is this here? TODO
3087                          case 26:                          case 26:
3088                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3089                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3090                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
3091                                      " (uknown SGI-IP26 ?)");    /*  TODO  */                                      " (uknown SGI-IP26 ?)",
3092                                        MACHINE_NAME_MAXBUF);       /*  TODO  */
3093                                  machine->main_console_handle =                                  machine->main_console_handle =
3094                                      dev_zs_init(machine, mem, 0x1fbd9830,                                      dev_zs_init(machine, mem, 0x1fbd9830,
3095                                      0, 1, "zs console");                                      0, 1, "zs console");
3096                                  break;                                  break;
3097                          case 27:                          case 27:
3098                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
3099                                      " (Origin 200/2000, Onyx2)");                                      " (Origin 200/2000, Onyx2)",
3100                                        MACHINE_NAME_MAXBUF);
3101                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3102                                  /*  2 cpus per node  */                                  /*  2 cpus per node  */
3103    
# Line 2794  Why is this here? TODO Line 3108  Why is this here? TODO
3108                          case 28:                          case 28:
3109                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3110                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3111                                  strcat(machine->machine_name, " (Impact Indigo2 ?)");                                  strlcat(machine->machine_name,
3112                                        " (Impact Indigo2 ?)", MACHINE_NAME_MAXBUF);
3113    
3114                                  device_add(machine, "random addr=0x1fbe0000, len=1");                                  device_add(machine, "random addr=0x1fbe0000, len=1");
3115    
# Line 2804  Why is this here? TODO Line 3119  Why is this here? TODO
3119                          case 30:                          case 30:
3120                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3121                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3122                                  strcat(machine->machine_name, " (Octane)");                                  strlcat(machine->machine_name,
3123                                        " (Octane)", MACHINE_NAME_MAXBUF);
3124    
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 2828  Why is this here? TODO Line 3146  Why is this here? TODO
3146                                   *  program dumps something there, but it doesn't look like                                   *  program dumps something there, but it doesn't look like
3147                                   *  readable text.  (TODO)                                   *  readable text.  (TODO)
3148                                   */                                   */
3149                                  machine->main_console_handle = dev_ns16550_init(machine, mem, 0x1f620170, 0, 1,  
3150                                      machine->use_x11? 0 : 1, "serial 0");  /*  TODO: irq?  */                                  /*  TODO: irq!  */
3151                                  dev_ns16550_init(machine, mem, 0x1f620178, 0, 1,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620170 name2=tty0 in_use=%i", machine->use_x11? 0 : 1);
3152                                      0, "serial 1");  /*  TODO: irq?  */                                  machine->main_console_handle = (size_t)device_add(machine, tmpstr);
3153                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620178 name2=tty1 in_use=0");
3154                                    device_add(machine, tmpstr);
3155    
3156                                  /*  MardiGras graphics:  */                                  /*  MardiGras graphics:  */
3157                                  device_add(machine, "sgi_mardigras addr=0x1c000000");                                  device_add(machine, "sgi_mardigras addr=0x1c000000");
3158    
3159                                  break;                                  break;
3160                          case 32:                          case 32:
3161                                  strcat(machine->machine_name, " (O2)");                                  strlcat(machine->machine_name,
3162                                        " (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 2893  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    
                                 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)  */  
   
3217                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3218                                  eaddr_string = malloc(30);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3219                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
3220                                          fprintf(stderr, "out of memory\n");                                          fprintf(stderr, "out of memory\n");
3221                                          exit(1);                                          exit(1);
3222                                  }                                  }
3223                                  sprintf(eaddr_string, "eaddr=%02x:%02x:"                                  snprintf(eaddr_string, ETHERNET_STRING_MAXLEN,
3224                                      "%02x:%02x:%02x:%02x",                                      "eaddr=%02x:%02x:%02x:%02x:%02x:%02x",
3225                                      macaddr[0], macaddr[1], macaddr[2],                                      macaddr[0], macaddr[1], macaddr[2],
3226                                      macaddr[3], macaddr[4], macaddr[5]);                                      macaddr[3], macaddr[4], macaddr[5]);
3227                                  dev_sgi_mec_init(machine, mem, 0x1f280000, MACE_ETHERNET, macaddr);                                  dev_sgi_mec_init(machine, mem, 0x1f280000,
3228                                        MACE_ETHERNET, macaddr);
3229    
3230                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */
3231    
3232                                  j = dev_ns16550_init(machine, mem, 0x1f390000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f390000 addr_mult=0x100 in_use=%i name2=tty0",
3233                                      (1<<20) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<20) + MACE_PERIPH_SERIAL, machine->use_x11? 0 : 1);
3234                                      machine->use_x11? 0 : 1, "serial 0");       /*  com0  */                                  j = (size_t)device_add(machine, tmpstr);
3235                                  dev_ns16550_init(machine, mem, 0x1f398000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",
3236                                      (1<<26) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3237                                      0, "serial 1");                             /*  com1  */                                  device_add(machine, tmpstr);
3238    
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                                  }
                                         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 2936  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 2947  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:
3281                                  strcat(machine->machine_name, " (Origin 3000)");                                  strlcat(machine->machine_name,
3282                                        " (Origin 3000)", MACHINE_NAME_MAXBUF);
3283                                  /*  4 cpus per node  */                                  /*  4 cpus per node  */
3284    
3285                                  machine->main_console_handle =                                  machine->main_console_handle =
# Line 2962  Why is this here? TODO Line 3287  Why is this here? TODO
3287                                      0, 1, "zs console");                                      0, 1, "zs console");
3288                                  break;                                  break;
3289                          case 53:                          case 53:
3290                                  strcat(machine->machine_name, " (Origin 350)");                                  strlcat(machine->machine_name,
3291                                        " (Origin 350)", MACHINE_NAME_MAXBUF);
3292                                  /*                                  /*
3293                                   *  According to http://kumba.drachentekh.net/xml/myguide.html                                   *  According to http://kumba.drachentekh.net/xml/myguide.html
3294                                   *  Origin 350, Tezro IP53 R16000                                   *  Origin 350, Tezro IP53 R16000
# Line 2989  Why is this here? TODO Line 3315  Why is this here? TODO
3315    
3316                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3317                                  case MACHINE_ARC_NEC_RD94:                                  case MACHINE_ARC_NEC_RD94:
3318                                          strcat(machine->machine_name, " (NEC-RD94, NEC RISCstation 2250)");                                          strlcat(machine->machine_name,
3319                                                " (NEC-RD94, NEC RISCstation 2250)",
3320                                                MACHINE_NAME_MAXBUF);
3321                                          break;                                          break;
3322                                  case MACHINE_ARC_NEC_R94:                                  case MACHINE_ARC_NEC_R94:
3323                                          strcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)");                                          strlcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)",
3324                                                MACHINE_NAME_MAXBUF);
3325                                          break;                                          break;
3326                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3327                                          strcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)");                                          strlcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)",
3328                                                MACHINE_NAME_MAXBUF);
3329                                          break;                                          break;
3330                                  }                                  }
3331    
# Line 3007  Why is this here? TODO Line 3337  Why is this here? TODO
3337                                  device_add(machine, "sn addr=0x80001000 irq=0");                                  device_add(machine, "sn addr=0x80001000 irq=0");
3338                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);
3339                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11, 0);                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11, 0);
3340                                  j = dev_ns16550_init(machine, mem, 0x80006000ULL,  
3341                                      3, 1, machine->use_x11? 0 : 1, "serial 0");  /*  com0  */                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3342                                  dev_ns16550_init(machine, mem, 0x80007000ULL,                                  j = (size_t)device_add(machine, tmpstr);
3343                                      0, 1, 0, "serial 1"); /*  com1  */                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0);
3344                                    device_add(machine, tmpstr);
3345    
3346                                  if (machine->use_x11)                                  if (machine->use_x11)
3347                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3025  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,
3363                                              VFB_GENERIC, 640,480, 1024,480,                                              VFB_GENERIC, 640,480, 1024,480,
3364                                              8, "necvdfrb", 1);                                              8, "necvdfrb");
3365                                          break;                                          break;
3366                                  }                                  }
3367                                  break;                                  break;
# Line 3049  Why is this here? TODO Line 3380  Why is this here? TODO
3380                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"
3381                                   */                                   */
3382    
3383                                  strcat(machine->machine_name, " (NEC-R98; NEC RISCserver 4200)");                                  strlcat(machine->machine_name,
3384                                        " (NEC-R98; NEC RISCserver 4200)",
3385                                        MACHINE_NAME_MAXBUF);
3386    
3387                                  /*                                  /*
3388                                   *  Windows NT access stuff at these addresses:                                   *  Windows NT access stuff at these addresses:
# Line 3105  Why is this here? TODO Line 3438  Why is this here? TODO
3438    
3439                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3440                                  case MACHINE_ARC_JAZZ_PICA:                                  case MACHINE_ARC_JAZZ_PICA:
3441                                          strcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)",
3442                                                MACHINE_NAME_MAXBUF);
3443                                          break;                                          break;
3444                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3445                                          strcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)",
3446                                                MACHINE_NAME_MAXBUF);
3447                                          break;                                          break;
3448                                  default:                                  default:
3449                                          fatal("error in machine.c. jazz\n");                                          fatal("error in machine.c. jazz\n");
# Line 3122  Why is this here? TODO Line 3457  Why is this here? TODO
3457                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3458                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3459    
3460                                  j = dev_ns16550_init(machine, mem,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3461                                      0x80006000ULL, 8 + 8, 1,                                  j = (size_t)device_add(machine, tmpstr);
3462                                      machine->use_x11? 0 : 1, "serial 0");                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3463                                  dev_ns16550_init(machine, mem,                                  device_add(machine, tmpstr);
                                     0x80007000ULL, 8 + 9, 1, 0, "serial 1");  
3464    
3465                                  if (machine->use_x11)                                  if (machine->use_x11)
3466                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3145  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?  */
3487                                          dev_fb_init(machine, mem, 0x60200000ULL,                                          dev_fb_init(machine, mem, 0x60200000ULL,
3488                                              VFB_GENERIC, 1024,768, 1024,768,                                              VFB_GENERIC, 1024,768, 1024,768,
3489                                              8, "VXL", 1);                                              8, "VXL");
3490                                          break;                                          break;
3491                                  }                                  }
3492    
# Line 3171  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 3186  Not yet. Line 3521  Not yet.
3521                                   *  See http://mail-index.netbsd.org/port-arc/2000/10/18/0001.html.                                   *  See http://mail-index.netbsd.org/port-arc/2000/10/18/0001.html.
3522                                   */                                   */
3523    
3524                                  strcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)");                                  strlcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)",
3525                                        MACHINE_NAME_MAXBUF);
3526    
3527                                  machine->md_int.jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3528                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
# Line 3200  Not yet. Line 3536  Not yet.
3536                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3537                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3538  #endif  #endif
3539                                  j = dev_ns16550_init(machine, mem,  
3540                                      0x80006000ULL, 8 + 8, 1,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3541                                      machine->use_x11? 0 : 1, "serial 0");                                  j = (size_t)device_add(machine, tmpstr);
3542                                  dev_ns16550_init(machine, mem,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3543                                      0x80007000ULL, 8 + 9, 1, 0, "serial 1");                                  device_add(machine, tmpstr);
3544    
3545                                  if (machine->use_x11)                                  if (machine->use_x11)
3546                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3224  Not yet. Line 3560  Not yet.
3560                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html
3561                                   */                                   */
3562    
3563                                  strcat(machine->machine_name, " (Deskstation Tyne)");                                  strlcat(machine->machine_name, " (Deskstation Tyne)",
3564                                        MACHINE_NAME_MAXBUF);
3565    
3566                                  i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3567                                  dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1");                                  i = (size_t)device_add(machine, tmpstr);
3568                                  dev_ns16550_init(machine, mem, 0x9000003e8ULL, 0, 1, 0, "serial 2");                                  device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0 name2=tty1");
3569                                  dev_ns16550_init(machine, mem, 0x9000002e8ULL, 0, 1, 0, "serial 3");                                  device_add(machine, "ns16550 irq=0 addr=0x9000003e8 in_use=0 name2=tty2");
3570                                    device_add(machine, "ns16550 irq=0 addr=0x9000002e8 in_use=0 name2=tty3");
3571    
3572                                  dev_mc146818_init(machine, mem,                                  dev_mc146818_init(machine, mem,
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 3270  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                                          strcat(init_bootpath, "xio(0)pci(15)");                          init_bootpath = malloc(500);
3628                                  if (machine->machine_subtype == 32)                          if (init_bootpath == NULL) {
3629                                          strcat(init_bootpath, "pci(0)");                                  fprintf(stderr, "out of mem, bootpath\n");
3630                                    exit(1);
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                  if (machine->machine_type == MACHINE_ARC)                                                      MACHINE_NAME_MAXBUF);
3645                          strcat(init_bootpath, "\\");                                  }
3646    
3647                  bootstr = malloc(strlen(init_bootpath) +                                  if (diskimage_is_a_cdrom(machine, bootdev_id,
3648                      strlen(machine->boot_kernel_filename) + 1);                                      bootdev_type))
3649                  strcpy(bootstr, init_bootpath);                                          snprintf(init_bootpath + strlen(init_bootpath),
3650                  strcat(bootstr, machine->boot_kernel_filename);                                              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                  /*  Boot args., eg "-a"  */                          if (machine->machine_type == MACHINE_ARC)
3658                  bootarg = machine->boot_string_argument;                                  strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
3659    
3660                  /*  argc, argv, envp in a0, a1, a2:  */                          bootstr = malloc(BOOTSTR_BUFLEN);
3661                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */                          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                  /*  TODO:  not needed?  */                          /*  Boot args., eg "-a"  */
3673                  cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)                          bootarg = machine->boot_string_argument;
                     (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);  
3674    
3675                  /*  Set up argc/argv:  */                          /*  argc, argv, envp in a0, a1, a2:  */
3676                  addr = ARC_ENV_STRINGS;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */
                 addr2 = ARC_ARGV_START;  
                 cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;  
3677    
3678                  /*  bootstr:  */                          /*  TODO:  not needed?  */
3679                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3680                  add_environment_string(cpu, bootstr, &addr);                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3681                  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;  
3682                            /*  Set up argc/argv:  */
3683                            addr = ARC_ENV_STRINGS;
3684                            addr2 = ARC_ARGV_START;
3685                            cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
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;  
                         tmp = malloc(strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2);  
                         sprintf(tmp, "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 3501  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 3556  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 3569  no_arc_prom_emulation:         /*  TODO: ugly, Line 3915  no_arc_prom_emulation:         /*  TODO: ugly,
3915    
3916                  break;                  break;
3917    
3918            case MACHINE_EVBMIPS:
3919                    /*  http://www.netbsd.org/Ports/evbmips/  */
3920                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
3921    
3922                    switch (machine->machine_subtype) {
3923                    case MACHINE_EVBMIPS_MALTA:
3924                    case MACHINE_EVBMIPS_MALTA_BE:
3925                            machine->machine_name = "MALTA (evbmips, little endian)";
3926                            cpu->byte_order = EMUL_LITTLE_ENDIAN;
3927    
3928                            if (machine->machine_subtype == MACHINE_EVBMIPS_MALTA_BE) {
3929                                    machine->machine_name = "MALTA (evbmips, big endian)";
3930                                    cpu->byte_order = EMUL_BIG_ENDIAN;
3931                            }
3932    
3933                            machine->md_interrupt = isa8_interrupt;
3934                            machine->isa_pic_data.native_irq = 2;
3935    
3936                            bus_isa(machine, 0, 0x18000000, 0x10000000, 8, 24);
3937    
3938                            snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x name2=tty2", MALTA_CBUSUART);
3939                            device_add(machine, tmpstr);
3940    
3941                            pci_data = dev_gt_init(machine, mem, 0x1be00000, 8+9, 8+9, 120);
3942    
3943                            if (machine->use_x11) {
3944                                    if (strlen(machine->boot_string_argument) < 3)
3945                                            fatal("WARNING: remember to use  -o 'console=tty0'  "
3946                                                "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");
3954                            break;
3955                    case MACHINE_EVBMIPS_PB1000:
3956                            machine->machine_name = "PB1000 (evbmips)";
3957                            cpu->byte_order = EMUL_BIG_ENDIAN;
3958    
3959                            machine->md_interrupt = au1x00_interrupt;
3960                            machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem);
3961                            /*  TODO  */
3962                            break;
3963                    default:
3964                            fatal("Unimplemented EVBMIPS model.\n");
3965                            exit(1);
3966                    }
3967    
3968                    if (machine->prom_emulation) {
3969                            /*  NetBSD/evbmips wants these: (at least for Malta)  */
3970    
3971                            /*  a0 = argc  */
3972                            cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
3973    
3974                            /*  a1 = argv  */
3975                            cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
3976                            store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
3977                            store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
3978                            store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
3979    
3980                            bootstr = strdup(machine->boot_kernel_filename);
3981                            bootarg = strdup(machine->boot_string_argument);
3982                            store_string(cpu, (int32_t)0x9fc01040, bootstr);
3983                            store_string(cpu, (int32_t)0x9fc01200, bootarg);
3984    
3985                            /*  a2 = (yamon_env_var *)envp  */
3986                            cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
3987                            {
3988                                    uint64_t env = cpu->cd.mips.gpr[MIPS_GPR_A2];
3989                                    uint64_t tmpptr = 0xffffffff9fc01c00ULL;
3990                                    char tmps[50];
3991    
3992                                    snprintf(tmps, sizeof(tmps), "0x%08x",
3993                                        machine->physical_ram_in_mb * 1048576);
3994                                    add_environment_string_dual(cpu,
3995                                        &env, &tmpptr, "memsize", tmps);
3996    
3997                                    add_environment_string_dual(cpu,
3998                                        &env, &tmpptr, "yamonrev", "02.06");
3999    
4000                                    /*  End of env:  */
4001                                    tmpptr = 0;
4002                                    add_environment_string_dual(cpu,
4003                                        &env, &tmpptr, NULL, NULL);
4004                            }
4005    
4006                            /*  a3 = memsize  */
4007                            cpu->cd.mips.gpr[MIPS_GPR_A3] =
4008                                machine->physical_ram_in_mb * 1048576;
4009                            /*  Hm. Linux ignores a3.  */
4010    
4011                            /*
4012                             *  TODO:
4013                             *      Core ID numbers.
4014                             *      How much of this is not valid for PBxxxx?
4015                             *
4016                             *  See maltareg.h for more info.
4017                             */
4018                            store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION), (1 << 10) + 0x26);
4019    
4020                            /*  Call vectors at 0x9fc005xx:  */
4021                            for (i=0; i<0x100; i+=4)
4022                                    store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,
4023                                        (int64_t)(int32_t)0x9fc00800 + i);
4024                    }
4025                    break;
4026    
4027            case MACHINE_PSP:
4028                    /*
4029                     *  The Playstation Portable seems to be a strange beast.
4030                     *
4031                     *  http://yun.cup.com/psppg004.html (in Japanese) seems to
4032                     *  suggest that virtual addresses are not displaced by
4033                     *  0x80000000 as on normal CPUs, but by 0x40000000?
4034                     */
4035                    machine->machine_name = "Playstation Portable";
4036                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
4037    
4038                    if (!machine->use_x11 && !quiet_mode)
4039                            fprintf(stderr, "-------------------------------------"
4040                                "------------------------------------------\n"
4041                                "\n  WARNING! You are emulating a PSP without -X. "
4042                                "You will miss graphical output!\n\n"
4043                                "-------------------------------------"
4044                                "------------------------------------------\n");
4045    
4046                    /*  480 x 272 pixels framebuffer (512 bytes per line)  */
4047                    fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPC,
4048                        480,272, 512,1088, -15, "Playstation Portable");
4049    
4050                    /*
4051                     *  TODO/NOTE: This is ugly, but necessary since GXemul doesn't
4052                     *  emulate any MIPS CPU without MMU right now.
4053                     */
4054                    mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,
4055                        0x44000000 /*vaddr*/, 0x4000000, 0x4000000 + 1048576*16,
4056                        1,1,1,1,1, 0, 2, 2);
4057                    mips_coproc_tlb_set_entry(cpu, 1, 1048576*16,
4058                        0x8000000 /*vaddr*/, 0x0, 0x0 + 1048576*16,
4059                        1,1,1,1,1, 0, 2, 2);
4060                    mips_coproc_tlb_set_entry(cpu, 2, 1048576*16,
4061                        0x9000000 /*vaddr*/, 0x01000000, 0x01000000 + 1048576*16,
4062                        1,1,1,1,1, 0, 2, 2);
4063                    mips_coproc_tlb_set_entry(cpu, 3, 1048576*16,
4064                        0x0 /*vaddr*/, 0, 0 + 1048576*16, 1,1,1,1,1, 0, 2, 2);
4065    
4066                    cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;
4067    
4068                    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  */
4123    
4124    #ifdef ENABLE_PPC
4125          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
4126                  /*                  /*
4127                   *  A "bare" PPC machine.                   *  A "bare" PPC machine.
# Line 3585  no_arc_prom_emulation:         /*  TODO: ugly, Line 4138  no_arc_prom_emulation:         /*  TODO: ugly,
4138                  machine->machine_name = "PPC test machine";                  machine->machine_name = "PPC test machine";
4139    
4140                  /*  TODO: interrupt for PPC?  */                  /*  TODO: interrupt for PPC?  */
4141                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4142                      machine, mem, DEV_CONS_ADDRESS, "console", 0);                      (long long)DEV_CONS_ADDRESS);
4143                    cons_data = device_add(machine, tmpstr);
4144                    machine->main_console_handle = cons_data->console_handle;
4145    
4146                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4147                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
4148                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
4149    
4150                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4151                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testppc generic");
4152    
4153                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4154                        (long long)DEV_DISK_ADDRESS);
4155                    device_add(machine, tmpstr);
4156    
4157                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4158                        (long long)DEV_ETHER_ADDRESS);
4159                    device_add(machine, tmpstr);
4160    
4161                  break;                  break;
4162    
4163          case MACHINE_WALNUT:          case MACHINE_WALNUT:
# Line 3602  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 3609  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->main_console_handle = dev_ns16550_init(machine, mem,                  machine->md_interrupt = cpc700_interrupt;
4187                      0xff600300, 0, 1, 1, "serial 0");  
4188                  dev_ns16550_init(machine, mem,                  /*  RTC at "ext int 5" = "int 25" in IBM jargon, int
4189                      0xff600400, 0, 1, 0, "serial 1");                      31-25 = 6 for the rest of us.  */
4190                    dev_mc146818_init(machine, mem, 0x7ff00000, 31-25, MC146818_PMPPC, 1);
4191    
4192                    bus_pci_add(machine, machine->md_int.cpc700_data->pci_data,
4193                        mem, 0, 8, 0, "dec21143");
4194    
4195                  break;                  break;
4196    
# Line 3626  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 3641  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                  /*  Serial, used by NetBSD:  */                  machine->md_interrupt = isa32_interrupt;
4217                  machine->main_console_handle = dev_ns16550_init(machine, mem,  
4218                      0x800003f8, 0, 1, 1, "serial 0");                  pci_data = dev_eagle_init(machine, mem,
4219                        32 /*  isa irq base */, 0 /*  pci irq: TODO */);
4220                  /*  Serial, used by Linux:  */  
4221                  dev_ns16550_init(machine, mem, 0x800002f8, 0, 1, 0, "serial 1");                  bus_isa(machine, BUS_ISA_IDE0 | BUS_ISA_VGA,
4222                        0x80000000, 0xc0000000, 32, 48);
4223                  /*  This is used by Linux too:  */  
4224                  dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,                  if (machine->prom_emulation) {
4225                      machine->machine_name);                          /*  According to the docs, and also used by NetBSD:  */
4226                            store_32bit_word(cpu, 0x3010, machine->physical_ram_in_mb * 1048576);
4227                  store_32bit_word(cpu, 0x3010,  
4228                      machine->physical_ram_in_mb * 1048576);                          /*  Used by Linux:  */
4229                            store_32bit_word(cpu, 0x32f8, machine->physical_ram_in_mb * 1048576);
4230                  /*  TODO: List of stuff, see http://www.beatjapan.org/  
4231                      mirror/www.be.com/aboutbe/benewsletter/                          /*  TODO: List of stuff, see http://www.beatjapan.org/
4232                      Issue27.html#Cookbook  for the details.  */                              mirror/www.be.com/aboutbe/benewsletter/
4233                  store_32bit_word(cpu, 0x301c, 0);                              Issue27.html#Cookbook  for the details.  */
4234                            store_32bit_word(cpu, 0x301c, 0);
4235                  /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,  
4236                      r5 = args, r6 = ptr to bootinfo?  */                          /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4237                  cpu->cd.ppc.gpr[3] = 0x3100;                              r5 = args, r6 = ptr to bootinfo?  */
4238                  cpu->cd.ppc.gpr[4] = 0x200000;                          cpu->cd.ppc.gpr[3] = 0x3100;
4239                  cpu->cd.ppc.gpr[5] = 0x2000;                          cpu->cd.ppc.gpr[4] = 0x400000;
4240                  store_string(cpu, cpu->cd.ppc.gpr[5], "-a");                          cpu->cd.ppc.gpr[5] = 0x2000;
4241                  cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576                          store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4242                      - 0x100;                          cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4243    
4244                  /*  See NetBSD's bebox/include/bootinfo.h for details  */                          /*  See NetBSD's bebox/include/bootinfo.h for details  */
4245                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */                          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  */                          store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4247                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,                          store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4248                      machine->physical_ram_in_mb * 1048576);                              machine->physical_ram_in_mb * 1048576);
4249    
4250                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */                          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 */                          store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4252                  store_buf(cpu, cpu->cd.ppc.gpr[6] + 20, "com", 4);                          store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4253                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */                              machine->use_x11? "vga" : "com", 4);
4254                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */                          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                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */  
4257                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */                          store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4258                  store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);                          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 3694  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                    bus_pci_add(machine, pci_data, mem, 0, 13, 0, "dec21143");
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                  /*  Linux on PReP has 0xdeadc0de at address 0? (See                          /*  r4 should point to first free byte after the loaded kernel:  */
4291                      http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */                          cpu->cd.ppc.gpr[4] = 6 * 1048576;
                 store_32bit_word(cpu, 0, 0xdeadc0de);  
   
                 /*  r6 should point to "residual data"?  */  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x1000;  
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 3719  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 = dev_ns16550_init(machine, mem,                  machine->main_console_handle = (size_t)device_add(machine,
4383                      0x1d000020, 0, 4, 1, "serial console");                      "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 3739  no_arc_prom_emulation:         /*  TODO: ugly, Line 4390  no_arc_prom_emulation:         /*  TODO: ugly,
4390                  }                  }
4391    
4392                  break;                  break;
4393    #endif  /*  ENABLE_PPC  */
4394    
4395          case MACHINE_BARESPARC:  #ifdef ENABLE_SH
4396                  /*  A bare SPARC machine, with no devices.  */          case MACHINE_BARESH:
4397                  machine->machine_name = "\"Bare\" SPARC machine";                  /*  A bare SH machine, with no devices.  */
4398                    machine->machine_name = "\"Bare\" SH machine";
4399                  break;                  break;
4400    
4401          case MACHINE_ULTRA1:          case MACHINE_TESTSH:
4402                  /*                  machine->machine_name = "SH test machine";
4403                   *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)  
4404                   *  OpenBSD/sparc64 (http://www.openbsd.org/sparc64.html)                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4405                   */                      (long long)DEV_CONS_ADDRESS);
4406                  machine->machine_name = "Sun Ultra1";                  cons_data = device_add(machine, tmpstr);
4407                  break;                  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    
         case MACHINE_BAREURISC:  
                 machine->machine_name = "\"Bare\" URISC machine";  
4424                  break;                  break;
4425    
4426          case MACHINE_TESTURISC:          case MACHINE_HPCSH:
4427                  machine->machine_name = "URISC test machine";                  /*  Handheld SH-based machines:  */
4428                    machine->machine_name = "HPCsh";
4429    
4430                  /*  TODO  */                  /*  TODO  */
                 /*  A special "device" for accessing normal devices  
                     using urisc accesses?  */  
   
                 device_add(machine, "urisc addr=0x12341234");  
4431    
4432                  break;                  break;
4433    #endif  /*  ENABLE_SH  */
4434    
4435    #ifdef ENABLE_HPPA
4436          case MACHINE_BAREHPPA:          case MACHINE_BAREHPPA:
4437                    /*  A bare HPPA machine, with no devices.  */
4438                  machine->machine_name = "\"Bare\" HPPA machine";                  machine->machine_name = "\"Bare\" HPPA machine";
4439                  break;                  break;
4440    
4441          case MACHINE_TESTHPPA:          case MACHINE_TESTHPPA:
4442                  machine->machine_name = "HPPA test machine";                  machine->machine_name = "HPPA test machine";
4443    
4444                  /*  TODO  */                  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;                  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
4500            case MACHINE_BARESPARC:
4501                    /*  A bare SPARC machine, with no devices.  */
4502                    machine->machine_name = "\"Bare\" SPARC machine";
4503                    break;
4504    
4505            case MACHINE_TESTSPARC:
4506                    machine->machine_name = "SPARC test machine";
4507    
4508                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4509                        (long long)DEV_CONS_ADDRESS);
4510                    cons_data = device_add(machine, tmpstr);
4511                    machine->main_console_handle = cons_data->console_handle;
4512    
4513                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4514                        (long long)DEV_MP_ADDRESS);
4515                    device_add(machine, tmpstr);
4516    
4517                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4518                        640,480, 640,480, 24, "testsparc generic");
4519    
4520                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4521                        (long long)DEV_DISK_ADDRESS);
4522                    device_add(machine, tmpstr);
4523    
4524                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4525                        (long long)DEV_ETHER_ADDRESS);
4526                    device_add(machine, tmpstr);
4527    
4528                    break;
4529    
4530            case MACHINE_ULTRA1:
4531                    /*
4532                     *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)
4533                     *  OpenBSD/sparc64 (http://www.openbsd.org/sparc64.html)
4534                     */
4535                    machine->machine_name = "Sun Ultra1";
4536                    break;
4537    #endif  /*  ENABLE_SPARC  */
4538    
4539    #ifdef ENABLE_ALPHA
4540          case MACHINE_BAREALPHA:          case MACHINE_BAREALPHA:
4541                  machine->machine_name = "\"Bare\" Alpha machine";                  machine->machine_name = "\"Bare\" Alpha machine";
4542                  break;                  break;
# Line 3785  no_arc_prom_emulation:         /*  TODO: ugly, Line 4544  no_arc_prom_emulation:         /*  TODO: ugly,
4544          case MACHINE_TESTALPHA:          case MACHINE_TESTALPHA:
4545                  machine->machine_name = "Alpha test machine";                  machine->machine_name = "Alpha test machine";
4546    
4547                  /*  TODO  */                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4548                        (long long)DEV_CONS_ADDRESS);
4549                    cons_data = device_add(machine, tmpstr);
4550                    machine->main_console_handle = cons_data->console_handle;
4551    
4552                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4553                        (long long)DEV_MP_ADDRESS);
4554                    device_add(machine, tmpstr);
4555    
4556                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4557                        640,480, 640,480, 24, "testalpha generic");
4558    
4559                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4560                        (long long)DEV_DISK_ADDRESS);
4561                    device_add(machine, tmpstr);
4562    
4563                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4564                        (long long)DEV_ETHER_ADDRESS);
4565                    device_add(machine, tmpstr);
4566    
4567                    break;
4568    
4569            case MACHINE_ALPHA:
4570                    if (machine->prom_emulation) {
4571                            struct rpb rpb;
4572                            struct crb crb;
4573                            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  */
4588                            memset(&rpb, 0, sizeof(struct rpb));
4589                            store_64bit_word_in_host(cpu, (unsigned char *)
4590                                &(rpb.rpb_phys), HWRPB_ADDR);
4591                            strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8);
4592                            store_64bit_word_in_host(cpu, (unsigned char *)
4593                                &(rpb.rpb_size), sizeof(struct rpb));
4594                            store_64bit_word_in_host(cpu, (unsigned char *)
4595                                &(rpb.rpb_page_size), 8192);
4596                            store_64bit_word_in_host(cpu, (unsigned char *)
4597                                &(rpb.rpb_type), machine->machine_subtype);
4598                            store_64bit_word_in_host(cpu, (unsigned char *)
4599                                &(rpb.rpb_cc_freq), 100000000);
4600                            store_64bit_word_in_host(cpu, (unsigned char *)
4601                                &(rpb.rpb_ctb_off), CTB_ADDR - HWRPB_ADDR);
4602                            store_64bit_word_in_host(cpu, (unsigned char *)
4603                                &(rpb.rpb_crb_off), CRB_ADDR - HWRPB_ADDR);
4604    
4605                            /*  CTB: Console Terminal Block  */
4606                            memset(&ctb, 0, sizeof(struct ctb));
4607                            store_64bit_word_in_host(cpu, (unsigned char *)
4608                                &(ctb.ctb_term_type), machine->use_x11?
4609                                CTB_GRAPHICS : CTB_PRINTERPORT);
4610    
4611                            /*  CRB: Console Routine Block  */
4612                            memset(&crb, 0, sizeof(struct crb));
4613                            store_64bit_word_in_host(cpu, (unsigned char *)
4614                                &(crb.crb_v_dispatch), CRB_ADDR - 0x100);
4615                            store_64bit_word(cpu, CRB_ADDR - 0x100 + 8, 0x10000);
4616    
4617                            /*
4618                             *  Place a special "hack" palcode call at 0x10000:
4619                             *  (Hopefully nothing else will be there.)
4620                             */
4621                            store_32bit_word(cpu, 0x10000, 0x3fffffe);
4622    
4623                            store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb));
4624                            store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb));
4625                            store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb));
4626                    }
4627    
4628                    switch (machine->machine_subtype) {
4629                    case ST_DEC_3000_300:
4630                            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;
4638                    default:fatal("Unimplemented Alpha machine type %i\n",
4639                                machine->machine_subtype);
4640                            exit(1);
4641                    }
4642    
4643                  break;                  break;
4644    #endif  /*  ENABLE_ALPHA  */
4645    
4646    #ifdef ENABLE_ARM
4647          case MACHINE_BAREARM:          case MACHINE_BAREARM:
4648                  machine->machine_name = "\"Bare\" ARM machine";                  machine->machine_name = "\"Bare\" ARM machine";
4649                  break;                  break;
# Line 3795  no_arc_prom_emulation:         /*  TODO: ugly, Line 4651  no_arc_prom_emulation:         /*  TODO: ugly,
4651          case MACHINE_TESTARM:          case MACHINE_TESTARM:
4652                  machine->machine_name = "ARM test machine";                  machine->machine_name = "ARM test machine";
4653    
4654                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4655                        (long long)DEV_CONS_ADDRESS);
4656                    cons_data = device_add(machine, tmpstr);
4657                    machine->main_console_handle = cons_data->console_handle;
4658    
4659                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4660                        (long long)DEV_MP_ADDRESS);
4661                    device_add(machine, tmpstr);
4662    
4663                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4664                        640,480, 640,480, 24, "testarm generic");
4665    
4666                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4667                        (long long)DEV_DISK_ADDRESS);
4668                    device_add(machine, tmpstr);
4669    
4670                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4671                        (long long)DEV_ETHER_ADDRESS);
4672                    device_add(machine, tmpstr);
4673    
4674                    /*  Place a tiny stub at end of memory, and set the link
4675                        register to point to it. This stub halts the machine.  */
4676                    cpu->cd.arm.r[ARM_SP] =
4677                        machine->physical_ram_in_mb * 1048576 - 4096;
4678                    cpu->cd.arm.r[ARM_LR] = cpu->cd.arm.r[ARM_SP] + 32;
4679                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 0, 0xe3a00201);
4680                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 4, 0xe5c00010);
4681                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4682                        0xeafffffe);
4683                    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  */                  /*  TODO  */
4902                    if (machine->prom_emulation) {
4903                            arm_setup_initial_translation_table(cpu, 0x4000);
4904                    }
4905                  break;                  break;
4906    
4907          case MACHINE_BAREX86:          case MACHINE_NETWINDER:
4908                  machine->machine_name = "\"Bare\" x86 machine";                  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;                  break;
4943    
4944          case MACHINE_X86:          case MACHINE_SHARK:
4945                  if (machine->machine_subtype == MACHINE_X86_XT)                  machine->machine_name = "Digital DNARD (\"Shark\")";
4946                          machine->machine_name = "PC XT";                  if (machine->prom_emulation) {
4947                  else                          arm_setup_initial_translation_table(cpu,
4948                          machine->machine_name = "Generic x86 PC";                              machine->physical_ram_in_mb * 1048576 - 65536);
4949    
4950                  /*  Interrupt controllers:  */                          /*
4951                  snprintf(tmpstr, sizeof(tmpstr) - 1, "8259 addr=0x%llx",                           *  r0 = OpenFirmware entry point.  NOTE: See
4952                      (long long)(X86_IO_BASE + 0x20));                           *  cpu_arm.c for the rest of this semi-ugly hack.
4953                  machine->md.pc.pic1 = device_add(machine, tmpstr);                           */
4954                  if (machine->machine_subtype != MACHINE_X86_XT) {                          cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
                         snprintf(tmpstr, sizeof(tmpstr) - 1, "8259 addr=0x%llx irq=2",  
                             (long long)(X86_IO_BASE + 0xa0));  
                         machine->md.pc.pic2 = device_add(machine, tmpstr);  
4955                  }                  }
4956                    break;
4957    
4958                  machine->md_interrupt = x86_pc_interrupt;          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  */
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
5032            case MACHINE_BAREIA64:
5033                    machine->machine_name = "\"Bare\" IA64 machine";
5034                    break;
5035    
5036            case MACHINE_TESTIA64:
5037                    machine->machine_name = "IA64 test machine";
5038    
5039                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
5040                        (long long)DEV_CONS_ADDRESS);
5041                    cons_data = device_add(machine, tmpstr);
5042                    machine->main_console_handle = cons_data->console_handle;
5043    
5044                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
5045                        (long long)DEV_MP_ADDRESS);
5046                    device_add(machine, tmpstr);
5047    
5048                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
5049                        640,480, 640,480, 24, "testia64 generic");
5050    
5051                  /*  Timer:  */                  snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
5052                  snprintf(tmpstr, sizeof(tmpstr) - 1, "8253 addr=0x%llx irq=0",                      (long long)DEV_DISK_ADDRESS);
                     (long long)(X86_IO_BASE + 0x40));  
5053                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
5054    
5055                  snprintf(tmpstr, sizeof(tmpstr) - 1, "pccmos addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
5056                      (long long)(X86_IO_BASE + 0x70));                      (long long)DEV_ETHER_ADDRESS);
5057                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
5058    
5059                  /*  TODO: IRQ when emulating a PC XT?  */                  break;
5060    #endif  /*  ENABLE_IA64  */
5061    
5062                  /*  IDE controllers:  */  #ifdef ENABLE_M68K
5063                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||          case MACHINE_BAREM68K:
5064                      diskimage_exist(machine, 1, DISKIMAGE_IDE))                  machine->machine_name = "\"Bare\" M68K machine";
5065                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x1f0, 14, 0);                  break;
5066                  if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||  
5067                      diskimage_exist(machine, 3, DISKIMAGE_IDE))          case MACHINE_TESTM68K:
5068                          dev_wdc_init(machine, mem, X86_IO_BASE + 0x170, 15, 2);                  machine->machine_name = "M68K test machine";
5069    
5070                  /*  Floppy controller at irq 6  */                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
5071                  snprintf(tmpstr, sizeof(tmpstr) - 1, "fdc addr=0x%llx irq=6",                      (long long)DEV_CONS_ADDRESS);
5072                      (long long)(X86_IO_BASE + 0x3f0));                  cons_data = device_add(machine, tmpstr);
5073                    machine->main_console_handle = cons_data->console_handle;
5074    
5075                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
5076                        (long long)DEV_MP_ADDRESS);
5077                    device_add(machine, tmpstr);
5078    
5079                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
5080                        640,480, 640,480, 24, "testm68k generic");
5081    
5082                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
5083                        (long long)DEV_DISK_ADDRESS);
5084                    device_add(machine, tmpstr);
5085    
5086                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
5087                        (long long)DEV_ETHER_ADDRESS);
5088                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
5089    
5090                  /*  TODO: sound blaster (eventually) at irq 7?  */                  break;
5091    #endif  /*  ENABLE_M68K  */
5092    
5093                  /*  TODO: parallel port  */  #ifdef ENABLE_X86
5094            case MACHINE_BAREX86:
5095                    machine->machine_name = "\"Bare\" x86 machine";
5096                    break;
5097    
5098            case MACHINE_X86:
5099                    if (machine->machine_subtype == MACHINE_X86_XT)
5100                            machine->machine_name = "PC XT";
5101                    else
5102                            machine->machine_name = "Generic x86 PC";
5103    
5104                    machine->md_interrupt = x86_pc_interrupt;
5105    
5106                  /*  Serial ports:  (TODO: 8250 for PC XT?)  */                  bus_isa(machine, BUS_ISA_IDE0 | BUS_ISA_IDE1 | BUS_ISA_VGA |
5107                  dev_ns16550_init(machine, mem, X86_IO_BASE + 0x3f8, 4, 1, 0, "com1");                      BUS_ISA_PCKBC_FORCE_USE |
5108                  dev_ns16550_init(machine, mem, X86_IO_BASE + 0x378, 3, 1, 0, "com2");                      (machine->machine_subtype == MACHINE_X86_XT?
5109                        BUS_ISA_NO_SECOND_PIC : 0) | BUS_ISA_FDC,
5110                  /*  VGA + keyboard:  */                      X86_IO_BASE, 0x00000000, 0, 16);
                 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 3869  no_arc_prom_emulation:         /*  TODO: ugly, Line 5120  no_arc_prom_emulation:         /*  TODO: ugly,
5120                              "-------------------------------------"                              "-------------------------------------"
5121                              "------------------------------------------\n");                              "------------------------------------------\n");
5122                  break;                  break;
5123    #endif  /*  ENABLE_X86  */
5124    
5125          default:          default:
5126                  fatal("Unknown emulation type %i\n", machine->machine_type);                  fatal("Unknown emulation type %i\n", machine->machine_type);
# Line 3882  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 3937  void machine_memsize_fix(struct machine Line 5190  void machine_memsize_fix(struct machine
5190                  case MACHINE_NETGEAR:                  case MACHINE_NETGEAR:
5191                          m->physical_ram_in_mb = 16;                          m->physical_ram_in_mb = 16;
5192                          break;                          break;
5193                    case MACHINE_EVBMIPS:
5194                            m->physical_ram_in_mb = 64;
5195                            break;
5196                    case MACHINE_PSP:
5197                            /*
5198                             *  According to
5199                             *  http://wiki.ps2dev.org/psp:memory_map:
5200                             *      0×08000000 = 8 MB kernel memory
5201                             *      0×08800000 = 24 MB user memory
5202                             */
5203                            m->physical_ram_in_mb = 8 + 24;
5204                            break;
5205                  case MACHINE_ARC:                  case MACHINE_ARC:
5206                          switch (m->machine_subtype) {                          switch (m->machine_subtype) {
5207                          case MACHINE_ARC_JAZZ_PICA:                          case MACHINE_ARC_JAZZ_PICA:
# Line 3958  void machine_memsize_fix(struct machine Line 5223  void machine_memsize_fix(struct machine
5223                                  m->physical_ram_in_mb = 32;                                  m->physical_ram_in_mb = 32;
5224                          }                          }
5225                          break;                          break;
5226                    case MACHINE_ALPHA:
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_BAREURISC:                  case MACHINE_HPCARM:
5234                  case MACHINE_TESTURISC:                          m->physical_ram_in_mb = 32;
5235                          m->physical_ram_in_mb = 2;                          break;
5236                    case MACHINE_NETWINDER:
5237                            m->physical_ram_in_mb = 16;
5238                          break;                          break;
5239                  case MACHINE_X86:                  case MACHINE_X86:
5240                          if (m->machine_subtype == MACHINE_X86_XT)                          if (m->machine_subtype == MACHINE_X86_XT)
# Line 4100  void machine_default_cputype(struct mach Line 5371  void machine_default_cputype(struct mach
5371                  if (m->cpu_name == NULL)                  if (m->cpu_name == NULL)
5372                          m->cpu_name = strdup("R4400");                          m->cpu_name = strdup("R4400");
5373                  break;                  break;
5374            case MACHINE_EVBMIPS:
5375                    switch (m->machine_subtype) {
5376                    case MACHINE_EVBMIPS_MALTA:
5377                    case MACHINE_EVBMIPS_MALTA_BE:
5378                            m->cpu_name = strdup("5Kc");
5379                            break;
5380                    case MACHINE_EVBMIPS_PB1000:
5381                            m->cpu_name = strdup("AU1000");
5382                            break;
5383                    default:fatal("Unimpl. evbmips.\n");
5384                            exit(1);
5385                    }
5386                    break;
5387            case MACHINE_PSP:
5388                    m->cpu_name = strdup("Allegrex");
5389                    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 4128  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 4145  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          /*  SPARC:  */          /*  SH:  */
5439          case MACHINE_BARESPARC:          case MACHINE_BARESH:
5440                  m->cpu_name = strdup("SPARCV9");          case MACHINE_TESTSH:
5441                  break;          case MACHINE_HPCSH:
5442          case MACHINE_ULTRA1:                  m->cpu_name = strdup("SH");
                 m->cpu_name = strdup("SPARCV9");  
                 break;  
   
         /*  URISC:  */  
         case MACHINE_BAREURISC:  
         case MACHINE_TESTURISC:  
                 m->cpu_name = strdup("URISC");  
5443                  break;                  break;
5444    
5445          /*  HPPA:  */          /*  HPPA:  */
5446          case MACHINE_BAREHPPA:          case MACHINE_BAREHPPA:
5447          case MACHINE_TESTHPPA:          case MACHINE_TESTHPPA:
5448                  m->cpu_name = strdup("HPPA2.0");                  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:  */
5458            case MACHINE_BARESPARC:
5459            case MACHINE_TESTSPARC:
5460            case MACHINE_ULTRA1:
5461                    m->cpu_name = strdup("SPARCv9");
5462                  break;                  break;
5463    
5464          /*  Alpha:  */          /*  Alpha:  */
5465          case MACHINE_BAREALPHA:          case MACHINE_BAREALPHA:
5466          case MACHINE_TESTALPHA:          case MACHINE_TESTALPHA:
5467                  m->cpu_name = strdup("EV4");          case MACHINE_ALPHA:
5468                    m->cpu_name = strdup("Alpha");
5469                  break;                  break;
5470    
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;
5494    
5495            /*  IA64:  */
5496            case MACHINE_BAREIA64:
5497            case MACHINE_TESTIA64:
5498                    m->cpu_name = strdup("IA64");
5499                    break;
5500    
5501            /*  M68K:  */
5502            case MACHINE_BAREM68K:
5503            case MACHINE_TESTM68K:
5504                    m->cpu_name = strdup("68020");
5505                  break;                  break;
5506    
5507          /*  x86:  */          /*  x86:  */
# Line 4223  void machine_dumpinfo(struct machine *m) Line 5550  void machine_dumpinfo(struct machine *m)
5550          if (m->single_step_on_bad_addr)          if (m->single_step_on_bad_addr)
5551                  debug("single-step on bad addresses\n");                  debug("single-step on bad addresses\n");
5552    
5553          if (m->bintrans_enable)          if (m->arch == ARCH_MIPS) {
5554                  debug("bintrans enabled (%i MB cache)\n",                  if (m->bintrans_enable)
5555                      (int) (m->bintrans_size / 1048576));                          debug("bintrans enabled (%i MB cache)\n",
5556          else                              (int) (m->bintrans_size / 1048576));
5557                  debug("bintrans disabled, other speedtricks %s\n",                  else
5558                      m->speed_tricks? "enabled" : "disabled");                          debug("bintrans disabled, other speedtricks %s\n",
5559                                m->speed_tricks? "enabled" : "disabled");
5560            }
5561    
5562          debug("clock: ");          debug("clock: ");
5563          if (m->automatic_clock_adjustment)          if (m->automatic_clock_adjustment)
# Line 4253  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 4408  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    
5748          useremul_list_emuls();          useremul_list_emuls();
5749            debug("Userland emulation works for programs with the complexity"
5750                " of Hello World,\nbut not much more.\n");
5751  }  }
5752    
5753    
# Line 4433  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 4456  void machine_init(void) Line 5798  void machine_init(void)
5798                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5799          }          }
5800    
5801          /*  Test-machine for URISC:  */          /*  Test-machine for SPARC:  */
5802          me = machine_entry_new("Test-machine for URISC", ARCH_URISC,          me = machine_entry_new("Test-machine for SPARC", ARCH_SPARC,
5803              MACHINE_TESTURISC, 1, 0);              MACHINE_TESTSPARC, 1, 0);
5804          me->aliases[0] = "testurisc";          me->aliases[0] = "testsparc";
5805          if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {          if (cpu_family_ptr_by_number(ARCH_SPARC) != NULL) {
5806                    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;                  me->next = first_machine_entry; first_machine_entry = me;
5815          }          }
5816    
# Line 4480  void machine_init(void) Line 5830  void machine_init(void)
5830                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5831          }          }
5832    
5833            /*  Test-machine for M68K:  */
5834            me = machine_entry_new("Test-machine for M68K", ARCH_M68K,
5835                MACHINE_TESTM68K, 1, 0);
5836            me->aliases[0] = "testm68k";
5837            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
5838                    me->next = first_machine_entry; first_machine_entry = me;
5839            }
5840    
5841            /*  Test-machine for IA64:  */
5842            me = machine_entry_new("Test-machine for IA64", ARCH_IA64,
5843                MACHINE_TESTIA64, 1, 0);
5844            me->aliases[0] = "testia64";
5845            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
5846                    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:  */          /*  Test-machine for HPPA:  */
5858          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5859              MACHINE_TESTHPPA, 1, 0);              MACHINE_TESTHPPA, 1, 0);
# Line 4530  void machine_init(void) Line 5904  void machine_init(void)
5904          }          }
5905    
5906          /*  SGI:  */          /*  SGI:  */
5907          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 9);          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 10);
5908          me->aliases[0] = "silicon graphics";          me->aliases[0] = "silicon graphics";
5909          me->aliases[1] = "sgi";          me->aliases[1] = "sgi";
5910          me->subtype[0] = machine_entry_subtype_new("IP19", 19, 1);          me->subtype[0] = machine_entry_subtype_new("IP12", 12, 1);
5911          me->subtype[0]->aliases[0] = "ip19";          me->subtype[0]->aliases[0] = "ip12";
5912          me->subtype[1] = machine_entry_subtype_new("IP20", 20, 1);          me->subtype[1] = machine_entry_subtype_new("IP19", 19, 1);
5913          me->subtype[1]->aliases[0] = "ip20";          me->subtype[1]->aliases[0] = "ip19";
5914          me->subtype[2] = machine_entry_subtype_new("IP22", 22, 2);          me->subtype[2] = machine_entry_subtype_new("IP20", 20, 1);
5915          me->subtype[2]->aliases[0] = "ip22";          me->subtype[2]->aliases[0] = "ip20";
5916          me->subtype[2]->aliases[1] = "indy";          me->subtype[3] = machine_entry_subtype_new("IP22", 22, 2);
5917          me->subtype[3] = machine_entry_subtype_new("IP24", 24, 1);          me->subtype[3]->aliases[0] = "ip22";
5918          me->subtype[3]->aliases[0] = "ip24";          me->subtype[3]->aliases[1] = "indy";
5919          me->subtype[4] = machine_entry_subtype_new("IP27", 27, 3);          me->subtype[4] = machine_entry_subtype_new("IP24", 24, 1);
5920          me->subtype[4]->aliases[0] = "ip27";          me->subtype[4]->aliases[0] = "ip24";
5921          me->subtype[4]->aliases[1] = "origin 200";          me->subtype[5] = machine_entry_subtype_new("IP27", 27, 3);
5922          me->subtype[4]->aliases[2] = "origin 2000";          me->subtype[5]->aliases[0] = "ip27";
5923          me->subtype[5] = machine_entry_subtype_new("IP28", 28, 1);          me->subtype[5]->aliases[1] = "origin 200";
5924          me->subtype[5]->aliases[0] = "ip28";          me->subtype[5]->aliases[2] = "origin 2000";
5925          me->subtype[6] = machine_entry_subtype_new("IP30", 30, 2);          me->subtype[6] = machine_entry_subtype_new("IP28", 28, 1);
5926          me->subtype[6]->aliases[0] = "ip30";          me->subtype[6]->aliases[0] = "ip28";
5927          me->subtype[6]->aliases[1] = "octane";          me->subtype[7] = machine_entry_subtype_new("IP30", 30, 2);
5928          me->subtype[7] = machine_entry_subtype_new("IP32", 32, 2);          me->subtype[7]->aliases[0] = "ip30";
5929          me->subtype[7]->aliases[0] = "ip32";          me->subtype[7]->aliases[1] = "octane";
5930          me->subtype[7]->aliases[1] = "o2";          me->subtype[8] = machine_entry_subtype_new("IP32", 32, 2);
5931          me->subtype[8] = machine_entry_subtype_new("IP35", 35, 1);          me->subtype[8]->aliases[0] = "ip32";
5932          me->subtype[8]->aliases[0] = "ip35";          me->subtype[8]->aliases[1] = "o2";
5933            me->subtype[9] = machine_entry_subtype_new("IP35", 35, 1);
5934            me->subtype[9]->aliases[0] = "ip35";
5935          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5936                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5937          }          }
# Line 4568  void machine_init(void) Line 5944  void machine_init(void)
5944                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5945          }          }
5946    
5947            /*  Playstation Portable:  */
5948            me = machine_entry_new("Playstation Portable", ARCH_MIPS,
5949                MACHINE_PSP, 1, 0);
5950            me->aliases[0] = "psp";
5951            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5952                    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 4606  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 (HPC)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
6032              ARCH_MIPS, MACHINE_HPCMIPS, 2, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
6033          me->aliases[0] = "hpcmips";          me->aliases[0] = "hpcmips";
         me->aliases[1] = "hpc";  
6034          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
6035              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);
6036          me->subtype[0]->aliases[0] = "be-300";          me->subtype[0]->aliases[0] = "be-300";
# Line 4643  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 4651  void machine_init(void) Line 6085  void machine_init(void)
6085                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6086          }          }
6087    
         /*  Generic "bare" URISC machine:  */  
         me = machine_entry_new("Generic \"bare\" URISC machine", ARCH_URISC,  
             MACHINE_BAREURISC, 1, 0);  
         me->aliases[0] = "bareurisc";  
         if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {  
                 me->next = first_machine_entry; first_machine_entry = me;  
         }  
   
6088          /*  Generic "bare" SPARC machine:  */          /*  Generic "bare" SPARC machine:  */
6089          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,
6090              MACHINE_BARESPARC, 1, 0);              MACHINE_BARESPARC, 1, 0);
# Line 4667  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 4683  void machine_init(void) Line 6117  void machine_init(void)
6117                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6118          }          }
6119    
6120            /*  Generic "bare" M68K machine:  */
6121            me = machine_entry_new("Generic \"bare\" M68K machine", ARCH_M68K,
6122                MACHINE_BAREM68K, 1, 0);
6123            me->aliases[0] = "barem68k";
6124            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
6125                    me->next = first_machine_entry; first_machine_entry = me;
6126            }
6127    
6128            /*  Generic "bare" IA64 machine:  */
6129            me = machine_entry_new("Generic \"bare\" IA64 machine", ARCH_IA64,
6130                MACHINE_BAREIA64, 1, 0);
6131            me->aliases[0] = "bareia64";
6132            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
6133                    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:  */          /*  Generic "bare" HPPA machine:  */
6145          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
6146              MACHINE_BAREHPPA, 1, 0);              MACHINE_BAREHPPA, 1, 0);
# Line 4691  void machine_init(void) Line 6149  void machine_init(void)
6149                  me->next = first_machine_entry; first_machine_entry = me;                  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 4707  void machine_init(void) Line 6173  void machine_init(void)
6173                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6174          }          }
6175    
6176            /*  Evaluation Boards (MALTA etc):  */
6177            me = machine_entry_new("Evaluation boards (evbmips)", ARCH_MIPS,
6178                MACHINE_EVBMIPS, 1, 3);
6179            me->aliases[0] = "evbmips";
6180            me->subtype[0] = machine_entry_subtype_new("Malta",
6181                MACHINE_EVBMIPS_MALTA, 1);
6182            me->subtype[0]->aliases[0] = "malta";
6183            me->subtype[1] = machine_entry_subtype_new("Malta (Big-Endian)",
6184                MACHINE_EVBMIPS_MALTA_BE, 1);
6185            me->subtype[1]->aliases[0] = "maltabe";
6186            me->subtype[2] = machine_entry_subtype_new("PB1000",
6187                MACHINE_EVBMIPS_PB1000, 1);
6188            me->subtype[2]->aliases[0] = "pb1000";
6189            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
6190                    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 4774  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 4838  void machine_init(void) Line 6338  void machine_init(void)
6338          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
6339                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6340          }          }
6341    
6342            /*  Alpha:  */
6343            me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6344            me->aliases[0] = "alpha";
6345            me->subtype[0] = machine_entry_subtype_new(
6346                "DEC 3000/300", ST_DEC_3000_300, 1);
6347            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) {
6352                    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.6  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26