/[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 2 by dpavlin, Mon Oct 8 16:17:48 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.406 2005/04/06 23:13:37 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"
 #include "arcbios_other.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 84  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 107  struct machine_entry { Line 118  struct machine_entry {
118          struct machine_entry_subtype **subtype;          struct machine_entry_subtype **subtype;
119  };  };
120    
121    
122    /*  See main.c:  */
123    extern int quiet_mode;
124    
125    
126  /*  This is initialized by machine_init():  */  /*  This is initialized by machine_init():  */
127  static struct machine_entry *first_machine_entry = NULL;  static struct machine_entry *first_machine_entry = NULL;
128    
# Line 133  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 144  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 167  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 195  int machine_name_to_type(char *stype, ch Line 219  int machine_name_to_type(char *stype, ch
219                                                          return 1;                                                          return 1;
220                                                  }                                                  }
221    
222                                  fatal("unknown subtype '%s' for emulation"                                  fatal("Unknown subtype '%s' for emulation"
223                                      " '%s'\n", ssubtype, stype);                                      " '%s'\n", ssubtype, stype);
224                                    if (!ssubtype[0])
225                                            fatal("(Maybe you forgot the -e"
226                                                " command line option?)\n");
227                                  exit(1);                                  exit(1);
228                          }                          }
229    
230                  me = me->next;                  me = me->next;
231          }          }
232    
233          fatal("machine_name_to_type(): unknown emulation type '%s' (", stype);          /*  Not found? Then just check ssubtype:  */
234          if (ssubtype == NULL)          me = first_machine_entry;
235                  fatal("no subtype)\n");          while (me != NULL) {
236          else                  if (me->n_subtypes == 0) {
237                  fatal("subtype '%s')\n", ssubtype);                          me = me->next;
238                            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    
         fatal("Use the -H command line option to get a list of available"  
             " types and subtypes.\n");  
275          return 0;          return 0;
276  }  }
277    
# Line 332  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 371  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 396  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 415  int store_16bit_word(struct cpu *cpu, ui Line 505  int store_16bit_word(struct cpu *cpu, ui
505   */   */
506  void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len)  void store_buf(struct cpu *cpu, uint64_t addr, char *s, size_t len)
507  {  {
508          if ((addr >> 32) == 0)          int psize = 1024;       /*  1024 256 64 16 4 1  */
509    
510            if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
511                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
         if ((addr & 7) == 0 && (((size_t)s) & 7) == 0) {  
                 while (len >= 8) {  
                         cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)s,  
                             8, MEM_WRITE, CACHE_DATA);  
                         addr += 8;  
                         s += 8;  
                         len -= 8;  
                 }  
         }  
512    
513          if ((addr & 3) == 0 && (((size_t)s) & 3) == 0) {          while (len != 0) {
514                  while (len >= 4) {                  if ((addr & (psize-1)) == 0) {
515                          cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)s,                          while (len >= psize) {
516                              4, MEM_WRITE, CACHE_DATA);                                  cpu->memory_rw(cpu, cpu->mem, addr,
517                          addr += 4;                                      (unsigned char *)s, psize, MEM_WRITE,
518                          s += 4;                                      CACHE_DATA);
519                          len -= 4;                                  addr += psize;
520                                    s += psize;
521                                    len -= psize;
522                            }
523                  }                  }
524                    psize >>= 2;
525          }          }
526    
527          while (len-- != 0)          while (len-- != 0)
# Line 473  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 488  uint32_t load_32bit_word(struct cpu *cpu Line 575  uint32_t load_32bit_word(struct cpu *cpu
575    
576    
577  /*  /*
578     *  load_16bit_word():
579     *
580     *  Helper function.  Prints a warning and returns 0, if the read failed.
581     *  Emulated byte order is taken into account.
582     */
583    uint16_t load_16bit_word(struct cpu *cpu, uint64_t addr)
584    {
585            unsigned char data[2];
586    
587            if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
588                    addr = (int64_t)(int32_t)addr;
589            cpu->memory_rw(cpu, cpu->mem,
590                addr, data, sizeof(data), MEM_READ, CACHE_DATA);
591    
592            if (cpu->byte_order == EMUL_LITTLE_ENDIAN) {
593                    int tmp = data[0]; data[0] = data[1]; data[1] = tmp;
594            }
595    
596            return (data[0] << 8) + data[1];
597    }
598    
599    
600    /*
601   *  store_64bit_word_in_host():   *  store_64bit_word_in_host():
602   *   *
603   *  Stores a 64-bit word in the _host's_ RAM.  Emulated byte order is taken   *  Stores a 64-bit word in the _host's_ RAM.  Emulated byte order is taken
# Line 571  void kn02_interrupt(struct machine *m, s Line 681  void kn02_interrupt(struct machine *m, s
681    
682          if (assrt) {          if (assrt) {
683                  /*  OR in the irq_nr into the CSR:  */                  /*  OR in the irq_nr into the CSR:  */
684                  m->kn02_csr->csr[0] |= irq_nr;                  m->md_int.kn02_csr->csr[0] |= irq_nr;
685          } else {          } else {
686                  /*  AND out the irq_nr from the CSR:  */                  /*  AND out the irq_nr from the CSR:  */
687                  m->kn02_csr->csr[0] &= ~irq_nr;                  m->md_int.kn02_csr->csr[0] &= ~irq_nr;
688          }          }
689    
690          current = m->kn02_csr->csr[0] & m->kn02_csr->csr[2];          current = m->md_int.kn02_csr->csr[0] & m->md_int.kn02_csr->csr[2];
691          if (current == 0)          if (current == 0)
692                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
693          else          else
# Line 596  void kmin_interrupt(struct machine *m, s Line 706  void kmin_interrupt(struct machine *m, s
706          /*  debug("kmin_interrupt(): irq_nr=%i assrt=%i\n", irq_nr, assrt);  */          /*  debug("kmin_interrupt(): irq_nr=%i assrt=%i\n", irq_nr, assrt);  */
707    
708          if (assrt)          if (assrt)
709                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr;                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr;
710          else          else
711                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr;                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr;
712    
713          if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]          if (m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]
714              & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10])              & m->md_int.dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10])
715                  cpu_interrupt(cpu, KMIN_INT_TC3);                  cpu_interrupt(cpu, KMIN_INT_TC3);
716          else          else
717                  cpu_interrupt_ack(cpu, KMIN_INT_TC3);                  cpu_interrupt_ack(cpu, KMIN_INT_TC3);
# Line 617  void kn03_interrupt(struct machine *m, s Line 727  void kn03_interrupt(struct machine *m, s
727          /*  debug("kn03_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);  */          /*  debug("kn03_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);  */
728    
729          if (assrt)          if (assrt)
730                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr;                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] |= irq_nr;
731          else          else
732                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr;                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10] &= ~irq_nr;
733    
734          if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]          if (m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]
735              & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10])              & m->md_int.dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START) / 0x10])
736                  cpu_interrupt(cpu, KN03_INT_ASIC);                  cpu_interrupt(cpu, KN03_INT_ASIC);
737          else          else
738                  cpu_interrupt_ack(cpu, KN03_INT_ASIC);                  cpu_interrupt_ack(cpu, KN03_INT_ASIC);
# Line 639  void maxine_interrupt(struct machine *m, Line 749  void maxine_interrupt(struct machine *m,
749          debug("maxine_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);          debug("maxine_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);
750    
751          if (assrt)          if (assrt)
752                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)
753                      / 0x10] |= irq_nr;                      / 0x10] |= irq_nr;
754          else          else
755                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)
756                      / 0x10] &= ~irq_nr;                      / 0x10] &= ~irq_nr;
757    
758          if (m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]          if (m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START) / 0x10]
759              & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START)              & m->md_int.dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START)
760              / 0x10])              / 0x10])
761                  cpu_interrupt(cpu, XINE_INT_TC3);                  cpu_interrupt(cpu, XINE_INT_TC3);
762          else          else
# Line 661  void kn230_interrupt(struct machine *m, Line 771  void kn230_interrupt(struct machine *m,
771  {  {
772          int r2 = 0;          int r2 = 0;
773    
774          m->kn230_csr->csr |= irq_nr;          m->md_int.kn230_csr->csr |= irq_nr;
775    
776          switch (irq_nr) {          switch (irq_nr) {
777          case KN230_CSR_INTR_SII:          case KN230_CSR_INTR_SII:
# Line 679  void kn230_interrupt(struct machine *m, Line 789  void kn230_interrupt(struct machine *m,
789    
790          if (assrt) {          if (assrt) {
791                  /*  OR in the irq_nr mask into the CSR:  */                  /*  OR in the irq_nr mask into the CSR:  */
792                  m->kn230_csr->csr |= irq_nr;                  m->md_int.kn230_csr->csr |= irq_nr;
793    
794                  /*  Assert MIPS interrupt 2 or 3:  */                  /*  Assert MIPS interrupt 2 or 3:  */
795                  cpu_interrupt(cpu, r2);                  cpu_interrupt(cpu, r2);
796          } else {          } else {
797                  /*  AND out the irq_nr mask from the CSR:  */                  /*  AND out the irq_nr mask from the CSR:  */
798                  m->kn230_csr->csr &= ~irq_nr;                  m->md_int.kn230_csr->csr &= ~irq_nr;
799    
800                  /*  If the CSR interrupt bits are all zero,                  /*  If the CSR interrupt bits are all zero,
801                      clear the bit in the cause register as well.  */                      clear the bit in the cause register as well.  */
802                  if (r2 == 2) {                  if (r2 == 2) {
803                          /*  irq 2:  */                          /*  irq 2:  */
804                          if ((m->kn230_csr->csr & (KN230_CSR_INTR_DZ0                          if ((m->md_int.kn230_csr->csr & (KN230_CSR_INTR_DZ0
805                              | KN230_CSR_INTR_OPT0 | KN230_CSR_INTR_OPT1)) == 0)                              | KN230_CSR_INTR_OPT0 | KN230_CSR_INTR_OPT1)) == 0)
806                                  cpu_interrupt_ack(cpu, r2);                                  cpu_interrupt_ack(cpu, r2);
807                  } else {                  } else {
808                          /*  irq 3:  */                          /*  irq 3:  */
809                          if ((m->kn230_csr->csr & (KN230_CSR_INTR_SII |                          if ((m->md_int.kn230_csr->csr & (KN230_CSR_INTR_SII |
810                              KN230_CSR_INTR_LANCE)) == 0)                              KN230_CSR_INTR_LANCE)) == 0)
811                                  cpu_interrupt_ack(cpu, r2);                                  cpu_interrupt_ack(cpu, r2);
812                  }                  }
# Line 730  void jazz_interrupt(struct machine *m, s Line 840  void jazz_interrupt(struct machine *m, s
840    
841          if (isa) {          if (isa) {
842                  if (assrt)                  if (assrt)
843                          m->jazz_data->isa_int_asserted |= irq;                          m->md_int.jazz_data->isa_int_asserted |= irq;
844                  else                  else
845                          m->jazz_data->isa_int_asserted &= ~irq;                          m->md_int.jazz_data->isa_int_asserted &= ~irq;
846          } else {          } else {
847                  if (assrt)                  if (assrt)
848                          m->jazz_data->int_asserted |= irq;                          m->md_int.jazz_data->int_asserted |= irq;
849                  else                  else
850                          m->jazz_data->int_asserted &= ~irq;                          m->md_int.jazz_data->int_asserted &= ~irq;
851          }          }
852    
853          /*  debug("   %08x %08x\n", m->jazz_data->int_asserted,          /*  debug("   %08x %08x\n", m->md_int.jazz_data->int_asserted,
854                  m->jazz_data->int_enable_mask);  */                  m->md_int.jazz_data->int_enable_mask);  */
855          /*  debug("   %08x %08x\n", m->jazz_data->isa_int_asserted,          /*  debug("   %08x %08x\n", m->md_int.jazz_data->isa_int_asserted,
856                  m->jazz_data->isa_int_enable_mask);  */                  m->md_int.jazz_data->isa_int_enable_mask);  */
857    
858          if (m->jazz_data->int_asserted /* & m->jazz_data->int_enable_mask  */          if (m->md_int.jazz_data->int_asserted
859              & ~0x8000 )              /* & m->md_int.jazz_data->int_enable_mask  */ & ~0x8000 )
860                  cpu_interrupt(cpu, 3);                  cpu_interrupt(cpu, 3);
861          else          else
862                  cpu_interrupt_ack(cpu, 3);                  cpu_interrupt_ack(cpu, 3);
863    
864          if (m->jazz_data->isa_int_asserted & m->jazz_data->isa_int_enable_mask)          if (m->md_int.jazz_data->isa_int_asserted &
865                m->md_int.jazz_data->isa_int_enable_mask)
866                  cpu_interrupt(cpu, 4);                  cpu_interrupt(cpu, 4);
867          else          else
868                  cpu_interrupt_ack(cpu, 4);                  cpu_interrupt_ack(cpu, 4);
869    
870          /*  TODO: this "15" (0x8000) is the timer... fix this?  */          /*  TODO: this "15" (0x8000) is the timer... fix this?  */
871          if (m->jazz_data->int_asserted & 0x8000)          if (m->md_int.jazz_data->int_asserted & 0x8000)
872                  cpu_interrupt(cpu, 6);                  cpu_interrupt(cpu, 6);
873          else          else
874                  cpu_interrupt_ack(cpu, 6);                  cpu_interrupt_ack(cpu, 6);
# Line 782  void vr41xx_interrupt(struct machine *m, Line 893  void vr41xx_interrupt(struct machine *m,
893                  giu_irq = irq_nr - 32;                  giu_irq = irq_nr - 32;
894    
895                  if (assrt)                  if (assrt)
896                          m->vr41xx_data->giuint |= (1 << giu_irq);                          m->md_int.vr41xx_data->giuint |= (1 << giu_irq);
897                  else                  else
898                          m->vr41xx_data->giuint &= ~(1 << giu_irq);                          m->md_int.vr41xx_data->giuint &= ~(1 << giu_irq);
899          }          }
900    
901          /*  TODO: This is wrong. What about GIU bit 8?  */          /*  TODO: This is wrong. What about GIU bit 8?  */
# Line 792  void vr41xx_interrupt(struct machine *m, Line 903  void vr41xx_interrupt(struct machine *m,
903          if (irq_nr != 8) {          if (irq_nr != 8) {
904                  /*  If any GIU bit is asserted, then assert the main                  /*  If any GIU bit is asserted, then assert the main
905                      GIU interrupt:  */                      GIU interrupt:  */
906                  if (m->vr41xx_data->giuint & m->vr41xx_data->giumask)                  if (m->md_int.vr41xx_data->giuint &
907                        m->md_int.vr41xx_data->giumask)
908                          vr41xx_interrupt(m, cpu, 8 + 8, 1);                          vr41xx_interrupt(m, cpu, 8 + 8, 1);
909                  else                  else
910                          vr41xx_interrupt(m, cpu, 8 + 8, 0);                          vr41xx_interrupt(m, cpu, 8 + 8, 0);
# Line 803  void vr41xx_interrupt(struct machine *m, Line 915  void vr41xx_interrupt(struct machine *m,
915    
916          if (irq_nr < 16) {          if (irq_nr < 16) {
917                  if (assrt)                  if (assrt)
918                          m->vr41xx_data->sysint1 |= (1 << irq_nr);                          m->md_int.vr41xx_data->sysint1 |= (1 << irq_nr);
919                  else                  else
920                          m->vr41xx_data->sysint1 &= ~(1 << irq_nr);                          m->md_int.vr41xx_data->sysint1 &= ~(1 << irq_nr);
921          } else if (irq_nr < 32) {          } else if (irq_nr < 32) {
922                  irq_nr -= 16;                  irq_nr -= 16;
923                  if (assrt)                  if (assrt)
924                          m->vr41xx_data->sysint2 |= (1 << irq_nr);                          m->md_int.vr41xx_data->sysint2 |= (1 << irq_nr);
925                  else                  else
926                          m->vr41xx_data->sysint2 &= ~(1 << irq_nr);                          m->md_int.vr41xx_data->sysint2 &= ~(1 << irq_nr);
927          }          }
928    
929          /*  TODO: Which hardware interrupt pin?  */          /*  TODO: Which hardware interrupt pin?  */
930    
931          /*  debug("    sysint1=%04x mask=%04x, sysint2=%04x mask=%04x\n",          /*  debug("    sysint1=%04x mask=%04x, sysint2=%04x mask=%04x\n",
932              m->vr41xx_data->sysint1, m->vr41xx_data->msysint1,              m->md_int.vr41xx_data->sysint1, m->md_int.vr41xx_data->msysint1,
933              m->vr41xx_data->sysint2, m->vr41xx_data->msysint2);  */              m->md_int.vr41xx_data->sysint2, m->md_int.vr41xx_data->msysint2); */
934    
935          if ((m->vr41xx_data->sysint1 & m->vr41xx_data->msysint1) |          if ((m->md_int.vr41xx_data->sysint1 & m->md_int.vr41xx_data->msysint1) |
936              (m->vr41xx_data->sysint2 & m->vr41xx_data->msysint2))              (m->md_int.vr41xx_data->sysint2 & m->md_int.vr41xx_data->msysint2))
937                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
938          else          else
939                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
# Line 830  void vr41xx_interrupt(struct machine *m, Line 942  void vr41xx_interrupt(struct machine *m,
942    
943  /*  /*
944   *  Playstation 2 interrupt routine:   *  Playstation 2 interrupt routine:
945     *
946     *  irq_nr =    8 + x           normal irq x
947     *              8 + 16 + y      dma irq y
948     *              8 + 32 + 0      sbus irq 0 (pcmcia)
949     *              8 + 32 + 1      sbus irq 1 (usb)
950   */   */
951  void ps2_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)  void ps2_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
952  {  {
953          irq_nr -= 8;          irq_nr -= 8;
954          debug("ps2_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);          debug("ps2_interrupt(): irq_nr=0x%x assrt=%i\n", irq_nr, assrt);
955    
956          if (assrt) {          if (irq_nr >= 32) {
957                  /*  OR into the INTR:  */                  int msk = 0;
958                  if (irq_nr < 0x10000)                  switch (irq_nr - 32) {
959                          m->ps2_data->intr |= irq_nr;                  case 0: /*  PCMCIA:  */
960                            msk = 0x100;
961                            break;
962                    case 1: /*  USB:  */
963                            msk = 0x400;
964                            break;
965                    default:
966                            fatal("ps2_interrupt(): bad irq_nr %i\n", irq_nr);
967                    }
968    
969                    if (assrt)
970                            m->md_int.ps2_data->sbus_smflg |= msk;
971                  else                  else
972                          m->ps2_data->dmac_reg[0x601] |= (irq_nr >> 16);                          m->md_int.ps2_data->sbus_smflg &= ~msk;
973    
974                  /*  Assert interrupt:   TODO: masks  */                  if (m->md_int.ps2_data->sbus_smflg != 0)
975                  if (irq_nr >= 0x10000)                          cpu_interrupt(cpu, 8 + 1);
976                          cpu_interrupt(cpu, 3);                  else
977                            cpu_interrupt_ack(cpu, 8 + 1);
978                    return;
979            }
980    
981            if (assrt) {
982                    /*  OR into the INTR:  */
983                    if (irq_nr < 16)
984                            m->md_int.ps2_data->intr |= (1 << irq_nr);
985                  else                  else
986                          cpu_interrupt(cpu, 2);                          m->md_int.ps2_data->dmac_reg[0x601] |=
987                                (1 << (irq_nr-16));
988          } else {          } else {
989                  /*  AND out of the INTR:  */                  /*  AND out of the INTR:  */
990                  if (irq_nr < 0x10000)                  if (irq_nr < 16)
991                          m->ps2_data->intr &= ~irq_nr;                          m->md_int.ps2_data->intr &= ~(1 << irq_nr);
992                  else                  else
993                          m->ps2_data->dmac_reg[0x601] &= ~(irq_nr >> 16);                          m->md_int.ps2_data->dmac_reg[0x601] &=
994                                ~(1 << (irq_nr-16));
                 /*  TODO: masks  */  
                 if ((m->ps2_data->intr & 0xffff) == 0)  
                         cpu_interrupt_ack(cpu, 2);  
                 if ((m->ps2_data->dmac_reg[0x601] & 0xffff) == 0)  
                         cpu_interrupt_ack(cpu, 3);  
995          }          }
996    
997            /*  TODO: Hm? How about the mask?  */
998            if (m->md_int.ps2_data->intr /*  & m->md_int.ps2_data->imask */ )
999                    cpu_interrupt(cpu, 2);
1000            else
1001                    cpu_interrupt_ack(cpu, 2);
1002    
1003            /*  TODO: mask?  */
1004            if (m->md_int.ps2_data->dmac_reg[0x601] & 0xffff)
1005                    cpu_interrupt(cpu, 3);
1006            else
1007                    cpu_interrupt_ack(cpu, 3);
1008  }  }
1009    
1010    
# Line 889  void sgi_ip22_interrupt(struct machine * Line 1033  void sgi_ip22_interrupt(struct machine *
1033                  int ms = irq_nr / 64;                  int ms = irq_nr / 64;
1034                  uint32_t new = 1 << ms;                  uint32_t new = 1 << ms;
1035                  if (assrt)                  if (assrt)
1036                          m->sgi_ip22_data->reg[4] |= new;                          m->md_int.sgi_ip22_data->reg[4] |= new;
1037                  else                  else
1038                          m->sgi_ip22_data->reg[4] &= ~new;                          m->md_int.sgi_ip22_data->reg[4] &= ~new;
1039                  /*  TODO: is this enough?  */                  /*  TODO: is this enough?  */
1040                  irq_nr &= 63;                  irq_nr &= 63;
1041          }          }
1042    
1043          if (irq_nr < 32) {          if (irq_nr < 32) {
1044                  if (assrt)                  if (assrt)
1045                          m->sgi_ip22_data->reg[0] |= newmask;                          m->md_int.sgi_ip22_data->reg[0] |= newmask;
1046                  else                  else
1047                          m->sgi_ip22_data->reg[0] &= ~newmask;                          m->md_int.sgi_ip22_data->reg[0] &= ~newmask;
1048          } else {          } else {
1049                  if (assrt)                  if (assrt)
1050                          m->sgi_ip22_data->reg[2] |= newmask;                          m->md_int.sgi_ip22_data->reg[2] |= newmask;
1051                  else                  else
1052                          m->sgi_ip22_data->reg[2] &= ~newmask;                          m->md_int.sgi_ip22_data->reg[2] &= ~newmask;
1053          }          }
1054    
1055          /*  Read stat and mask for local0:  */          /*  Read stat and mask for local0:  */
1056          stat = m->sgi_ip22_data->reg[0];          stat = m->md_int.sgi_ip22_data->reg[0];
1057          mask = m->sgi_ip22_data->reg[1];          mask = m->md_int.sgi_ip22_data->reg[1];
1058          if ((stat & mask) == 0)          if ((stat & mask) == 0)
1059                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
1060          else          else
1061                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1062    
1063          /*  Read stat and mask for local1:  */          /*  Read stat and mask for local1:  */
1064          stat = m->sgi_ip22_data->reg[2];          stat = m->md_int.sgi_ip22_data->reg[2];
1065          mask = m->sgi_ip22_data->reg[3];          mask = m->md_int.sgi_ip22_data->reg[3];
1066          if ((stat & mask) == 0)          if ((stat & mask) == 0)
1067                  cpu_interrupt_ack(cpu, 3);                  cpu_interrupt_ack(cpu, 3);
1068          else          else
# Line 950  void sgi_ip30_interrupt(struct machine * Line 1094  void sgi_ip30_interrupt(struct machine *
1094          newmask = (int64_t)1 << irq_nr;          newmask = (int64_t)1 << irq_nr;
1095    
1096          if (assrt)          if (assrt)
1097                  m->sgi_ip30_data->isr |= newmask;                  m->md_int.sgi_ip30_data->isr |= newmask;
1098          else          else
1099                  m->sgi_ip30_data->isr &= ~newmask;                  m->md_int.sgi_ip30_data->isr &= ~newmask;
1100    
1101  just_assert_and_such:  just_assert_and_such:
1102    
# Line 962  just_assert_and_such: Line 1106  just_assert_and_such:
1106          cpu_interrupt_ack(cpu, 5);          cpu_interrupt_ack(cpu, 5);
1107          cpu_interrupt_ack(cpu, 6);          cpu_interrupt_ack(cpu, 6);
1108    
1109          stat = m->sgi_ip30_data->isr;          stat = m->md_int.sgi_ip30_data->isr;
1110          mask = m->sgi_ip30_data->imask0;          mask = m->md_int.sgi_ip30_data->imask0;
1111    
1112          if ((stat & mask) & 0x000000000000ffffULL)          if ((stat & mask) & 0x000000000000ffffULL)
1113                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
# Line 994  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 1015  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->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->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 1043  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->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->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->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 1084  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->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->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 1101  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 1134  void au1x00_interrupt(struct machine *m, Line 1275  void au1x00_interrupt(struct machine *m,
1275                  ms = 1 << (irq_nr & 31);                  ms = 1 << (irq_nr & 31);
1276    
1277                  if (assrt)                  if (assrt)
1278                          m->au1x00_ic_data->request0_int |= ms;                          m->md_int.au1x00_ic_data->request0_int |= ms;
1279                  else                  else
1280                          m->au1x00_ic_data->request0_int &= ~ms;                          m->md_int.au1x00_ic_data->request0_int &= ~ms;
1281    
1282                  /*  TODO: Controller 1  */                  /*  TODO: Controller 1  */
1283          }          }
1284    
1285          if ((m->au1x00_ic_data->request0_int &          if ((m->md_int.au1x00_ic_data->request0_int &
1286              m->au1x00_ic_data->mask) != 0)              m->md_int.au1x00_ic_data->mask) != 0)
1287                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1288          else          else
1289                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
# Line 1153  void au1x00_interrupt(struct machine *m, Line 1294  void au1x00_interrupt(struct machine *m,
1294  }  }
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:
1379     *
1380     *  (irq_nr = 16 can be used to just reassert/deassert interrupts.)
1381     */
1382    void x86_pc_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
1383    {
1384            int mask = 1 << (irq_nr & 7);
1385    
1386            if (irq_nr < 8) {
1387                    if (assrt)
1388                            m->isa_pic_data.pic1->irr |= mask;
1389                    else
1390                            m->isa_pic_data.pic1->irr &= ~mask;
1391            } else if (irq_nr < 16) {
1392                    if (m->isa_pic_data.pic2 == NULL) {
1393                            fatal("x86_pc_interrupt(): pic2 used (irq_nr = %i), "
1394                                "but we are emulating an XT?\n", irq_nr);
1395                            return;
1396                    }
1397                    if (assrt)
1398                            m->isa_pic_data.pic2->irr |= mask;
1399                    else
1400                            m->isa_pic_data.pic2->irr &= ~mask;
1401            }
1402    
1403            if (m->isa_pic_data.pic2 != NULL) {
1404                    /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1405                    /*  (TODO: don't hardcode this here)  */
1406                    if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1407                            m->isa_pic_data.pic1->irr |= 0x04;
1408                    else
1409                            m->isa_pic_data.pic1->irr &= ~0x04;
1410            }
1411    
1412            /*  Now, PIC1:  */
1413            if (m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier)
1414                    cpu->cd.x86.interrupt_asserted = 1;
1415            else
1416                    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 1172  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 1187  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:  */
         struct arcbios_spb arcbios_spb;  
         struct arcbios_spb_64 arcbios_spb_64;  
         struct arcbios_sysid arcbios_sysid;  
         struct arcbios_dsp_stat arcbios_dsp_stat;  
         uint64_t mem_base, mem_count;  
         uint64_t system = 0;  
1578          uint64_t sgi_ram_offset = 0;          uint64_t sgi_ram_offset = 0;
         uint64_t arc_reserved;  
1579          int arc_wordlen = sizeof(uint32_t);          int arc_wordlen = sizeof(uint32_t);
         char *short_machine_name = NULL;  
1580          char *eaddr_string = "eaddr=10:20:30:40:50:60";   /*  nonsense  */          char *eaddr_string = "eaddr=10:20:30:40:50:60";   /*  nonsense  */
1581          unsigned char macaddr[6];          unsigned char macaddr[6];
1582    
1583          /*  Generic bootstring stuff:  */          /*  Generic bootstring stuff:  */
1584          int bootdev_id = diskimage_bootdev(machine);          int bootdev_type = 0;
1585            int bootdev_id;
1586          char *bootstr = NULL;          char *bootstr = NULL;
1587          char *bootarg = NULL;          char *bootarg = NULL;
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];
1598    
1599    
1600            bootdev_id = diskimage_bootdev(machine, &bootdev_type);
1601    
1602          mem = cpu->mem;          mem = cpu->mem;
1603          machine->machine_name = NULL;          machine->machine_name = NULL;
1604    
# Line 1233  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 1249  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 1261  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 1317  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 1407  void machine_setup(struct machine *machi Line 1805  void machine_setup(struct machine *machi
1805                          dev_mc146818_init(machine, mem,                          dev_mc146818_init(machine, mem,
1806                              KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1);                              KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1);
1807    
1808                          machine->kn02_csr =                          machine->md_int.kn02_csr =
1809                              dev_kn02_init(cpu, mem, KN02_SYS_CSR);                              dev_kn02_init(cpu, mem, KN02_SYS_CSR);
1810    
1811                          framebuffer_console_name = "osconsole=0,7";                          framebuffer_console_name = "osconsole=0,7";
# Line 1441  void machine_setup(struct machine *machi Line 1839  void machine_setup(struct machine *machi
1839                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1c300000) slot 12                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1c300000) slot 12
1840                           *  dma for asc0                                                (0x1c380000) slot 14                           *  dma for asc0                                                (0x1c380000) slot 14
1841                           */                           */
1842                          machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0);                          machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0);
1843                          dev_le_init(machine, mem, 0x1c0c0000, 0, 0, KMIN_INTR_LANCE +8, 4*65536);                          dev_le_init(machine, mem, 0x1c0c0000, 0, 0, KMIN_INTR_LANCE +8, 4*65536);
1844                          dev_scc_init(machine, mem, 0x1c100000, KMIN_INTR_SCC_0 +8, machine->use_x11, 0, 1);                          dev_scc_init(machine, mem, 0x1c100000, KMIN_INTR_SCC_0 +8, machine->use_x11, 0, 1);
1845                          dev_scc_init(machine, mem, 0x1c180000, KMIN_INTR_SCC_1 +8, machine->use_x11, 1, 1);                          dev_scc_init(machine, mem, 0x1c180000, KMIN_INTR_SCC_1 +8, machine->use_x11, 1, 1);
# Line 1507  void machine_setup(struct machine *machi Line 1905  void machine_setup(struct machine *machi
1905                           *  mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000)                           *  mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000)
1906                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000)                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000)
1907                           */                           */
1908                          machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1f800000, 0);                          machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1f800000, 0);
1909    
1910                          dev_le_init(machine, mem, KN03_SYS_LANCE, 0, 0, KN03_INTR_LANCE +8, 4*65536);                          dev_le_init(machine, mem, KN03_SYS_LANCE, 0, 0, KN03_INTR_LANCE +8, 4*65536);
1911    
1912                          machine->dec_ioasic_data->dma_func[3] = dev_scc_dma_func;                          machine->md_int.dec_ioasic_data->dma_func[3] = dev_scc_dma_func;
1913                          machine->dec_ioasic_data->dma_func_extra[2] = dev_scc_init(machine, mem, KN03_SYS_SCC_0, KN03_INTR_SCC_0 +8, machine->use_x11, 0, 1);                          machine->md_int.dec_ioasic_data->dma_func_extra[2] = dev_scc_init(machine, mem, KN03_SYS_SCC_0, KN03_INTR_SCC_0 +8, machine->use_x11, 0, 1);
1914                          machine->dec_ioasic_data->dma_func[2] = dev_scc_dma_func;                          machine->md_int.dec_ioasic_data->dma_func[2] = dev_scc_dma_func;
1915                          machine->dec_ioasic_data->dma_func_extra[3] = dev_scc_init(machine, mem, KN03_SYS_SCC_1, KN03_INTR_SCC_1 +8, machine->use_x11, 1, 1);                          machine->md_int.dec_ioasic_data->dma_func_extra[3] = dev_scc_init(machine, mem, KN03_SYS_SCC_1, KN03_INTR_SCC_1 +8, machine->use_x11, 1, 1);
1916    
1917                          dev_mc146818_init(machine, mem, KN03_SYS_CLOCK, KN03_INT_RTC, MC146818_DEC, 1);                          dev_mc146818_init(machine, mem, KN03_SYS_CLOCK, KN03_INT_RTC, MC146818_DEC, 1);
1918                          dev_asc_init(machine, mem, KN03_SYS_SCSI,                          dev_asc_init(machine, mem, KN03_SYS_SCSI,
# Line 1573  void machine_setup(struct machine *machi Line 1971  void machine_setup(struct machine *machi
1971                           *  Clock uses interrupt 3 (shared with XMI?).                           *  Clock uses interrupt 3 (shared with XMI?).
1972                           */                           */
1973    
1974                          machine->dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000);                          machine->md_int.dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000);
1975                          dev_decbi_init(mem, 0x10000000);                          dev_decbi_init(mem, 0x10000000);
1976                          dev_ssc_init(machine, mem, 0x10140000, 2, machine->use_x11, &machine->dec5800_csr->csr);                          dev_ssc_init(machine, mem, 0x10140000, 2, machine->use_x11, &machine->md_int.dec5800_csr->csr);
1977                          dev_decxmi_init(mem, 0x11800000);                          dev_decxmi_init(mem, 0x11800000);
1978                          dev_deccca_init(mem, DEC_DECCCA_BASEADDR);                          dev_deccca_init(mem, DEC_DECCCA_BASEADDR);
1979    
# Line 1644  void machine_setup(struct machine *machi Line 2042  void machine_setup(struct machine *machi
2042                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7         (0x1c300000)                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7         (0x1c300000)
2043                           *  xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer     (0xa000000)                           *  xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer     (0xa000000)
2044                           */                           */
2045                          machine->dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0);                          machine->md_int.dec_ioasic_data = dev_dec_ioasic_init(cpu, mem, 0x1c000000, 0);
2046    
2047                          /*  TURBOchannel slots (0 and 1):  */                          /*  TURBOchannel slots (0 and 1):  */
2048                          dev_turbochannel_init(machine, mem, 0,                          dev_turbochannel_init(machine, mem, 0,
# Line 1749  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->kn230_csr = device_add(machine, tmpstr);                          machine->md_int.kn230_csr = device_add(machine, tmpstr);
2153    
2154                          serial_console_name = "osconsole=0";                          serial_console_name = "osconsole=0";
2155                          break;                          break;
# Line 1762  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);
                 /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */  
                 for (i=0; i<100; i++) {  
                         store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,  
                             0x03e00008);        /*  return  */  
                         store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,  
                             0x00000000);        /*  nop  */  
                 }  
2174    
2175                  /*                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2176                   *  According to dec_prom.h from NetBSD:                          for (i=0; i<100; i++) {
2177                   *                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2178                   *  "Programs loaded by the new PROMs pass the following arguments:                                      0x03e00008);        /*  return  */
2179                   *      a0      argc                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2180                   *      a1      argv                                      0x00000000);        /*  nop  */
2181                   *      a2      DEC_PROM_MAGIC                          }
                  *      a3      The callback vector defined below"  
                  *  
                  *  So we try to emulate a PROM, even though no such thing has been  
                  *  loaded.  
                  */  
2182    
2183                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          /*
2184                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                           *  According to dec_prom.h from NetBSD:
2185                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                           *
2186                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                           *  "Programs loaded by the new PROMs pass the following arguments:
2187                             *      a0      argc
2188                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                           *      a1      argv
2189                      BOOTINFO_MAGIC);                           *      a2      DEC_PROM_MAGIC
2190                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                           *      a3      The callback vector defined below"
2191                      BOOTINFO_ADDR);                           *
2192                             *  So we try to emulate a PROM, even though no such thing has been
2193                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                           *  loaded.
2194                      (DEC_PROM_INITIAL_ARGV + 0x10));                           */
                 store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,  
                     (DEC_PROM_INITIAL_ARGV + 0x70));  
                 store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,  
                     (DEC_PROM_INITIAL_ARGV + 0xe0));  
                 store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);  
2195    
2196                  /*                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2197                   *  NetBSD and Ultrix expect the boot args to be like this:                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2198                   *                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2199                   *      "boot" "bootdev" [args?]                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2200                   *  
2201                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2202                   *  3100/2100 (although that crashes Ultrix :-/), and                              BOOTINFO_MAGIC);
2203                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2204                   *  slot number of the boot device.                              BOOTINFO_ADDR);
2205                   *  
2206                   *  'rz' for disks, 'tz' for tapes.                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2207                   *                              (DEC_PROM_INITIAL_ARGV + 0x10));
2208                   *  TODO:  Make this nicer.                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2209                   */                              (DEC_PROM_INITIAL_ARGV + 0x70));
2210                  {                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2211                          char bootpath[200];                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2212                            store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2213    
2214                            /*
2215                             *  NetBSD and Ultrix expect the boot args to be like this:
2216                             *
2217                             *      "boot" "bootdev" [args?]
2218                             *
2219                             *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2220                             *  3100/2100 (although that crashes Ultrix :-/), and
2221                             *  "5/rz0a/netbsd" for all others.  The number '5' is the
2222                             *  slot number of the boot device.
2223                             *
2224                             *  'rz' for disks, 'tz' for tapes.
2225                             *
2226                             *  TODO:  Make this nicer.
2227                             */
2228                            {
2229                            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:  */
2243                                  bootpath[0] = '0' + boot_scsi_boardnumber;                                  bootpath[0] = '0' + boot_scsi_boardnumber;
2244                                  if (diskimage_is_a_tape(machine, bootdev_id))                                  if (diskimage_is_a_tape(machine, bootdev_id,
2245                                        bootdev_type))
2246                                          bootpath[2] = 't';                                          bootpath[2] = 't';
2247                                  bootpath[4] = '0' + bootdev_id;                                  bootpath[4] = '0' + bootdev_id;
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 1974  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                  machine->main_console_handle = dev_ns16550_init(machine, mem,  
2405                      0x1c800000, 5, 1, 1, "serial console");                  machine->main_console_handle = (size_t)
2406                        device_add(machine, "ns16550 irq=5 addr=0x1c800000 name2=tty0 in_use=1");
2407    
2408                    /*  TODO: bus_isa() ?  */
2409    
2410    #if 0
2411                    device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0");
2412    #endif
2413    
2414                  /*                  /*
2415                   *  According to NetBSD/cobalt:                   *  According to NetBSD/cobalt:
# Line 1990  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 2038  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                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4131);  
2474                            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                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);  
2502                            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->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->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->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->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->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;
2620    
2621                          /*  TODO: Hm... irq 17 according to linux, but                          /*  TODO: Hm... irq 17 according to linux, but
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->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->vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
   
                 /*  NetBSD/hpcmips and possibly others expects the following:  */  
2684    
2685                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */                  if (machine->prom_emulation) {
2686                  cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576                          /*  NetBSD/hpcmips and possibly others expects the following:  */
                     + 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);  
2687    
2688                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2689                            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                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  if (!machine->use_x11)
2715                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2716                                    tmp[tmplen-1] = '\0';
                         snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"  
                             "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");  
                         tmp[tmplen-1] = '\0';  
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';  
2723    
2724                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  bootarg = tmp;
2725                            } else if (machine->boot_string_argument[0]) {
2726                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2727    
2728                          bootarg = tmp;                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2729                  } else if (machine->boot_string_argument[0]) {                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
                         cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */  
2730    
2731                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2732                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                      machine->boot_string_argument);
2733    
2734                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,                                  bootarg = machine->boot_string_argument;
2735                              machine->boot_string_argument);                          }
   
                         bootarg = machine->boot_string_argument;  
                 }  
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 2384  void machine_setup(struct machine *machi Line 2783  void machine_setup(struct machine *machi
2783                   *      ohci0: OHCI version 1.0                   *      ohci0: OHCI version 1.0
2784                   */                   */
2785    
2786                    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                  machine->ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);                  device_add(machine, "ps2_ether addr=0x14001000");
2789                  dev_ps2_ohci_init(cpu, mem, 0x1f801600);                  dev_ram_init(machine, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0); /*  TODO: how much?  */
2790                  dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0);     /*  TODO: how much?  */                  /*  irq = 8 + 32 + 1 (SBUS/USB)  */
2791                    device_add(machine, "ohci addr=0x1f801600 irq=41");
2792    
2793                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2794    
2795                  add_symbol_name(&machine->symbol_context,                  /*  Set the Harddisk controller present flag, if either
2796                      PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0);                      disk 0 or 1 is present:  */
2797                  store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2798                  store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2799                            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);
2802                    }
2803    
2804  #if 0                  if (machine->prom_emulation) {
2805                  /*  Harddisk controller present flag:  */                          int tmplen = 1000;
2806                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                          char *tmp = malloc(tmplen);
2807                  dev_ps2_spd_init(machine, mem, 0x14000000);                          time_t timet;
2808  #endif                          struct tm *tm_ptr;
2809    
2810                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                          add_symbol_name(&machine->symbol_context,
2811                  bootstr = "root=/dev/hda1 crtmode=vesa0,60";                              PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2812                  store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          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) {
2817                                    fprintf(stderr, "out of memory\n");
2818                                    exit(1);
2819                            }
2820    
2821                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          strlcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60", tmplen);
2822                  {  
2823                          time_t timet;                          if (machine->boot_string_argument[0])
2824                          struct tm *tmp;                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),
2825                                        " %s", machine->boot_string_argument);
2826                            tmp[tmplen-1] = '\0';
2827    
2828                            bootstr = tmp;
2829                            store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
2830    
2831                            /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
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, 3);                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);
2846                    }
                 /*  TODO:  Is this necessary?  */  
                 cpu->cd.mips.gpr[MIPS_GPR_SP] = 0x80007f00;  
2847    
2848                  break;                  break;
2849    
# Line 2441  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);
2864                  }                  }
                 short_machine_name = malloc(500);  
                 if (short_machine_name == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
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(short_machine_name, "SGI-IP%i", machine->machine_subtype);                          snprintf(machine->machine_name, MACHINE_NAME_MAXBUF,
2869                          sprintf(machine->machine_name, "SGI-IP%i", machine->machine_subtype);                              "SGI-IP%i", machine->machine_subtype);
   
                         /*  Super-special case for IP24:  */  
                         if (machine->machine_subtype == 24)  
                                 sprintf(short_machine_name, "SGI-IP22");  
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(short_machine_name, "ARC");                          snprintf(machine->machine_name,
2890                          sprintf(machine->machine_name, "ARC");                              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 2493  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 2513  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 2533  void machine_setup(struct machine *machi Line 2949  void machine_setup(struct machine *machi
2949                                   */                                   */
2950    
2951                                  /*  int0 at mainbus0 addr 0x1fb801c0  */                                  /*  int0 at mainbus0 addr 0x1fb801c0  */
2952                                  machine->sgi_ip20_data = dev_sgi_ip20_init(cpu, mem, DEV_SGI_IP20_BASE);                                  machine->md_int.sgi_ip20_data = dev_sgi_ip20_init(cpu, mem, DEV_SGI_IP20_BASE);
2953    
2954                                  /*  imc0 at mainbus0 addr 0x1fa00000: revision 0:  TODO (or in dev_sgi_ip20?)  */                                  /*  imc0 at mainbus0 addr 0x1fa00000: revision 0:  TODO (or in dev_sgi_ip20?)  */
2955    
# Line 2558  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 2568  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                                          machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);                                              " (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);
2992                                  } else {                                  } else {
2993                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Guiness)");                                          strlcat(machine->machine_name,
2994                                          machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);                                              " (Indy, Indigo2, Challenge S; Guiness)",
2995                                                MACHINE_NAME_MAXBUF);
2996                                            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 2615  Why is this here? TODO Line 3036  Why is this here? TODO
3036    
3037                                  /*  Not supported by NetBSD 1.6.2, but by 2.0_BETA:  */                                  /*  Not supported by NetBSD 1.6.2, but by 2.0_BETA:  */
3038                                  j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,                                  j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,
3039                                      0, 0, machine->use_x11);  /*  TODO: irq numbers  */                                      0, 0, machine->use_x11, 0);  /*  TODO: irq numbers  */
3040    
3041                                  if (machine->use_x11)                                  if (machine->use_x11)
3042                                          machine->main_console_handle = j;                                          machine->main_console_handle = j;
# Line 2644  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 2665  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 2684  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 2694  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->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 2718  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->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  */
3175                                  dev_sgi_gbe_init(machine, mem, 0x16000000);     /*  gbe?  framebuffer?  */                                  dev_sgi_gbe_init(machine, mem, 0x16000000);     /*  gbe?  framebuffer?  */
3176    
# Line 2766  Why is this here? TODO Line 3197  Why is this here? TODO
3197                                   *        1f3a0000        mcclock0                                   *        1f3a0000        mcclock0
3198                                   */                                   */
3199    
3200                                  machine->mace_data = dev_mace_init(mem, 0x1f310000, 2);                                  machine->md_int.ip32.mace_data = dev_mace_init(mem, 0x1f310000, 2);
3201                                  machine->md_interrupt = sgi_ip32_interrupt;                                  machine->md_interrupt = sgi_ip32_interrupt;
3202    
3203                                  /*                                  /*
# Line 2783  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);  
                                                         /*  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 2826  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  #if 1  
3265                                  bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr);                                  /*  TODO: make this nicer  */
3266  #endif                                  if (diskimage_exist(machine, 0, DISKIMAGE_SCSI) ||
3267                                  /*  bus_pci_add(machine, pci_data, mem, 0, 2, 0, pci_ahc_init, pci_ahc_rr);  */                                      diskimage_exist(machine, 1, DISKIMAGE_SCSI) ||
3268                                        diskimage_exist(machine, 2, DISKIMAGE_SCSI) ||
3269                                        diskimage_exist(machine, 3, DISKIMAGE_SCSI) ||
3270                                        diskimage_exist(machine, 4, DISKIMAGE_SCSI) ||
3271                                        diskimage_exist(machine, 5, DISKIMAGE_SCSI) ||
3272                                        diskimage_exist(machine, 6, DISKIMAGE_SCSI) ||
3273                                        diskimage_exist(machine, 7, DISKIMAGE_SCSI))
3274                                            bus_pci_add(machine, pci_data, mem, 0, 1, 0, "ahc");
3275    
3276                                    /*  TODO: second ahc  */
3277                                    /*  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 2842  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 2869  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 2886  Why is this here? TODO Line 3336  Why is this here? TODO
3336    
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);                                  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 2905  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 2929  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 2985  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");
3450                                          exit(1);                                          exit(1);
3451                                  }                                  }
3452    
3453                                  machine->jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3454                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
3455                                  machine->md_interrupt = jazz_interrupt;                                  machine->md_interrupt = jazz_interrupt;
3456    
3457                                    i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3458                                        PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3459    
3460                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3461                                    j = (size_t)device_add(machine, tmpstr);
3462                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3463                                    device_add(machine, tmpstr);
3464    
3465                                    if (machine->use_x11)
3466                                            machine->main_console_handle = i;
3467                                    else
3468                                            machine->main_console_handle = j;
3469    
3470                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3471                                  case MACHINE_ARC_JAZZ_PICA:                                  case MACHINE_ARC_JAZZ_PICA:
3472                                          dev_vga_init(machine, mem,                                          if (machine->use_x11) {
3473                                              0x400b8000ULL, 0x600003c0ULL,                                                  dev_vga_init(machine, mem,
3474                                              ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);                                                      0x400a0000ULL, 0x600003c0ULL,
3475                                          arcbios_console_init(cpu, 0x400b8000ULL,                                                      machine->machine_name);
3476                                              0x600003c0ULL, ARC_CONSOLE_MAX_X,                                                  arcbios_console_init(machine,
3477                                              ARC_CONSOLE_MAX_Y);                                                      0x400b8000ULL, 0x600003c0ULL);
3478                                            }
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 3026  Why is this here? TODO Line 3495  Why is this here? TODO
3495    
3496                                  dev_asc_init(machine, mem,                                  dev_asc_init(machine, mem,
3497                                      0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA,                                      0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA,
3498                                      dev_jazz_dma_controller, machine->jazz_data);                                      dev_jazz_dma_controller,
3499                                        machine->md_int.jazz_data);
3500    
3501                                  device_add(machine, "fdc addr=0x80003000, irq=0");                                  device_add(machine, "fdc addr=0x80003000, irq=0");
3502    
3503                                  dev_mc146818_init(machine, mem,                                  dev_mc146818_init(machine, mem,
3504                                      0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);                                      0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);
3505    
                                 i = dev_pckbc_init(machine, mem, 0x80005000ULL,  
                                     PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11);  
   
                                 j = dev_ns16550_init(machine, mem,  
                                     0x80006000ULL, 8 + 8, 1,  
                                     machine->use_x11? 0 : 1, "serial 0");  
                                 dev_ns16550_init(machine, mem,  
                                     0x80007000ULL, 8 + 9, 1, 0, "serial 1");  
   
                                 if (machine->use_x11)  
                                         machine->main_console_handle = i;  
                                 else  
                                         machine->main_console_handle = j;  
   
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 3064  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->jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3528                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
3529                                  machine->md_interrupt = jazz_interrupt;                                  machine->md_interrupt = jazz_interrupt;
3530    
# Line 3076  Not yet. Line 3534  Not yet.
3534                                  i = 0;          /*  TODO: Yuck!  */                                  i = 0;          /*  TODO: Yuck!  */
3535  #if 0  #if 0
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);                                      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 3102  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                                  dev_vga_init(machine, mem, 0x1000b8000ULL, 0x9000003c0ULL,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3567                                      ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);                                  i = (size_t)device_add(machine, tmpstr);
3568                                    device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0 name2=tty1");
3569                                  arcbios_console_init(cpu, 0x1000b8000ULL,                                  device_add(machine, "ns16550 irq=0 addr=0x9000003e8 in_use=0 name2=tty2");
3570                                      0x9000003c0ULL, ARC_CONSOLE_MAX_X,                                  device_add(machine, "ns16550 irq=0 addr=0x9000002e8 in_use=0 name2=tty3");
                                     ARC_CONSOLE_MAX_Y);  
   
                                 i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");  
                                 dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1");  
                                 dev_ns16550_init(machine, mem, 0x9000003e8ULL, 0, 1, 0, "serial 2");  
                                 dev_ns16550_init(machine, mem, 0x9000002e8ULL, 0, 1, 0, "serial 3");  
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,
3582                                      PCKBC_8042, 0, 0, machine->use_x11);                                      PCKBC_8042, 0, 0, machine->use_x11, 0);
3583    
3584                                  if (machine->use_x11)                                  if (machine->use_x11)
3585                                          machine->main_console_handle = j;                                          machine->main_console_handle = j;
3586                                  else                                  else
3587                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3588    
3589                                    if (machine->use_x11) {
3590                                            dev_vga_init(machine, mem, 0x1000a0000ULL,
3591                                                0x9000003c0ULL, machine->machine_name);
3592    
3593                                            arcbios_console_init(machine,
3594                                                0x1000b8000ULL, 0x9000003c0ULL);
3595                                    }
3596                                  break;                                  break;
3597    
3598                          default:                          default:
# Line 3141  Not yet. Line 3602  Not yet.
3602                          }                          }
3603                  }                  }
3604    
   
                 if (!machine->prom_emulation)  
                         goto no_arc_prom_emulation;     /*  TODO: ugly  */  
   
   
3605                  /*                  /*
3606                   *  This is important:  :-)                   *  This is important:  :-)
3607                   *                   *
3608                   *  TODO:  There should not be any use of                   *  TODO:  There should not be any use of ARCBIOS before this
3609                   *  ARCBIOS before this statement.                   *  point.
3610                   */                   */
                 if (arc_wordlen == sizeof(uint64_t))  
                         arcbios_set_64bit_mode(1);  
3611    
3612                  if (machine->physical_ram_in_mb < 16)                  if (machine->prom_emulation) {
3613                          fprintf(stderr, "WARNING! The ARC platform specification doesn't allow less than 16 MB of RAM. Continuing anyway.\n");                          arcbios_init(machine, arc_wordlen == sizeof(uint64_t),
3614                                sgi_ram_offset);
3615    
3616                  arcbios_set_default_exception_handler(cpu);                          /*
3617                             *  TODO: How to build the component tree intermixed with
3618                             *  the rest of device initialization?
3619                             */
3620    
3621                  memset(&arcbios_sysid, 0, sizeof(arcbios_sysid));                          /*
3622                  if (machine->machine_type == MACHINE_SGI) {                           *  Boot string in ARC format:
3623                          /*  Vendor ID, max 8 chars:  */                           *
3624                          strncpy(arcbios_sysid.VendorId,  "SGI", 3);                           *  TODO: How about floppies? multi()disk()fdisk()
3625                          switch (machine->machine_subtype) {                           *        Is tftp() good for netbooting?
3626                          case 22:                           */
3627                                  strncpy(arcbios_sysid.ProductId,                          init_bootpath = malloc(500);
3628                                      "87654321", 8);     /*  some kind of ID?  */                          if (init_bootpath == NULL) {
3629                                  break;                                  fprintf(stderr, "out of mem, bootpath\n");
                         case 32:  
                                 strncpy(arcbios_sysid.ProductId, "8", 1);  
                                     /*  6 or 8 (?)  */  
                                 break;  
                         default:  
                                 snprintf(arcbios_sysid.ProductId, 8, "IP%i",  
                                     machine->machine_subtype);  
                         }  
                 } else {  
                         switch (machine->machine_subtype) {  
                         case MACHINE_ARC_NEC_RD94:  
                                 strncpy(arcbios_sysid.VendorId,  "NEC W&S", 8); /*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "RD94", 4);    /*  NOTE: max 8 chars  */  
                                 break;  
                         case MACHINE_ARC_NEC_R94:  
                                 strncpy(arcbios_sysid.VendorId,  "NEC W&S", 8); /*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "ijkl", 4);    /*  NOTE: max 8 chars  */  
                                 break;  
                         case MACHINE_ARC_NEC_R96:  
                                 strncpy(arcbios_sysid.VendorId,  "MIPS DUO", 8);        /*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "blahblah", 8);        /*  NOTE: max 8 chars  */  
                                 break;  
                         case MACHINE_ARC_NEC_R98:  
                                 strncpy(arcbios_sysid.VendorId,  "NEC W&S", 8); /*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "R98", 4);     /*  NOTE: max 8 chars  */  
                                 break;  
                         case MACHINE_ARC_JAZZ_PICA:  
                                 strncpy(arcbios_sysid.VendorId,  "MIPS MAG", 8);/*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "ijkl", 4);    /*  NOTE: max 8 chars  */  
                                 break;  
                         case MACHINE_ARC_JAZZ_MAGNUM:  
                                 strncpy(arcbios_sysid.VendorId,  "MIPS MAG", 8);/*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "ijkl", 4);    /*  NOTE: max 8 chars  */  
                                 break;  
                         case MACHINE_ARC_JAZZ_M700:  
                                 strncpy(arcbios_sysid.VendorId,  "OLI00000", 8);/*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "ijkl", 4);    /*  NOTE: max 8 chars  */  
                                 break;  
                         case MACHINE_ARC_DESKTECH_TYNE:  
                                 strncpy(arcbios_sysid.VendorId,  "DESKTECH", 8);/*  NOTE: max 8 chars  */  
                                 strncpy(arcbios_sysid.ProductId, "ijkl", 4);    /*  NOTE: max 8 chars  */  
                                 break;  
                         default:  
                                 fatal("error in machine.c sysid\n");  
3630                                  exit(1);                                  exit(1);
3631                          }                          }
3632                  }                          init_bootpath[0] = '\0';
                 store_buf(cpu, SGI_SYSID_ADDR, (char *)&arcbios_sysid, sizeof(arcbios_sysid));  
   
                 arcbios_get_dsp_stat(cpu, &arcbios_dsp_stat);  
                 store_buf(cpu, ARC_DSPSTAT_ADDR, (char *)&arcbios_dsp_stat, sizeof(arcbios_dsp_stat));  
3633    
3634                  /*                          if (bootdev_id < 0 || machine->force_netboot) {
3635                   *  The first 12 MBs of RAM are simply reserved... this simplifies things a lot.                                  snprintf(init_bootpath, 400, "tftp()");
3636                   *  If there's more than 512MB of RAM, it has to be split in two, according to                          } else {
3637                   *  the ARC spec.  This code creates a number of chunks of at most 512MB each.                                  /*  TODO: Make this nicer.  */
3638                   *                                  if (machine->machine_type == MACHINE_SGI) {
3639                   *  NOTE:  The region of physical address space between 0x10000000 and 0x1fffffff                                          if (machine->machine_subtype == 30)
3640                   *  (256 - 512 MB) is usually occupied by memory mapped devices, so that portion is "lost".                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3641                   */                                                      MACHINE_NAME_MAXBUF);
3642                                            if (machine->machine_subtype == 32)
3643                                                    strlcat(init_bootpath, "pci(0)",
3644                                                        MACHINE_NAME_MAXBUF);
3645                                    }
3646    
3647                  arc_reserved = 0x2000;                                  if (diskimage_is_a_cdrom(machine, bootdev_id,
3648                  if (machine->machine_type == MACHINE_SGI)                                      bootdev_type))
3649                          arc_reserved = 0x4000;                                          snprintf(init_bootpath + strlen(init_bootpath),
3650                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3651                  arcbios_add_memory_descriptor(cpu, 0, arc_reserved, ARCBIOS_MEM_FirmwarePermanent);                                  else
3652                  arcbios_add_memory_descriptor(cpu, sgi_ram_offset + arc_reserved, 0x60000-arc_reserved, ARCBIOS_MEM_FirmwareTemporary);                                          snprintf(init_bootpath + strlen(init_bootpath),
3653                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3654                  mem_base = 12;                                              bootdev_id);
                 mem_base += sgi_ram_offset / 1048576;  
   
                 while (mem_base < machine->physical_ram_in_mb + sgi_ram_offset/1048576) {  
                         mem_count = machine->physical_ram_in_mb + sgi_ram_offset/1048576  
                             - mem_base;  
   
                         /*  Skip the 256-512MB region (for devices)  */  
                         if (mem_base < 256 && mem_base + mem_count > 256) {  
                                 mem_count = 256-mem_base;  
3655                          }                          }
3656    
3657                          /*  At most 512MB per descriptor (at least the first 512MB                          if (machine->machine_type == MACHINE_ARC)
3658                              must be separated this way, according to the ARC spec)  */                                  strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
                         if (mem_count > 512)  
                                 mem_count = 512;  
   
                         arcbios_add_memory_descriptor(cpu, mem_base * 1048576,  
                             mem_count * 1048576, ARCBIOS_MEM_FreeMemory);  
   
                         mem_base += mem_count;  
   
                         /*  Skip the devices:  */  
                         if (mem_base == 256)  
                                 mem_base = 512;  
                 }  
   
   
                 /*  
                  *  Components:   (this is an example of what a system could look like)  
                  *  
                  *  [System]  
                  *      [CPU]  (one for each cpu)  
                  *          [FPU]  (one for each cpu)  
                  *          [CPU Caches]  
                  *      [Memory]  
                  *      [Ethernet]  
                  *      [Serial]  
                  *      [SCSI]  
                  *          [Disk]  
                  *  
                  *  Here's a good list of what hardware is in different IP-models:  
                  *  http://www.linux-mips.org/archives/linux-mips/2001-03/msg00101.html  
                  */  
   
                 if (machine->machine_name == NULL)  
                         fatal("ERROR: machine_name == NULL\n");  
                 if (short_machine_name == NULL)  
                         fatal("ERROR: short_machine_name == NULL\n");  
3659    
3660                  switch (machine->machine_type) {                          bootstr = malloc(BOOTSTR_BUFLEN);
3661                  case MACHINE_SGI:                          if (bootstr == NULL) {
3662                          system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,                                  fprintf(stderr, "out of memory\n");
                             0, 1, 2, 0, 0xffffffff, short_machine_name, 0  /*  ROOT  */ , NULL, 0);  
                         break;  
                 default:  
                         /*  ARC:  */  
                         switch (machine->machine_subtype) {  
                         case MACHINE_ARC_NEC_RD94:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "NEC-RD94", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         case MACHINE_ARC_NEC_R94:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "NEC-R94", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         case MACHINE_ARC_NEC_R96:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "NEC-R96", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         case MACHINE_ARC_NEC_R98:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "NEC-R98", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         case MACHINE_ARC_JAZZ_PICA:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "PICA-61", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         case MACHINE_ARC_JAZZ_MAGNUM:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "Microsoft-Jazz", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         case MACHINE_ARC_JAZZ_M700:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "Microsoft-Jazz", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         case MACHINE_ARC_DESKTECH_TYNE:  
                                 system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                                     0, 1, 2, 0, 0xffffffff, "DESKTECH-TYNE", 0  /*  ROOT  */ , NULL, 0);  
                                 break;  
                         default:  
                                 fatal("Unimplemented ARC machine type %i\n",  
                                     machine->machine_subtype);  
3663                                  exit(1);                                  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                   *  Common stuff for both SGI and ARC:                                  exit(1);
                  */  
                 debug("ARC system @ 0x%llx\n", (long long)system);  
   
                 for (i=0; i<machine->ncpus; i++) {  
                         uint64_t cpuaddr, fpu=0, picache, pdcache, sdcache=0;  
                         int cache_size, cache_line_size;  
                         unsigned int jj;  
                         char arc_cpu_name[100];  
                         char arc_fpc_name[105];  
   
                         snprintf(arc_cpu_name, sizeof(arc_cpu_name),  
                             "MIPS-%s", machine->cpu_name);  
   
                         if (machine->machine_type == MACHINE_ARC &&  
                             machine->machine_subtype == MACHINE_ARC_NEC_R96)  
                                 snprintf(arc_cpu_name, sizeof(arc_cpu_name),  
                                     "MIPS-%s - Pr 4/5.0, Fp 5/0",  
                                     machine->cpu_name);  
   
                         arc_cpu_name[sizeof(arc_cpu_name)-1] = 0;  
                         for (jj=0; jj<strlen(arc_cpu_name); jj++)  
                                 if (arc_cpu_name[jj] >= 'a' && arc_cpu_name[jj] <= 'z')  
                                         arc_cpu_name[jj] += ('A' - 'a');  
   
                         strcpy(arc_fpc_name, arc_cpu_name);  
                         strcat(arc_fpc_name, "FPC");  
   
                         cpuaddr = arcbios_addchild_manual(cpu, COMPONENT_CLASS_ProcessorClass, COMPONENT_TYPE_CPU,  
                             0, 1, 2, i, 0xffffffff, arc_cpu_name, system, NULL, 0);  
   
                         /*  
                          *  TODO: This was in the ARC specs, but it isn't  
                          *  really used by ARC implementations?  
                          *  At least SGI-IP32 uses it.  
                          */  
                         if (machine->machine_type == MACHINE_SGI)  
                                 fpu = arcbios_addchild_manual(cpu, COMPONENT_CLASS_ProcessorClass, COMPONENT_TYPE_FPU,  
                                     0, 1, 2, 0, 0xffffffff, arc_fpc_name, cpuaddr, NULL, 0);  
   
                         cache_size = DEFAULT_PCACHE_SIZE - 12;  
                         if (machine->cache_picache)  
                                 cache_size = machine->cache_picache - 12;  
                         if (cache_size < 0)  
                                 cache_size = 0;  
   
                         cache_line_size = DEFAULT_PCACHE_LINESIZE;  
                         if (machine->cache_picache_linesize)  
                                 cache_line_size = machine->cache_picache_linesize;  
                         if (cache_line_size < 0)  
                                 cache_line_size = 0;  
   
                         picache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass,  
                             COMPONENT_TYPE_PrimaryICache, 0, 1, 2,  
                             /*  
                              *  Key bits:  0xXXYYZZZZ  
                              *  XX is refill-size.  
                              *  Cache line size is 1 << YY,  
                              *  Cache size is 4KB << ZZZZ.  
                              */  
                             0x01000000 + (cache_line_size << 16) + cache_size,  
                                 /*  32 bytes per line, default = 32 KB total  */  
                             0xffffffff, NULL, cpuaddr, NULL, 0);  
   
                         cache_size = DEFAULT_PCACHE_SIZE - 12;  
                         if (machine->cache_pdcache)  
                                 cache_size = machine->cache_pdcache - 12;  
                         if (cache_size < 0)  
                                 cache_size = 0;  
   
                         cache_line_size = DEFAULT_PCACHE_LINESIZE;  
                         if (machine->cache_pdcache_linesize)  
                                 cache_line_size = machine->cache_pdcache_linesize;  
                         if (cache_line_size < 0)  
                                 cache_line_size = 0;  
   
                         pdcache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass,  
                             COMPONENT_TYPE_PrimaryDCache, 0, 1, 2,  
                             /*  
                              *  Key bits:  0xYYZZZZ  
                              *  Cache line size is 1 << YY,  
                              *  Cache size is 4KB << ZZZZ.  
                              */  
                             0x01000000 + (cache_line_size << 16) + cache_size,  
                                 /*  32 bytes per line, default = 32 KB total  */  
                             0xffffffff, NULL, cpuaddr, NULL, 0);  
   
                         if (machine->cache_secondary >= 12) {  
                                 cache_size = machine->cache_secondary - 12;  
   
                                 cache_line_size = 6;    /*  64 bytes default  */  
                                 if (machine->cache_secondary_linesize)  
                                         cache_line_size = machine->cache_secondary_linesize;  
                                 if (cache_line_size < 0)  
                                         cache_line_size = 0;  
   
                                 sdcache = arcbios_addchild_manual(cpu, COMPONENT_CLASS_CacheClass,  
                                     COMPONENT_TYPE_SecondaryDCache, 0, 1, 2,  
                                     /*  
                                      *  Key bits:  0xYYZZZZ  
                                      *  Cache line size is 1 << YY,  
                                      *  Cache size is 4KB << ZZZZ.  
                                      */  
                                     0x01000000 + (cache_line_size << 16) + cache_size,  
                                         /*  64 bytes per line, default = 1 MB total  */  
                                     0xffffffff, NULL, cpuaddr, NULL, 0);  
                         }  
   
                         debug("ARC cpu%i @ 0x%llx", i, (long long)cpuaddr);  
   
                         if (fpu != 0)  
                                 debug(" (fpu @ 0x%llx)\n", (long long)fpu);  
                         else  
                                 debug("\n");  
   
                         debug("    picache @ 0x%llx, pdcache @ 0x%llx\n",  
                             (long long)picache, (long long)pdcache);  
   
                         if (machine->cache_secondary >= 12)  
                                 debug("    sdcache @ 0x%llx\n",  
                                     (long long)sdcache);  
   
                         if (machine->machine_type == MACHINE_SGI) {  
                                 /*  TODO:  Memory amount (and base address?)!  */  
                                 uint64_t memory = arcbios_addchild_manual(cpu, COMPONENT_CLASS_MemoryClass,  
                                     COMPONENT_TYPE_MemoryUnit,  
                                     0, 1, 2, 0, 0xffffffff, "memory", cpuaddr, NULL, 0);  
                                 debug("    memory @ 0x%llx\n", (long long)memory);  
3670                          }                          }
                 }  
   
3671    
3672                  /*                          /*  Boot args., eg "-a"  */
3673                   *  Other components, and default TLB entries:                          bootarg = machine->boot_string_argument;
                  *  
                  *  TODO: How to build the component tree intermixed with  
                  *  the rest of device initialization?  
                  */  
3674    
3675                  if (machine->machine_type == MACHINE_SGI) {                          /*  argc, argv, envp in a0, a1, a2:  */
3676                          /*  TODO: On which models is this required?  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */
                         mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,  
                             0xc000000000000000ULL,  
                             0x0, 1048576*16,  
                             1, 1, 1, 1, 1, 0, 2, 2);  
                 }  
   
                 if (machine->machine_type == MACHINE_ARC &&  
                     ( machine->machine_subtype == MACHINE_ARC_NEC_RD94 ||  
                     machine->machine_subtype == MACHINE_ARC_NEC_R94 ||  
                     machine->machine_subtype == MACHINE_ARC_NEC_R96 )) {  
                         uint64_t jazzbus, eisa, other;  
   
                         jazzbus = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_AdapterClass,  
                             COMPONENT_TYPE_MultiFunctionAdapter,  
                             0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus",  
                             system, NULL, 0);  
3677    
3678                          switch (machine->machine_subtype) {                          /*  TODO:  not needed?  */
3679                          case MACHINE_ARC_NEC_RD94:                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3680                          case MACHINE_ARC_NEC_R94:                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3681                                  if (machine->use_x11)  
3682                                          arcbios_addchild_manual(cpu,                          /*  Set up argc/argv:  */
3683                                              COMPONENT_CLASS_ControllerClass,                          addr = ARC_ENV_STRINGS;
3684                                              COMPONENT_TYPE_DisplayController,                          addr2 = ARC_ARGV_START;
3685                                              0, 1, 2, 0, 0x0, "10110004",                          cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
                                             system, NULL, 0);  
                                 break;  
                         case MACHINE_ARC_NEC_R96:  
                                 if (machine->use_x11) {  
                                         uint64_t x;  
                                         x = arcbios_addchild_manual(cpu,  
                                             COMPONENT_CLASS_ControllerClass,  
                                             COMPONENT_TYPE_DisplayController,  
                                             COMPONENT_FLAG_ConsoleOut |  
                                               COMPONENT_FLAG_Output,  
                                             1, 2, 0, 0x0, "necvdfrb",  
                                             jazzbus, NULL, 0);  
                                         arcbios_addchild_manual(cpu,  
                                             COMPONENT_CLASS_PeripheralClass,  
                                             COMPONENT_TYPE_MonitorPeripheral,  
                                             COMPONENT_FLAG_ConsoleOut |  
                                                 COMPONENT_FLAG_Output,  
                                             1, 2, 0, 0xffffffff, "640x480",  
                                             x, NULL, 0);  
                                 }  
3686    
3687                                  /*  TODO: R[D]94 too?  */                          /*  bootstr:  */
3688                                  eisa = arcbios_addchild_manual(cpu,                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3689                                      COMPONENT_CLASS_AdapterClass,                          add_environment_string(cpu, bootstr, &addr);
3690                                      COMPONENT_TYPE_EISAAdapter,                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                                     0, 1, 2, 0, 0xffffffff, "EISA",  
                                     system, NULL, 0);  
   
                                 other = arcbios_addchild_manual(cpu,  
                                     COMPONENT_CLASS_ControllerClass,  
                                     COMPONENT_TYPE_OtherController,  
                                     0, 1, 2, 0, 0xffffffff, "NEC1C01",  
                                     eisa, NULL, 0);  
3691    
3692                                  break;                          /*  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                  if (machine->machine_type == MACHINE_ARC &&                          cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;
                     (machine->machine_subtype == MACHINE_ARC_JAZZ_PICA  
                     || machine->machine_subtype == MACHINE_ARC_JAZZ_MAGNUM)) {  
                         uint64_t jazzbus, ali_s3, vxl;  
                         uint64_t diskcontroller, floppy, kbdctl, kbd;  
                         uint64_t ptrctl, ptr, paral, audio;  
                         uint64_t eisa, scsi;  
                         /*  uint64_t serial1, serial2;  */  
   
                         jazzbus = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_AdapterClass,  
                             COMPONENT_TYPE_MultiFunctionAdapter,  
                             0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus",  
                             system, NULL, 0);  
3700    
3701                          /*                          /*
3702                           *  DisplayController, needed by NetBSD:                           *  Add environment variables.  For each variable, add it
3703                           *  TODO: NetBSD still doesn't use it :(                           *  as a string using add_environment_string(), and add a
3704                             *  pointer to it to the ARC_ENV_POINTERS array.
3705                           */                           */
3706                          switch (machine->machine_subtype) {                          if (machine->use_x11) {
3707                          case MACHINE_ARC_JAZZ_PICA:                                  if (machine->machine_type == MACHINE_ARC) {
3708                                  /*  Default TLB entries on PICA-61:  */                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3709                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3710                                  /* 7: 256K, asid: 0x0, v: 0xe1000000,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3711                                     p0: 0xfff00000(2.VG), p1: 0x0(0..G)  */                                          add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3712                                  mips_coproc_tlb_set_entry(cpu, 7, 262144,                                  } else {
3713                                      0xffffffffe1000000ULL,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3714                                      0x0fff00000ULL, 0,                                          add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3715                                      1, 0, 0, 0, 1, 0, 2, 0);                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3716                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3717                                  /* 8: 64K, asid: 0x0, v: 0xe0000000,  
3718                                     p0: 0x80000000(2DVG), p1: 0x0(0..G) */                                          /*  g for graphical mode. G for graphical mode
3719                                  mips_coproc_tlb_set_entry(cpu, 8, 65536,                                              with SGI logo visible on Irix?  */
3720                                      0xffffffffe0000000ULL,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3721                                      0x080000000ULL, 0,                                          add_environment_string(cpu, "console=g", &addr);
                                     1, 0, 1, 0, 1, 0, 2, 0);  
   
                                 /* 9: 64K, asid: 0x0, v: 0xe00e0000,  
                                    p0: 0x800e0000(2DVG), p1: 0x800f0000(2DVG) */  
                                 mips_coproc_tlb_set_entry(cpu, 9, 65536,  
                                     (uint64_t)0xffffffffe00e0000ULL,  
                                     (uint64_t)0x0800e0000ULL,  
                                     (uint64_t)0x0800f0000ULL,  
                                     1, 1, 1, 1, 1, 0, 2, 2);  
   
                                 /* 10: 4K, asid: 0x0, v: 0xe0100000,  
                                    p0: 0xf0000000(2DVG), p1: 0x0(0..G) */  
                                 mips_coproc_tlb_set_entry(cpu, 10, 4096,  
                                     (uint64_t)0xffffffffe0100000ULL,  
                                     (uint64_t)0x0f0000000ULL, 0,  
                                     1, 0, 1, 0, 1, 0, 2, 0);  
   
                                 /* 11: 1M, asid: 0x0, v: 0xe0200000,  
                                    p0: 0x60000000(2DVG), p1: 0x60100000(2DVG) */  
                                 mips_coproc_tlb_set_entry(cpu, 11, 1048576,  
                                     0xffffffffe0200000ULL,  
                                     0x060000000ULL, 0x060100000ULL,  
                                     1, 1, 1, 1, 1, 0, 2, 2);  
   
                                 /* 12: 1M, asid: 0x0, v: 0xe0400000,  
                                    p0: 0x60200000(2DVG), p1: 0x60300000(2DVG) */  
                                 mips_coproc_tlb_set_entry(cpu, 12, 1048576,  
                                     0xffffffffe0400000ULL,  
                                     0x060200000ULL, 0x060300000ULL,  
                                     1, 1, 1, 1, 1, 0, 2, 2);  
   
                                 /* 13: 4M, asid: 0x0, v: 0xe0800000,  
                                    p0: 0x40000000(2DVG), p1: 0x40400000(2DVG) */  
                                 mips_coproc_tlb_set_entry(cpu, 13, 1048576*4,  
                                     0xffffffffe0800000ULL,  
                                     0x040000000ULL, 0x040400000ULL,  
                                     1, 1, 1, 1, 1, 0, 2, 2);  
   
                                 /* 14: 16M, asid: 0x0, v: 0xe2000000,  
                                    p0: 0x90000000(2DVG), p1: 0x91000000(2DVG) */  
                                 mips_coproc_tlb_set_entry(cpu, 14, 1048576*16,  
                                     0xffffffffe2000000ULL,  
                                     0x090000000ULL, 0x091000000ULL,  
                                     1, 1, 1, 1, 1, 0, 2, 2);  
   
                                 if (machine->use_x11) {  
                                         ali_s3 = arcbios_addchild_manual(cpu,  
                                             COMPONENT_CLASS_ControllerClass,  
                                             COMPONENT_TYPE_DisplayController,  
                                             COMPONENT_FLAG_ConsoleOut |  
                                                 COMPONENT_FLAG_Output,  
                                             1, 2, 0, 0xffffffff, "ALI_S3",  
                                             jazzbus, NULL, 0);  
   
                                         arcbios_addchild_manual(cpu,  
                                             COMPONENT_CLASS_PeripheralClass,  
                                             COMPONENT_TYPE_MonitorPeripheral,  
                                             COMPONENT_FLAG_ConsoleOut |  
                                                 COMPONENT_FLAG_Output,  
                                             1, 2, 0, 0xffffffff, "1024x768",  
                                             ali_s3, NULL, 0);  
3722                                  }                                  }
3723                                  break;                          } else {
3724                          case MACHINE_ARC_JAZZ_MAGNUM:                                  if (machine->machine_type == MACHINE_ARC) {
3725                                  if (machine->use_x11) {                                          /*  TODO: serial console for ARC?  */
3726                                          vxl = arcbios_addchild_manual(cpu,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3727                                              COMPONENT_CLASS_ControllerClass,                                          add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3728                                              COMPONENT_TYPE_DisplayController,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3729                                              COMPONENT_FLAG_ConsoleOut |                                          add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3730                                                  COMPONENT_FLAG_Output,                                  } else {
3731                                              1, 2, 0, 0xffffffff, "VXL",                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3732                                              jazzbus, NULL, 0);                                          add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3733                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3734                                          arcbios_addchild_manual(cpu,                                          add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3735                                              COMPONENT_CLASS_PeripheralClass,  
3736                                              COMPONENT_TYPE_MonitorPeripheral,                                          /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3737                                              COMPONENT_FLAG_ConsoleOut |                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3738                                                  COMPONENT_FLAG_Output,                                          add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
                                             1, 2, 0, 0xffffffff, "1024x768",  
                                             vxl, NULL, 0);  
3739                                  }                                  }
                                 break;  
3740                          }                          }
3741    
                         diskcontroller = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_DiskController,  
                                 COMPONENT_FLAG_Input |  
                                 COMPONENT_FLAG_Output,  
                             1, 2, 0, 0xffffffff, "I82077",  
                             jazzbus, NULL, 0);  
   
                         floppy = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_PeripheralClass,  
                             COMPONENT_TYPE_FloppyDiskPeripheral,  
                                 COMPONENT_FLAG_Removable |  
                                 COMPONENT_FLAG_Input |  
                                 COMPONENT_FLAG_Output,  
                             1, 2, 0, 0xffffffff, NULL,  
                             diskcontroller, NULL, 0);  
   
                         kbdctl = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_KeyboardController,  
                                 COMPONENT_FLAG_ConsoleIn |  
                                 COMPONENT_FLAG_Input,  
                             1, 2, 0, 0xffffffff, "I8742",  
                             jazzbus, NULL, 0);  
   
                         kbd = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_PeripheralClass,  
                             COMPONENT_TYPE_KeyboardPeripheral,  
                                 COMPONENT_FLAG_ConsoleIn |  
                                 COMPONENT_FLAG_Input,  
                             1, 2, 0, 0xffffffff, "PCAT_ENHANCED",  
                             kbdctl, NULL, 0);  
   
                         ptrctl = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_PointerController,  
                                 COMPONENT_FLAG_Input,  
                             1, 2, 0, 0xffffffff, "I8742",  
                             jazzbus, NULL, 0);  
   
                         ptr = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_PeripheralClass,  
                             COMPONENT_TYPE_PointerPeripheral,  
                                 COMPONENT_FLAG_Input,  
                             1, 2, 0, 0xffffffff, "PS2 MOUSE",  
                             ptrctl, NULL, 0);  
   
 /*  These cause Windows NT to bug out.  */  
 #if 0  
                         serial1 = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_SerialController,  
                                 COMPONENT_FLAG_Input |  
                                 COMPONENT_FLAG_Output,  
                             1, 2, 0, 0xffffffff, "COM1",  
                             jazzbus, NULL, 0);  
   
                         serial2 = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_SerialController,  
                                 COMPONENT_FLAG_Input |  
                                 COMPONENT_FLAG_Output,  
                             1, 2, 0, 0xffffffff, "COM1",  
                             jazzbus, NULL, 0);  
 #endif  
   
                         paral = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_ParallelController,  
                                 COMPONENT_FLAG_Input |  
                                 COMPONENT_FLAG_Output,  
                             1, 2, 0, 0xffffffff, "LPT1",  
                             jazzbus, NULL, 0);  
   
                         audio = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_ControllerClass,  
                             COMPONENT_TYPE_AudioController,  
                                 COMPONENT_FLAG_Input |  
                                 COMPONENT_FLAG_Output,  
                             1, 2, 0, 0xffffffff, "MAGNUM",  
                             jazzbus, NULL, 0);  
   
                         eisa = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_AdapterClass,  
                             COMPONENT_TYPE_EISAAdapter,  
                             0, 1, 2, 0, 0xffffffff, "EISA",  
                             system, NULL, 0);  
   
 {  
 unsigned char config[78];  
 memset(config, 0, sizeof(config));  
   
 /*  config data version: 1, revision: 2, count: 4  */  
 config[0] = 0x01; config[1] = 0x00;  
 config[2] = 0x02; config[3] = 0x00;  
 config[4] = 0x04; config[5] = 0x00; config[6] = 0x00; config[7] = 0x00;  
   
 /*  
           type: Interrupt  
            share_disposition: DeviceExclusive, flags: LevelSensitive  
            level: 4, vector: 22, reserved1: 0  
 */  
 config[8] = arc_CmResourceTypeInterrupt;  
 config[9] = arc_CmResourceShareDeviceExclusive;  
 config[10] = arc_CmResourceInterruptLevelSensitive;  
 config[12] = 4;  
 config[16] = 22;  
 config[20] = 0;  
   
 /*  
           type: Memory  
            share_disposition: DeviceExclusive, flags: ReadWrite  
            start: 0x 0 80002000, length: 0x1000  
 */  
 config[24] = arc_CmResourceTypeMemory;  
 config[25] = arc_CmResourceShareDeviceExclusive;  
 config[26] = arc_CmResourceMemoryReadWrite;  
 config[28] = 0x00; config[29] = 0x20; config[30] = 0x00; config[31] = 0x80;  
   config[32] = 0x00; config[33] = 0x00; config[34] = 0x00; config[35] = 0x00;  
 config[36] = 0x00; config[37] = 0x10; config[38] = 0x00; config[39] = 0x00;  
   
 /*  
           type: DMA  
            share_disposition: DeviceExclusive, flags: 0x0  
            channel: 0, port: 0, reserved1: 0  
 */  
 config[40] = arc_CmResourceTypeDMA;  
 config[41] = arc_CmResourceShareDeviceExclusive;  
 /*  42..43 = flags, 44,45,46,47 = channel, 48,49,50,51 = port, 52,53,54,55 = reserved  */  
   
 /*          type: DeviceSpecific  
            share_disposition: DeviceExclusive, flags: 0x0  
            datasize: 6, reserved1: 0, reserved2: 0  
            data: [0x1:0x0:0x2:0x0:0x7:0x30]  
 */  
 config[56] = arc_CmResourceTypeDeviceSpecific;  
 config[57] = arc_CmResourceShareDeviceExclusive;  
 /*  58,59 = flags  60,61,62,63 = data size, 64..71 = reserved  */  
 config[60] = 6;  
 /*  72..77 = the data  */  
 config[72] = 0x01;  
 config[73] = 0x00;  
 config[74] = 0x02;  
 config[75] = 0x00;  
 config[76] = 0x07;  
 config[77] = 0x30;  
                         scsi = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_AdapterClass,  
                             COMPONENT_TYPE_SCSIAdapter,  
                             0, 1, 2, 0, 0xffffffff, "ESP216",  
                             system, config, sizeof(config));  
   
                         arcbios_register_scsicontroller(scsi);  
 }  
   
                 }  
   
   
                 add_symbol_name(&machine->symbol_context,  
                     ARC_FIRMWARE_ENTRIES, 0x10000, "[ARCBIOS entry]", 0);  
   
                 switch (arc_wordlen) {  
                 case sizeof(uint64_t):  
                         for (i=0; i<100; i++)  
                                 store_64bit_word(cpu, ARC_FIRMWARE_VECTORS + i*8,  
                                     ARC_FIRMWARE_ENTRIES + i*8);  
                         for (i=0; i<100; i++)  
                                 store_64bit_word(cpu, ARC_PRIVATE_VECTORS + i*8,  
                                     ARC_PRIVATE_ENTRIES + i*8);  
                         break;  
                 default:  
                         for (i=0; i<100; i++)  
                                 store_32bit_word(cpu, ARC_FIRMWARE_VECTORS + i*4,  
                                     ARC_FIRMWARE_ENTRIES + i*4);  
                         for (i=0; i<100; i++)  
                                 store_32bit_word(cpu, ARC_PRIVATE_VECTORS + i*4,  
                                     ARC_PRIVATE_ENTRIES + i*4);  
                 }  
   
                 switch (arc_wordlen) {  
                 case sizeof(uint64_t):  
                         /*  
                          *  ARCS64 SPD (TODO: This is just a guess)  
                          */  
                         memset(&arcbios_spb_64, 0, sizeof(arcbios_spb_64));  
                         store_64bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.SPBSignature, ARCBIOS_SPB_SIGNATURE);  
                         store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.Version, 64);  
                         store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.Revision, 0);  
                         store_64bit_word_in_host(cpu, (unsigned char *)&arcbios_spb_64.FirmwareVector, ARC_FIRMWARE_VECTORS);  
                         store_buf(cpu, SGI_SPB_ADDR, (char *)&arcbios_spb_64, sizeof(arcbios_spb_64));  
                         break;  
                 default:        /*  32-bit  */  
                         /*  
                          *  ARCBIOS SPB:  (For ARC and 32-bit SGI modes)  
                          */  
                         memset(&arcbios_spb, 0, sizeof(arcbios_spb));  
                         store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.SPBSignature, ARCBIOS_SPB_SIGNATURE);  
                         store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.SPBLength, sizeof(arcbios_spb));  
                         store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.Version, 1);  
                         store_16bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.Revision, machine->machine_type == MACHINE_SGI? 10 : 2);  
                         store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.FirmwareVector, ARC_FIRMWARE_VECTORS);  
                         store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.FirmwareVectorLength, 100 * 4);     /*  ?  */  
                         store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.PrivateVector, ARC_PRIVATE_VECTORS);  
                         store_32bit_word_in_host(cpu, (unsigned char *)&arcbios_spb.PrivateVectorLength, 100 * 4);      /*  ?  */  
                         store_buf(cpu, SGI_SPB_ADDR, (char *)&arcbios_spb, sizeof(arcbios_spb));  
                 }  
   
                 /*  
                  *  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';  
   
                 if (bootdev_id < 0 || machine->force_netboot) {  
                         snprintf(init_bootpath, 400, "tftp()");  
                 } else {  
                         /*  TODO: Make this nicer.  */  
3742                          if (machine->machine_type == MACHINE_SGI) {                          if (machine->machine_type == MACHINE_SGI) {
3743                                  if (machine->machine_subtype == 30)                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3744                                          strcat(init_bootpath, "xio(0)pci(15)");                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3745                                  if (machine->machine_subtype == 32)                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3746                                          strcat(init_bootpath, "pci(0)");                                  add_environment_string(cpu, "diskless=0", &addr);
3747                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3748                                    add_environment_string(cpu, "volume=80", &addr);
3749                          if (diskimage_is_a_cdrom(machine, bootdev_id))                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3750                                  snprintf(init_bootpath + strlen(init_bootpath), 400,                                  add_environment_string(cpu, "sgilogo=y", &addr);
                                     "scsi(0)cdrom(%i)fdisk(0)", bootdev_id);  
                         else  
                                 snprintf(init_bootpath + strlen(init_bootpath), 400,  
                                     "scsi(0)disk(%i)rdisk(0)partition(1)", bootdev_id);  
                 }  
   
                 if (machine->machine_type == MACHINE_ARC)  
                         strcat(init_bootpath, "\\");  
   
                 bootstr = malloc(strlen(init_bootpath) +  
                     strlen(machine->boot_kernel_filename) + 1);  
                 strcpy(bootstr, init_bootpath);  
                 strcat(bootstr, machine->boot_kernel_filename);  
   
                 /*  Boot args., eg "-a"  */  
                 bootarg = machine->boot_string_argument;  
   
                 /*  argc, argv, envp in a0, a1, a2:  */  
                 cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */  
3751    
3752                  /*  TODO:  not needed?  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3753                  cpu->cd.mips.gpr[MIPS_GPR_SP] = machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080;                                  add_environment_string(cpu, "monitor=h", &addr);
3754                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3755                                    add_environment_string(cpu, "TimeZone=GMT", &addr);
3756                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3757                                    add_environment_string(cpu, "nogfxkbd=1", &addr);
3758    
3759                  /*  Set up argc/argv:  */                                  /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */
                 addr = ARC_ENV_STRINGS;  
                 addr2 = ARC_ARGV_START;  
                 cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;  
3760    
3761                  /*  bootstr:  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3762                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &addr);
3763                  add_environment_string(cpu, bootstr, &addr);                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3764                  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                                  add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);
3765                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3766                                    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);
3769    
3770                  /*  bootarg:  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3771                  if (bootarg[0] != '\0') {                                  add_environment_string(cpu, "rbaud=9600", &addr);
3772                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3773                          add_environment_string(cpu, bootarg, &addr);                                  add_environment_string(cpu, "rebound=y", &addr);
3774                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                                  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                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3780                                    add_environment_string(cpu, "keybd=US", &addr);
3781    
                 /*  
                  *  Add environment variables.  For each variable, add it  
                  *  as a string using add_environment_string(), and add a  
                  *  pointer to it to the ARC_ENV_POINTERS array.  
                  */  
                 if (machine->use_x11) {  
                         if (machine->machine_type == MACHINE_ARC) {  
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, "CONSOLEIN=multi()key()keyboard()console()", &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, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
                         } else {  
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, "ConsoleIn=keyboard()", &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, "ConsoleOut=video()", &addr);                                  add_environment_string(cpu, "verbose=istrue", &addr);
   
                                 /*  g for graphical mode. G for graphical mode  
                                     with SGI logo visible on Irix?  */  
3790                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3791                                  add_environment_string(cpu, "console=g", &addr);                                  add_environment_string(cpu, "showconfig=istrue", &addr);
                         }  
                 } else {  
                         if (machine->machine_type == MACHINE_ARC) {  
                                 /*  TODO: serial console for ARC?  */  
3792                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3793                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "diagmode=v", &addr);
3794                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3795                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "kernname=unix", &addr);
3796                          } else {                          } 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));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3802                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  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, "ConsoleOut=serial(0)", &addr);                                  add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3806    
                                 /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */  
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, "console=d", &addr);                /*  d2 = serial?  */                                  add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3809                          }                          }
                 }  
3810    
3811                  if (machine->machine_type == MACHINE_SGI) {                          /*  End the environment strings with an empty zero-terminated
3812                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                              string, and the envp array with a NULL pointer.  */
3813                          add_environment_string(cpu, "AutoLoad=No", &addr);                          add_environment_string(cpu, "", &addr); /*  the end  */
3814                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          store_pointer_and_advance(cpu, &addr2,
3815                          add_environment_string(cpu, "diskless=0", &addr);                              0, arc_wordlen==sizeof(uint64_t));
                         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);  
3816    
3817                          /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */                          /*  Return address:  (0x20 = ReturnFromMain())  */
3818                            cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "SystemPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(8)", &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);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "rbaud=9600", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "rebound=y", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "crt_option=1", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "netaddr=10.0.0.1", &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "keybd=US", &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "cpufreq=3", &addr);  
                         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);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);  
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 4067  no_arc_prom_emulation:         /*  TODO: ugly, Line 3830  no_arc_prom_emulation:         /*  TODO: ugly,
3830    
3831                  /*  First of all, the MeshCube has an Au1500 in it:  */                  /*  First of all, the MeshCube has an Au1500 in it:  */
3832                  machine->md_interrupt = au1x00_interrupt;                  machine->md_interrupt = au1x00_interrupt;
3833                  machine->au1x00_ic_data = dev_au1x00_init(machine, mem);                  machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem);
3834    
3835                  /*                  /*
3836                   *  TODO:  Which non-Au1500 devices, and at what addresses?                   *  TODO:  Which non-Au1500 devices, and at what addresses?
# Line 4084  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 4115  no_arc_prom_emulation:         /*  TODO: ugly, Line 3878  no_arc_prom_emulation:         /*  TODO: ugly,
3878                  device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0");                  device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0");
3879                  break;                  break;
3880    
         case MACHINE_WRT54G:  
                 machine->machine_name = "Linksys WRT54G";  
   
                 if (machine->use_x11)  
                         fprintf(stderr, "WARNING! Linksys WRT54G with -X is meaningless. Continuing anyway.\n");  
   
                 /*  200 MHz default  */  
                 if (machine->emulated_hz == 0)  
                         machine->emulated_hz = 200000000;  
   
                 /*  
                  *  Linux should be loaded at 0x80001000.  
                  *  RAM: 16 or 32 MB, Flash RAM: 4 or 8 MB.  
                  *  http://www.bumpclub.ee/~jaanus/wrt54g/vana/minicom.cap:  
                  *  
                  *  Starting program at 0x80001000  
                  *  CPU revision is: 00029007  
                  *  Primary instruction cache 8kb, linesize 16 bytes (2 ways)  
                  *  Primary data cache 4kb, linesize 16 bytes (2 ways)  
                  *   memory: 01000000 @ 00000000 (usable)  
                  *  Kernel command line: root=/dev/mtdblock2 rootfstype=squashfs init=/etc/preinit noinitrd console=ttyS0,115200  
                  *  CPU: BCM4712 rev 1 at 200 MHz  
                  *  Calibrating delay loop... 199.47 BogoMIPS  
                  *  ttyS00 at 0xb8000300 (irq = 3) is a 16550A  
                  *  ttyS01 at 0xb8000400 (irq = 0) is a 16550A  
                  *  Flash device: 0x400000 at 0x1c000000  
                  *  ..  
                  */  
   
                 /*  TODO: What should the initial register contents be?  */  
 #if 1  
 {  
 int i;  
 for (i=0; i<32; i++)  
                 cpu->cd.mips.gpr[i] = 0x01230000 + (i << 8) + 0x55;  
 }  
 #endif  
   
                 break;  
   
3881          case MACHINE_SONYNEWS:          case MACHINE_SONYNEWS:
3882                  /*                  /*
3883                   *  There are several models, according to                   *  There are several models, according to
# Line 4179  for (i=0; i<32; i++) Line 3902  for (i=0; i<32; i++)
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 4192  for (i=0; i<32; i++) Line 3915  for (i=0; i<32; i++)
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 4208  for (i=0; i<32; i++) Line 4138  for (i=0; i<32; i++)
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 4225  for (i=0; i<32; i++) Line 4166  for (i=0; i<32; i++)
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 4232  for (i=0; i<32; i++) Line 4178  for (i=0; i<32; i++)
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 4249  for (i=0; i<32; i++) Line 4200  for (i=0; i<32; i++)
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 4264  for (i=0; i<32; i++) Line 4211  for (i=0; i<32; i++)
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, 0xc00b8000ULL, 0x800003c0ULL, 80, 25,                  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 4317  for (i=0; i<32; i++) Line 4265  for (i=0; i<32; i++)
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 4342  for (i=0; i<32; i++) Line 4327  for (i=0; i<32; i++)
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 4362  for (i=0; i<32; i++) Line 4390  for (i=0; i<32; i++)
4390                  }                  }
4391    
4392                  break;                  break;
4393    #endif  /*  ENABLE_PPC  */
4394    
4395    #ifdef ENABLE_SH
4396            case MACHINE_BARESH:
4397                    /*  A bare SH machine, with no devices.  */
4398                    machine->machine_name = "\"Bare\" SH machine";
4399                    break;
4400    
4401            case MACHINE_TESTSH:
4402                    machine->machine_name = "SH test machine";
4403    
4404                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4405                        (long long)DEV_CONS_ADDRESS);
4406                    cons_data = device_add(machine, tmpstr);
4407                    machine->main_console_handle = cons_data->console_handle;
4408    
4409                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4410                        (long long)DEV_MP_ADDRESS);
4411                    device_add(machine, tmpstr);
4412    
4413                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4414                        640,480, 640,480, 24, "testsh generic");
4415    
4416                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4417                        (long long)DEV_DISK_ADDRESS);
4418                    device_add(machine, tmpstr);
4419    
4420                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4421                        (long long)DEV_ETHER_ADDRESS);
4422                    device_add(machine, tmpstr);
4423    
4424                    break;
4425    
4426            case MACHINE_HPCSH:
4427                    /*  Handheld SH-based machines:  */
4428                    machine->machine_name = "HPCsh";
4429    
4430                    /*  TODO  */
4431    
4432                    break;
4433    #endif  /*  ENABLE_SH  */
4434    
4435    #ifdef ENABLE_HPPA
4436            case MACHINE_BAREHPPA:
4437                    /*  A bare HPPA machine, with no devices.  */
4438                    machine->machine_name = "\"Bare\" HPPA machine";
4439                    break;
4440    
4441            case MACHINE_TESTHPPA:
4442                    machine->machine_name = "HPPA test machine";
4443    
4444                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4445                        (long long)DEV_CONS_ADDRESS);
4446                    cons_data = device_add(machine, tmpstr);
4447                    machine->main_console_handle = cons_data->console_handle;
4448    
4449                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4450                        (long long)DEV_MP_ADDRESS);
4451                    device_add(machine, tmpstr);
4452    
4453                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4454                        640,480, 640,480, 24, "testhppa generic");
4455    
4456                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4457                        (long long)DEV_DISK_ADDRESS);
4458                    device_add(machine, tmpstr);
4459    
4460                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4461                        (long long)DEV_ETHER_ADDRESS);
4462                    device_add(machine, tmpstr);
4463    
4464                    break;
4465    #endif  /*  ENABLE_HPPA  */
4466    
4467    #ifdef ENABLE_I960
4468            case MACHINE_BAREI960:
4469                    /*  A bare I960 machine, with no devices.  */
4470                    machine->machine_name = "\"Bare\" i960 machine";
4471                    break;
4472    
4473            case MACHINE_TESTI960:
4474                    machine->machine_name = "i960 test machine";
4475    
4476                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4477                        (long long)DEV_CONS_ADDRESS);
4478                    cons_data = device_add(machine, tmpstr);
4479                    machine->main_console_handle = cons_data->console_handle;
4480    
4481                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4482                        (long long)DEV_MP_ADDRESS);
4483                    device_add(machine, tmpstr);
4484    
4485                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4486                        640,480, 640,480, 24, "testi960 generic");
4487    
4488                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4489                        (long long)DEV_DISK_ADDRESS);
4490                    device_add(machine, tmpstr);
4491    
4492                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4493                        (long long)DEV_ETHER_ADDRESS);
4494                    device_add(machine, tmpstr);
4495    
4496                    break;
4497    #endif  /*  ENABLE_I960  */
4498    
4499    #ifdef ENABLE_SPARC
4500          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
4501                  /*  A bare SPARC machine, with no devices.  */                  /*  A bare SPARC machine, with no devices.  */
4502                  machine->machine_name = "\"Bare\" SPARC machine";                  machine->machine_name = "\"Bare\" SPARC machine";
4503                  break;                  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:          case MACHINE_ULTRA1:
4531                  /*                  /*
4532                   *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)                   *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)
# Line 4375  for (i=0; i<32; i++) Line 4534  for (i=0; i<32; i++)
4534                   */                   */
4535                  machine->machine_name = "Sun Ultra1";                  machine->machine_name = "Sun Ultra1";
4536                  break;                  break;
4537    #endif  /*  ENABLE_SPARC  */
4538    
4539          case MACHINE_BAREURISC:  #ifdef ENABLE_ALPHA
4540                  machine->machine_name = "\"Bare\" URISC machine";          case MACHINE_BAREALPHA:
4541                    machine->machine_name = "\"Bare\" Alpha machine";
4542                  break;                  break;
4543    
4544          case MACHINE_TESTURISC:          case MACHINE_TESTALPHA:
4545                  machine->machine_name = "URISC test machine";                  machine->machine_name = "Alpha test machine";
4546    
4547                    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                  /*  TODO  */                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4553                  /*  A special "device" for accessing normal devices                      (long long)DEV_MP_ADDRESS);
4554                      using urisc accesses?  */                  device_add(machine, tmpstr);
4555    
4556                  device_add(machine, "urisc addr=0x12341234");                  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;                  break;
4568    
4569          case MACHINE_BAREHPPA:          case MACHINE_ALPHA:
4570                  machine->machine_name = "\"Bare\" HPPA machine";                  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          case MACHINE_TESTHPPA:  #ifdef ENABLE_ARM
4647                  machine->machine_name = "HPPA test machine";          case MACHINE_BAREARM:
4648                    machine->machine_name = "\"Bare\" ARM machine";
4649                    break;
4650    
4651                  /*  TODO  */          case MACHINE_TESTARM:
4652                    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;                  break;
4684    
4685          case MACHINE_BAREALPHA:          case MACHINE_CATS:
4686                  machine->machine_name = "\"Bare\" Alpha machine";                  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;                  break;
4772    
4773          case MACHINE_TESTALPHA:          case MACHINE_HPCARM:
4774                  machine->machine_name = "Alpha test machine";                  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;
4906    
4907            case MACHINE_NETWINDER:
4908                    machine->machine_name = "NetWinder";
4909    
4910                    if (machine->physical_ram_in_mb > 256)
4911                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4912                                " have more than 256 MB RAM. Continuing anyway.\n");
4913    
4914                    machine->md_int.footbridge_data =
4915                        device_add(machine, "footbridge addr=0x42000000");
4916                    machine->md_interrupt = isa32_interrupt;
4917                    machine->isa_pic_data.native_irq = 11;
4918    
4919                    bus_isa(machine, 0, 0x7c000000, 0x80000000, 32, 48);
4920    #if 0
4921                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4922                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4923                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4924                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4925    
4926                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4927                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4928    
4929                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4930                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4931                                32 + 1, 32 + 12, machine->use_x11, 0);
4932                            machine->main_console_handle = j;
4933    #endif
4934                    if (machine->use_x11) {
4935                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4936                                mem, 0xc0, 8, 0, "igsfb");
4937                    }
4938    
4939                    if (machine->prom_emulation) {
4940                            arm_setup_initial_translation_table(cpu, 0x4000);
4941                    }
4942                    break;
4943    
4944            case MACHINE_SHARK:
4945                    machine->machine_name = "Digital DNARD (\"Shark\")";
4946                    if (machine->prom_emulation) {
4947                            arm_setup_initial_translation_table(cpu,
4948                                machine->physical_ram_in_mb * 1048576 - 65536);
4949    
4950                            /*
4951                             *  r0 = OpenFirmware entry point.  NOTE: See
4952                             *  cpu_arm.c for the rest of this semi-ugly hack.
4953                             */
4954                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4955                    }
4956                    break;
4957    
4958            case MACHINE_IQ80321:
4959                    /*
4960                     *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4961                     *  for more details about the memory map.
4962                     */
4963                    machine->machine_name = "Intel IQ80321 (ARM)";
4964                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4965                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4966                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4967    
4968                    /*  Used by "Redboot":  */
4969                    dev_ram_init(machine, 0xa800024, 4, DEV_RAM_RAM, 0);
4970                    store_32bit_word(cpu, 0xa800024, 0x7fff);
4971                    device_add(machine, "ns16550 irq=0 addr=0x0d800000 addr_mult=4");
4972                    device_add(machine, "ns16550 irq=0 addr=0x0d800020 addr_mult=4");
4973    
4974                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
4975                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4976                        DEV_RAM_MIRROR, 0x0);
4977                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4978                        DEV_RAM_MIRROR, 0x0);
4979    
4980                    /*  0xe0000000 and 0xff000000 = cache flush regions  */
4981                    dev_ram_init(machine, 0xe0000000, 0x100000, DEV_RAM_RAM, 0x0);
4982                    dev_ram_init(machine, 0xff000000, 0x100000, DEV_RAM_RAM, 0x0);
4983    
4984                    device_add(machine, "i80321 addr=0xffffe000");
4985    
4986                    if (machine->prom_emulation) {
4987                            arm_setup_initial_translation_table(cpu, 0x4000);
4988                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
4989                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
4990                            arm_translation_table_set_l1(cpu, 0xe0000000, 0xe0000000);
4991                            arm_translation_table_set_l1(cpu, 0xf0000000, 0xf0000000);
4992                    }
4993                    break;
4994    
4995            case MACHINE_IYONIX:
4996                    machine->machine_name = "Iyonix";
4997                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4998                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4999    
5000                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
5001                    device_add(machine, "ns16550 irq=0 addr=0x900003f8");
5002                    device_add(machine, "ns16550 irq=0 addr=0x900002f8");
5003    
5004                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
5005                    dev_ram_init(machine, 0xa0000000, 0x20000000,
5006                        DEV_RAM_MIRROR, 0x0);
5007                    dev_ram_init(machine, 0xc0000000, 0x20000000,
5008                        DEV_RAM_MIRROR, 0x0);
5009                    dev_ram_init(machine, 0xf0000000, 0x08000000,
5010                        DEV_RAM_MIRROR, 0x0);
5011    
5012                    device_add(machine, "i80321 addr=0xffffe000");
5013    
5014                    if (machine->prom_emulation) {
5015                            arm_setup_initial_translation_table(cpu,
5016                                machine->physical_ram_in_mb * 1048576 - 65536);
5017                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
5018                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
5019                            arm_translation_table_set_l1_b(cpu, 0xff000000, 0xff000000);
5020                    }
5021                    break;
5022    #endif  /*  ENABLE_ARM  */
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                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
5052                        (long long)DEV_DISK_ADDRESS);
5053                    device_add(machine, tmpstr);
5054    
5055                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
5056                        (long long)DEV_ETHER_ADDRESS);
5057                    device_add(machine, tmpstr);
5058    
5059                    break;
5060    #endif  /*  ENABLE_IA64  */
5061    
5062    #ifdef ENABLE_M68K
5063            case MACHINE_BAREM68K:
5064                    machine->machine_name = "\"Bare\" M68K machine";
5065                    break;
5066    
5067            case MACHINE_TESTM68K:
5068                    machine->machine_name = "M68K test machine";
5069    
5070                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
5071                        (long long)DEV_CONS_ADDRESS);
5072                    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);
5089    
5090                    break;
5091    #endif  /*  ENABLE_M68K  */
5092    
5093    #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                    bus_isa(machine, BUS_ISA_IDE0 | BUS_ISA_IDE1 | BUS_ISA_VGA |
5107                        BUS_ISA_PCKBC_FORCE_USE |
5108                        (machine->machine_subtype == MACHINE_X86_XT?
5109                        BUS_ISA_NO_SECOND_PIC : 0) | BUS_ISA_FDC,
5110                        X86_IO_BASE, 0x00000000, 0, 16);
5111    
5112                    if (machine->prom_emulation)
5113                            pc_bios_init(cpu);
5114    
5115                    if (!machine->use_x11 && !quiet_mode)
5116                            fprintf(stderr, "-------------------------------------"
5117                                "------------------------------------------\n"
5118                                "\n  WARNING! You are emulating a PC without -X. "
5119                                "You will miss graphical output!\n\n"
5120                                "-------------------------------------"
5121                                "------------------------------------------\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 4423  for (i=0; i<32; i++) Line 5134  for (i=0; i<32; i++)
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 4478  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_WRT54G:                  case MACHINE_EVBMIPS:
5194                          m->physical_ram_in_mb = 32;                          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;                          break;
5205                  case MACHINE_ARC:                  case MACHINE_ARC:
5206                          switch (m->machine_subtype) {                          switch (m->machine_subtype) {
# Line 4502  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;
5239                    case MACHINE_X86:
5240                            if (m->machine_subtype == MACHINE_X86_XT)
5241                                    m->physical_ram_in_mb = 1;
5242                          break;                          break;
5243                  }                  }
5244          }          }
5245    
5246          /*  Special hack for WRT54G and hpcmips machines:  */          /*  Special hack for hpcmips machines:  */
5247          if (m->machine_type == MACHINE_WRT54G ||          if (m->machine_type == MACHINE_HPCMIPS) {
             m->machine_type == MACHINE_HPCMIPS) {  
5248                  m->dbe_on_nonexistant_memaccess = 0;                  m->dbe_on_nonexistant_memaccess = 0;
5249          }          }
5250    
# Line 4610  void machine_default_cputype(struct mach Line 5340  void machine_default_cputype(struct mach
5340          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
5341                  m->cpu_name = strdup("RC32334");                  m->cpu_name = strdup("RC32334");
5342                  break;                  break;
         case MACHINE_WRT54G:  
                 m->cpu_name = strdup("BCM4712");  
                 break;  
5343          case MACHINE_ARC:          case MACHINE_ARC:
5344                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5345                  case MACHINE_ARC_JAZZ_PICA:                  case MACHINE_ARC_JAZZ_PICA:
# Line 4644  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 4672  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 4689  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;
5470    
5471            /*  ARM:  */
5472            case MACHINE_BAREARM:
5473            case MACHINE_TESTARM:
5474            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;
5506    
5507            /*  x86:  */
5508            case MACHINE_BAREX86:
5509            case MACHINE_X86:
5510                    if (m->machine_subtype == MACHINE_X86_XT)
5511                            m->cpu_name = strdup("8086");
5512                    else
5513                            m->cpu_name = strdup("AMD64");
5514                  break;                  break;
5515          }          }
5516    
# Line 4752  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 4782  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 4937  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 4962  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:  */
5778            me = machine_entry_new("x86-based PC", ARCH_X86,
5779                MACHINE_X86, 2, 2);
5780            me->aliases[0] = "pc";
5781            me->aliases[1] = "x86";
5782            me->subtype[0] = machine_entry_subtype_new("Generic PC",
5783                MACHINE_X86_GENERIC, 2);
5784            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);
5787            me->subtype[1]->aliases[0] = "xt";
5788            if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {
5789                    me->next = first_machine_entry; first_machine_entry = me;
5790            }
5791    
5792          /*  Walnut: (NetBSD/evbppc)  */          /*  Walnut: (NetBSD/evbppc)  */
5793          me = machine_entry_new("Walnut evaluation board", ARCH_PPC,          me = machine_entry_new("Walnut evaluation board", ARCH_PPC,
5794              MACHINE_WALNUT, 2, 0);              MACHINE_WALNUT, 2, 0);
# Line 4971  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 4995  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 5003  void machine_init(void) Line 5862  void machine_init(void)
5862                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5863          }          }
5864    
5865            /*  Test-machine for ARM:  */
5866            me = machine_entry_new("Test-machine for ARM", ARCH_ARM,
5867                MACHINE_TESTARM, 1, 0);
5868            me->aliases[0] = "testarm";
5869            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5870                    me->next = first_machine_entry; first_machine_entry = me;
5871            }
5872    
5873          /*  Test-machine for Alpha:  */          /*  Test-machine for Alpha:  */
5874          me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA,          me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA,
5875              MACHINE_TESTALPHA, 1, 0);              MACHINE_TESTALPHA, 1, 0);
# Line 5037  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 5075  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 5113  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          /*  Linksys:  */          /*  Iyonix:  */
6001          me = machine_entry_new("Linksys WRT54G", ARCH_MIPS,          me = machine_entry_new("Iyonix", ARCH_ARM,
6002              MACHINE_WRT54G, 2, 0);              MACHINE_IYONIX, 1, 0);
6003          me->aliases[0] = "linksys";          me->aliases[0] = "iyonix";
6004          me->aliases[1] = "wrt54g";          if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6005          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {                  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;                  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 5159  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          /*  Generic "bare" URISC machine:  */          /*  HPCarm:  */
6067          me = machine_entry_new("Generic \"bare\" URISC machine", ARCH_URISC,          me = machine_entry_new("Handheld ARM (HPCarm)",
6068              MACHINE_BAREURISC, 1, 0);              ARCH_ARM, MACHINE_HPCARM, 1, 2);
6069          me->aliases[0] = "bareurisc";          me->aliases[0] = "hpcarm";
6070          if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {          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:  */
6081            me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
6082                MACHINE_BAREX86, 1, 0);
6083            me->aliases[0] = "barex86";
6084            if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {
6085                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6086          }          }
6087    
# Line 5175  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 5191  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 5199  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:  */
6161            me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
6162                MACHINE_BAREARM, 1, 0);
6163            me->aliases[0] = "barearm";
6164            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6165                    me->next = first_machine_entry; first_machine_entry = me;
6166            }
6167    
6168          /*  Generic "bare" Alpha machine:  */          /*  Generic "bare" Alpha machine:  */
6169          me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA,          me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA,
6170              MACHINE_BAREALPHA, 1, 0);              MACHINE_BAREALPHA, 1, 0);
# Line 5207  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 5274  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 5338  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.2  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26