/[gxemul]/upstream/0.4.2/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 /upstream/0.4.2/src/machine.c

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

revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 14 by dpavlin, Mon Oct 8 16:18:51 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: machine.c,v 1.420 2005/04/17 00:15:24 debug Exp $   *  $Id: machine.c,v 1.565 2005/10/07 22:10:50 debug Exp $
29   *   *
30   *  Emulation of specific machines.   *  Emulation of specific machines.
31   *   *
# Line 53  Line 53 
53  #include "arcbios.h"  #include "arcbios.h"
54  #include "bus_pci.h"  #include "bus_pci.h"
55  #include "cpu.h"  #include "cpu.h"
 #include "cpu_mips.h"  
56  #include "device.h"  #include "device.h"
57  #include "devices.h"  #include "devices.h"
58  #include "diskimage.h"  #include "diskimage.h"
# Line 65  Line 64 
64  #include "net.h"  #include "net.h"
65  #include "symbol.h"  #include "symbol.h"
66    
67    /*  For Alpha emulation:  */
68    #include "alpha_rpb.h"
69    
70    /*  For CATS emulation:  */
71    #include "cyclone_boot.h"
72    
73  /*  For SGI and ARC emulation:  */  /*  For SGI and ARC emulation:  */
74  #include "sgi_arcbios.h"  #include "sgi_arcbios.h"
 #include "arcbios_other.h"  
75  #include "crimereg.h"  #include "crimereg.h"
76    
77    /*  For evbmips emulation:  */
78    #include "maltareg.h"
79    
80  /*  For DECstation emulation:  */  /*  For DECstation emulation:  */
81  #include "dec_prom.h"  #include "dec_prom.h"
82  #include "dec_bootinfo.h"  #include "dec_bootinfo.h"
# Line 84  Line 91 
91  #include "hpc_bootinfo.h"  #include "hpc_bootinfo.h"
92  #include "vripreg.h"  #include "vripreg.h"
93    
94    #define BOOTSTR_BUFLEN          1000
95    #define BOOTARG_BUFLEN          2000
96    #define ETHERNET_STRING_MAXLEN  40
97    
98  struct machine_entry_subtype {  struct machine_entry_subtype {
99          int                     machine_subtype;/*  Old-style subtype  */          int                     machine_subtype;/*  Old-style subtype  */
# Line 107  struct machine_entry { Line 117  struct machine_entry {
117          struct machine_entry_subtype **subtype;          struct machine_entry_subtype **subtype;
118  };  };
119    
120    
121    /*  See main.c:  */
122    extern int quiet_mode;
123    
124    
125  /*  This is initialized by machine_init():  */  /*  This is initialized by machine_init():  */
126  static struct machine_entry *first_machine_entry = NULL;  static struct machine_entry *first_machine_entry = NULL;
127    
# Line 133  struct machine *machine_new(char *name, Line 148  struct machine *machine_new(char *name,
148          m->name = strdup(name);          m->name = strdup(name);
149    
150          /*  Sane default values:  */          /*  Sane default values:  */
151          m->serial_nr = 0;          m->serial_nr = 1;
152          m->machine_type = MACHINE_NONE;          m->machine_type = MACHINE_NONE;
153          m->machine_subtype = MACHINE_NONE;          m->machine_subtype = MACHINE_NONE;
154    #ifdef BINTRANS
155          m->bintrans_enable = 1;          m->bintrans_enable = 1;
156            m->old_bintrans_enable = 1;
157    #endif
158            m->arch_pagesize = 4096;        /*  Should be overriden in
159                                                emul.c for other pagesizes.  */
160            m->dyntrans_alignment_check = 1;
161          m->prom_emulation = 1;          m->prom_emulation = 1;
162          m->speed_tricks = 1;          m->speed_tricks = 1;
163          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;
# Line 167  int machine_name_to_type(char *stype, ch Line 188  int machine_name_to_type(char *stype, ch
188          int *type, int *subtype, int *arch)          int *type, int *subtype, int *arch)
189  {  {
190          struct machine_entry *me;          struct machine_entry *me;
191          int i, j, k;          int i, j, k, nmatches = 0;
192    
193          *type = MACHINE_NONE;          *type = MACHINE_NONE;
194          *subtype = 0;          *subtype = 0;
195    
196            /*  Check stype, and optionally ssubtype:  */
197          me = first_machine_entry;          me = first_machine_entry;
198          while (me != NULL) {          while (me != NULL) {
199                  for (i=0; i<me->n_aliases; i++)                  for (i=0; i<me->n_aliases; i++)
# Line 195  int machine_name_to_type(char *stype, ch Line 217  int machine_name_to_type(char *stype, ch
217                                                          return 1;                                                          return 1;
218                                                  }                                                  }
219    
220                                  fatal("unknown subtype '%s' for emulation"                                  fatal("Unknown subtype '%s' for emulation"
221                                      " '%s'\n", ssubtype, stype);                                      " '%s'\n", ssubtype, stype);
222                                    if (!ssubtype[0])
223                                            fatal("(Maybe you forgot the -e"
224                                                " command line option?)\n");
225                                  exit(1);                                  exit(1);
226                          }                          }
227    
228                  me = me->next;                  me = me->next;
229          }          }
230    
231          fatal("machine_name_to_type(): unknown emulation type '%s' (", stype);          /*  Not found? Then just check ssubtype:  */
232          if (ssubtype == NULL)          me = first_machine_entry;
233                  fatal("no subtype)\n");          while (me != NULL) {
234          else                  if (me->n_subtypes == 0) {
235                  fatal("subtype '%s')\n", ssubtype);                          me = me->next;
236                            continue;
237                    }
238    
239                    /*  Check for subtype:  */
240                    for (j=0; j<me->n_subtypes; j++)
241                            for (k=0; k<me->subtype[j]->n_aliases; k++)
242                                    if (strcasecmp(ssubtype, me->subtype[j]->
243                                        aliases[k]) == 0) {
244                                            *type = me->machine_type;
245                                            *arch = me->arch;
246                                            *subtype = me->subtype[j]->
247                                                machine_subtype;
248                                            nmatches ++;
249                                    }
250    
251                    me = me->next;
252            }
253    
254            switch (nmatches) {
255            case 0: fatal("\nSorry, emulation \"%s\"", stype);
256                    if (ssubtype != NULL && ssubtype[0] != '\0')
257                            fatal(" (subtype \"%s\")", ssubtype);
258                    fatal(" is unknown.\n");
259                    break;
260            case 1: return 1;
261            default:fatal("\nSorry, multiple matches for \"%s\"", stype);
262                    if (ssubtype != NULL && ssubtype[0] != '\0')
263                            fatal(" (subtype \"%s\")", ssubtype);
264                    fatal(".\n");
265            }
266    
267            *type = MACHINE_NONE;
268            *subtype = 0;
269    
270            fatal("Use the -H command line option to get a list of "
271                "available types and subtypes.\n\n");
272    
         fatal("Use the -H command line option to get a list of available"  
             " types and subtypes.\n");  
273          return 0;          return 0;
274  }  }
275    
# Line 332  void add_environment_string(struct cpu * Line 391  void add_environment_string(struct cpu *
391    
392    
393  /*  /*
394     *  add_environment_string_dual():
395     *
396     *  Add "dual" environment strings, one for the variable name and one for the
397     *  value, and update pointers afterwards.
398     */
399    void add_environment_string_dual(struct cpu *cpu,
400            uint64_t *ptrp, uint64_t *addrp, char *s1, char *s2)
401    {
402            uint64_t ptr = *ptrp, addr = *addrp;
403    
404            store_32bit_word(cpu, ptr, addr);
405            ptr += sizeof(uint32_t);
406            if (addr != 0) {
407                    store_string(cpu, addr, s1);
408                    addr += strlen(s1) + 1;
409            }
410            store_32bit_word(cpu, ptr, addr);
411            ptr += sizeof(uint32_t);
412            if (addr != 0) {
413                    store_string(cpu, addr, s2);
414                    addr += strlen(s2) + 1;
415            }
416    
417            *ptrp = ptr;
418            *addrp = addr;
419    }
420    
421    
422    /*
423   *  store_64bit_word():   *  store_64bit_word():
424   *   *
425   *  Stores a 64-bit word in emulated RAM.  Byte order is taken into account.   *  Stores a 64-bit word in emulated RAM.  Byte order is taken into account.
# Line 371  int store_64bit_word(struct cpu *cpu, ui Line 459  int store_64bit_word(struct cpu *cpu, ui
459  int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)  int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
460  {  {
461          unsigned char data[4];          unsigned char data[4];
462          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
463                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
464          data[0] = (data32 >> 24) & 255;          data[0] = (data32 >> 24) & 255;
465          data[1] = (data32 >> 16) & 255;          data[1] = (data32 >> 16) & 255;
# Line 396  int store_32bit_word(struct cpu *cpu, ui Line 484  int store_32bit_word(struct cpu *cpu, ui
484  int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16)  int store_16bit_word(struct cpu *cpu, uint64_t addr, uint64_t data16)
485  {  {
486          unsigned char data[2];          unsigned char data[2];
487          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
488                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
489          data[0] = (data16 >> 8) & 255;          data[0] = (data16 >> 8) & 255;
490          data[1] = (data16) & 255;          data[1] = (data16) & 255;
# Line 415  int store_16bit_word(struct cpu *cpu, ui Line 503  int store_16bit_word(struct cpu *cpu, ui
503   */   */
504  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)
505  {  {
506          if ((addr >> 32) == 0)          int psize = 1024;       /*  1024 256 64 16 4 1  */
507    
508            if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
509                  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;  
                 }  
         }  
510    
511          if ((addr & 3) == 0 && (((size_t)s) & 3) == 0) {          while (len != 0) {
512                  while (len >= 4) {                  if ((addr & (psize-1)) == 0) {
513                          cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)s,                          while (len >= psize) {
514                              4, MEM_WRITE, CACHE_DATA);                                  cpu->memory_rw(cpu, cpu->mem, addr,
515                          addr += 4;                                      (unsigned char *)s, psize, MEM_WRITE,
516                          s += 4;                                      CACHE_DATA);
517                          len -= 4;                                  addr += psize;
518                                    s += psize;
519                                    len -= psize;
520                            }
521                  }                  }
522                    psize >>= 2;
523          }          }
524    
525          while (len-- != 0)          while (len-- != 0)
# Line 473  uint32_t load_32bit_word(struct cpu *cpu Line 558  uint32_t load_32bit_word(struct cpu *cpu
558  {  {
559          unsigned char data[4];          unsigned char data[4];
560    
561          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
562                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
563          cpu->memory_rw(cpu, cpu->mem,          cpu->memory_rw(cpu, cpu->mem,
564              addr, data, sizeof(data), MEM_READ, CACHE_DATA);              addr, data, sizeof(data), MEM_READ, CACHE_DATA);
# Line 497  uint16_t load_16bit_word(struct cpu *cpu Line 582  uint16_t load_16bit_word(struct cpu *cpu
582  {  {
583          unsigned char data[2];          unsigned char data[2];
584    
585          if ((addr >> 32) == 0)          if (cpu->machine->arch == ARCH_MIPS && (addr >> 32) == 0)
586                  addr = (int64_t)(int32_t)addr;                  addr = (int64_t)(int32_t)addr;
587          cpu->memory_rw(cpu, cpu->mem,          cpu->memory_rw(cpu, cpu->mem,
588              addr, data, sizeof(data), MEM_READ, CACHE_DATA);              addr, data, sizeof(data), MEM_READ, CACHE_DATA);
# Line 594  void kn02_interrupt(struct machine *m, s Line 679  void kn02_interrupt(struct machine *m, s
679    
680          if (assrt) {          if (assrt) {
681                  /*  OR in the irq_nr into the CSR:  */                  /*  OR in the irq_nr into the CSR:  */
682                  m->kn02_csr->csr[0] |= irq_nr;                  m->md_int.kn02_csr->csr[0] |= irq_nr;
683          } else {          } else {
684                  /*  AND out the irq_nr from the CSR:  */                  /*  AND out the irq_nr from the CSR:  */
685                  m->kn02_csr->csr[0] &= ~irq_nr;                  m->md_int.kn02_csr->csr[0] &= ~irq_nr;
686          }          }
687    
688          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];
689          if (current == 0)          if (current == 0)
690                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
691          else          else
# Line 619  void kmin_interrupt(struct machine *m, s Line 704  void kmin_interrupt(struct machine *m, s
704          /*  debug("kmin_interrupt(): irq_nr=%i assrt=%i\n", irq_nr, assrt);  */          /*  debug("kmin_interrupt(): irq_nr=%i assrt=%i\n", irq_nr, assrt);  */
705    
706          if (assrt)          if (assrt)
707                  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;
708          else          else
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    
711          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]
712              & 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])
713                  cpu_interrupt(cpu, KMIN_INT_TC3);                  cpu_interrupt(cpu, KMIN_INT_TC3);
714          else          else
715                  cpu_interrupt_ack(cpu, KMIN_INT_TC3);                  cpu_interrupt_ack(cpu, KMIN_INT_TC3);
# Line 640  void kn03_interrupt(struct machine *m, s Line 725  void kn03_interrupt(struct machine *m, s
725          /*  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);  */
726    
727          if (assrt)          if (assrt)
728                  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;
729          else          else
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    
732          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]
733              & 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])
734                  cpu_interrupt(cpu, KN03_INT_ASIC);                  cpu_interrupt(cpu, KN03_INT_ASIC);
735          else          else
736                  cpu_interrupt_ack(cpu, KN03_INT_ASIC);                  cpu_interrupt_ack(cpu, KN03_INT_ASIC);
# Line 662  void maxine_interrupt(struct machine *m, Line 747  void maxine_interrupt(struct machine *m,
747          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);
748    
749          if (assrt)          if (assrt)
750                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)
751                      / 0x10] |= irq_nr;                      / 0x10] |= irq_nr;
752          else          else
753                  m->dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)                  m->md_int.dec_ioasic_data->reg[(IOASIC_INTR - IOASIC_SLOT_1_START)
754                      / 0x10] &= ~irq_nr;                      / 0x10] &= ~irq_nr;
755    
756          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]
757              & m->dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START)              & m->md_int.dec_ioasic_data->reg[(IOASIC_IMSK - IOASIC_SLOT_1_START)
758              / 0x10])              / 0x10])
759                  cpu_interrupt(cpu, XINE_INT_TC3);                  cpu_interrupt(cpu, XINE_INT_TC3);
760          else          else
# Line 684  void kn230_interrupt(struct machine *m, Line 769  void kn230_interrupt(struct machine *m,
769  {  {
770          int r2 = 0;          int r2 = 0;
771    
772          m->kn230_csr->csr |= irq_nr;          m->md_int.kn230_csr->csr |= irq_nr;
773    
774          switch (irq_nr) {          switch (irq_nr) {
775          case KN230_CSR_INTR_SII:          case KN230_CSR_INTR_SII:
# Line 702  void kn230_interrupt(struct machine *m, Line 787  void kn230_interrupt(struct machine *m,
787    
788          if (assrt) {          if (assrt) {
789                  /*  OR in the irq_nr mask into the CSR:  */                  /*  OR in the irq_nr mask into the CSR:  */
790                  m->kn230_csr->csr |= irq_nr;                  m->md_int.kn230_csr->csr |= irq_nr;
791    
792                  /*  Assert MIPS interrupt 2 or 3:  */                  /*  Assert MIPS interrupt 2 or 3:  */
793                  cpu_interrupt(cpu, r2);                  cpu_interrupt(cpu, r2);
794          } else {          } else {
795                  /*  AND out the irq_nr mask from the CSR:  */                  /*  AND out the irq_nr mask from the CSR:  */
796                  m->kn230_csr->csr &= ~irq_nr;                  m->md_int.kn230_csr->csr &= ~irq_nr;
797    
798                  /*  If the CSR interrupt bits are all zero,                  /*  If the CSR interrupt bits are all zero,
799                      clear the bit in the cause register as well.  */                      clear the bit in the cause register as well.  */
800                  if (r2 == 2) {                  if (r2 == 2) {
801                          /*  irq 2:  */                          /*  irq 2:  */
802                          if ((m->kn230_csr->csr & (KN230_CSR_INTR_DZ0                          if ((m->md_int.kn230_csr->csr & (KN230_CSR_INTR_DZ0
803                              | KN230_CSR_INTR_OPT0 | KN230_CSR_INTR_OPT1)) == 0)                              | KN230_CSR_INTR_OPT0 | KN230_CSR_INTR_OPT1)) == 0)
804                                  cpu_interrupt_ack(cpu, r2);                                  cpu_interrupt_ack(cpu, r2);
805                  } else {                  } else {
806                          /*  irq 3:  */                          /*  irq 3:  */
807                          if ((m->kn230_csr->csr & (KN230_CSR_INTR_SII |                          if ((m->md_int.kn230_csr->csr & (KN230_CSR_INTR_SII |
808                              KN230_CSR_INTR_LANCE)) == 0)                              KN230_CSR_INTR_LANCE)) == 0)
809                                  cpu_interrupt_ack(cpu, r2);                                  cpu_interrupt_ack(cpu, r2);
810                  }                  }
# Line 753  void jazz_interrupt(struct machine *m, s Line 838  void jazz_interrupt(struct machine *m, s
838    
839          if (isa) {          if (isa) {
840                  if (assrt)                  if (assrt)
841                          m->jazz_data->isa_int_asserted |= irq;                          m->md_int.jazz_data->isa_int_asserted |= irq;
842                  else                  else
843                          m->jazz_data->isa_int_asserted &= ~irq;                          m->md_int.jazz_data->isa_int_asserted &= ~irq;
844          } else {          } else {
845                  if (assrt)                  if (assrt)
846                          m->jazz_data->int_asserted |= irq;                          m->md_int.jazz_data->int_asserted |= irq;
847                  else                  else
848                          m->jazz_data->int_asserted &= ~irq;                          m->md_int.jazz_data->int_asserted &= ~irq;
849          }          }
850    
851          /*  debug("   %08x %08x\n", m->jazz_data->int_asserted,          /*  debug("   %08x %08x\n", m->md_int.jazz_data->int_asserted,
852                  m->jazz_data->int_enable_mask);  */                  m->md_int.jazz_data->int_enable_mask);  */
853          /*  debug("   %08x %08x\n", m->jazz_data->isa_int_asserted,          /*  debug("   %08x %08x\n", m->md_int.jazz_data->isa_int_asserted,
854                  m->jazz_data->isa_int_enable_mask);  */                  m->md_int.jazz_data->isa_int_enable_mask);  */
855    
856          if (m->jazz_data->int_asserted /* & m->jazz_data->int_enable_mask  */          if (m->md_int.jazz_data->int_asserted
857              & ~0x8000 )              /* & m->md_int.jazz_data->int_enable_mask  */ & ~0x8000 )
858                  cpu_interrupt(cpu, 3);                  cpu_interrupt(cpu, 3);
859          else          else
860                  cpu_interrupt_ack(cpu, 3);                  cpu_interrupt_ack(cpu, 3);
861    
862          if (m->jazz_data->isa_int_asserted & m->jazz_data->isa_int_enable_mask)          if (m->md_int.jazz_data->isa_int_asserted &
863                m->md_int.jazz_data->isa_int_enable_mask)
864                  cpu_interrupt(cpu, 4);                  cpu_interrupt(cpu, 4);
865          else          else
866                  cpu_interrupt_ack(cpu, 4);                  cpu_interrupt_ack(cpu, 4);
867    
868          /*  TODO: this "15" (0x8000) is the timer... fix this?  */          /*  TODO: this "15" (0x8000) is the timer... fix this?  */
869          if (m->jazz_data->int_asserted & 0x8000)          if (m->md_int.jazz_data->int_asserted & 0x8000)
870                  cpu_interrupt(cpu, 6);                  cpu_interrupt(cpu, 6);
871          else          else
872                  cpu_interrupt_ack(cpu, 6);                  cpu_interrupt_ack(cpu, 6);
# Line 805  void vr41xx_interrupt(struct machine *m, Line 891  void vr41xx_interrupt(struct machine *m,
891                  giu_irq = irq_nr - 32;                  giu_irq = irq_nr - 32;
892    
893                  if (assrt)                  if (assrt)
894                          m->vr41xx_data->giuint |= (1 << giu_irq);                          m->md_int.vr41xx_data->giuint |= (1 << giu_irq);
895                  else                  else
896                          m->vr41xx_data->giuint &= ~(1 << giu_irq);                          m->md_int.vr41xx_data->giuint &= ~(1 << giu_irq);
897          }          }
898    
899          /*  TODO: This is wrong. What about GIU bit 8?  */          /*  TODO: This is wrong. What about GIU bit 8?  */
# Line 815  void vr41xx_interrupt(struct machine *m, Line 901  void vr41xx_interrupt(struct machine *m,
901          if (irq_nr != 8) {          if (irq_nr != 8) {
902                  /*  If any GIU bit is asserted, then assert the main                  /*  If any GIU bit is asserted, then assert the main
903                      GIU interrupt:  */                      GIU interrupt:  */
904                  if (m->vr41xx_data->giuint & m->vr41xx_data->giumask)                  if (m->md_int.vr41xx_data->giuint &
905                        m->md_int.vr41xx_data->giumask)
906                          vr41xx_interrupt(m, cpu, 8 + 8, 1);                          vr41xx_interrupt(m, cpu, 8 + 8, 1);
907                  else                  else
908                          vr41xx_interrupt(m, cpu, 8 + 8, 0);                          vr41xx_interrupt(m, cpu, 8 + 8, 0);
# Line 826  void vr41xx_interrupt(struct machine *m, Line 913  void vr41xx_interrupt(struct machine *m,
913    
914          if (irq_nr < 16) {          if (irq_nr < 16) {
915                  if (assrt)                  if (assrt)
916                          m->vr41xx_data->sysint1 |= (1 << irq_nr);                          m->md_int.vr41xx_data->sysint1 |= (1 << irq_nr);
917                  else                  else
918                          m->vr41xx_data->sysint1 &= ~(1 << irq_nr);                          m->md_int.vr41xx_data->sysint1 &= ~(1 << irq_nr);
919          } else if (irq_nr < 32) {          } else if (irq_nr < 32) {
920                  irq_nr -= 16;                  irq_nr -= 16;
921                  if (assrt)                  if (assrt)
922                          m->vr41xx_data->sysint2 |= (1 << irq_nr);                          m->md_int.vr41xx_data->sysint2 |= (1 << irq_nr);
923                  else                  else
924                          m->vr41xx_data->sysint2 &= ~(1 << irq_nr);                          m->md_int.vr41xx_data->sysint2 &= ~(1 << irq_nr);
925          }          }
926    
927          /*  TODO: Which hardware interrupt pin?  */          /*  TODO: Which hardware interrupt pin?  */
928    
929          /*  debug("    sysint1=%04x mask=%04x, sysint2=%04x mask=%04x\n",          /*  debug("    sysint1=%04x mask=%04x, sysint2=%04x mask=%04x\n",
930              m->vr41xx_data->sysint1, m->vr41xx_data->msysint1,              m->md_int.vr41xx_data->sysint1, m->md_int.vr41xx_data->msysint1,
931              m->vr41xx_data->sysint2, m->vr41xx_data->msysint2);  */              m->md_int.vr41xx_data->sysint2, m->md_int.vr41xx_data->msysint2); */
932    
933          if ((m->vr41xx_data->sysint1 & m->vr41xx_data->msysint1) |          if ((m->md_int.vr41xx_data->sysint1 & m->md_int.vr41xx_data->msysint1) |
934              (m->vr41xx_data->sysint2 & m->vr41xx_data->msysint2))              (m->md_int.vr41xx_data->sysint2 & m->md_int.vr41xx_data->msysint2))
935                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
936          else          else
937                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
# Line 878  void ps2_interrupt(struct machine *m, st Line 965  void ps2_interrupt(struct machine *m, st
965                  }                  }
966    
967                  if (assrt)                  if (assrt)
968                          m->ps2_data->sbus_smflg |= msk;                          m->md_int.ps2_data->sbus_smflg |= msk;
969                  else                  else
970                          m->ps2_data->sbus_smflg &= ~msk;                          m->md_int.ps2_data->sbus_smflg &= ~msk;
971    
972                  if (m->ps2_data->sbus_smflg != 0)                  if (m->md_int.ps2_data->sbus_smflg != 0)
973                          cpu_interrupt(cpu, 8 + 1);                          cpu_interrupt(cpu, 8 + 1);
974                  else                  else
975                          cpu_interrupt_ack(cpu, 8 + 1);                          cpu_interrupt_ack(cpu, 8 + 1);
# Line 892  void ps2_interrupt(struct machine *m, st Line 979  void ps2_interrupt(struct machine *m, st
979          if (assrt) {          if (assrt) {
980                  /*  OR into the INTR:  */                  /*  OR into the INTR:  */
981                  if (irq_nr < 16)                  if (irq_nr < 16)
982                          m->ps2_data->intr |= (1 << irq_nr);                          m->md_int.ps2_data->intr |= (1 << irq_nr);
983                  else                  else
984                          m->ps2_data->dmac_reg[0x601] |= (1 << (irq_nr-16));                          m->md_int.ps2_data->dmac_reg[0x601] |=
985                                (1 << (irq_nr-16));
986          } else {          } else {
987                  /*  AND out of the INTR:  */                  /*  AND out of the INTR:  */
988                  if (irq_nr < 16)                  if (irq_nr < 16)
989                          m->ps2_data->intr &= ~(1 << irq_nr);                          m->md_int.ps2_data->intr &= ~(1 << irq_nr);
990                  else                  else
991                          m->ps2_data->dmac_reg[0x601] &= ~(1 << (irq_nr-16));                          m->md_int.ps2_data->dmac_reg[0x601] &=
992                                ~(1 << (irq_nr-16));
993          }          }
994    
995          /*  TODO: Hm? How about the mask?  */          /*  TODO: Hm? How about the mask?  */
996          if (m->ps2_data->intr /*  & m->ps2_data->imask */ )          if (m->md_int.ps2_data->intr /*  & m->md_int.ps2_data->imask */ )
997                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
998          else          else
999                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
1000    
1001          /*  TODO: mask?  */          /*  TODO: mask?  */
1002          if (m->ps2_data->dmac_reg[0x601] & 0xffff)          if (m->md_int.ps2_data->dmac_reg[0x601] & 0xffff)
1003                  cpu_interrupt(cpu, 3);                  cpu_interrupt(cpu, 3);
1004          else          else
1005                  cpu_interrupt_ack(cpu, 3);                  cpu_interrupt_ack(cpu, 3);
# Line 942  void sgi_ip22_interrupt(struct machine * Line 1031  void sgi_ip22_interrupt(struct machine *
1031                  int ms = irq_nr / 64;                  int ms = irq_nr / 64;
1032                  uint32_t new = 1 << ms;                  uint32_t new = 1 << ms;
1033                  if (assrt)                  if (assrt)
1034                          m->sgi_ip22_data->reg[4] |= new;                          m->md_int.sgi_ip22_data->reg[4] |= new;
1035                  else                  else
1036                          m->sgi_ip22_data->reg[4] &= ~new;                          m->md_int.sgi_ip22_data->reg[4] &= ~new;
1037                  /*  TODO: is this enough?  */                  /*  TODO: is this enough?  */
1038                  irq_nr &= 63;                  irq_nr &= 63;
1039          }          }
1040    
1041          if (irq_nr < 32) {          if (irq_nr < 32) {
1042                  if (assrt)                  if (assrt)
1043                          m->sgi_ip22_data->reg[0] |= newmask;                          m->md_int.sgi_ip22_data->reg[0] |= newmask;
1044                  else                  else
1045                          m->sgi_ip22_data->reg[0] &= ~newmask;                          m->md_int.sgi_ip22_data->reg[0] &= ~newmask;
1046          } else {          } else {
1047                  if (assrt)                  if (assrt)
1048                          m->sgi_ip22_data->reg[2] |= newmask;                          m->md_int.sgi_ip22_data->reg[2] |= newmask;
1049                  else                  else
1050                          m->sgi_ip22_data->reg[2] &= ~newmask;                          m->md_int.sgi_ip22_data->reg[2] &= ~newmask;
1051          }          }
1052    
1053          /*  Read stat and mask for local0:  */          /*  Read stat and mask for local0:  */
1054          stat = m->sgi_ip22_data->reg[0];          stat = m->md_int.sgi_ip22_data->reg[0];
1055          mask = m->sgi_ip22_data->reg[1];          mask = m->md_int.sgi_ip22_data->reg[1];
1056          if ((stat & mask) == 0)          if ((stat & mask) == 0)
1057                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
1058          else          else
1059                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1060    
1061          /*  Read stat and mask for local1:  */          /*  Read stat and mask for local1:  */
1062          stat = m->sgi_ip22_data->reg[2];          stat = m->md_int.sgi_ip22_data->reg[2];
1063          mask = m->sgi_ip22_data->reg[3];          mask = m->md_int.sgi_ip22_data->reg[3];
1064          if ((stat & mask) == 0)          if ((stat & mask) == 0)
1065                  cpu_interrupt_ack(cpu, 3);                  cpu_interrupt_ack(cpu, 3);
1066          else          else
# Line 1003  void sgi_ip30_interrupt(struct machine * Line 1092  void sgi_ip30_interrupt(struct machine *
1092          newmask = (int64_t)1 << irq_nr;          newmask = (int64_t)1 << irq_nr;
1093    
1094          if (assrt)          if (assrt)
1095                  m->sgi_ip30_data->isr |= newmask;                  m->md_int.sgi_ip30_data->isr |= newmask;
1096          else          else
1097                  m->sgi_ip30_data->isr &= ~newmask;                  m->md_int.sgi_ip30_data->isr &= ~newmask;
1098    
1099  just_assert_and_such:  just_assert_and_such:
1100    
# Line 1015  just_assert_and_such: Line 1104  just_assert_and_such:
1104          cpu_interrupt_ack(cpu, 5);          cpu_interrupt_ack(cpu, 5);
1105          cpu_interrupt_ack(cpu, 6);          cpu_interrupt_ack(cpu, 6);
1106    
1107          stat = m->sgi_ip30_data->isr;          stat = m->md_int.sgi_ip30_data->isr;
1108          mask = m->sgi_ip30_data->imask0;          mask = m->md_int.sgi_ip30_data->imask0;
1109    
1110          if ((stat & mask) & 0x000000000000ffffULL)          if ((stat & mask) & 0x000000000000ffffULL)
1111                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
# Line 1047  void sgi_ip32_interrupt(struct machine * Line 1136  void sgi_ip32_interrupt(struct machine *
1136           *  interrupt 2 should be asserted.           *  interrupt 2 should be asserted.
1137           *           *
1138           *  TODO:  how should all this be done nicely?           *  TODO:  how should all this be done nicely?
          *  
          *  TODO:  mace interrupt mask  
1139           */           */
1140    
1141          uint64_t crime_addr = CRIME_INTSTAT;          uint64_t crime_addr = CRIME_INTSTAT;
1142          uint64_t mace_addr = 0x14;          uint64_t mace_addr = 0x10;
1143          uint64_t crime_interrupts, crime_interrupts_mask, mace_interrupts;          uint64_t crime_interrupts, crime_interrupts_mask;
1144            uint64_t mace_interrupts, mace_interrupt_mask;
1145          unsigned int i;          unsigned int i;
1146          unsigned char x[8];          unsigned char x[8];
1147    
1148            /*  Read current MACE interrupt assertions:  */
1149            memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr,
1150                sizeof(uint64_t));
1151            mace_interrupts = 0;
1152            for (i=0; i<sizeof(uint64_t); i++) {
1153                    mace_interrupts <<= 8;
1154                    mace_interrupts |= x[i];
1155            }
1156    
1157            /*  Read current MACE interrupt mask:  */
1158            memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr + 8,
1159                sizeof(uint64_t));
1160            mace_interrupt_mask = 0;
1161            for (i=0; i<sizeof(uint64_t); i++) {
1162                    mace_interrupt_mask <<= 8;
1163                    mace_interrupt_mask |= x[i];
1164            }
1165    
1166          /*          /*
1167           *  This mapping of both MACE and CRIME interrupts into the same           *  This mapping of both MACE and CRIME interrupts into the same
1168           *  'int' is really ugly.           *  'int' is really ugly.
# Line 1068  void sgi_ip32_interrupt(struct machine * Line 1174  void sgi_ip32_interrupt(struct machine *
1174           *  TODO: fix.           *  TODO: fix.
1175           */           */
1176          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];  
                 }  
   
1177                  if (assrt)                  if (assrt)
1178                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_SERIAL);                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_SERIAL);
1179                  else                  else
1180                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_SERIAL);                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_SERIAL);
1181    
                 /*  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));  
   
1182                  irq_nr = MACE_PERIPH_SERIAL;                  irq_nr = MACE_PERIPH_SERIAL;
1183                  if (mace_interrupts == 0)                  if ((mace_interrupts & mace_interrupt_mask) == 0)
1184                          assrt = 0;                          assrt = 0;
1185                  else                  else
1186                          assrt = 1;                          assrt = 1;
# Line 1096  void sgi_ip32_interrupt(struct machine * Line 1188  void sgi_ip32_interrupt(struct machine *
1188    
1189          /*  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.  */
1190          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];  
                 }  
   
1191                  if (assrt)                  if (assrt)
1192                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_MISC);                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_MISC);
1193                  else                  else
1194                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_MISC);                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_MISC);
1195    
                 /*  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));  
   
1196                  irq_nr = MACE_PERIPH_MISC;                  irq_nr = MACE_PERIPH_MISC;
1197                  if (mace_interrupts == 0)                  if ((mace_interrupts & mace_interrupt_mask) == 0)
1198                          assrt = 0;                          assrt = 0;
1199                  else                  else
1200                          assrt = 1;                          assrt = 1;
1201          }          }
1202    
1203            /*  Write back MACE interrupt assertions:  */
1204            for (i=0; i<sizeof(uint64_t); i++)
1205                    x[7-i] = mace_interrupts >> (i*8);
1206            memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint64_t));
1207    
1208          /*  Read CRIME_INTSTAT:  */          /*  Read CRIME_INTSTAT:  */
1209          memcpy(x, m->crime_data->reg + crime_addr, sizeof(uint64_t));          memcpy(x, m->md_int.ip32.crime_data->reg + crime_addr,
1210                sizeof(uint64_t));
1211          crime_interrupts = 0;          crime_interrupts = 0;
1212          for (i=0; i<8; i++) {          for (i=0; i<sizeof(uint64_t); i++) {
                 /*  SGI is big-endian...  */  
1213                  crime_interrupts <<= 8;                  crime_interrupts <<= 8;
1214                  crime_interrupts |= x[i];                  crime_interrupts |= x[i];
1215          }          }
# Line 1137  void sgi_ip32_interrupt(struct machine * Line 1220  void sgi_ip32_interrupt(struct machine *
1220                  crime_interrupts &= ~irq_nr;                  crime_interrupts &= ~irq_nr;
1221    
1222          /*  Write back CRIME_INTSTAT:  */          /*  Write back CRIME_INTSTAT:  */
1223          for (i=0; i<8; i++)          for (i=0; i<sizeof(uint64_t); i++)
1224                  x[7-i] = crime_interrupts >> (i*8);                  x[7-i] = crime_interrupts >> (i*8);
1225          memcpy(m->crime_data->reg + crime_addr, x, sizeof(uint64_t));          memcpy(m->md_int.ip32.crime_data->reg + crime_addr, x,
1226                sizeof(uint64_t));
1227    
1228          /*  Read CRIME_INTMASK:  */          /*  Read CRIME_INTMASK:  */
1229          memcpy(x, m->crime_data->reg + CRIME_INTMASK, sizeof(uint64_t));          memcpy(x, m->md_int.ip32.crime_data->reg + CRIME_INTMASK,
1230                sizeof(uint64_t));
1231          crime_interrupts_mask = 0;          crime_interrupts_mask = 0;
1232          for (i=0; i<8; i++) {          for (i=0; i<sizeof(uint64_t); i++) {
1233                  crime_interrupts_mask <<= 8;                  crime_interrupts_mask <<= 8;
1234                  crime_interrupts_mask |= x[i];                  crime_interrupts_mask |= x[i];
1235          }          }
# Line 1154  void sgi_ip32_interrupt(struct machine * Line 1239  void sgi_ip32_interrupt(struct machine *
1239          else          else
1240                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1241    
1242          /*  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",
1243                assrt, irq_nr, crime_interrupts);  */
1244  }  }
1245    
1246    
# Line 1187  void au1x00_interrupt(struct machine *m, Line 1273  void au1x00_interrupt(struct machine *m,
1273                  ms = 1 << (irq_nr & 31);                  ms = 1 << (irq_nr & 31);
1274    
1275                  if (assrt)                  if (assrt)
1276                          m->au1x00_ic_data->request0_int |= ms;                          m->md_int.au1x00_ic_data->request0_int |= ms;
1277                  else                  else
1278                          m->au1x00_ic_data->request0_int &= ~ms;                          m->md_int.au1x00_ic_data->request0_int &= ~ms;
1279    
1280                  /*  TODO: Controller 1  */                  /*  TODO: Controller 1  */
1281          }          }
1282    
1283          if ((m->au1x00_ic_data->request0_int &          if ((m->md_int.au1x00_ic_data->request0_int &
1284              m->au1x00_ic_data->mask) != 0)              m->md_int.au1x00_ic_data->mask) != 0)
1285                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1286          else          else
1287                  cpu_interrupt_ack(cpu, 2);                  cpu_interrupt_ack(cpu, 2);
# Line 1206  void au1x00_interrupt(struct machine *m, Line 1292  void au1x00_interrupt(struct machine *m,
1292  }  }
1293    
1294    
1295    /*
1296     *  Malta (evbmips) interrupts:
1297     *
1298     *  ISA interrupts.
1299     *  (irq_nr = 16+8 can be used to just reassert/deassert interrupts.)
1300     */
1301    void malta_interrupt(struct machine *m, struct cpu *cpu, int irq_nr,
1302            int assrt)
1303    {
1304            int mask;
1305    
1306            irq_nr -= 8;
1307            mask = 1 << (irq_nr & 7);
1308    
1309            if (irq_nr < 8) {
1310                    if (assrt)
1311                            m->isa_pic_data.pic1->irr |= mask;
1312                    else
1313                            m->isa_pic_data.pic1->irr &= ~mask;
1314            } else if (irq_nr < 16) {
1315                    if (assrt)
1316                            m->isa_pic_data.pic2->irr |= mask;
1317                    else
1318                            m->isa_pic_data.pic2->irr &= ~mask;
1319            }
1320    
1321            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1322            /*  (TODO: don't hardcode this here)  */
1323            if (m->isa_pic_data.pic2->irr &
1324                ~m->isa_pic_data.pic2->ier)
1325                    m->isa_pic_data.pic1->irr |= 0x04;
1326            else
1327                    m->isa_pic_data.pic1->irr &= ~0x04;
1328    
1329            /*  Now, PIC1:  */
1330            if (m->isa_pic_data.pic1->irr &
1331                ~m->isa_pic_data.pic1->ier)
1332                    cpu_interrupt(cpu, 2);
1333            else
1334                    cpu_interrupt_ack(cpu, 2);
1335    
1336            /*  printf("MALTA: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "
1337                "ier=0x%02x\n", m->isa_pic_data.pic1->irr,
1338                m->isa_pic_data.pic1->ier,
1339                m->isa_pic_data.pic2->irr,
1340                m->isa_pic_data.pic2->ier);  */
1341    }
1342    
1343    
1344    /*
1345     *  Cobalt interrupts:
1346     *
1347     *  (irq_nr = 8 + 16 can be used to just reassert/deassert interrupts.)
1348     */
1349    void cobalt_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
1350    {
1351            int mask;
1352    
1353            irq_nr -= 8;
1354            mask = 1 << (irq_nr & 7);
1355    
1356            if (irq_nr < 8) {
1357                    if (assrt)
1358                            m->isa_pic_data.pic1->irr |= mask;
1359                    else
1360                            m->isa_pic_data.pic1->irr &= ~mask;
1361            } else if (irq_nr < 16) {
1362                    if (assrt)
1363                            m->isa_pic_data.pic2->irr |= mask;
1364                    else
1365                            m->isa_pic_data.pic2->irr &= ~mask;
1366            }
1367    
1368            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1369            /*  (TODO: don't hardcode this here)  */
1370            if (m->isa_pic_data.pic2->irr &
1371                ~m->isa_pic_data.pic2->ier)
1372                    m->isa_pic_data.pic1->irr |= 0x04;
1373            else
1374                    m->isa_pic_data.pic1->irr &= ~0x04;
1375    
1376            /*  Now, PIC1:  */
1377            if (m->isa_pic_data.pic1->irr &
1378                ~m->isa_pic_data.pic1->ier)
1379                    cpu_interrupt(cpu, 6);
1380            else
1381                    cpu_interrupt_ack(cpu, 6);
1382    
1383            /*  printf("COBALT: pic1.irr=0x%02x ier=0x%02x pic2.irr=0x%02x "
1384                "ier=0x%02x\n", m->isa_pic_data.pic1->irr,
1385                m->isa_pic_data.pic1->ier,
1386                m->isa_pic_data.pic2->irr,
1387                m->isa_pic_data.pic2->ier);  */
1388    }
1389    
1390    
1391    /*
1392     *  x86 (PC) interrupts:
1393     *
1394     *  (irq_nr = 16 can be used to just reassert/deassert interrupts.)
1395     */
1396    void x86_pc_interrupt(struct machine *m, struct cpu *cpu, int irq_nr, int assrt)
1397    {
1398            int mask = 1 << (irq_nr & 7);
1399    
1400            if (irq_nr < 8) {
1401                    if (assrt)
1402                            m->isa_pic_data.pic1->irr |= mask;
1403                    else
1404                            m->isa_pic_data.pic1->irr &= ~mask;
1405            } else if (irq_nr < 16) {
1406                    if (m->isa_pic_data.pic2 == NULL) {
1407                            fatal("x86_pc_interrupt(): pic2 used (irq_nr = %i), "
1408                                "but we are emulating an XT?\n", irq_nr);
1409                            return;
1410                    }
1411                    if (assrt)
1412                            m->isa_pic_data.pic2->irr |= mask;
1413                    else
1414                            m->isa_pic_data.pic2->irr &= ~mask;
1415            }
1416    
1417            if (m->isa_pic_data.pic2 != NULL) {
1418                    /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1419                    /*  (TODO: don't hardcode this here)  */
1420                    if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1421                            m->isa_pic_data.pic1->irr |= 0x04;
1422                    else
1423                            m->isa_pic_data.pic1->irr &= ~0x04;
1424            }
1425    
1426            /*  Now, PIC1:  */
1427            if (m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier)
1428                    cpu->cd.x86.interrupt_asserted = 1;
1429            else
1430                    cpu->cd.x86.interrupt_asserted = 0;
1431    }
1432    
1433    
1434    /*
1435     *  Footbridge interrupts:
1436     *
1437     *  0..31  = footbridge interrupt
1438     *  32..47 = ISA (connected to IRQ_IN_L2 on CATS, L3 on NetWinder)
1439     *  64     = reassert
1440     */
1441    void footbridge_interrupt(struct machine *m, struct cpu *cpu, int irq_nr,
1442            int assrt)
1443    {
1444            uint32_t mask = 1 << (irq_nr & 31);
1445            int old_isa_assert, new_isa_assert;
1446            int isa_int = m->machine_type == MACHINE_CATS? 10 : 11;
1447    
1448            old_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1449    
1450            if (irq_nr >= 32 && irq_nr < 32 + 8) {
1451                    int mm = 1 << (irq_nr & 7);
1452                    if (assrt)
1453                            m->isa_pic_data.pic1->irr |= mm;
1454                    else
1455                            m->isa_pic_data.pic1->irr &= ~mm;
1456            } else if (irq_nr >= 32+8 && irq_nr < 32+16) {
1457                    int mm = 1 << (irq_nr & 7);
1458                    if (assrt)
1459                            m->isa_pic_data.pic2->irr |= mm;
1460                    else
1461                            m->isa_pic_data.pic2->irr &= ~mm;
1462            }
1463    
1464            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1465            /*  (TODO: don't hardcode this here)  */
1466            if (m->isa_pic_data.pic2->irr & ~m->isa_pic_data.pic2->ier)
1467                    m->isa_pic_data.pic1->irr |= 0x04;
1468            else
1469                    m->isa_pic_data.pic1->irr &= ~0x04;
1470    
1471            /*  Now, PIC1:  */
1472            new_isa_assert = m->isa_pic_data.pic1->irr & ~m->isa_pic_data.pic1->ier;
1473            if (old_isa_assert != new_isa_assert) {
1474                    if (new_isa_assert)
1475                            cpu_interrupt(cpu, isa_int);
1476                    else
1477                            cpu_interrupt_ack(cpu, isa_int);
1478                    return;
1479            }
1480    
1481            if (irq_nr < 32) {
1482                    if (assrt)
1483                            m->md_int.footbridge_data->irq_status |= mask;
1484                    else
1485                            m->md_int.footbridge_data->irq_status &= ~mask;
1486            }
1487    
1488            if (m->md_int.footbridge_data->irq_status &
1489                m->md_int.footbridge_data->irq_enable)
1490                    cpu_interrupt(cpu, 65);
1491            else
1492                    cpu_interrupt_ack(cpu, 65);
1493    }
1494    
1495    
1496  /****************************************************************************  /****************************************************************************
1497   *                                                                          *   *                                                                          *
1498   *                  Machine dependant Initialization routines               *   *                  Machine dependant Initialization routines               *
# Line 1225  void machine_setup(struct machine *machi Line 1512  void machine_setup(struct machine *machi
1512          int i, j;          int i, j;
1513          struct memory *mem;          struct memory *mem;
1514          char tmpstr[1000];          char tmpstr[1000];
1515            struct cons_data *cons_data;
1516    
1517          /*  DECstation:  */          /*  DECstation:  */
1518          char *framebuffer_console_name, *serial_console_name;          char *framebuffer_console_name, *serial_console_name;
# Line 1248  void machine_setup(struct machine *machi Line 1536  void machine_setup(struct machine *machi
1536          int hpcmips_fb_ysize_mem = 0;          int hpcmips_fb_ysize_mem = 0;
1537    
1538          /*  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;  
1539          uint64_t sgi_ram_offset = 0;          uint64_t sgi_ram_offset = 0;
         uint64_t arc_reserved;  
1540          int arc_wordlen = sizeof(uint32_t);          int arc_wordlen = sizeof(uint32_t);
         char *short_machine_name = NULL;  
1541          char *eaddr_string = "eaddr=10:20:30:40:50:60";   /*  nonsense  */          char *eaddr_string = "eaddr=10:20:30:40:50:60";   /*  nonsense  */
1542          unsigned char macaddr[6];          unsigned char macaddr[6];
1543    
1544          /*  Generic bootstring stuff:  */          /*  Generic bootstring stuff:  */
1545          int bootdev_id = diskimage_bootdev(machine);          int bootdev_type = 0;
1546            int bootdev_id;
1547          char *bootstr = NULL;          char *bootstr = NULL;
1548          char *bootarg = NULL;          char *bootarg = NULL;
1549          char *init_bootpath;          char *init_bootpath;
1550    
1551          /*  PCI stuff:  */          /*  PCI stuff:  */
1552          struct pci_data *pci_data;          struct pci_data *pci_data = NULL;
1553    
1554          /*  Framebuffer stuff:  */          /*  Framebuffer stuff:  */
1555          struct vfb_data *fb;          struct vfb_data *fb = NULL;
1556    
1557          /*  Abreviation:  :-)  */          /*  Abreviation:  :-)  */
1558          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];
1559    
1560    
1561            bootdev_id = diskimage_bootdev(machine, &bootdev_type);
1562    
1563          mem = cpu->mem;          mem = cpu->mem;
1564          machine->machine_name = NULL;          machine->machine_name = NULL;
1565    
# Line 1302  void machine_setup(struct machine *machi Line 1585  void machine_setup(struct machine *machi
1585                  printf("\nNo emulation type specified.\n");                  printf("\nNo emulation type specified.\n");
1586                  exit(1);                  exit(1);
1587    
1588    #ifdef ENABLE_MIPS
1589          case MACHINE_BAREMIPS:          case MACHINE_BAREMIPS:
1590                  /*                  /*
1591                   *  A "bare" MIPS test machine.                   *  A "bare" MIPS test machine.
# Line 1314  void machine_setup(struct machine *machi Line 1598  void machine_setup(struct machine *machi
1598    
1599          case MACHINE_TESTMIPS:          case MACHINE_TESTMIPS:
1600                  /*                  /*
1601                   *  A MIPS test machine (which happens to work with my                   *  A MIPS test machine (which happens to work with the
1602                   *  thesis work).                   *  code in my master's thesis).  :-)
1603                     *
1604                     *  IRQ map:
1605                     *      7       CPU counter
1606                     *      6       SMP IPIs
1607                     *      5       not used yet
1608                     *      4       not used yet
1609                     *      3       ethernet
1610                     *      2       serial console
1611                   */                   */
1612                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
1613                  machine->machine_name = "MIPS test machine";                  machine->machine_name = "MIPS test machine";
1614    
1615                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=2",
1616                      machine, mem, DEV_CONS_ADDRESS, "console", 2);                      (long long)DEV_CONS_ADDRESS);
1617                    cons_data = device_add(machine, tmpstr);
1618                    machine->main_console_handle = cons_data->console_handle;
1619    
1620                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
1621                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
1622                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
1623    
1624                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
1625                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testmips generic");
1626    
1627                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
1628                        (long long)DEV_DISK_ADDRESS);
1629                    device_add(machine, tmpstr);
1630    
1631                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=3",
1632                        (long long)DEV_ETHER_ADDRESS);
1633                    device_add(machine, tmpstr);
1634    
1635                  break;                  break;
1636    
1637          case MACHINE_DEC:          case MACHINE_DEC:
# Line 1370  void machine_setup(struct machine *machi Line 1673  void machine_setup(struct machine *machi
1673                           */                           */
1674                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,
1675                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,
1676                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01", 1);                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01");
1677                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);
1678                          dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag);                          dev_vdac_init(mem, KN01_SYS_VDAC, fb->rgb_palette, color_fb_flag);
1679                          dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576);                          dev_le_init(machine, mem, KN01_SYS_LANCE, KN01_SYS_LANCE_B_START, KN01_SYS_LANCE_B_END, KN01_INT_LANCE, 4*1048576);
# Line 1460  void machine_setup(struct machine *machi Line 1763  void machine_setup(struct machine *machi
1763                          dev_mc146818_init(machine, mem,                          dev_mc146818_init(machine, mem,
1764                              KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1);                              KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1);
1765    
1766                          machine->kn02_csr =                          machine->md_int.kn02_csr =
1767                              dev_kn02_init(cpu, mem, KN02_SYS_CSR);                              dev_kn02_init(cpu, mem, KN02_SYS_CSR);
1768    
1769                          framebuffer_console_name = "osconsole=0,7";                          framebuffer_console_name = "osconsole=0,7";
# Line 1494  void machine_setup(struct machine *machi Line 1797  void machine_setup(struct machine *machi
1797                           *  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
1798                           *  dma for asc0                                                (0x1c380000) slot 14                           *  dma for asc0                                                (0x1c380000) slot 14
1799                           */                           */
1800                          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);
1801                          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);
1802                          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);
1803                          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 1560  void machine_setup(struct machine *machi Line 1863  void machine_setup(struct machine *machi
1863                           *  mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000)                           *  mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000)
1864                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000)                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000)
1865                           */                           */
1866                          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);
1867    
1868                          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);
1869    
1870                          machine->dec_ioasic_data->dma_func[3] = dev_scc_dma_func;                          machine->md_int.dec_ioasic_data->dma_func[3] = dev_scc_dma_func;
1871                          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);
1872                          machine->dec_ioasic_data->dma_func[2] = dev_scc_dma_func;                          machine->md_int.dec_ioasic_data->dma_func[2] = dev_scc_dma_func;
1873                          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);
1874    
1875                          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);
1876                          dev_asc_init(machine, mem, KN03_SYS_SCSI,                          dev_asc_init(machine, mem, KN03_SYS_SCSI,
# Line 1626  void machine_setup(struct machine *machi Line 1929  void machine_setup(struct machine *machi
1929                           *  Clock uses interrupt 3 (shared with XMI?).                           *  Clock uses interrupt 3 (shared with XMI?).
1930                           */                           */
1931    
1932                          machine->dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000);                          machine->md_int.dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000);
1933                          dev_decbi_init(mem, 0x10000000);                          dev_decbi_init(mem, 0x10000000);
1934                          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);
1935                          dev_decxmi_init(mem, 0x11800000);                          dev_decxmi_init(mem, 0x11800000);
1936                          dev_deccca_init(mem, DEC_DECCCA_BASEADDR);                          dev_deccca_init(mem, DEC_DECCCA_BASEADDR);
1937    
# Line 1697  void machine_setup(struct machine *machi Line 2000  void machine_setup(struct machine *machi
2000                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7         (0x1c300000)                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7         (0x1c300000)
2001                           *  xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer     (0xa000000)                           *  xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer     (0xa000000)
2002                           */                           */
2003                          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);
2004    
2005                          /*  TURBOchannel slots (0 and 1):  */                          /*  TURBOchannel slots (0 and 1):  */
2006                          dev_turbochannel_init(machine, mem, 0,                          dev_turbochannel_init(machine, mem, 0,
# Line 1802  void machine_setup(struct machine *machi Line 2105  void machine_setup(struct machine *machi
2105                          dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576);                          dev_le_init(machine, mem, KN230_SYS_LANCE, KN230_SYS_LANCE_B_START, KN230_SYS_LANCE_B_END, KN230_CSR_INTR_LANCE, 4*1048576);
2106                          dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII);                          dev_sii_init(machine, mem, KN230_SYS_SII, KN230_SYS_SII_B_START, KN230_SYS_SII_B_END, KN230_CSR_INTR_SII);
2107    
2108                          snprintf(tmpstr, sizeof(tmpstr) - 1,                          snprintf(tmpstr, sizeof(tmpstr),
2109                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);
2110                          machine->kn230_csr = device_add(machine, tmpstr);                          machine->md_int.kn230_csr = device_add(machine, tmpstr);
2111    
2112                          serial_console_name = "osconsole=0";                          serial_console_name = "osconsole=0";
2113                          break;                          break;
# Line 1820  void machine_setup(struct machine *machi Line 2123  void machine_setup(struct machine *machi
2123                   */                   */
2124                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
2125    
2126                  /*  DECstation PROM stuff:  (TODO: endianness)  */                  if (machine->prom_emulation) {
2127                  for (i=0; i<100; i++)                          /*  DECstation PROM stuff:  (TODO: endianness)  */
2128                          store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,                          for (i=0; i<100; i++)
2129                              DEC_PROM_EMULATION + i*8);                                  store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
2130                                        DEC_PROM_EMULATION + i*8);
                 /*  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  */  
                 }  
2131    
2132                  /*                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2133                   *  According to dec_prom.h from NetBSD:                          for (i=0; i<100; i++) {
2134                   *                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2135                   *  "Programs loaded by the new PROMs pass the following arguments:                                      0x03e00008);        /*  return  */
2136                   *      a0      argc                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2137                   *      a1      argv                                      0x00000000);        /*  nop  */
2138                   *      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.  
                  */  
2139    
2140                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          /*
2141                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                           *  According to dec_prom.h from NetBSD:
2142                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                           *
2143                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                           *  "Programs loaded by the new PROMs pass the following arguments:
2144                             *      a0      argc
2145                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                           *      a1      argv
2146                      BOOTINFO_MAGIC);                           *      a2      DEC_PROM_MAGIC
2147                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                           *      a3      The callback vector defined below"
2148                      BOOTINFO_ADDR);                           *
2149                             *  So we try to emulate a PROM, even though no such thing has been
2150                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                           *  loaded.
2151                      (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);  
2152    
2153                  /*                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2154                   *  NetBSD and Ultrix expect the boot args to be like this:                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2155                   *                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2156                   *      "boot" "bootdev" [args?]                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2157                   *  
2158                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2159                   *  3100/2100 (although that crashes Ultrix :-/), and                              BOOTINFO_MAGIC);
2160                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2161                   *  slot number of the boot device.                              BOOTINFO_ADDR);
2162                   *  
2163                   *  'rz' for disks, 'tz' for tapes.                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2164                   *                              (DEC_PROM_INITIAL_ARGV + 0x10));
2165                   *  TODO:  Make this nicer.                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2166                   */                              (DEC_PROM_INITIAL_ARGV + 0x70));
2167                  {                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2168                          char bootpath[200];                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2169                            store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2170    
2171                            /*
2172                             *  NetBSD and Ultrix expect the boot args to be like this:
2173                             *
2174                             *      "boot" "bootdev" [args?]
2175                             *
2176                             *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2177                             *  3100/2100 (although that crashes Ultrix :-/), and
2178                             *  "5/rz0a/netbsd" for all others.  The number '5' is the
2179                             *  slot number of the boot device.
2180                             *
2181                             *  'rz' for disks, 'tz' for tapes.
2182                             *
2183                             *  TODO:  Make this nicer.
2184                             */
2185                            {
2186                            char bootpath[200];
2187  #if 0  #if 0
2188                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
2189                                  strcpy(bootpath, "rz(0,0,0)");                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
2190                          else                          else
2191  #endif  #endif
2192                                  strcpy(bootpath, "5/rz1/");                                  strlcpy(bootpath, "5/rz1/", sizeof(bootpath));
2193    
2194                          if (bootdev_id < 0 || machine->force_netboot) {                          if (bootdev_id < 0 || machine->force_netboot) {
2195                                  /*  tftp boot:  */                                  /*  tftp boot:  */
2196                                  strcpy(bootpath, "5/tftp/");                                  strlcpy(bootpath, "5/tftp/", sizeof(bootpath));
2197                                  bootpath[0] = '0' + boot_net_boardnumber;                                  bootpath[0] = '0' + boot_net_boardnumber;
2198                          } else {                          } else {
2199                                  /*  disk boot:  */                                  /*  disk boot:  */
2200                                  bootpath[0] = '0' + boot_scsi_boardnumber;                                  bootpath[0] = '0' + boot_scsi_boardnumber;
2201                                  if (diskimage_is_a_tape(machine, bootdev_id))                                  if (diskimage_is_a_tape(machine, bootdev_id,
2202                                        bootdev_type))
2203                                          bootpath[2] = 't';                                          bootpath[2] = 't';
2204                                  bootpath[4] = '0' + bootdev_id;                                  bootpath[4] = '0' + bootdev_id;
2205                          }                          }
2206    
2207                          init_bootpath = bootpath;                          init_bootpath = bootpath;
2208                  }                          }
2209    
2210                  bootarg = malloc(strlen(init_bootpath) +                          bootarg = malloc(BOOTARG_BUFLEN);
2211                      strlen(machine->boot_kernel_filename) + 1 +                          if (bootarg == NULL) {
2212                      strlen(machine->boot_string_argument) + 1);                                  fprintf(stderr, "out of memory\n");
2213                  strcpy(bootarg, init_bootpath);                                  exit(1);
2214                  strcat(bootarg, machine->boot_kernel_filename);                          }
2215                            strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2216                  bootstr = "boot";                          if (strlcat(bootarg, machine->boot_kernel_filename,
2217                                BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2218                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                                  fprintf(stderr, "bootarg truncated?\n");
2219                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                                  exit(1);
2220                  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;  
2221    
2222                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          bootstr = "boot";
2223    
2224                  /*                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2225                   *  The system's memmap:  (memmap is a global variable, in                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2226                   *  dec_prom.h)                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2227                   */                              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);  
2228    
2229                  /*                          /*  Decrease the nr of args, if there are no args :-)  */
2230                   *  The KN5800 (SMP system) uses a CCA (console communications                          if (machine->boot_string_argument == NULL ||
2231                   *  area):  (See VAX 6000 documentation for details.)                              machine->boot_string_argument[0] == '\0')
2232                   */                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2233                  {  
2234                          char tmps[300];                          if (machine->boot_string_argument[0] != '\0') {
2235                          sprintf(tmps, "cca=%x",                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2236                              (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));                                  if (strlcat(bootarg, machine->boot_string_argument,
2237                          add_environment_string(cpu, tmps, &addr);                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2238                  }                                          fprintf(stderr, "bootstr truncated?\n");
2239                                            exit(1);
2240                                    }
2241                            }
2242    
2243                  /*  These are needed for Sprite to boot:  */                          xx.a.common.next = (char *)&xx.b - (char *)&xx;
2244                  {                          xx.a.common.type = BTINFO_MAGIC;
2245                          char tmps[300];                          xx.a.magic = BOOTINFO_MAGIC;
2246    
2247                            xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2248                            xx.b.common.type = BTINFO_BOOTPATH;
2249                            strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2250    
2251                            xx.c.common.next = 0;
2252                            xx.c.common.type = BTINFO_SYMTAB;
2253                            xx.c.nsym = 0;
2254                            xx.c.ssym = 0;
2255                            xx.c.esym = machine->file_loaded_end_addr;
2256    
2257                          sprintf(tmps, "boot=%s", bootarg);                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
                         add_environment_string(cpu, tmps, &addr);  
2258    
2259                          sprintf(tmps, "bitmap=0x%x", (uint32_t)((                          /*
2260                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))                           *  The system's memmap:  (memmap is a global variable, in
2261                              & 0xffffffffULL));                           *  dec_prom.h)
2262                          add_environment_string(cpu, tmps, &addr);                           */
2263                            store_32bit_word_in_host(cpu,
2264                          sprintf(tmps, "bitmaplen=0x%x",                              (unsigned char *)&memmap.pagesize, 4096);
2265                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                          {
2266                          add_environment_string(cpu, tmps, &addr);                                  unsigned int i;
2267                  }                                  for (i=0; i<sizeof(memmap.bitmap); i++)
2268                                            memmap.bitmap[i] = ((int)i * 4096*8 <
2269                  add_environment_string(cpu, "scsiid0=7", &addr);                                              1048576*machine->physical_ram_in_mb)?
2270                  add_environment_string(cpu, "bootmode=a", &addr);                                              0xff : 0x00;
2271                  add_environment_string(cpu, "testaction=q", &addr);                          }
2272                  add_environment_string(cpu, "haltaction=h", &addr);                          store_buf(cpu, DEC_MEMMAP_ADDR, (char *)&memmap, sizeof(memmap));
                 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);  
2273    
2274                  /*  The end:  */                          /*  Environment variables:  */
2275                  add_environment_string(cpu, "", &addr);                          addr = DEC_PROM_STRINGS;
2276    
2277                            if (machine->use_x11 && machine->n_gfx_cards > 0)
2278                                    /*  (0,3)  Keyboard and Framebuffer  */
2279                                    add_environment_string(cpu, framebuffer_console_name, &addr);
2280                            else
2281                                    /*  Serial console  */
2282                                    add_environment_string(cpu, serial_console_name, &addr);
2283    
2284                            /*
2285                             *  The KN5800 (SMP system) uses a CCA (console communications
2286                             *  area):  (See VAX 6000 documentation for details.)
2287                             */
2288                            {
2289                                    char tmps[300];
2290                                    snprintf(tmps, sizeof(tmps), "cca=%x",
2291                                        (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2292                                    add_environment_string(cpu, tmps, &addr);
2293                            }
2294    
2295                            /*  These are needed for Sprite to boot:  */
2296                            {
2297                                    char tmps[500];
2298    
2299                                    snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2300                                    tmps[sizeof(tmps)-1] = '\0';
2301                                    add_environment_string(cpu, tmps, &addr);
2302    
2303                                    snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2304                                        DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2305                                        & 0xffffffffULL));
2306                                    tmps[sizeof(tmps)-1] = '\0';
2307                                    add_environment_string(cpu, tmps, &addr);
2308    
2309                                    snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2310                                        machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2311                                    tmps[sizeof(tmps)-1] = '\0';
2312                                    add_environment_string(cpu, tmps, &addr);
2313                            }
2314    
2315                            add_environment_string(cpu, "scsiid0=7", &addr);
2316                            add_environment_string(cpu, "bootmode=a", &addr);
2317                            add_environment_string(cpu, "testaction=q", &addr);
2318                            add_environment_string(cpu, "haltaction=h", &addr);
2319                            add_environment_string(cpu, "more=24", &addr);
2320    
2321                            /*  Used in at least Ultrix on the 5100:  */
2322                            add_environment_string(cpu, "scsiid=7", &addr);
2323                            add_environment_string(cpu, "baud0=9600", &addr);
2324                            add_environment_string(cpu, "baud1=9600", &addr);
2325                            add_environment_string(cpu, "baud2=9600", &addr);
2326                            add_environment_string(cpu, "baud3=9600", &addr);
2327                            add_environment_string(cpu, "iooption=0x1", &addr);
2328    
2329                            /*  The end:  */
2330                            add_environment_string(cpu, "", &addr);
2331                    }
2332    
2333                  break;                  break;
2334    
# Line 2027  void machine_setup(struct machine *machi Line 2345  void machine_setup(struct machine *machi
2345                   *      4       Tulip 1                   *      4       Tulip 1
2346                   *      5       16550 UART (serial console)                   *      5       16550 UART (serial console)
2347                   *      6       VIA southbridge PIC                   *      6       VIA southbridge PIC
2348                   *      7       PCI                   *      7       PCI  (Note: Not used. The PCI controller
2349                     *              interrupts at ISA interrupt 9.)
2350                   */                   */
2351  /*              dev_XXX_init(cpu, mem, 0x10000000, machine->emulated_hz);       */  
2352                    /*  ISA interrupt controllers:  */
2353                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2354                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2355                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2356                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2357                    machine->md_interrupt = cobalt_interrupt;
2358    
2359                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);
2360                  machine->main_console_handle = dev_ns16550_init(machine, mem,  
2361                      0x1c800000, 5, 1, 1, "serial console");                  machine->main_console_handle = (size_t)
2362                        device_add(machine, "ns16550 irq=5 addr=0x1c800000 name2=tty0 in_use=1");
2363    
2364    #if 0
2365                    device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0");
2366    #endif
2367    
2368                  /*                  /*
2369                   *  According to NetBSD/cobalt:                   *  According to NetBSD/cobalt:
# Line 2043  void machine_setup(struct machine *machi Line 2374  void machine_setup(struct machine *machi
2374                   *  pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37                   *  pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo VP) PCI-ISA Bridge, rev 37
2375                   *  pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr                   *  pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo VP) ATA33 cr
2376                   *  tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1                   *  tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1
2377                     *
2378                     *  The PCI controller interrupts at ISA interrupt 9.
2379                   */                   */
2380                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 6); /*  7 for PCI, not 6?  */                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 8 + 9, 11);
2381                  /*  bus_pci_add(machine, pci_data, mem, 0,  7, 0, pci_dec21143_init, pci_dec21143_rr);  */                  /*  bus_pci_add(machine, pci_data, mem, 0,  7, 0, pci_dec21143_init, pci_dec21143_rr);  */
2382                  bus_pci_add(machine, pci_data, mem, 0,  8, 0, NULL, NULL);  /*  PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860  */                  bus_pci_add(machine, pci_data, mem, 0,  8, 0, NULL, NULL);  /*  PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860  */
2383                  bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);                  bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);
2384                  bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);                  bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
2385                  /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr);  */                  /*  bus_pci_add(machine, pci_data, mem, 0, 12, 0, pci_dec21143_init, pci_dec21143_rr);  */
2386    
2387                  /*                  if (machine->prom_emulation) {
2388                   *  NetBSD/cobalt expects memsize in a0, but it seems that what                          /*
2389                   *  it really wants is the end of memory + 0x80000000.                           *  NetBSD/cobalt expects memsize in a0, but it seems that what
2390                   *                           *  it really wants is the end of memory + 0x80000000.
2391                   *  The bootstring should be stored starting 512 bytes before end                           *
2392                   *  of physical ram.                           *  The bootstring is stored 512 bytes before the end of
2393                   */                           *  physical ram.
2394                  cpu->cd.mips.gpr[MIPS_GPR_A0] = machine->physical_ram_in_mb * 1048576 + 0x80000000;                           */
2395                  bootstr = "root=/dev/hda1 ro";                          cpu->cd.mips.gpr[MIPS_GPR_A0] =
2396                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                              machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2397                  store_string(cpu, 0xffffffff80000000ULL +                          bootstr = "root=/dev/hda1 ro";
2398                      machine->physical_ram_in_mb * 1048576 - 512, bootstr);                          /*  bootstr = "nfsroot=/usr/cobalt/";  */
2399                            /*  TODO: bootarg, and/or automagic boot device detection  */
2400                            store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);
2401                    }
2402                  break;                  break;
2403    
2404          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
# Line 2099  void machine_setup(struct machine *machi Line 2435  void machine_setup(struct machine *machi
2435                          hpcmips_fb_bits = 15;                          hpcmips_fb_bits = 15;
2436                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2437    
2438                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2439                              machine, mem, 0xa008680, 0, 4,                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
2440                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2441                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4131);  
2442                            machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);
2443                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2444    
2445                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
# Line 2130  void machine_setup(struct machine *machi Line 2467  void machine_setup(struct machine *machi
2467                          hpcmips_fb_bits = 16;                          hpcmips_fb_bits = 16;
2468                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2469    
2470                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2471                              machine, mem, 0xa008680, 0, 4,                          snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x0a008680 addr_mult=4 in_use=%i", machine->use_x11? 0 : 1);
2472                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2473                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);  
2474                            machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
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,                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
# Line 2161  void machine_setup(struct machine *machi Line 2499  void machine_setup(struct machine *machi
2499                          hpcmips_fb_bits = 16;                          hpcmips_fb_bits = 16;
2500                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2501    
2502                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2503                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2504    
2505                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
# Line 2189  void machine_setup(struct machine *machi Line 2527  void machine_setup(struct machine *machi
2527                          hpcmips_fb_bits = 16;                          hpcmips_fb_bits = 16;
2528                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2529    
2530                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2531                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2532    
2533                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
# Line 2217  void machine_setup(struct machine *machi Line 2555  void machine_setup(struct machine *machi
2555                          hpcmips_fb_bits = 16;                          hpcmips_fb_bits = 16;
2556                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2557    
2558                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2559                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2560    
2561                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
# Line 2245  void machine_setup(struct machine *machi Line 2583  void machine_setup(struct machine *machi
2583                          hpcmips_fb_bits = 16;                          hpcmips_fb_bits = 16;
2584                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2585    
2586                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2587                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2588    
2589                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
# Line 2273  void machine_setup(struct machine *machi Line 2611  void machine_setup(struct machine *machi
2611                          hpcmips_fb_bits = 4;                          hpcmips_fb_bits = 4;
2612                          hpcmips_fb_encoding = BIFB_D4_M2L_F;                          hpcmips_fb_encoding = BIFB_D4_M2L_F;
2613    
2614                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4181);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4181);
2615                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2616    
2617                          /*  TODO: Hm... irq 17 according to linux, but                          /*  TODO: Hm... irq 17 according to linux, but
2618                              VRIP_INTR_SIU (=9) here?  */                              VRIP_INTR_SIU (=9) here?  */
2619                          {                          {
2620                                  int x;                                  int x;
2621                                  x = dev_ns16550_init(machine, mem, 0x0c000010,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x0c000010", 8 + VRIP_INTR_SIU);
2622                                      8 + VRIP_INTR_SIU, 1, 1, "serial 0");                                  x = (size_t)device_add(machine, tmpstr);
2623    
2624                                  if (!machine->use_x11)                                  if (!machine->use_x11)
2625                                          machine->main_console_handle = x;                                          machine->main_console_handle = x;
# Line 2304  void machine_setup(struct machine *machi Line 2642  void machine_setup(struct machine *machi
2642                          break;                          break;
2643                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:
2644                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2645                          machine->machine_name = "Agenda VR3";                          machine->machine_name = "IBM Workpad Z50";
2646                          /*  TODO:  */                          /*  TODO:  */
2647                          hpcmips_fb_addr = 0xa000000;                          hpcmips_fb_addr = 0xa000000;
2648                          hpcmips_fb_xsize = 640;                          hpcmips_fb_xsize = 640;
# Line 2314  void machine_setup(struct machine *machi Line 2652  void machine_setup(struct machine *machi
2652                          hpcmips_fb_bits = 16;                          hpcmips_fb_bits = 16;
2653                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpcmips_fb_encoding = BIFB_D16_0000;
2654    
2655                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2656                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2657    
2658                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
# Line 2337  void machine_setup(struct machine *machi Line 2675  void machine_setup(struct machine *machi
2675    
2676                  if (machine->use_x11)                  if (machine->use_x11)
2677                          machine->main_console_handle =                          machine->main_console_handle =
2678                              machine->vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
2679    
2680                  /*  NetBSD/hpcmips and possibly others expects the following:  */                  if (machine->prom_emulation) {
2681                            /*  NetBSD/hpcmips and possibly others expects the following:  */
                 cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */  
                 cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576  
                     + 0xffffffff80000000ULL - 512;      /*  argv  */  
                 cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576  
                     + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */  
   
                 bootstr = machine->boot_kernel_filename;  
                 store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16);  
                 store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);  
                 store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);  
   
                 /*  Special case for the Agenda VR3:  */  
                 if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {  
                         const int tmplen = 1000;  
                         char *tmp = malloc(tmplen);  
2682    
2683                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2684                            cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2685                                + 0xffffffff80000000ULL - 512;      /*  argv  */
2686                            cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2687                                + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */
2688    
2689                            bootstr = machine->boot_kernel_filename;
2690                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512,
2691                                0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2692                            store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2693                            store_string(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2694    
2695                            /*  Special case for the Agenda VR3:  */
2696                            if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2697                                    const int tmplen = 1000;
2698                                    char *tmp = malloc(tmplen);
2699    
2700                                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */
2701    
2702                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2703                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2704    
2705                                    snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2706                                        "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2707                                    tmp[tmplen-1] = '\0';
2708    
2709                          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)
2710                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2711                                    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';  
2712    
2713                          if (!machine->use_x11)                                  if (machine->boot_string_argument[0])
2714                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2715                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2716    
2717                          if (machine->boot_string_argument[0])                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
                                 snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);  
                         tmp[tmplen-1] = '\0';  
2718    
2719                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  bootarg = tmp;
2720                            } else if (machine->boot_string_argument[0]) {
2721                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2722    
2723                          bootarg = tmp;                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2724                  } else if (machine->boot_string_argument[0]) {                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
                         cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */  
2725    
2726                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2727                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                      machine->boot_string_argument);
2728    
2729                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,                                  bootarg = machine->boot_string_argument;
2730                              machine->boot_string_argument);                          }
2731    
2732                          bootarg = machine->boot_string_argument;                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2733                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2734                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);
2735                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);
2736                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);
2737                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);
2738                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);
2739                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */
2740    
2741                            /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);
2742                                printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */
2743                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2744                            store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2745                  }                  }
2746    
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);  
                 store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */  
   
                 /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);  
                     printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */  
                 store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);  
                 store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));  
   
2747                  if (hpcmips_fb_addr != 0) {                  if (hpcmips_fb_addr != 0) {
2748                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,
2749                              hpcmips_fb_xsize, hpcmips_fb_ysize,                              hpcmips_fb_xsize, hpcmips_fb_ysize,
2750                              hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,                              hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,
2751                              hpcmips_fb_bits, "HPCmips", 0);                              hpcmips_fb_bits, "HPCmips");
2752    
2753                          /*  NetBSD/hpcmips uses framebuffer at physical                          /*  NetBSD/hpcmips uses framebuffer at physical
2754                              address 0x8.......:  */                              address 0x8.......:  */
# Line 2437  void machine_setup(struct machine *machi Line 2778  void machine_setup(struct machine *machi
2778                   *      ohci0: OHCI version 1.0                   *      ohci0: OHCI version 1.0
2779                   */                   */
2780    
2781                  machine->ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);                  machine->md_int.ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);
2782                  device_add(machine, "ps2_gs addr=0x12000000");                  device_add(machine, "ps2_gs addr=0x12000000");
2783                  device_add(machine, "ps2_ether addr=0x14001000");                  device_add(machine, "ps2_ether addr=0x14001000");
2784                  dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0);     /*  TODO: how much?  */                  dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0);     /*  TODO: how much?  */
# Line 2446  void machine_setup(struct machine *machi Line 2787  void machine_setup(struct machine *machi
2787    
2788                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2789    
                 add_symbol_name(&machine->symbol_context,  
                     PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0);  
                 store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);  
                 store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);  
   
2790                  /*  Set the Harddisk controller present flag, if either                  /*  Set the Harddisk controller present flag, if either
2791                      disk 0 or 1 is present:  */                      disk 0 or 1 is present:  */
2792                  if (diskimage_exist(machine, 0) || diskimage_exist(machine, 1)) {                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2793                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2794                            if (machine->prom_emulation)
2795                                    store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2796                          dev_ps2_spd_init(machine, mem, 0x14000000);                          dev_ps2_spd_init(machine, mem, 0x14000000);
2797                  }                  }
2798    
2799                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                  if (machine->prom_emulation) {
                 {  
2800                          int tmplen = 1000;                          int tmplen = 1000;
2801                          char *tmp = malloc(tmplen);                          char *tmp = malloc(tmplen);
2802                            time_t timet;
2803                            struct tm *tm_ptr;
2804    
2805                            add_symbol_name(&machine->symbol_context,
2806                                PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2807                            store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2808                            store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2809    
2810                            store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2811                          if (tmp == NULL) {                          if (tmp == NULL) {
2812                                  fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2813                                  exit(1);                                  exit(1);
2814                          }                          }
2815    
2816                          strcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60");                          strlcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60", tmplen);
2817    
2818                          if (machine->boot_string_argument[0])                          if (machine->boot_string_argument[0])
2819                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),
# Line 2476  void machine_setup(struct machine *machi Line 2822  void machine_setup(struct machine *machi
2822    
2823                          bootstr = tmp;                          bootstr = tmp;
2824                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
                 }  
2825    
2826                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
                 {  
                         time_t timet;  
                         struct tm *tmp;  
2827    
2828                          /*  RTC data given by the BIOS:  */                          /*  RTC data given by the BIOS:  */
2829                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */
2830                          tmp = gmtime(&timet);                          tm_ptr = gmtime(&timet);
2831                          /*  TODO:  are these 0- or 1-based?  */                          /*  TODO:  are these 0- or 1-based?  */
2832                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 1, int_to_bcd(tmp->tm_sec));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 1, int_to_bcd(tm_ptr->tm_sec));
2833                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 2, int_to_bcd(tmp->tm_min));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 2, int_to_bcd(tm_ptr->tm_min));
2834                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 3, int_to_bcd(tmp->tm_hour));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 3, int_to_bcd(tm_ptr->tm_hour));
2835                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 5, int_to_bcd(tmp->tm_mday));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 5, int_to_bcd(tm_ptr->tm_mday));
2836                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 6, int_to_bcd(tmp->tm_mon + 1));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 6, int_to_bcd(tm_ptr->tm_mon + 1));
2837                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 7, int_to_bcd(tmp->tm_year - 100));                          store_byte(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x10 + 7, int_to_bcd(tm_ptr->tm_year - 100));
                 }  
2838    
2839                  /*  "BOOTINFO_PCMCIA_TYPE" in NetBSD's bootinfo.h. This contains the sbus controller type.  */                          /*  "BOOTINFO_PCMCIA_TYPE" in NetBSD's bootinfo.h. This contains the sbus controller type.  */
2840                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x1c, 2);
2841                    }
2842    
2843                  break;                  break;
2844    
# Line 2510  void machine_setup(struct machine *machi Line 2852  void machine_setup(struct machine *machi
2852                   *  detailed list of IP ("Inhouse Processor") model numbers.                   *  detailed list of IP ("Inhouse Processor") model numbers.
2853                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)
2854                   */                   */
2855                  machine->machine_name = malloc(500);                  machine->machine_name = malloc(MACHINE_NAME_MAXBUF);
2856                  if (machine->machine_name == NULL) {                  if (machine->machine_name == NULL) {
2857                          fprintf(stderr, "out of memory\n");                          fprintf(stderr, "out of memory\n");
2858                          exit(1);                          exit(1);
2859                  }                  }
                 short_machine_name = malloc(500);  
                 if (short_machine_name == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
2860    
2861                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2862                          cpu->byte_order = EMUL_BIG_ENDIAN;                          cpu->byte_order = EMUL_BIG_ENDIAN;
2863                          sprintf(short_machine_name, "SGI-IP%i", machine->machine_subtype);                          snprintf(machine->machine_name, MACHINE_NAME_MAXBUF,
2864                          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");  
2865    
2866                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;
2867    
# Line 2546  void machine_setup(struct machine *machi Line 2879  void machine_setup(struct machine *machi
2879                          }                          }
2880                  } else {                  } else {
2881                          cpu->byte_order = EMUL_LITTLE_ENDIAN;                          cpu->byte_order = EMUL_LITTLE_ENDIAN;
2882                          sprintf(short_machine_name, "ARC");                          snprintf(machine->machine_name,
2883                          sprintf(machine->machine_name, "ARC");                              MACHINE_NAME_MAXBUF, "ARC");
2884                  }                  }
2885    
2886                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2887                          /*  TODO:  Other SGI machine types?  */                          /*  TODO:  Other SGI machine types?  */
2888                          switch (machine->machine_subtype) {                          switch (machine->machine_subtype) {
2889                          case 12:                          case 12:
2890                                  strcat(machine->machine_name, " (Iris Indigo IP12)");                                  strlcat(machine->machine_name,
2891                                        " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);
2892    
2893                                  /*  TODO  */                                  /*  TODO  */
2894                                  /*  33 MHz R3000, according to http://www.irisindigo.com/  */                                  /*  33 MHz R3000, according to http://www.irisindigo.com/  */
# Line 2562  void machine_setup(struct machine *machi Line 2896  void machine_setup(struct machine *machi
2896    
2897                                  break;                                  break;
2898                          case 19:                          case 19:
2899                                  strcat(machine->machine_name, " (Everest IP19)");                                  strlcat(machine->machine_name,
2900                                        " (Everest IP19)", MACHINE_NAME_MAXBUF);
2901                                  machine->main_console_handle =                                  machine->main_console_handle =
2902                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */
2903                                  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 2582  void machine_setup(struct machine *machi Line 2917  void machine_setup(struct machine *machi
2917    
2918                                  break;                                  break;
2919                          case 20:                          case 20:
2920                                  strcat(machine->machine_name, " (Indigo)");                                  strlcat(machine->machine_name,
2921                                        " (Indigo)", MACHINE_NAME_MAXBUF);
2922    
2923                                  /*                                  /*
2924                                   *  Guesses based on NetBSD 2.0 beta, 20040606.                                   *  Guesses based on NetBSD 2.0 beta, 20040606.
# Line 2602  void machine_setup(struct machine *machi Line 2938  void machine_setup(struct machine *machi
2938                                   */                                   */
2939    
2940                                  /*  int0 at mainbus0 addr 0x1fb801c0  */                                  /*  int0 at mainbus0 addr 0x1fb801c0  */
2941                                  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);
2942    
2943                                  /*  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?)  */
2944    
# Line 2627  void machine_setup(struct machine *machi Line 2963  void machine_setup(struct machine *machi
2963    
2964                                  break;                                  break;
2965                          case 21:                          case 21:
2966                                  strcat(machine->machine_name, " (uknown SGI-IP21 ?)");  /*  TODO  */                                  strlcat(machine->machine_name,  /*  TODO  */
2967                                        " (uknown SGI-IP21 ?)", MACHINE_NAME_MAXBUF);
2968                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2969                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2970    
# Line 2637  void machine_setup(struct machine *machi Line 2974  void machine_setup(struct machine *machi
2974                          case 22:                          case 22:
2975                          case 24:                          case 24:
2976                                  if (machine->machine_subtype == 22) {                                  if (machine->machine_subtype == 22) {
2977                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Full-house)");                                          strlcat(machine->machine_name,
2978                                          machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);                                              " (Indy, Indigo2, Challenge S; Full-house)",
2979                                                MACHINE_NAME_MAXBUF);
2980                                            machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);
2981                                  } else {                                  } else {
2982                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Guiness)");                                          strlcat(machine->machine_name,
2983                                          machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);                                              " (Indy, Indigo2, Challenge S; Guiness)",
2984                                                MACHINE_NAME_MAXBUF);
2985                                            machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);
2986                                  }                                  }
2987    
2988  /*  /*
# Line 2684  Why is this here? TODO Line 3025  Why is this here? TODO
3025    
3026                                  /*  Not supported by NetBSD 1.6.2, but by 2.0_BETA:  */                                  /*  Not supported by NetBSD 1.6.2, but by 2.0_BETA:  */
3027                                  j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,                                  j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,
3028                                      0, 0, machine->use_x11);  /*  TODO: irq numbers  */                                      0, 0, machine->use_x11, 0);  /*  TODO: irq numbers  */
3029    
3030                                  if (machine->use_x11)                                  if (machine->use_x11)
3031                                          machine->main_console_handle = j;                                          machine->main_console_handle = j;
# Line 2713  Why is this here? TODO Line 3054  Why is this here? TODO
3054                          case 25:                          case 25:
3055                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3056                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3057                                  strcat(machine->machine_name, " (Everest IP25)");                                  strlcat(machine->machine_name,
3058                                        " (Everest IP25)", MACHINE_NAME_MAXBUF);
3059    
3060                                   /*  serial? irix?  */                                   /*  serial? irix?  */
3061                                  dev_scc_init(machine, mem,                                  dev_scc_init(machine, mem,
# Line 2734  Why is this here? TODO Line 3076  Why is this here? TODO
3076                          case 26:                          case 26:
3077                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3078                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3079                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
3080                                      " (uknown SGI-IP26 ?)");    /*  TODO  */                                      " (uknown SGI-IP26 ?)",
3081                                        MACHINE_NAME_MAXBUF);       /*  TODO  */
3082                                  machine->main_console_handle =                                  machine->main_console_handle =
3083                                      dev_zs_init(machine, mem, 0x1fbd9830,                                      dev_zs_init(machine, mem, 0x1fbd9830,
3084                                      0, 1, "zs console");                                      0, 1, "zs console");
3085                                  break;                                  break;
3086                          case 27:                          case 27:
3087                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
3088                                      " (Origin 200/2000, Onyx2)");                                      " (Origin 200/2000, Onyx2)",
3089                                        MACHINE_NAME_MAXBUF);
3090                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3091                                  /*  2 cpus per node  */                                  /*  2 cpus per node  */
3092    
# Line 2753  Why is this here? TODO Line 3097  Why is this here? TODO
3097                          case 28:                          case 28:
3098                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3099                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3100                                  strcat(machine->machine_name, " (Impact Indigo2 ?)");                                  strlcat(machine->machine_name,
3101                                        " (Impact Indigo2 ?)", MACHINE_NAME_MAXBUF);
3102    
3103                                  device_add(machine, "random addr=0x1fbe0000, len=1");                                  device_add(machine, "random addr=0x1fbe0000, len=1");
3104    
# Line 2763  Why is this here? TODO Line 3108  Why is this here? TODO
3108                          case 30:                          case 30:
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, " (Octane)");                                  strlcat(machine->machine_name,
3112                                        " (Octane)", MACHINE_NAME_MAXBUF);
3113    
3114                                  machine->sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);
3115                                  machine->md_interrupt = sgi_ip30_interrupt;                                  machine->md_interrupt = sgi_ip30_interrupt;
3116    
3117                                  dev_ram_init(mem,    0xa0000000ULL,                                  dev_ram_init(mem,    0xa0000000ULL,
# Line 2787  Why is this here? TODO Line 3133  Why is this here? TODO
3133                                   *  program dumps something there, but it doesn't look like                                   *  program dumps something there, but it doesn't look like
3134                                   *  readable text.  (TODO)                                   *  readable text.  (TODO)
3135                                   */                                   */
3136                                  machine->main_console_handle = dev_ns16550_init(machine, mem, 0x1f620170, 0, 1,  
3137                                      machine->use_x11? 0 : 1, "serial 0");  /*  TODO: irq?  */                                  /*  TODO: irq!  */
3138                                  dev_ns16550_init(machine, mem, 0x1f620178, 0, 1,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620170 name2=tty0 in_use=%i", machine->use_x11? 0 : 1);
3139                                      0, "serial 1");  /*  TODO: irq?  */                                  machine->main_console_handle = (size_t)device_add(machine, tmpstr);
3140                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620178 name2=tty1 in_use=0");
3141                                    device_add(machine, tmpstr);
3142    
3143                                  /*  MardiGras graphics:  */                                  /*  MardiGras graphics:  */
3144                                  device_add(machine, "sgi_mardigras addr=0x1c000000");                                  device_add(machine, "sgi_mardigras addr=0x1c000000");
3145    
3146                                  break;                                  break;
3147                          case 32:                          case 32:
3148                                  strcat(machine->machine_name, " (O2)");                                  strlcat(machine->machine_name,
3149                                        " (O2)", MACHINE_NAME_MAXBUF);
3150    
3151                                  /*  TODO:  Find out where the physical ram is actually located.  */                                  /*  TODO:  Find out where the physical ram is actually located.  */
3152                                  dev_ram_init(mem, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(mem, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
# Line 2808  Why is this here? TODO Line 3157  Why is this here? TODO
3157                                  dev_ram_init(mem, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);                                  dev_ram_init(mem, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);
3158                                  dev_ram_init(mem, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);                                  dev_ram_init(mem, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);
3159    
3160                                  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  */
3161                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */
3162                                  dev_sgi_gbe_init(machine, mem, 0x16000000);     /*  gbe?  framebuffer?  */                                  dev_sgi_gbe_init(machine, mem, 0x16000000);     /*  gbe?  framebuffer?  */
3163    
# Line 2835  Why is this here? TODO Line 3184  Why is this here? TODO
3184                                   *        1f3a0000        mcclock0                                   *        1f3a0000        mcclock0
3185                                   */                                   */
3186    
3187                                  machine->mace_data = dev_mace_init(mem, 0x1f310000, 2);                                  machine->md_int.ip32.mace_data = dev_mace_init(mem, 0x1f310000, 2);
3188                                  machine->md_interrupt = sgi_ip32_interrupt;                                  machine->md_interrupt = sgi_ip32_interrupt;
3189    
3190                                  /*                                  /*
# Line 2852  Why is this here? TODO Line 3201  Why is this here? TODO
3201                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
3202                                   */                                   */
3203    
                                 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)  */  
   
3204                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3205                                  eaddr_string = malloc(30);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3206                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
3207                                          fprintf(stderr, "out of memory\n");                                          fprintf(stderr, "out of memory\n");
3208                                          exit(1);                                          exit(1);
3209                                  }                                  }
3210                                  sprintf(eaddr_string, "eaddr=%02x:%02x:"                                  snprintf(eaddr_string, ETHERNET_STRING_MAXLEN,
3211                                      "%02x:%02x:%02x:%02x",                                      "eaddr=%02x:%02x:%02x:%02x:%02x:%02x",
3212                                      macaddr[0], macaddr[1], macaddr[2],                                      macaddr[0], macaddr[1], macaddr[2],
3213                                      macaddr[3], macaddr[4], macaddr[5]);                                      macaddr[3], macaddr[4], macaddr[5]);
3214                                  dev_sgi_mec_init(machine, mem, 0x1f280000, MACE_ETHERNET, macaddr);                                  dev_sgi_mec_init(machine, mem, 0x1f280000,
3215                                        MACE_ETHERNET, macaddr);
3216    
3217                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */
3218    
3219                                  j = dev_ns16550_init(machine, mem, 0x1f390000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f390000 addr_mult=0x100 in_use=%i name2=tty0",
3220                                      (1<<20) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<20) + MACE_PERIPH_SERIAL, machine->use_x11? 0 : 1);
3221                                      machine->use_x11? 0 : 1, "serial 0");       /*  com0  */                                  j = (size_t)device_add(machine, tmpstr);
3222                                  dev_ns16550_init(machine, mem, 0x1f398000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",
3223                                      (1<<26) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3224                                      0, "serial 1");                             /*  com1  */                                  device_add(machine, tmpstr);
3225    
3226                                  if (machine->use_x11)                                  machine->main_console_handle = j;
3227    
3228                                    /*  TODO: Once this works, it should be enabled
3229                                        always, not just when using X!  */
3230                                    if (machine->use_x11) {
3231                                            i = dev_pckbc_init(machine, mem, 0x1f320000,
3232                                                PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
3233                                                0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
3234                                                    /*  keyb+mouse (mace irq numbers)  */
3235                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3236                                  else                                  }
                                         machine->main_console_handle = j;  
3237    
3238                                  dev_mc146818_init(machine, mem, 0x1f3a0000, (1<<8) + MACE_PERIPH_MISC, MC146818_SGI, 0x40);  /*  mcclock0  */                                  dev_mc146818_init(machine, mem, 0x1f3a0000, (1<<8) + MACE_PERIPH_MISC, MC146818_SGI, 0x40);  /*  mcclock0  */
3239                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");                                  dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "zs console");
# Line 2896  Why is this here? TODO Line 3248  Why is this here? TODO
3248    
3249                                  pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE);  /*  macepci0  */                                  pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE);  /*  macepci0  */
3250                                  /*  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, pci_ne2000_init, pci_ne2000_rr);  TODO  */
3251  #if 1  
3252                                  bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr);                                  /*  TODO: make this nicer  */
3253  #endif                                  if (diskimage_exist(machine, 0, DISKIMAGE_SCSI) ||
3254                                        diskimage_exist(machine, 1, DISKIMAGE_SCSI) ||
3255                                        diskimage_exist(machine, 2, DISKIMAGE_SCSI) ||
3256                                        diskimage_exist(machine, 3, DISKIMAGE_SCSI) ||
3257                                        diskimage_exist(machine, 4, DISKIMAGE_SCSI) ||
3258                                        diskimage_exist(machine, 5, DISKIMAGE_SCSI) ||
3259                                        diskimage_exist(machine, 6, DISKIMAGE_SCSI) ||
3260                                        diskimage_exist(machine, 7, DISKIMAGE_SCSI))
3261                                            bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr);
3262    
3263                                    /*  TODO: second ahc  */
3264                                  /*  bus_pci_add(machine, pci_data, mem, 0, 2, 0, pci_ahc_init, pci_ahc_rr);  */                                  /*  bus_pci_add(machine, pci_data, mem, 0, 2, 0, pci_ahc_init, pci_ahc_rr);  */
3265    
3266                                  break;                                  break;
3267                          case 35:                          case 35:
3268                                  strcat(machine->machine_name, " (Origin 3000)");                                  strlcat(machine->machine_name,
3269                                        " (Origin 3000)", MACHINE_NAME_MAXBUF);
3270                                  /*  4 cpus per node  */                                  /*  4 cpus per node  */
3271    
3272                                  machine->main_console_handle =                                  machine->main_console_handle =
# Line 2911  Why is this here? TODO Line 3274  Why is this here? TODO
3274                                      0, 1, "zs console");                                      0, 1, "zs console");
3275                                  break;                                  break;
3276                          case 53:                          case 53:
3277                                  strcat(machine->machine_name, " (Origin 350)");                                  strlcat(machine->machine_name,
3278                                        " (Origin 350)", MACHINE_NAME_MAXBUF);
3279                                  /*                                  /*
3280                                   *  According to http://kumba.drachentekh.net/xml/myguide.html                                   *  According to http://kumba.drachentekh.net/xml/myguide.html
3281                                   *  Origin 350, Tezro IP53 R16000                                   *  Origin 350, Tezro IP53 R16000
# Line 2938  Why is this here? TODO Line 3302  Why is this here? TODO
3302    
3303                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3304                                  case MACHINE_ARC_NEC_RD94:                                  case MACHINE_ARC_NEC_RD94:
3305                                          strcat(machine->machine_name, " (NEC-RD94, NEC RISCstation 2250)");                                          strlcat(machine->machine_name,
3306                                                " (NEC-RD94, NEC RISCstation 2250)",
3307                                                MACHINE_NAME_MAXBUF);
3308                                          break;                                          break;
3309                                  case MACHINE_ARC_NEC_R94:                                  case MACHINE_ARC_NEC_R94:
3310                                          strcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)");                                          strlcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)",
3311                                                MACHINE_NAME_MAXBUF);
3312                                          break;                                          break;
3313                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3314                                          strcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)");                                          strlcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)",
3315                                                MACHINE_NAME_MAXBUF);
3316                                          break;                                          break;
3317                                  }                                  }
3318    
# Line 2955  Why is this here? TODO Line 3323  Why is this here? TODO
3323    
3324                                  device_add(machine, "sn addr=0x80001000 irq=0");                                  device_add(machine, "sn addr=0x80001000 irq=0");
3325                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);
3326                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11);                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL, PCKBC_8042, 0, 0, machine->use_x11, 0);
3327                                  j = dev_ns16550_init(machine, mem, 0x80006000ULL,  
3328                                      3, 1, machine->use_x11? 0 : 1, "serial 0");  /*  com0  */                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3329                                  dev_ns16550_init(machine, mem, 0x80007000ULL,                                  j = (size_t)device_add(machine, tmpstr);
3330                                      0, 1, 0, "serial 1"); /*  com1  */                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0);
3331                                    device_add(machine, tmpstr);
3332    
3333                                  if (machine->use_x11)                                  if (machine->use_x11)
3334                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 2979  Why is this here? TODO Line 3348  Why is this here? TODO
3348                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3349                                          dev_fb_init(machine, mem, 0x100e00000ULL,                                          dev_fb_init(machine, mem, 0x100e00000ULL,
3350                                              VFB_GENERIC, 640,480, 1024,480,                                              VFB_GENERIC, 640,480, 1024,480,
3351                                              8, "necvdfrb", 1);                                              8, "necvdfrb");
3352                                          break;                                          break;
3353                                  }                                  }
3354                                  break;                                  break;
# Line 2998  Why is this here? TODO Line 3367  Why is this here? TODO
3367                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"
3368                                   */                                   */
3369    
3370                                  strcat(machine->machine_name, " (NEC-R98; NEC RISCserver 4200)");                                  strlcat(machine->machine_name,
3371                                        " (NEC-R98; NEC RISCserver 4200)",
3372                                        MACHINE_NAME_MAXBUF);
3373    
3374                                  /*                                  /*
3375                                   *  Windows NT access stuff at these addresses:                                   *  Windows NT access stuff at these addresses:
# Line 3054  Why is this here? TODO Line 3425  Why is this here? TODO
3425    
3426                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3427                                  case MACHINE_ARC_JAZZ_PICA:                                  case MACHINE_ARC_JAZZ_PICA:
3428                                          strcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)",
3429                                                MACHINE_NAME_MAXBUF);
3430                                          break;                                          break;
3431                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3432                                          strcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)",
3433                                                MACHINE_NAME_MAXBUF);
3434                                          break;                                          break;
3435                                  default:                                  default:
3436                                          fatal("error in machine.c. jazz\n");                                          fatal("error in machine.c. jazz\n");
3437                                          exit(1);                                          exit(1);
3438                                  }                                  }
3439    
3440                                  machine->jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3441                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
3442                                  machine->md_interrupt = jazz_interrupt;                                  machine->md_interrupt = jazz_interrupt;
3443    
3444                                    i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3445                                        PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3446    
3447                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3448                                    j = (size_t)device_add(machine, tmpstr);
3449                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3450                                    device_add(machine, tmpstr);
3451    
3452                                    if (machine->use_x11)
3453                                            machine->main_console_handle = i;
3454                                    else
3455                                            machine->main_console_handle = j;
3456    
3457                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3458                                  case MACHINE_ARC_JAZZ_PICA:                                  case MACHINE_ARC_JAZZ_PICA:
3459                                          dev_vga_init(machine, mem,                                          if (machine->use_x11) {
3460                                              0x400b8000ULL, 0x600003c0ULL,                                                  dev_vga_init(machine, mem,
3461                                              ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);                                                      0x400a0000ULL, 0x600003c0ULL,
3462                                          arcbios_console_init(cpu, 0x400b8000ULL,                                                      machine->machine_name);
3463                                              0x600003c0ULL, ARC_CONSOLE_MAX_X,                                                  arcbios_console_init(machine,
3464                                              ARC_CONSOLE_MAX_Y);                                                      0x400b8000ULL, 0x600003c0ULL);
3465                                            }
3466                                          break;                                          break;
3467                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3468                                          /*  PROM mirror?  */                                          /*  PROM mirror?  */
# Line 3086  Why is this here? TODO Line 3473  Why is this here? TODO
3473                                          /*  control at 0x60100000?  */                                          /*  control at 0x60100000?  */
3474                                          dev_fb_init(machine, mem, 0x60200000ULL,                                          dev_fb_init(machine, mem, 0x60200000ULL,
3475                                              VFB_GENERIC, 1024,768, 1024,768,                                              VFB_GENERIC, 1024,768, 1024,768,
3476                                              8, "VXL", 1);                                              8, "VXL");
3477                                          break;                                          break;
3478                                  }                                  }
3479    
# Line 3095  Why is this here? TODO Line 3482  Why is this here? TODO
3482    
3483                                  dev_asc_init(machine, mem,                                  dev_asc_init(machine, mem,
3484                                      0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA,                                      0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA,
3485                                      dev_jazz_dma_controller, machine->jazz_data);                                      dev_jazz_dma_controller,
3486                                        machine->md_int.jazz_data);
3487    
3488                                  device_add(machine, "fdc addr=0x80003000, irq=0");                                  device_add(machine, "fdc addr=0x80003000, irq=0");
3489    
3490                                  dev_mc146818_init(machine, mem,                                  dev_mc146818_init(machine, mem,
3491                                      0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);                                      0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);
3492    
                                 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;  
   
3493  #if 0  #if 0
3494  Not yet.  Not yet.
3495                                  dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);                                  /*  irq = 8+16 + 14  */
3496                                    device_add(machine, "wdc addr=0x900001f0, irq=38");
3497  #endif  #endif
3498    
3499                                  break;                                  break;
# Line 3133  Not yet. Line 3508  Not yet.
3508                                   *  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.
3509                                   */                                   */
3510    
3511                                  strcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)");                                  strlcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)",
3512                                        MACHINE_NAME_MAXBUF);
3513    
3514                                  machine->jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3515                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
3516                                  machine->md_interrupt = jazz_interrupt;                                  machine->md_interrupt = jazz_interrupt;
3517    
# Line 3145  Not yet. Line 3521  Not yet.
3521                                  i = 0;          /*  TODO: Yuck!  */                                  i = 0;          /*  TODO: Yuck!  */
3522  #if 0  #if 0
3523                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3524                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11);                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3525  #endif  #endif
3526                                  j = dev_ns16550_init(machine, mem,  
3527                                      0x80006000ULL, 8 + 8, 1,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3528                                      machine->use_x11? 0 : 1, "serial 0");                                  j = (size_t)device_add(machine, tmpstr);
3529                                  dev_ns16550_init(machine, mem,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3530                                      0x80007000ULL, 8 + 9, 1, 0, "serial 1");                                  device_add(machine, tmpstr);
3531    
3532                                  if (machine->use_x11)                                  if (machine->use_x11)
3533                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3171  Not yet. Line 3547  Not yet.
3547                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html
3548                                   */                                   */
3549    
3550                                  strcat(machine->machine_name, " (Deskstation Tyne)");                                  strlcat(machine->machine_name, " (Deskstation Tyne)",
3551                                        MACHINE_NAME_MAXBUF);
                                 dev_vga_init(machine, mem, 0x1000b8000ULL, 0x9000003c0ULL,  
                                     ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);  
3552    
3553                                  arcbios_console_init(cpu, 0x1000b8000ULL,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3554                                      0x9000003c0ULL, ARC_CONSOLE_MAX_X,                                  i = (size_t)device_add(machine, tmpstr);
3555                                      ARC_CONSOLE_MAX_Y);                                  device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0 name2=tty1");
3556                                    device_add(machine, "ns16550 irq=0 addr=0x9000003e8 in_use=0 name2=tty2");
3557                                  i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");                                  device_add(machine, "ns16550 irq=0 addr=0x9000002e8 in_use=0 name2=tty3");
                                 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");  
3558    
3559                                  dev_mc146818_init(machine, mem,                                  dev_mc146818_init(machine, mem,
3560                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3561    
3562  #if 0  #if 0
3563                                  dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);                                  /*  TODO: irq, etc  */
3564                                  dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);                                  device_add(machine, "wdc addr=0x9000001f0, irq=0");
3565                                    device_add(machine, "wdc addr=0x900000170, irq=0");
3566  #endif  #endif
3567                                  /*  PC kbd  */                                  /*  PC kbd  */
3568                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,
3569                                      PCKBC_8042, 0, 0, machine->use_x11);                                      PCKBC_8042, 0, 0, machine->use_x11, 0);
3570    
3571                                  if (machine->use_x11)                                  if (machine->use_x11)
3572                                          machine->main_console_handle = j;                                          machine->main_console_handle = j;
3573                                  else                                  else
3574                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3575    
3576                                    if (machine->use_x11) {
3577                                            dev_vga_init(machine, mem, 0x1000a0000ULL,
3578                                                0x9000003c0ULL, machine->machine_name);
3579    
3580                                            arcbios_console_init(machine,
3581                                                0x1000b8000ULL, 0x9000003c0ULL);
3582                                    }
3583                                  break;                                  break;
3584    
3585                          default:                          default:
# Line 3210  Not yet. Line 3589  Not yet.
3589                          }                          }
3590                  }                  }
3591    
   
                 if (!machine->prom_emulation)  
                         goto no_arc_prom_emulation;     /*  TODO: ugly  */  
   
   
3592                  /*                  /*
3593                   *  This is important:  :-)                   *  This is important:  :-)
3594                   *                   *
3595                   *  TODO:  There should not be any use of                   *  TODO:  There should not be any use of ARCBIOS before this
3596                   *  ARCBIOS before this statement.                   *  point.
3597                   */                   */
                 if (arc_wordlen == sizeof(uint64_t))  
                         arcbios_set_64bit_mode(1);  
3598    
3599                  if (machine->physical_ram_in_mb < 16)                  if (machine->prom_emulation) {
3600                          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),
3601                                sgi_ram_offset);
3602    
3603                  arcbios_set_default_exception_handler(cpu);                          /*
3604                             *  TODO: How to build the component tree intermixed with
3605                             *  the rest of device initialization?
3606                             */
3607    
3608                  memset(&arcbios_sysid, 0, sizeof(arcbios_sysid));                          /*
3609                  if (machine->machine_type == MACHINE_SGI) {                           *  Boot string in ARC format:
3610                          /*  Vendor ID, max 8 chars:  */                           *
3611                          strncpy(arcbios_sysid.VendorId,  "SGI", 3);                           *  TODO: How about floppies? multi()disk()fdisk()
3612                          switch (machine->machine_subtype) {                           *        Is tftp() good for netbooting?
3613                          case 22:                           */
3614                                  strncpy(arcbios_sysid.ProductId,                          init_bootpath = malloc(500);
3615                                      "87654321", 8);     /*  some kind of ID?  */                          if (init_bootpath == NULL) {
3616                                  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");  
3617                                  exit(1);                                  exit(1);
3618                          }                          }
3619                  }                          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));  
3620    
3621                  /*                          if (bootdev_id < 0 || machine->force_netboot) {
3622                   *  The first 12 MBs of RAM are simply reserved... this simplifies things a lot.                                  snprintf(init_bootpath, 400, "tftp()");
3623                   *  If there's more than 512MB of RAM, it has to be split in two, according to                          } else {
3624                   *  the ARC spec.  This code creates a number of chunks of at most 512MB each.                                  /*  TODO: Make this nicer.  */
3625                   *                                  if (machine->machine_type == MACHINE_SGI) {
3626                   *  NOTE:  The region of physical address space between 0x10000000 and 0x1fffffff                                          if (machine->machine_subtype == 30)
3627                   *  (256 - 512 MB) is usually occupied by memory mapped devices, so that portion is "lost".                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3628                   */                                                      MACHINE_NAME_MAXBUF);
3629                                            if (machine->machine_subtype == 32)
3630                                                    strlcat(init_bootpath, "pci(0)",
3631                                                        MACHINE_NAME_MAXBUF);
3632                                    }
3633    
3634                  arc_reserved = 0x2000;                                  if (diskimage_is_a_cdrom(machine, bootdev_id,
3635                  if (machine->machine_type == MACHINE_SGI)                                      bootdev_type))
3636                          arc_reserved = 0x4000;                                          snprintf(init_bootpath + strlen(init_bootpath),
3637                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3638                  arcbios_add_memory_descriptor(cpu, 0, arc_reserved, ARCBIOS_MEM_FirmwarePermanent);                                  else
3639                  arcbios_add_memory_descriptor(cpu, sgi_ram_offset + arc_reserved, 0x60000-arc_reserved, ARCBIOS_MEM_FirmwareTemporary);                                          snprintf(init_bootpath + strlen(init_bootpath),
3640                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3641                  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;  
3642                          }                          }
3643    
3644                          /*  At most 512MB per descriptor (at least the first 512MB                          if (machine->machine_type == MACHINE_ARC)
3645                              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;  
                 }  
   
3646    
3647                  /*                          bootstr = malloc(BOOTSTR_BUFLEN);
3648                   *  Components:   (this is an example of what a system could look like)                          if (bootstr == NULL) {
3649                   *                                  fprintf(stderr, "out of memory\n");
                  *  [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");  
   
                 switch (machine->machine_type) {  
                 case MACHINE_SGI:  
                         system = arcbios_addchild_manual(cpu, COMPONENT_CLASS_SystemClass, COMPONENT_TYPE_ARC,  
                             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);  
3650                                  exit(1);                                  exit(1);
3651                          }                          }
3652                  }                          strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3653                            if (strlcat(bootstr, machine->boot_kernel_filename,
3654                                BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3655                  /*                                  fprintf(stderr, "boot string too long?\n");
3656                   *  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);  
3657                          }                          }
                 }  
3658    
3659                            /*  Boot args., eg "-a"  */
3660                            bootarg = machine->boot_string_argument;
3661    
3662                  /*                          /*  argc, argv, envp in a0, a1, a2:  */
3663                   *  Other components, and default TLB entries:                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 0;      /*  note: argc is increased later  */
                  *  
                  *  TODO: How to build the component tree intermixed with  
                  *  the rest of device initialization?  
                  */  
3664    
3665                  if (machine->machine_type == MACHINE_SGI) {                          /*  TODO:  not needed?  */
3666                          /*  TODO: On which models is this required?  */                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3667                          mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3668                              0xc000000000000000ULL,  
3669                              0x0, 1048576*16,                          /*  Set up argc/argv:  */
3670                              1, 1, 1, 1, 1, 0, 2, 2);                          addr = ARC_ENV_STRINGS;
3671                  }                          addr2 = ARC_ARGV_START;
3672                            cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
                 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);  
3673    
3674                          switch (machine->machine_subtype) {                          /*  bootstr:  */
3675                          case MACHINE_ARC_NEC_RD94:                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3676                          case MACHINE_ARC_NEC_R94:                          add_environment_string(cpu, bootstr, &addr);
3677                                  if (machine->use_x11)                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                                         arcbios_addchild_manual(cpu,  
                                             COMPONENT_CLASS_ControllerClass,  
                                             COMPONENT_TYPE_DisplayController,  
                                             0, 1, 2, 0, 0x0, "10110004",  
                                             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);  
                                 }  
   
                                 /*  TODO: R[D]94 too?  */  
                                 eisa = arcbios_addchild_manual(cpu,  
                                     COMPONENT_CLASS_AdapterClass,  
                                     COMPONENT_TYPE_EISAAdapter,  
                                     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);  
3678    
3679                                  break;                          /*  bootarg:  */
3680                            if (bootarg[0] != '\0') {
3681                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3682                                    add_environment_string(cpu, bootarg, &addr);
3683                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3684                          }                          }
                 }  
3685    
3686                  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);  
3687    
3688                          /*                          /*
3689                           *  DisplayController, needed by NetBSD:                           *  Add environment variables.  For each variable, add it
3690                           *  TODO: NetBSD still doesn't use it :(                           *  as a string using add_environment_string(), and add a
3691                             *  pointer to it to the ARC_ENV_POINTERS array.
3692                           */                           */
3693                          switch (machine->machine_subtype) {                          if (machine->use_x11) {
3694                          case MACHINE_ARC_JAZZ_PICA:                                  if (machine->machine_type == MACHINE_ARC) {
3695                                  /*  Default TLB entries on PICA-61:  */                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3696                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3697                                  /* 7: 256K, asid: 0x0, v: 0xe1000000,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3698                                     p0: 0xfff00000(2.VG), p1: 0x0(0..G)  */                                          add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3699                                  mips_coproc_tlb_set_entry(cpu, 7, 262144,                                  } else {
3700                                      0xffffffffe1000000ULL,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3701                                      0x0fff00000ULL, 0,                                          add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3702                                      1, 0, 0, 0, 1, 0, 2, 0);                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3703                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3704                                  /* 8: 64K, asid: 0x0, v: 0xe0000000,  
3705                                     p0: 0x80000000(2DVG), p1: 0x0(0..G) */                                          /*  g for graphical mode. G for graphical mode
3706                                  mips_coproc_tlb_set_entry(cpu, 8, 65536,                                              with SGI logo visible on Irix?  */
3707                                      0xffffffffe0000000ULL,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3708                                      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);  
3709                                  }                                  }
3710                                  break;                          } else {
3711                          case MACHINE_ARC_JAZZ_MAGNUM:                                  if (machine->machine_type == MACHINE_ARC) {
3712                                  if (machine->use_x11) {                                          /*  TODO: serial console for ARC?  */
3713                                          vxl = arcbios_addchild_manual(cpu,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3714                                              COMPONENT_CLASS_ControllerClass,                                          add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3715                                              COMPONENT_TYPE_DisplayController,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3716                                              COMPONENT_FLAG_ConsoleOut |                                          add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3717                                                  COMPONENT_FLAG_Output,                                  } else {
3718                                              1, 2, 0, 0xffffffff, "VXL",                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3719                                              jazzbus, NULL, 0);                                          add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3720                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3721                                          arcbios_addchild_manual(cpu,                                          add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3722                                              COMPONENT_CLASS_PeripheralClass,  
3723                                              COMPONENT_TYPE_MonitorPeripheral,                                          /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3724                                              COMPONENT_FLAG_ConsoleOut |                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3725                                                  COMPONENT_FLAG_Output,                                          add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
                                             1, 2, 0, 0xffffffff, "1024x768",  
                                             vxl, NULL, 0);  
3726                                  }                                  }
                                 break;  
3727                          }                          }
3728    
                         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.  */  
3729                          if (machine->machine_type == MACHINE_SGI) {                          if (machine->machine_type == MACHINE_SGI) {
3730                                  if (machine->machine_subtype == 30)                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3731                                          strcat(init_bootpath, "xio(0)pci(15)");                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3732                                  if (machine->machine_subtype == 32)                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3733                                          strcat(init_bootpath, "pci(0)");                                  add_environment_string(cpu, "diskless=0", &addr);
3734                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3735                                    add_environment_string(cpu, "volume=80", &addr);
3736                          if (diskimage_is_a_cdrom(machine, bootdev_id))                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3737                                  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  */  
3738    
3739                  /*  TODO:  not needed?  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3740                  cpu->cd.mips.gpr[MIPS_GPR_SP] = machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080;                                  add_environment_string(cpu, "monitor=h", &addr);
3741                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3742                                    add_environment_string(cpu, "TimeZone=GMT", &addr);
3743                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3744                                    add_environment_string(cpu, "nogfxkbd=1", &addr);
3745    
3746                  /*  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;  
3747    
3748                  /*  bootstr:  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3749                  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);
3750                  add_environment_string(cpu, bootstr, &addr);                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3751                  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                                  add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);
3752                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3753                                    add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
3754                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3755                                    add_environment_string(cpu, "OSLoader=sash", &addr);
3756    
3757                  /*  bootarg:  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3758                  if (bootarg[0] != '\0') {                                  add_environment_string(cpu, "rbaud=9600", &addr);
3759                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3760                          add_environment_string(cpu, bootarg, &addr);                                  add_environment_string(cpu, "rebound=y", &addr);
3761                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3762                  }                                  add_environment_string(cpu, "crt_option=1", &addr);
3763                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3764                                    add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
3765    
3766                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3767                                    add_environment_string(cpu, "keybd=US", &addr);
3768    
                 /*  
                  *  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) {  
3769                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3770                                  add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);                                  add_environment_string(cpu, "cpufreq=3", &addr);
3771                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3772                                  add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
                         } else {  
3773                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3774                                  add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);                                  add_environment_string(cpu, eaddr_string, &addr);
3775                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3776                                  add_environment_string(cpu, "ConsoleOut=video()", &addr);                                  add_environment_string(cpu, "verbose=istrue", &addr);
   
                                 /*  g for graphical mode. G for graphical mode  
                                     with SGI logo visible on Irix?  */  
3777                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3778                                  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?  */  
3779                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3780                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "diagmode=v", &addr);
3781                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3782                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "kernname=unix", &addr);
3783                          } else {                          } else {
3784                                    char *tmp;
3785                                    size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3786                                    tmp = malloc(mlen);
3787                                    snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3788                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3789                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  add_environment_string(cpu, tmp, &addr);
3790    
3791                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3792                                  add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);                                  add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);
3793    
                                 /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */  
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, "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);
3796                          }                          }
                 }  
   
                 if (machine->machine_type == MACHINE_SGI) {  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "AutoLoad=No", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "diskless=0", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "volume=80", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "sgilogo=y", &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "monitor=h", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "TimeZone=GMT", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "nogfxkbd=1", &addr);  
   
                         /*  TODO: 'xio(0)pci(15)scsi(0)disk(1)rdisk(0)partition(0)' on IP30 at least  */  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         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);  
3797    
3798                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  End the environment strings with an empty zero-terminated
3799                          add_environment_string(cpu, "cpufreq=3", &addr);                              string, and the envp array with a NULL pointer.  */
3800                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          add_environment_string(cpu, "", &addr); /*  the end  */
3801                          add_environment_string(cpu, "dbaud=9600", &addr);                          store_pointer_and_advance(cpu, &addr2,
3802                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                              0, 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);  
3803    
3804                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  Return address:  (0x20 = ReturnFromMain())  */
3805                          add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);                          cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;
3806                  }                  }
3807    
                 /*  End the environment strings with an empty zero-terminated  
                     string, and the envp array with a NULL pointer.  */  
                 add_environment_string(cpu, "", &addr); /*  the end  */  
                 store_pointer_and_advance(cpu, &addr2,  
                     0, arc_wordlen==sizeof(uint64_t));  
   
 no_arc_prom_emulation:          /*  TODO: ugly, get rid of the goto  */  
   
                 /*  Return address:  (0x20 = ReturnFromMain())  */  
                 cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;  
   
3808                  break;                  break;
3809    
3810          case MACHINE_MESHCUBE:          case MACHINE_MESHCUBE:
# Line 4136  no_arc_prom_emulation:         /*  TODO: ugly, Line 3817  no_arc_prom_emulation:         /*  TODO: ugly,
3817    
3818                  /*  First of all, the MeshCube has an Au1500 in it:  */                  /*  First of all, the MeshCube has an Au1500 in it:  */
3819                  machine->md_interrupt = au1x00_interrupt;                  machine->md_interrupt = au1x00_interrupt;
3820                  machine->au1x00_ic_data = dev_au1x00_init(machine, mem);                  machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem);
3821    
3822                  /*                  /*
3823                   *  TODO:  Which non-Au1500 devices, and at what addresses?                   *  TODO:  Which non-Au1500 devices, and at what addresses?
# Line 4153  no_arc_prom_emulation:         /*  TODO: ugly, Line 3834  no_arc_prom_emulation:         /*  TODO: ugly,
3834    
3835                  device_add(machine, "random addr=0x1017fffc len=4");                  device_add(machine, "random addr=0x1017fffc len=4");
3836    
3837                  /*                  if (machine->prom_emulation) {
3838                   *  TODO:  A Linux kernel wants "memsize" from somewhere... I                          /*
3839                   *  haven't found any docs on how it is used though.                           *  TODO:  A Linux kernel wants "memsize" from somewhere... I
3840                   */                           *  haven't found any docs on how it is used though.
3841                             */
3842                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
3843                  cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
3844                  store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
3845                      0xa0002000ULL);                              0xa0002000ULL);
3846                  store_string(cpu, 0xa0002000ULL, "something=somethingelse");                          store_string(cpu, 0xa0002000ULL, "something=somethingelse");
   
                 cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;  
                 store_string(cpu, 0xa0002000ULL, "hello=world\n");  
3847    
3848                            cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
3849                            store_string(cpu, 0xa0002000ULL, "hello=world\n");
3850                    }
3851                  break;                  break;
3852    
3853          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
3854                  machine->machine_name = "NetGear WG602";                  machine->machine_name = "NetGear WG602v1";
3855    
3856                  if (machine->use_x11)                  if (machine->use_x11)
3857                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
3858                  if (machine->physical_ram_in_mb != 16)                  if (machine->physical_ram_in_mb != 16)
3859                          fprintf(stderr, "WARNING! Real NetGear WG602 boxes have exactly 16 MB RAM. Continuing anyway.\n");                          fprintf(stderr, "WARNING! Real NetGear WG602v1 boxes have exactly 16 MB RAM. Continuing anyway.\n");
3860    
3861                  /*                  /*
3862                   *  Lots of info about the IDT 79RC 32334                   *  Lots of info about the IDT 79RC 32334
# Line 4184  no_arc_prom_emulation:         /*  TODO: ugly, Line 3865  no_arc_prom_emulation:         /*  TODO: ugly,
3865                  device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0");                  device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0");
3866                  break;                  break;
3867    
         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;  
   
3868          case MACHINE_SONYNEWS:          case MACHINE_SONYNEWS:
3869                  /*                  /*
3870                   *  There are several models, according to                   *  There are several models, according to
# Line 4248  for (i=0; i<32; i++) Line 3889  for (i=0; i<32; i++)
3889                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
3890                  machine->machine_name = "Sony NeWS (NET WORK STATION)";                  machine->machine_name = "Sony NeWS (NET WORK STATION)";
3891    
3892                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3893                  {                          /*  This is just a test.  TODO  */
3894                          int i;                          int i;
3895                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
3896                                  cpu->cd.mips.gpr[i] =                                  cpu->cd.mips.gpr[i] =
# Line 4261  for (i=0; i<32; i++) Line 3902  for (i=0; i<32; i++)
3902    
3903                  break;                  break;
3904    
3905            case MACHINE_EVBMIPS:
3906                    /*  http://www.netbsd.org/Ports/evbmips/  */
3907                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
3908    
3909                    switch (machine->machine_subtype) {
3910                    case MACHINE_EVBMIPS_MALTA:
3911                    case MACHINE_EVBMIPS_MALTA_BE:
3912                            machine->machine_name = "MALTA (evbmips, little endian)";
3913                            cpu->byte_order = EMUL_LITTLE_ENDIAN;
3914    
3915                            if (machine->machine_subtype == MACHINE_EVBMIPS_MALTA_BE) {
3916                                    machine->machine_name = "MALTA (evbmips, big endian)";
3917                                    cpu->byte_order = EMUL_BIG_ENDIAN;
3918                            }
3919    
3920                            /*  ISA interrupt controllers:  */
3921                            snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");
3922                            machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
3923                            snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");
3924                            machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
3925                            machine->md_interrupt = malta_interrupt;
3926    
3927                            dev_mc146818_init(machine, mem, 0x18000070, 8 + 8, MC146818_PC_CMOS, 1);
3928    
3929                            machine->main_console_handle = (size_t)
3930                                device_add(machine, "ns16550 irq=12 addr=0x180003f8 name2=tty0");
3931                            device_add(machine, "ns16550 irq=11 addr=0x180002f8 name2=tty1");
3932    
3933                            snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x name2=tty2", MALTA_CBUSUART);
3934                            device_add(machine, tmpstr);
3935                            /*  TODO: Irqs  */
3936                            pci_data = dev_gt_init(machine, mem, 0x1be00000, 8+9, 8+9, 120);
3937    
3938                            /*  TODO: Haha, this is bogus. Just a cut&paste
3939                                from the Cobalt emulation above.  */
3940                            bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);
3941                            bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
3942    
3943                            device_add(machine, "malta_lcd addr=0x1f000400");
3944                            break;
3945                    case MACHINE_EVBMIPS_PB1000:
3946                            machine->machine_name = "PB1000 (evbmips)";
3947                            cpu->byte_order = EMUL_BIG_ENDIAN;
3948    
3949                            machine->md_interrupt = au1x00_interrupt;
3950                            machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem);
3951                            /*  TODO  */
3952                            break;
3953                    default:
3954                            fatal("Unimplemented EVBMIPS model.\n");
3955                            exit(1);
3956                    }
3957    
3958                    if (machine->prom_emulation) {
3959                            /*  This is just a test.  TODO  */
3960                            for (i=0; i<32; i++)
3961                                    cpu->cd.mips.gpr[i] =
3962                                        0x01230000 + (i << 8) + 0x55;
3963    
3964                            /*  NetBSD/evbmips wants these: (at least for Malta)  */
3965    
3966                            /*  a0 = argc  */
3967                            cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
3968    
3969                            /*  a1 = argv  */
3970                            cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
3971                            store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
3972                            store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
3973                            store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
3974    
3975                            bootstr = strdup(machine->boot_kernel_filename);
3976                            bootarg = strdup(machine->boot_string_argument);
3977                            store_string(cpu, (int32_t)0x9fc01040, bootstr);
3978                            store_string(cpu, (int32_t)0x9fc01200, bootarg);
3979    
3980                            /*  a2 = (yamon_env_var *)envp  */
3981                            cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
3982                            {
3983                                    uint64_t env = cpu->cd.mips.gpr[MIPS_GPR_A2];
3984                                    uint64_t tmpptr = 0xffffffff9fc01c00ULL;
3985                                    char tmps[50];
3986    
3987                                    snprintf(tmps, sizeof(tmps), "0x%08x",
3988                                        machine->physical_ram_in_mb * 1048576);
3989                                    add_environment_string_dual(cpu,
3990                                        &env, &tmpptr, "memsize", tmps);
3991    
3992                                    add_environment_string_dual(cpu,
3993                                        &env, &tmpptr, "yamonrev", "02.06");
3994    
3995                                    /*  End of env:  */
3996                                    tmpptr = 0;
3997                                    add_environment_string_dual(cpu,
3998                                        &env, &tmpptr, NULL, NULL);
3999                            }
4000    
4001                            /*  a3 = memsize  */
4002                            cpu->cd.mips.gpr[MIPS_GPR_A3] =
4003                                machine->physical_ram_in_mb * 1048576;
4004                            /*  Hm. Linux ignores a3.  */
4005    
4006                            /*
4007                             *  TODO:
4008                             *      Core ID numbers.
4009                             *      How much of this is not valid for PBxxxx?
4010                             *
4011                             *  See maltareg.h for more info.
4012                             */
4013                            store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION), (1 << 10) + 0x26);
4014    
4015                            /*  Call vectors at 0x9fc005xx:  */
4016                            for (i=0; i<0x100; i+=4)
4017                                    store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,
4018                                        (int64_t)(int32_t)0x9fc00800 + i);
4019                    }
4020                    break;
4021    
4022            case MACHINE_PSP:
4023                    /*
4024                     *  The Playstation Portable seems to be a strange beast.
4025                     *
4026                     *  http://yun.cup.com/psppg004.html (in Japanese) seems to
4027                     *  suggest that virtual addresses are not displaced by
4028                     *  0x80000000 as on normal CPUs, but by 0x40000000?
4029                     */
4030                    machine->machine_name = "Playstation Portable";
4031                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
4032    
4033                    if (!machine->use_x11 && !quiet_mode)
4034                            fprintf(stderr, "-------------------------------------"
4035                                "------------------------------------------\n"
4036                                "\n  WARNING! You are emulating a PSP without -X. "
4037                                "You will miss graphical output!\n\n"
4038                                "-------------------------------------"
4039                                "------------------------------------------\n");
4040    
4041                    /*  480 x 272 pixels framebuffer (512 bytes per line)  */
4042                    fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPCMIPS,
4043                        480,272, 512,1088, -15, "Playstation Portable");
4044    
4045                    /*
4046                     *  TODO/NOTE: This is ugly, but necessary since GXemul doesn't
4047                     *  emulate any MIPS CPU without MMU right now.
4048                     */
4049                    mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,
4050                        0x44000000 /*vaddr*/, 0x4000000, 0x4000000 + 1048576*16,
4051                        1,1,1,1,1, 0, 2, 2);
4052                    mips_coproc_tlb_set_entry(cpu, 1, 1048576*16,
4053                        0x8000000 /*vaddr*/, 0x0, 0x0 + 1048576*16,
4054                        1,1,1,1,1, 0, 2, 2);
4055                    mips_coproc_tlb_set_entry(cpu, 2, 1048576*16,
4056                        0x9000000 /*vaddr*/, 0x01000000, 0x01000000 + 1048576*16,
4057                        1,1,1,1,1, 0, 2, 2);
4058                    mips_coproc_tlb_set_entry(cpu, 3, 1048576*16,
4059                        0x0 /*vaddr*/, 0, 0 + 1048576*16, 1,1,1,1,1, 0, 2, 2);
4060    
4061                    cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;
4062    
4063                    break;
4064    #endif  /*  ENABLE_MIPS  */
4065    
4066    #ifdef ENABLE_PPC
4067          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
4068                  /*                  /*
4069                   *  A "bare" PPC machine.                   *  A "bare" PPC machine.
# Line 4277  for (i=0; i<32; i++) Line 4080  for (i=0; i<32; i++)
4080                  machine->machine_name = "PPC test machine";                  machine->machine_name = "PPC test machine";
4081    
4082                  /*  TODO: interrupt for PPC?  */                  /*  TODO: interrupt for PPC?  */
4083                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4084                      machine, mem, DEV_CONS_ADDRESS, "console", 0);                      (long long)DEV_CONS_ADDRESS);
4085                    cons_data = device_add(machine, tmpstr);
4086                    machine->main_console_handle = cons_data->console_handle;
4087    
4088                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4089                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
4090                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
4091    
4092                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4093                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testppc generic");
4094    
4095                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4096                        (long long)DEV_DISK_ADDRESS);
4097                    device_add(machine, tmpstr);
4098    
4099                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4100                        (long long)DEV_ETHER_ADDRESS);
4101                    device_add(machine, tmpstr);
4102    
4103                  break;                  break;
4104    
4105          case MACHINE_WALNUT:          case MACHINE_WALNUT:
# Line 4305  for (i=0; i<32; i++) Line 4119  for (i=0; i<32; i++)
4119                  dev_pmppc_init(mem);                  dev_pmppc_init(mem);
4120    
4121                  /*  com0 = 0xff600300, com1 = 0xff600400  */                  /*  com0 = 0xff600300, com1 = 0xff600400  */
4122                  machine->main_console_handle = dev_ns16550_init(machine, mem,  
4123                      0xff600300, 0, 1, 1, "serial 0");                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0xff600300 name2=tty0");
4124                  dev_ns16550_init(machine, mem,                  device_add(machine, "ns16550 irq=0 addr=0xff600400 in_use=0 name2=tty1");
                     0xff600400, 0, 1, 0, "serial 1");  
4125    
4126                  break;                  break;
4127    
# Line 4335  for (i=0; i<32; i++) Line 4148  for (i=0; i<32; i++)
4148    
4149                  device_add(machine, "bebox");                  device_add(machine, "bebox");
4150    
4151                  /*  Serial, used by NetBSD:  */                  machine->main_console_handle = (size_t)
4152                  machine->main_console_handle = dev_ns16550_init(machine, mem,                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");
4153                      0x800003f8, 0, 1, 1, "serial 0");                  device_add(machine, "ns16550 irq=0 addr=0x800002f8 name2=tty1 in_use=0");
4154    
4155                  /*  Serial, used by Linux:  */                  dev_pckbc_init(machine, mem, 0x80000060, PCKBC_8042,
4156                  dev_ns16550_init(machine, mem, 0x800002f8, 0, 1, 0, "serial 1");                      1, 12, machine->use_x11, 1);
4157    
4158                  /*  This is used by Linux too:  */                  if (machine->use_x11)
4159                  dev_vga_init(machine, mem, 0xc00b8000ULL, 0x800003c0ULL, 80, 25,                          dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,
4160                      machine->machine_name);                              machine->machine_name);
4161    
4162                  store_32bit_word(cpu, 0x3010,                  if (machine->prom_emulation) {
4163                      machine->physical_ram_in_mb * 1048576);                          store_32bit_word(cpu, 0x3010, machine->physical_ram_in_mb * 1048576);
   
                 /*  TODO: List of stuff, see http://www.beatjapan.org/  
                     mirror/www.be.com/aboutbe/benewsletter/  
                     Issue27.html#Cookbook  for the details.  */  
                 store_32bit_word(cpu, 0x301c, 0);  
   
                 /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,  
                     r5 = args, r6 = ptr to bootinfo?  */  
                 cpu->cd.ppc.gpr[3] = 0x3100;  
                 cpu->cd.ppc.gpr[4] = 0x200000;  
                 cpu->cd.ppc.gpr[5] = 0x2000;  
                 store_string(cpu, cpu->cd.ppc.gpr[5], "-a");  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x100;  
   
                 /*  See NetBSD's bebox/include/bootinfo.h for details  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,  
                     machine->physical_ram_in_mb * 1048576);  
   
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */  
                 store_buf(cpu, cpu->cd.ppc.gpr[6] + 20, "com", 4);  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */  
   
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);  
4164    
4165                            /*  TODO: List of stuff, see http://www.beatjapan.org/
4166                                mirror/www.be.com/aboutbe/benewsletter/
4167                                Issue27.html#Cookbook  for the details.  */
4168                            store_32bit_word(cpu, 0x301c, 0);
4169    
4170                            /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4171                                r5 = args, r6 = ptr to bootinfo?  */
4172                            cpu->cd.ppc.gpr[3] = 0x3100;
4173                            cpu->cd.ppc.gpr[4] = 0x200000;
4174                            cpu->cd.ppc.gpr[5] = 0x2000;
4175                            store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4176                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4177    
4178                            /*  See NetBSD's bebox/include/bootinfo.h for details  */
4179                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */
4180                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4181                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4182                                machine->physical_ram_in_mb * 1048576);
4183    
4184                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */
4185                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4186                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4187                                machine->use_x11? "vga" : "com", 4);
4188                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4189                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4190    
4191                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4192                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */
4193                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4194                    }
4195                  break;                  break;
4196    
4197          case MACHINE_PREP:          case MACHINE_PREP:
# Line 4387  for (i=0; i<32; i++) Line 4200  for (i=0; i<32; i++)
4200                   */                   */
4201                  machine->machine_name = "PowerPC Reference Platform";                  machine->machine_name = "PowerPC Reference Platform";
4202    
4203                  {                  if (machine->prom_emulation) {
4204                          int i;                          /*  Linux on PReP has 0xdeadc0de at address 0? (See
4205                          for (i=0; i<32; i++)                              http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */
4206                                  cpu->cd.ppc.gpr[i] =                          store_32bit_word(cpu, 0, 0xdeadc0de);
                                     0x12340000 + (i << 8) + 0x55;  
                 }  
   
                 /*  Linux on PReP has 0xdeadc0de at address 0? (See  
                     http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */  
                 store_32bit_word(cpu, 0, 0xdeadc0de);  
   
                 /*  r6 should point to "residual data"?  */  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x1000;  
4207    
4208                            /*  r6 should point to "residual data"?  */
4209                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x1000;
4210                    }
4211                  break;                  break;
4212    
4213          case MACHINE_MACPPC:          case MACHINE_MACPPC:
# Line 4411  for (i=0; i<32; i++) Line 4217  for (i=0; i<32; i++)
4217                   */                   */
4218                  machine->machine_name = "Macintosh (PPC)";                  machine->machine_name = "Macintosh (PPC)";
4219    
4220                  /*  r5 = OpenFirmware entry point  */                  if (machine->prom_emulation) {
4221                  cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;                          uint64_t b = 8 * 1048576, a = b - 0x800;
4222                            int i;
4223                            /*
4224                             *  r3 = pointer to boot_args (for the Mach kernel).
4225                             *  See http://darwinsource.opendarwin.org/10.3/
4226                             *  BootX-59/bootx.tproj/include.subproj/boot_args.h
4227                             *  for more info.
4228                             */
4229                            cpu->cd.ppc.gpr[3] = a;
4230                            store_16bit_word(cpu, a + 0x0000, 1);   /*  revision  */
4231                            store_16bit_word(cpu, a + 0x0002, 2);   /*  version  */
4232                            store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
4233                            /*  26 dram banks; "long base; long size"  */
4234                            store_32bit_word(cpu, a + 0x0104, 0);   /*  base  */
4235                            store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
4236                                * 256);             /*  size (in pages)  */
4237                            for (i=8; i<26*8; i+= 4)
4238                                    store_32bit_word(cpu, a + 0x0104 + i, 0);
4239                            a += (0x104 + 26 * 8);
4240                            /*  Video info:  */
4241                            store_32bit_word(cpu, a+0, 0xd0000000); /*  video base  */
4242                            store_32bit_word(cpu, a+4, 0);          /*  display code (?)  */
4243                            store_32bit_word(cpu, a+8, 800);        /*  bytes per pixel row  */
4244                            store_32bit_word(cpu, a+12, 800);       /*  width  */
4245                            store_32bit_word(cpu, a+16, 600);       /*  height  */
4246                            store_32bit_word(cpu, a+20, 8);         /*  pixel depth  */
4247                            a += 24;
4248                            store_32bit_word(cpu, a+0, 127);        /*  gestalt number (TODO)  */
4249                            store_32bit_word(cpu, a+4, 0);          /*  device tree pointer (TODO)  */
4250                            store_32bit_word(cpu, a+8, 0);          /*  device tree length  */
4251                            store_32bit_word(cpu, a+12, b);         /*  last address of kernel data area  */
4252    
4253                            /*  r4 = "MOSX" (0x4D4F5358)  */
4254                            cpu->cd.ppc.gpr[4] = 0x4D4F5358;
4255    
4256                            /*
4257                             *  r5 = OpenFirmware entry point.  NOTE: See
4258                             *  cpu_ppc.c for the rest of this semi-ugly hack.
4259                             */
4260                            dev_ram_init(cpu->mem, cpu->cd.ppc.of_emul_addr,
4261                                0x1000, DEV_RAM_RAM, 0x0);
4262                            store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
4263                                0x44ee0002);
4264                            cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4265                    }
4266                  break;                  break;
4267    
4268          case MACHINE_DB64360:          case MACHINE_DB64360:
4269                  /*  For playing with PMON2000 for PPC:  */                  /*  For playing with PMON2000 for PPC:  */
4270                  machine->machine_name = "DB64360";                  machine->machine_name = "DB64360";
4271    
4272                  machine->main_console_handle = dev_ns16550_init(machine, mem,                  machine->main_console_handle = (size_t)device_add(machine,
4273                      0x1d000020, 0, 4, 1, "serial console");                      "ns16550 irq=0 addr=0x1d000020 addr_mult=4");
4274    
4275                  {                  if (machine->prom_emulation) {
4276                          int i;                          int i;
4277                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
4278                                  cpu->cd.ppc.gpr[i] =                                  cpu->cd.ppc.gpr[i] =
# Line 4431  for (i=0; i<32; i++) Line 4280  for (i=0; i<32; i++)
4280                  }                  }
4281    
4282                  break;                  break;
4283    #endif  /*  ENABLE_PPC  */
4284    
4285    #ifdef ENABLE_SH
4286            case MACHINE_BARESH:
4287                    /*  A bare SH machine, with no devices.  */
4288                    machine->machine_name = "\"Bare\" SH machine";
4289                    break;
4290    
4291            case MACHINE_TESTSH:
4292                    machine->machine_name = "SH test machine";
4293    
4294                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4295                        (long long)DEV_CONS_ADDRESS);
4296                    cons_data = device_add(machine, tmpstr);
4297                    machine->main_console_handle = cons_data->console_handle;
4298    
4299                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4300                        (long long)DEV_MP_ADDRESS);
4301                    device_add(machine, tmpstr);
4302    
4303                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4304                        640,480, 640,480, 24, "testsh generic");
4305    
4306                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4307                        (long long)DEV_DISK_ADDRESS);
4308                    device_add(machine, tmpstr);
4309    
4310                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4311                        (long long)DEV_ETHER_ADDRESS);
4312                    device_add(machine, tmpstr);
4313    
4314                    break;
4315    
4316            case MACHINE_HPCSH:
4317                    /*  Handheld SH-based machines:  */
4318                    machine->machine_name = "HPCsh";
4319    
4320                    /*  TODO  */
4321    
4322                    break;
4323    #endif  /*  ENABLE_SH  */
4324    
4325    #ifdef ENABLE_HPPA
4326            case MACHINE_BAREHPPA:
4327                    /*  A bare HPPA machine, with no devices.  */
4328                    machine->machine_name = "\"Bare\" HPPA machine";
4329                    break;
4330    
4331            case MACHINE_TESTHPPA:
4332                    machine->machine_name = "HPPA test machine";
4333    
4334                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4335                        (long long)DEV_CONS_ADDRESS);
4336                    cons_data = device_add(machine, tmpstr);
4337                    machine->main_console_handle = cons_data->console_handle;
4338    
4339                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4340                        (long long)DEV_MP_ADDRESS);
4341                    device_add(machine, tmpstr);
4342    
4343                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4344                        640,480, 640,480, 24, "testhppa generic");
4345    
4346                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4347                        (long long)DEV_DISK_ADDRESS);
4348                    device_add(machine, tmpstr);
4349    
4350                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4351                        (long long)DEV_ETHER_ADDRESS);
4352                    device_add(machine, tmpstr);
4353    
4354                    break;
4355    #endif  /*  ENABLE_HPPA  */
4356    
4357    #ifdef ENABLE_I960
4358            case MACHINE_BAREI960:
4359                    /*  A bare I960 machine, with no devices.  */
4360                    machine->machine_name = "\"Bare\" i960 machine";
4361                    break;
4362    
4363            case MACHINE_TESTI960:
4364                    machine->machine_name = "i960 test machine";
4365    
4366                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4367                        (long long)DEV_CONS_ADDRESS);
4368                    cons_data = device_add(machine, tmpstr);
4369                    machine->main_console_handle = cons_data->console_handle;
4370    
4371                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4372                        (long long)DEV_MP_ADDRESS);
4373                    device_add(machine, tmpstr);
4374    
4375                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4376                        640,480, 640,480, 24, "testi960 generic");
4377    
4378                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4379                        (long long)DEV_DISK_ADDRESS);
4380                    device_add(machine, tmpstr);
4381    
4382                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4383                        (long long)DEV_ETHER_ADDRESS);
4384                    device_add(machine, tmpstr);
4385    
4386                    break;
4387    #endif  /*  ENABLE_I960  */
4388    
4389    #ifdef ENABLE_SPARC
4390          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
4391                  /*  A bare SPARC machine, with no devices.  */                  /*  A bare SPARC machine, with no devices.  */
4392                  machine->machine_name = "\"Bare\" SPARC machine";                  machine->machine_name = "\"Bare\" SPARC machine";
4393                  break;                  break;
4394    
4395            case MACHINE_TESTSPARC:
4396                    machine->machine_name = "SPARC test machine";
4397    
4398                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4399                        (long long)DEV_CONS_ADDRESS);
4400                    cons_data = device_add(machine, tmpstr);
4401                    machine->main_console_handle = cons_data->console_handle;
4402    
4403                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4404                        (long long)DEV_MP_ADDRESS);
4405                    device_add(machine, tmpstr);
4406    
4407                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4408                        640,480, 640,480, 24, "testsparc generic");
4409    
4410                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4411                        (long long)DEV_DISK_ADDRESS);
4412                    device_add(machine, tmpstr);
4413    
4414                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4415                        (long long)DEV_ETHER_ADDRESS);
4416                    device_add(machine, tmpstr);
4417    
4418                    break;
4419    
4420          case MACHINE_ULTRA1:          case MACHINE_ULTRA1:
4421                  /*                  /*
4422                   *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)                   *  NetBSD/sparc64 (http://www.netbsd.org/Ports/sparc64/)
# Line 4444  for (i=0; i<32; i++) Line 4424  for (i=0; i<32; i++)
4424                   */                   */
4425                  machine->machine_name = "Sun Ultra1";                  machine->machine_name = "Sun Ultra1";
4426                  break;                  break;
4427    #endif  /*  ENABLE_SPARC  */
4428    
4429          case MACHINE_BAREURISC:  #ifdef ENABLE_ALPHA
4430                  machine->machine_name = "\"Bare\" URISC machine";          case MACHINE_BAREALPHA:
4431                    machine->machine_name = "\"Bare\" Alpha machine";
4432                  break;                  break;
4433    
4434          case MACHINE_TESTURISC:          case MACHINE_TESTALPHA:
4435                  machine->machine_name = "URISC test machine";                  machine->machine_name = "Alpha test machine";
4436    
4437                  /*  TODO  */                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4438                  /*  A special "device" for accessing normal devices                      (long long)DEV_CONS_ADDRESS);
4439                      using urisc accesses?  */                  cons_data = device_add(machine, tmpstr);
4440                    machine->main_console_handle = cons_data->console_handle;
4441    
4442                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4443                        (long long)DEV_MP_ADDRESS);
4444                    device_add(machine, tmpstr);
4445    
4446                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4447                        640,480, 640,480, 24, "testalpha generic");
4448    
4449                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4450                        (long long)DEV_DISK_ADDRESS);
4451                    device_add(machine, tmpstr);
4452    
4453                  device_add(machine, "urisc addr=0x12341234");                  snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4454                        (long long)DEV_ETHER_ADDRESS);
4455                    device_add(machine, tmpstr);
4456    
4457                  break;                  break;
4458    
4459          case MACHINE_BAREHPPA:          case MACHINE_ALPHA:
4460                  machine->machine_name = "\"Bare\" HPPA machine";                  if (machine->prom_emulation) {
4461                            struct rpb rpb;
4462                            struct crb crb;
4463                            struct ctb ctb;
4464    
4465                            /*  TODO:  Most of these... They are used by NetBSD/alpha:  */
4466                            /*  a0 = First free Page Frame Number  */
4467                            /*  a1 = PFN of current Level 1 page table  */
4468                            /*  a2 = Bootinfo magic  */
4469                            /*  a3 = Bootinfo pointer  */
4470                            /*  a4 = Bootinfo version  */
4471                            cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
4472                            cpu->cd.alpha.r[ALPHA_A1] = 0;
4473                            cpu->cd.alpha.r[ALPHA_A2] = 0;
4474                            cpu->cd.alpha.r[ALPHA_A3] = 0;
4475                            cpu->cd.alpha.r[ALPHA_A4] = 0;
4476    
4477                            /*  HWRPB: Hardware Restart Parameter Block  */
4478                            memset(&rpb, 0, sizeof(struct rpb));
4479                            store_64bit_word_in_host(cpu, (unsigned char *)
4480                                &(rpb.rpb_phys), HWRPB_ADDR);
4481                            strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8);
4482                            store_64bit_word_in_host(cpu, (unsigned char *)
4483                                &(rpb.rpb_size), sizeof(struct rpb));
4484                            store_64bit_word_in_host(cpu, (unsigned char *)
4485                                &(rpb.rpb_page_size), 8192);
4486                            store_64bit_word_in_host(cpu, (unsigned char *)
4487                                &(rpb.rpb_type), machine->machine_subtype);
4488                            store_64bit_word_in_host(cpu, (unsigned char *)
4489                                &(rpb.rpb_cc_freq), 100000000);
4490                            store_64bit_word_in_host(cpu, (unsigned char *)
4491                                &(rpb.rpb_ctb_off), CTB_ADDR - HWRPB_ADDR);
4492                            store_64bit_word_in_host(cpu, (unsigned char *)
4493                                &(rpb.rpb_crb_off), CRB_ADDR - HWRPB_ADDR);
4494    
4495                            /*  CTB: Console Terminal Block  */
4496                            memset(&ctb, 0, sizeof(struct ctb));
4497                            store_64bit_word_in_host(cpu, (unsigned char *)
4498                                &(ctb.ctb_term_type), machine->use_x11?
4499                                CTB_GRAPHICS : CTB_PRINTERPORT);
4500    
4501                            /*  CRB: Console Routine Block  */
4502                            memset(&crb, 0, sizeof(struct crb));
4503                            store_64bit_word_in_host(cpu, (unsigned char *)
4504                                &(crb.crb_v_dispatch), CRB_ADDR - 0x100);
4505                            store_64bit_word(cpu, CRB_ADDR - 0x100 + 8, 0x10000);
4506    
4507                            /*
4508                             *  Place a special "hack" palcode call at 0x10000:
4509                             *  (Hopefully nothing else will be there.)
4510                             */
4511                            store_32bit_word(cpu, 0x10000, 0x3fffffe);
4512    
4513                            store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb));
4514                            store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb));
4515                            store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb));
4516                    }
4517    
4518                    switch (machine->machine_subtype) {
4519                    case ST_DEC_3000_300:
4520                            machine->machine_name = "DEC 3000/300";
4521                            machine->main_console_handle =
4522                                dev_zs_init(machine, mem, 0x1b0200000ULL,
4523                                0, 4, "serial zs"); /*  serial? netbsd?  */
4524                            break;
4525                    case ST_EB164:
4526                            machine->machine_name = "EB164";
4527                            break;
4528                    default:fatal("Unimplemented Alpha machine type %i\n",
4529                                machine->machine_subtype);
4530                            exit(1);
4531                    }
4532    
4533                  break;                  break;
4534    #endif  /*  ENABLE_ALPHA  */
4535    
4536          case MACHINE_TESTHPPA:  #ifdef ENABLE_ARM
4537                  machine->machine_name = "HPPA test machine";          case MACHINE_BAREARM:
4538                    machine->machine_name = "\"Bare\" ARM machine";
4539                    break;
4540    
4541            case MACHINE_TESTARM:
4542                    machine->machine_name = "ARM test machine";
4543    
4544                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4545                        (long long)DEV_CONS_ADDRESS);
4546                    cons_data = device_add(machine, tmpstr);
4547                    machine->main_console_handle = cons_data->console_handle;
4548    
4549                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4550                        (long long)DEV_MP_ADDRESS);
4551                    device_add(machine, tmpstr);
4552    
4553                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4554                        640,480, 640,480, 24, "testarm generic");
4555    
4556                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4557                        (long long)DEV_DISK_ADDRESS);
4558                    device_add(machine, tmpstr);
4559    
4560                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4561                        (long long)DEV_ETHER_ADDRESS);
4562                    device_add(machine, tmpstr);
4563    
4564                    /*  Place a tiny stub at end of memory, and set the link
4565                        register to point to it. This stub halts the machine.  */
4566                    cpu->cd.arm.r[ARM_SP] =
4567                        machine->physical_ram_in_mb * 1048576 - 4096;
4568                    cpu->cd.arm.r[ARM_LR] = cpu->cd.arm.r[ARM_SP] + 32;
4569                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 0, 0xe3a00201);
4570                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 4, 0xe5c00010);
4571                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4572                        0xeafffffe);
4573                    break;
4574    
4575            case MACHINE_CATS:
4576                    machine->machine_name = "CATS evaluation board";
4577    
4578                    if (machine->physical_ram_in_mb > 256)
4579                            fprintf(stderr, "WARNING! Real CATS machines cannot"
4580                                " have more than 256 MB RAM. Continuing anyway.\n");
4581    
4582                    machine->md_int.footbridge_data =
4583                        device_add(machine, "footbridge addr=0x42000000");
4584                    machine->md_interrupt = footbridge_interrupt;
4585    
4586                    /*  NetBSD and OpenBSD clean their caches here:  */
4587                    dev_ram_init(mem, 0x50000000, 0x4000, DEV_RAM_RAM, 0);
4588    
4589                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4590                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4591                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4592                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4593    
4594                    device_add(machine, "pccmos addr=0x7c000070");
4595    
4596                    if (machine->use_x11) {
4597                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4598                                mem, 0xc0, 8, 0, pci_s3_virge_init, pci_s3_virge_rr);
4599                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4600                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4601                                32 + 1, 32 + 12, machine->use_x11, 0);
4602                            machine->main_console_handle = j;
4603                    }
4604    
4605                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0 in_use=0");
4606                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1 in_use=0");
4607    
4608                    if (machine->prom_emulation) {
4609                            struct ebsaboot ebsaboot;
4610    
4611                            cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
4612                                7 * 1048576 - 0x1000;
4613    
4614                            memset(&ebsaboot, 0, sizeof(struct ebsaboot));
4615                            store_32bit_word_in_host(cpu, (unsigned char *)
4616                                &(ebsaboot.bt_magic), BT_MAGIC_NUMBER_CATS);
4617                            store_32bit_word_in_host(cpu, (unsigned char *)
4618                                &(ebsaboot.bt_vargp), 0);
4619                            store_32bit_word_in_host(cpu, (unsigned char *)
4620                                &(ebsaboot.bt_pargp), 0);
4621                            store_32bit_word_in_host(cpu, (unsigned char *)
4622                                &(ebsaboot.bt_args), cpu->cd.arm.r[0]
4623                                + sizeof(struct ebsaboot));
4624                            store_32bit_word_in_host(cpu, (unsigned char *)
4625                                &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
4626                            store_32bit_word_in_host(cpu, (unsigned char *)
4627                                &(ebsaboot.bt_memstart), 0);
4628                            store_32bit_word_in_host(cpu, (unsigned char *)
4629                                &(ebsaboot.bt_memend),
4630                                machine->physical_ram_in_mb * 1048576);
4631                            store_32bit_word_in_host(cpu, (unsigned char *)
4632                                &(ebsaboot.bt_memavail), 7 * 1048576);
4633                            store_32bit_word_in_host(cpu, (unsigned char *)
4634                                &(ebsaboot.bt_fclk), 50 * 1000000);
4635                            store_32bit_word_in_host(cpu, (unsigned char *)
4636                                &(ebsaboot.bt_pciclk), 66 * 1000000);
4637                            /*  TODO: bt_vers  */
4638                            /*  TODO: bt_features  */
4639    
4640                            store_buf(cpu, cpu->cd.arm.r[0],
4641                                (char *)&ebsaboot, sizeof(struct ebsaboot));
4642                            store_string(cpu, cpu->cd.arm.r[0] +
4643                                sizeof(struct ebsaboot),
4644                                machine->boot_string_argument);
4645    
4646                            arm_setup_initial_translation_table(cpu,
4647                                7 * 1048576 - 32768);
4648                    }
4649                    break;
4650    
4651            case MACHINE_HPCARM:
4652                    machine->machine_name = "HPCarm";
4653                    dev_ram_init(mem, 0xc0000000, 0x10000000, DEV_RAM_MIRROR, 0x0);
4654    
4655                    /*  TODO: Different models  */
4656    
4657                    if (machine->prom_emulation) {
4658                            cpu->cd.arm.r[0] = 1;
4659                            cpu->cd.arm.r[ARM_SP] = 0xc000c000;
4660                    }
4661                    break;
4662    
4663            case MACHINE_ZAURUS:
4664                    machine->machine_name = "Zaurus";
4665                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4666                    device_add(machine, "ns16550 irq=0 addr=0x40100000 addr_mult=4");
4667                  /*  TODO  */                  /*  TODO  */
4668                    if (machine->prom_emulation) {
4669                            arm_setup_initial_translation_table(cpu, 0x4000);
4670                    }
4671                  break;                  break;
4672    
4673          case MACHINE_BAREALPHA:          case MACHINE_NETWINDER:
4674                  machine->machine_name = "\"Bare\" Alpha machine";                  machine->machine_name = "NetWinder";
4675    
4676                    if (machine->physical_ram_in_mb > 256)
4677                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4678                                " have more than 256 MB RAM. Continuing anyway.\n");
4679    
4680                    machine->md_int.footbridge_data =
4681                        device_add(machine, "footbridge addr=0x42000000");
4682                    machine->md_interrupt = footbridge_interrupt;
4683    
4684                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4685                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4686                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4687                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4688    
4689                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4690                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4691    
4692                    if (machine->use_x11) {
4693                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4694                                mem, 0xc0, 8, 0, pci_igsfb_init, pci_igsfb_rr);
4695                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4696                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4697                                32 + 1, 32 + 12, machine->use_x11, 0);
4698                            machine->main_console_handle = j;
4699                    }
4700    
4701                    if (machine->prom_emulation) {
4702                            arm_setup_initial_translation_table(cpu, 0x4000);
4703                    }
4704                  break;                  break;
4705    
4706          case MACHINE_TESTALPHA:          case MACHINE_SHARK:
4707                  machine->machine_name = "Alpha test machine";                  machine->machine_name = "Digital DNARD (\"Shark\")";
4708                    if (machine->prom_emulation) {
4709                            arm_setup_initial_translation_table(cpu,
4710                                machine->physical_ram_in_mb * 1048576 - 65536);
4711    
4712                  /*  TODO  */                          /*
4713                             *  r0 = OpenFirmware entry point.  NOTE: See
4714                             *  cpu_arm.c for the rest of this semi-ugly hack.
4715                             */
4716                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4717                    }
4718                    break;
4719    
4720            case MACHINE_IQ80321:
4721                    /*
4722                     *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4723                     *  for more details about the memory map.
4724                     */
4725                    machine->machine_name = "Intel IQ80321 (ARM)";
4726                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4727                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4728                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4729                    dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4730                    dev_ram_init(mem, 0xc0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
4731                    if (machine->prom_emulation) {
4732                            arm_setup_initial_translation_table(cpu, 0x8000);
4733                    }
4734                  break;                  break;
4735    
4736            case MACHINE_IYONIX:
4737                    machine->machine_name = "Iyonix";
4738                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4739                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4740                    if (machine->prom_emulation) {
4741                            arm_setup_initial_translation_table(cpu,
4742                                machine->physical_ram_in_mb * 1048576 - 65536);
4743                    }
4744                    break;
4745    #endif  /*  ENABLE_ARM  */
4746    
4747    #ifdef ENABLE_AVR
4748            case MACHINE_BAREAVR:
4749                    /*  A bare Atmel AVR machine, with no devices.  */
4750                    machine->machine_name = "\"Bare\" Atmel AVR machine";
4751                    break;
4752    #endif  /*  ENABLE_AVR  */
4753    
4754    #ifdef ENABLE_IA64
4755            case MACHINE_BAREIA64:
4756                    machine->machine_name = "\"Bare\" IA64 machine";
4757                    break;
4758    
4759            case MACHINE_TESTIA64:
4760                    machine->machine_name = "IA64 test machine";
4761    
4762                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4763                        (long long)DEV_CONS_ADDRESS);
4764                    cons_data = device_add(machine, tmpstr);
4765                    machine->main_console_handle = cons_data->console_handle;
4766    
4767                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4768                        (long long)DEV_MP_ADDRESS);
4769                    device_add(machine, tmpstr);
4770    
4771                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4772                        640,480, 640,480, 24, "testia64 generic");
4773    
4774                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4775                        (long long)DEV_DISK_ADDRESS);
4776                    device_add(machine, tmpstr);
4777    
4778                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4779                        (long long)DEV_ETHER_ADDRESS);
4780                    device_add(machine, tmpstr);
4781    
4782                    break;
4783    #endif  /*  ENABLE_IA64  */
4784    
4785    #ifdef ENABLE_M68K
4786            case MACHINE_BAREM68K:
4787                    machine->machine_name = "\"Bare\" M68K machine";
4788                    break;
4789    
4790            case MACHINE_TESTM68K:
4791                    machine->machine_name = "M68K test machine";
4792    
4793                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4794                        (long long)DEV_CONS_ADDRESS);
4795                    cons_data = device_add(machine, tmpstr);
4796                    machine->main_console_handle = cons_data->console_handle;
4797    
4798                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4799                        (long long)DEV_MP_ADDRESS);
4800                    device_add(machine, tmpstr);
4801    
4802                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4803                        640,480, 640,480, 24, "testm68k generic");
4804    
4805                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4806                        (long long)DEV_DISK_ADDRESS);
4807                    device_add(machine, tmpstr);
4808    
4809                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4810                        (long long)DEV_ETHER_ADDRESS);
4811                    device_add(machine, tmpstr);
4812    
4813                    break;
4814    #endif  /*  ENABLE_M68K  */
4815    
4816    #ifdef ENABLE_X86
4817          case MACHINE_BAREX86:          case MACHINE_BAREX86:
4818                  machine->machine_name = "\"Bare\" x86 machine";                  machine->machine_name = "\"Bare\" x86 machine";
4819                  break;                  break;
4820    
4821          case MACHINE_X86:          case MACHINE_X86:
4822                  machine->machine_name = "Generic x86 PC";                  if (machine->machine_subtype == MACHINE_X86_XT)
4823                            machine->machine_name = "PC XT";
4824                    else
4825                            machine->machine_name = "Generic x86 PC";
4826    
4827                  if (!machine->use_x11)                  /*  Interrupt controllers:  */
4828                          fprintf(stderr, "WARNING! You are emulating a PC "                  snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",
4829                              "without -X. You will miss any output going\n"                      (long long)(X86_IO_BASE + 0x20));
4830                              "to the screen!\n\n");                  machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4831                    if (machine->machine_subtype != MACHINE_X86_XT) {
4832                            snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",
4833                                (long long)(X86_IO_BASE + 0xa0));
4834                            machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4835                    }
4836    
4837                    machine->md_interrupt = x86_pc_interrupt;
4838    
4839                    /*  Timer:  */
4840                    snprintf(tmpstr, sizeof(tmpstr), "8253 addr=0x%llx irq=0",
4841                        (long long)(X86_IO_BASE + 0x40));
4842                    device_add(machine, tmpstr);
4843    
4844                  /*                  snprintf(tmpstr, sizeof(tmpstr), "pccmos addr=0x%llx",
4845                   *  Initialize all 16-bit interrupt vectors to point to                      (long long)(X86_IO_BASE + 0x70));
4846                   *  somewhere within the PC BIOS area (0xf000:0x8yyy):                  device_add(machine, tmpstr);
                  */  
                 for (i=0; i<256; i++) {  
                         store_16bit_word(cpu, i*4, 0x8000 + i);  
                         store_16bit_word(cpu, i*4 + 2, 0xf000);  
                 }  
4847    
4848                  dev_vga_init(machine, mem, 0xb8000ULL, 0x1000003c0ULL, 80, 25,                  /*  TODO: IRQ when emulating a PC XT?  */
                     "Generic x86 PC");  
4849    
4850                  dev_wdc_init(machine, mem, 0x1000001f0ULL, 14, 0);                  /*  IDE controllers:  */
4851                    if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
4852                        diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
4853                            snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4854                                X86_IO_BASE + 0x1f0, 14);
4855                            device_add(machine, tmpstr);
4856                    }
4857                    if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||
4858                        diskimage_exist(machine, 3, DISKIMAGE_IDE)) {
4859                            snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4860                                X86_IO_BASE + 0x170, 15);
4861                            device_add(machine, tmpstr);
4862                    }
4863    
4864                    /*  Floppy controller at irq 6  */
4865                    snprintf(tmpstr, sizeof(tmpstr), "fdc addr=0x%llx irq=6",
4866                        (long long)(X86_IO_BASE + 0x3f0));
4867                    device_add(machine, tmpstr);
4868    
4869                  /*  TODO: disable the "enable" flag when a keyboard has                  /*  TODO: sound blaster (eventually) at irq 7?  */
                     been added:  */  
                 machine->main_console_handle = dev_ns16550_init(machine, mem,  
                     0x1000003f8ULL, 4, 1, 1, "com1");  
                 dev_ns16550_init(machine, mem, 0x100000378ULL, 3, 1, 0, "com2");  
4870    
4871                    /*  TODO: parallel port  */
4872    
4873                    /*  Serial ports:  (TODO: 8250 for PC XT?)  */
4874    
4875                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%llx name2=com1 in_use=0",
4876                        (long long)X86_IO_BASE + 0x3f8);
4877                    device_add(machine, tmpstr);
4878                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x%llx name2=com2 in_use=0",
4879                        (long long)X86_IO_BASE + 0x2f8);
4880                    device_add(machine, tmpstr);
4881    
4882                    /*  VGA + keyboard:  */
4883                    dev_vga_init(machine, mem, 0xa0000ULL, X86_IO_BASE + 0x3c0,
4884                        "Generic x86 PC");
4885                    machine->main_console_handle = dev_pckbc_init(machine,
4886                        mem, X86_IO_BASE + 0x60, PCKBC_8042, 1, 12, 1, 1);
4887    
4888                    if (machine->prom_emulation)
4889                            pc_bios_init(cpu);
4890    
4891                    if (!machine->use_x11 && !quiet_mode)
4892                            fprintf(stderr, "-------------------------------------"
4893                                "------------------------------------------\n"
4894                                "\n  WARNING! You are emulating a PC without -X. "
4895                                "You will miss graphical output!\n\n"
4896                                "-------------------------------------"
4897                                "------------------------------------------\n");
4898                  break;                  break;
4899    #endif  /*  ENABLE_X86  */
4900    
4901          default:          default:
4902                  fatal("Unknown emulation type %i\n", machine->machine_type);                  fatal("Unknown emulation type %i\n", machine->machine_type);
# Line 4581  void machine_memsize_fix(struct machine Line 4965  void machine_memsize_fix(struct machine
4965                  case MACHINE_NETGEAR:                  case MACHINE_NETGEAR:
4966                          m->physical_ram_in_mb = 16;                          m->physical_ram_in_mb = 16;
4967                          break;                          break;
4968                  case MACHINE_WRT54G:                  case MACHINE_EVBMIPS:
4969                          m->physical_ram_in_mb = 32;                          m->physical_ram_in_mb = 64;
4970                            break;
4971                    case MACHINE_PSP:
4972                            /*
4973                             *  According to
4974                             *  http://wiki.ps2dev.org/psp:memory_map:
4975                             *      0×08000000 = 8 MB kernel memory
4976                             *      0×08800000 = 24 MB user memory
4977                             */
4978                            m->physical_ram_in_mb = 8 + 24;
4979                          break;                          break;
4980                  case MACHINE_ARC:                  case MACHINE_ARC:
4981                          switch (m->machine_subtype) {                          switch (m->machine_subtype) {
# Line 4605  void machine_memsize_fix(struct machine Line 4998  void machine_memsize_fix(struct machine
4998                                  m->physical_ram_in_mb = 32;                                  m->physical_ram_in_mb = 32;
4999                          }                          }
5000                          break;                          break;
5001                    case MACHINE_ALPHA:
5002                            m->physical_ram_in_mb = 64;
5003                            break;
5004                  case MACHINE_BEBOX:                  case MACHINE_BEBOX:
5005                          m->physical_ram_in_mb = 64;                          m->physical_ram_in_mb = 64;
5006                          break;                          break;
5007                  case MACHINE_BAREURISC:                  case MACHINE_CATS:
5008                  case MACHINE_TESTURISC:                          m->physical_ram_in_mb = 64;
5009                          m->physical_ram_in_mb = 2;                          break;
5010                    case MACHINE_ZAURUS:
5011                            m->physical_ram_in_mb = 64;
5012                            break;
5013                    case MACHINE_HPCARM:
5014                            m->physical_ram_in_mb = 32;
5015                            break;
5016                    case MACHINE_NETWINDER:
5017                            m->physical_ram_in_mb = 16;
5018                            break;
5019                    case MACHINE_X86:
5020                            if (m->machine_subtype == MACHINE_X86_XT)
5021                                    m->physical_ram_in_mb = 1;
5022                          break;                          break;
5023                  }                  }
5024          }          }
5025    
5026          /*  Special hack for WRT54G and hpcmips machines:  */          /*  Special hack for hpcmips machines:  */
5027          if (m->machine_type == MACHINE_WRT54G ||          if (m->machine_type == MACHINE_HPCMIPS) {
             m->machine_type == MACHINE_HPCMIPS) {  
5028                  m->dbe_on_nonexistant_memaccess = 0;                  m->dbe_on_nonexistant_memaccess = 0;
5029          }          }
5030    
# Line 4713  void machine_default_cputype(struct mach Line 5120  void machine_default_cputype(struct mach
5120          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
5121                  m->cpu_name = strdup("RC32334");                  m->cpu_name = strdup("RC32334");
5122                  break;                  break;
         case MACHINE_WRT54G:  
                 m->cpu_name = strdup("BCM4712");  
                 break;  
5123          case MACHINE_ARC:          case MACHINE_ARC:
5124                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5125                  case MACHINE_ARC_JAZZ_PICA:                  case MACHINE_ARC_JAZZ_PICA:
# Line 4747  void machine_default_cputype(struct mach Line 5151  void machine_default_cputype(struct mach
5151                  if (m->cpu_name == NULL)                  if (m->cpu_name == NULL)
5152                          m->cpu_name = strdup("R4400");                          m->cpu_name = strdup("R4400");
5153                  break;                  break;
5154            case MACHINE_EVBMIPS:
5155                    switch (m->machine_subtype) {
5156                    case MACHINE_EVBMIPS_MALTA:
5157                    case MACHINE_EVBMIPS_MALTA_BE:
5158                            m->cpu_name = strdup("5Kc");
5159                            break;
5160                    case MACHINE_EVBMIPS_PB1000:
5161                            m->cpu_name = strdup("AU1000");
5162                            break;
5163                    default:fatal("Unimpl. evbmips.\n");
5164                            exit(1);
5165                    }
5166                    break;
5167            case MACHINE_PSP:
5168                    m->cpu_name = strdup("Allegrex");
5169                    break;
5170    
5171          /*  PowerPC:  */          /*  PowerPC:  */
5172          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
# Line 4781  void machine_default_cputype(struct mach Line 5201  void machine_default_cputype(struct mach
5201          case MACHINE_MACPPC:          case MACHINE_MACPPC:
5202                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5203                  case MACHINE_MACPPC_G4:                  case MACHINE_MACPPC_G4:
5204                          m->cpu_name = strdup("G4e");                          m->cpu_name = strdup("PPC750");
5205                          break;                          break;
5206                  case MACHINE_MACPPC_G5:                  case MACHINE_MACPPC_G5:
5207                          m->cpu_name = strdup("PPC970");                          m->cpu_name = strdup("PPC970");
# Line 4792  void machine_default_cputype(struct mach Line 5212  void machine_default_cputype(struct mach
5212                  m->cpu_name = strdup("PPC750");                  m->cpu_name = strdup("PPC750");
5213                  break;                  break;
5214    
5215          /*  SPARC:  */          /*  SH:  */
5216          case MACHINE_BARESPARC:          case MACHINE_BARESH:
5217                  m->cpu_name = strdup("SPARCV9");          case MACHINE_TESTSH:
5218                  break;          case MACHINE_HPCSH:
5219          case MACHINE_ULTRA1:                  m->cpu_name = strdup("SH");
                 m->cpu_name = strdup("SPARCV9");  
                 break;  
   
         /*  URISC:  */  
         case MACHINE_BAREURISC:  
         case MACHINE_TESTURISC:  
                 m->cpu_name = strdup("URISC");  
5220                  break;                  break;
5221    
5222          /*  HPPA:  */          /*  HPPA:  */
5223          case MACHINE_BAREHPPA:          case MACHINE_BAREHPPA:
5224          case MACHINE_TESTHPPA:          case MACHINE_TESTHPPA:
5225                  m->cpu_name = strdup("HPPA2.0");                  m->cpu_name = strdup("HPPA");
5226                    break;
5227    
5228            /*  i960:  */
5229            case MACHINE_BAREI960:
5230            case MACHINE_TESTI960:
5231                    m->cpu_name = strdup("i960");
5232                    break;
5233    
5234            /*  SPARC:  */
5235            case MACHINE_BARESPARC:
5236            case MACHINE_TESTSPARC:
5237            case MACHINE_ULTRA1:
5238                    m->cpu_name = strdup("SPARCv9");
5239                  break;                  break;
5240    
5241          /*  Alpha:  */          /*  Alpha:  */
5242          case MACHINE_BAREALPHA:          case MACHINE_BAREALPHA:
5243          case MACHINE_TESTALPHA:          case MACHINE_TESTALPHA:
5244                  m->cpu_name = strdup("EV4");          case MACHINE_ALPHA:
5245                    m->cpu_name = strdup("Alpha");
5246                    break;
5247    
5248            /*  ARM:  */
5249            case MACHINE_BAREARM:
5250            case MACHINE_TESTARM:
5251            case MACHINE_HPCARM:
5252                    m->cpu_name = strdup("SA1110");
5253                    break;
5254            case MACHINE_IQ80321:
5255            case MACHINE_IYONIX:
5256                    m->cpu_name = strdup("80321_600_B0");
5257                    break;
5258            case MACHINE_CATS:
5259            case MACHINE_NETWINDER:
5260            case MACHINE_SHARK:
5261                    m->cpu_name = strdup("SA110");
5262                    break;
5263            case MACHINE_ZAURUS:
5264                    m->cpu_name = strdup("PXA210");
5265                    break;
5266    
5267            /*  AVR:  */
5268            case MACHINE_BAREAVR:
5269                    m->cpu_name = strdup("AVR");
5270                    break;
5271    
5272            /*  IA64:  */
5273            case MACHINE_BAREIA64:
5274            case MACHINE_TESTIA64:
5275                    m->cpu_name = strdup("IA64");
5276                    break;
5277    
5278            /*  M68K:  */
5279            case MACHINE_BAREM68K:
5280            case MACHINE_TESTM68K:
5281                    m->cpu_name = strdup("68020");
5282                  break;                  break;
5283    
5284          /*  x86:  */          /*  x86:  */
5285          case MACHINE_BAREX86:          case MACHINE_BAREX86:
5286          case MACHINE_X86:          case MACHINE_X86:
5287                  m->cpu_name = strdup("PENTIUM");                  if (m->machine_subtype == MACHINE_X86_XT)
5288                            m->cpu_name = strdup("8086");
5289                    else
5290                            m->cpu_name = strdup("AMD64");
5291                  break;                  break;
5292          }          }
5293    
# Line 4861  void machine_dumpinfo(struct machine *m) Line 5327  void machine_dumpinfo(struct machine *m)
5327          if (m->single_step_on_bad_addr)          if (m->single_step_on_bad_addr)
5328                  debug("single-step on bad addresses\n");                  debug("single-step on bad addresses\n");
5329    
5330          if (m->bintrans_enable)          if (m->arch == ARCH_MIPS) {
5331                  debug("bintrans enabled (%i MB cache)\n",                  if (m->bintrans_enable)
5332                      (int) (m->bintrans_size / 1048576));                          debug("bintrans enabled (%i MB cache)\n",
5333          else                              (int) (m->bintrans_size / 1048576));
5334                  debug("bintrans disabled, other speedtricks %s\n",                  else
5335                      m->speed_tricks? "enabled" : "disabled");                          debug("bintrans disabled, other speedtricks %s\n",
5336                                m->speed_tricks? "enabled" : "disabled");
5337            }
5338    
5339          debug("clock: ");          debug("clock: ");
5340          if (m->automatic_clock_adjustment)          if (m->automatic_clock_adjustment)
# Line 5053  void machine_list_available_types_and_cp Line 5521  void machine_list_available_types_and_cp
5521          debug("\n");          debug("\n");
5522    
5523          useremul_list_emuls();          useremul_list_emuls();
5524            debug("Userland emulation works for programs with the complexity"
5525                " of Hello World,\nbut not much more.\n");
5526  }  }
5527    
5528    
# Line 5071  void machine_init(void) Line 5541  void machine_init(void)
5541           *  entries will appear in normal order when listed.  :-)           *  entries will appear in normal order when listed.  :-)
5542           */           */
5543    
5544            /*  Zaurus:  */
5545            me = machine_entry_new("Zaurus (ARM)",
5546                ARCH_ARM, MACHINE_ZAURUS, 1, 0);
5547            me->aliases[0] = "zaurus";
5548            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5549                    me->next = first_machine_entry; first_machine_entry = me;
5550            }
5551    
5552          /*  X86 machine:  */          /*  X86 machine:  */
5553          me = machine_entry_new("x86 (generic PC-style machine)", ARCH_X86,          me = machine_entry_new("x86-based PC", ARCH_X86,
5554              MACHINE_X86, 2, 0);              MACHINE_X86, 2, 2);
5555          me->aliases[0] = "pc";          me->aliases[0] = "pc";
5556          me->aliases[1] = "x86";          me->aliases[1] = "x86";
5557            me->subtype[0] = machine_entry_subtype_new("Generic PC",
5558                MACHINE_X86_GENERIC, 1);
5559            me->subtype[0]->aliases[0] = "generic";
5560            me->subtype[1] = machine_entry_subtype_new("PC XT", MACHINE_X86_XT, 1);
5561            me->subtype[1]->aliases[0] = "xt";
5562          if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {          if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {
5563                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5564          }          }
# Line 5089  void machine_init(void) Line 5572  void machine_init(void)
5572                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5573          }          }
5574    
5575          /*  Test-machine for URISC:  */          /*  Test-machine for SPARC:  */
5576          me = machine_entry_new("Test-machine for URISC", ARCH_URISC,          me = machine_entry_new("Test-machine for SPARC", ARCH_SPARC,
5577              MACHINE_TESTURISC, 1, 0);              MACHINE_TESTSPARC, 1, 0);
5578          me->aliases[0] = "testurisc";          me->aliases[0] = "testsparc";
5579          if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {          if (cpu_family_ptr_by_number(ARCH_SPARC) != NULL) {
5580                    me->next = first_machine_entry; first_machine_entry = me;
5581            }
5582    
5583            /*  Test-machine for SH:  */
5584            me = machine_entry_new("Test-machine for SH", ARCH_SH,
5585                MACHINE_TESTSH, 1, 0);
5586            me->aliases[0] = "testsh";
5587            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5588                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5589          }          }
5590    
# Line 5113  void machine_init(void) Line 5604  void machine_init(void)
5604                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5605          }          }
5606    
5607            /*  Test-machine for M68K:  */
5608            me = machine_entry_new("Test-machine for M68K", ARCH_M68K,
5609                MACHINE_TESTM68K, 1, 0);
5610            me->aliases[0] = "testm68k";
5611            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
5612                    me->next = first_machine_entry; first_machine_entry = me;
5613            }
5614    
5615            /*  Test-machine for IA64:  */
5616            me = machine_entry_new("Test-machine for IA64", ARCH_IA64,
5617                MACHINE_TESTIA64, 1, 0);
5618            me->aliases[0] = "testia64";
5619            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
5620                    me->next = first_machine_entry; first_machine_entry = me;
5621            }
5622    
5623            /*  Test-machine for i960:  */
5624            me = machine_entry_new("Test-machine for i960", ARCH_I960,
5625                MACHINE_TESTI960, 1, 0);
5626            me->aliases[0] = "testi960";
5627            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5628                    me->next = first_machine_entry; first_machine_entry = me;
5629            }
5630    
5631          /*  Test-machine for HPPA:  */          /*  Test-machine for HPPA:  */
5632          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5633              MACHINE_TESTHPPA, 1, 0);              MACHINE_TESTHPPA, 1, 0);
# Line 5121  void machine_init(void) Line 5636  void machine_init(void)
5636                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5637          }          }
5638    
5639            /*  Test-machine for ARM:  */
5640            me = machine_entry_new("Test-machine for ARM", ARCH_ARM,
5641                MACHINE_TESTARM, 1, 0);
5642            me->aliases[0] = "testarm";
5643            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5644                    me->next = first_machine_entry; first_machine_entry = me;
5645            }
5646    
5647          /*  Test-machine for Alpha:  */          /*  Test-machine for Alpha:  */
5648          me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA,          me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA,
5649              MACHINE_TESTALPHA, 1, 0);              MACHINE_TESTALPHA, 1, 0);
# Line 5155  void machine_init(void) Line 5678  void machine_init(void)
5678          }          }
5679    
5680          /*  SGI:  */          /*  SGI:  */
5681          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 9);          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 10);
5682          me->aliases[0] = "silicon graphics";          me->aliases[0] = "silicon graphics";
5683          me->aliases[1] = "sgi";          me->aliases[1] = "sgi";
5684          me->subtype[0] = machine_entry_subtype_new("IP19", 19, 1);          me->subtype[0] = machine_entry_subtype_new("IP12", 12, 1);
5685          me->subtype[0]->aliases[0] = "ip19";          me->subtype[0]->aliases[0] = "ip12";
5686          me->subtype[1] = machine_entry_subtype_new("IP20", 20, 1);          me->subtype[1] = machine_entry_subtype_new("IP19", 19, 1);
5687          me->subtype[1]->aliases[0] = "ip20";          me->subtype[1]->aliases[0] = "ip19";
5688          me->subtype[2] = machine_entry_subtype_new("IP22", 22, 2);          me->subtype[2] = machine_entry_subtype_new("IP20", 20, 1);
5689          me->subtype[2]->aliases[0] = "ip22";          me->subtype[2]->aliases[0] = "ip20";
5690          me->subtype[2]->aliases[1] = "indy";          me->subtype[3] = machine_entry_subtype_new("IP22", 22, 2);
5691          me->subtype[3] = machine_entry_subtype_new("IP24", 24, 1);          me->subtype[3]->aliases[0] = "ip22";
5692          me->subtype[3]->aliases[0] = "ip24";          me->subtype[3]->aliases[1] = "indy";
5693          me->subtype[4] = machine_entry_subtype_new("IP27", 27, 3);          me->subtype[4] = machine_entry_subtype_new("IP24", 24, 1);
5694          me->subtype[4]->aliases[0] = "ip27";          me->subtype[4]->aliases[0] = "ip24";
5695          me->subtype[4]->aliases[1] = "origin 200";          me->subtype[5] = machine_entry_subtype_new("IP27", 27, 3);
5696          me->subtype[4]->aliases[2] = "origin 2000";          me->subtype[5]->aliases[0] = "ip27";
5697          me->subtype[5] = machine_entry_subtype_new("IP28", 28, 1);          me->subtype[5]->aliases[1] = "origin 200";
5698          me->subtype[5]->aliases[0] = "ip28";          me->subtype[5]->aliases[2] = "origin 2000";
5699          me->subtype[6] = machine_entry_subtype_new("IP30", 30, 2);          me->subtype[6] = machine_entry_subtype_new("IP28", 28, 1);
5700          me->subtype[6]->aliases[0] = "ip30";          me->subtype[6]->aliases[0] = "ip28";
5701          me->subtype[6]->aliases[1] = "octane";          me->subtype[7] = machine_entry_subtype_new("IP30", 30, 2);
5702          me->subtype[7] = machine_entry_subtype_new("IP32", 32, 2);          me->subtype[7]->aliases[0] = "ip30";
5703          me->subtype[7]->aliases[0] = "ip32";          me->subtype[7]->aliases[1] = "octane";
5704          me->subtype[7]->aliases[1] = "o2";          me->subtype[8] = machine_entry_subtype_new("IP32", 32, 2);
5705          me->subtype[8] = machine_entry_subtype_new("IP35", 35, 1);          me->subtype[8]->aliases[0] = "ip32";
5706          me->subtype[8]->aliases[0] = "ip35";          me->subtype[8]->aliases[1] = "o2";
5707            me->subtype[9] = machine_entry_subtype_new("IP35", 35, 1);
5708            me->subtype[9]->aliases[0] = "ip35";
5709          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5710                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5711          }          }
# Line 5193  void machine_init(void) Line 5718  void machine_init(void)
5718                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5719          }          }
5720    
5721            /*  Playstation Portable:  */
5722            me = machine_entry_new("Playstation Portable", ARCH_MIPS,
5723                MACHINE_PSP, 1, 0);
5724            me->aliases[0] = "psp";
5725            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5726                    me->next = first_machine_entry; first_machine_entry = me;
5727            }
5728    
5729            /*  NetWinder:  */
5730            me = machine_entry_new("NetWinder", ARCH_ARM, MACHINE_NETWINDER, 1, 0);
5731            me->aliases[0] = "netwinder";
5732            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5733                    me->next = first_machine_entry; first_machine_entry = me;
5734            }
5735    
5736          /*  NetGear:  */          /*  NetGear:  */
5737          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602v1", ARCH_MIPS,
5738              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);
5739          me->aliases[0] = "netgear";          me->aliases[0] = "netgear";
5740          me->aliases[1] = "wg602";          me->aliases[1] = "wg602v1";
5741          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5742                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5743          }          }
# Line 5231  void machine_init(void) Line 5771  void machine_init(void)
5771                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5772          }          }
5773    
5774          /*  Linksys:  */          /*  Iyonix:  */
5775          me = machine_entry_new("Linksys WRT54G", ARCH_MIPS,          me = machine_entry_new("Iyonix", ARCH_ARM,
5776              MACHINE_WRT54G, 2, 0);              MACHINE_IYONIX, 1, 0);
5777          me->aliases[0] = "linksys";          me->aliases[0] = "iyonix";
5778          me->aliases[1] = "wrt54g";          if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5779          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {                  me->next = first_machine_entry; first_machine_entry = me;
5780            }
5781    
5782            /*  Intel IQ80321 (ARM):  */
5783            me = machine_entry_new("Intel IQ80321 (ARM)", ARCH_ARM,
5784                MACHINE_IQ80321, 1, 0);
5785            me->aliases[0] = "iq80321";
5786            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5787                    me->next = first_machine_entry; first_machine_entry = me;
5788            }
5789    
5790            /*  HPCarm:  */
5791            me = machine_entry_new("Handheld SH (HPCsh)",
5792                ARCH_SH, MACHINE_HPCSH, 1, 2);
5793            me->aliases[0] = "hpcsh";
5794            me->subtype[0] = machine_entry_subtype_new("Jornada 680",
5795                MACHINE_HPCSH_JORNADA680, 1);
5796            me->subtype[0]->aliases[0] = "jornada680";
5797            me->subtype[1] = machine_entry_subtype_new(
5798                "Jornada 690", MACHINE_HPCSH_JORNADA690, 1);
5799            me->subtype[1]->aliases[0] = "jornada690";
5800            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5801                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5802          }          }
5803    
5804          /*  HPCmips:  */          /*  HPCmips:  */
5805          me = machine_entry_new("Handheld MIPS (HPC)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
5806              ARCH_MIPS, MACHINE_HPCMIPS, 2, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
5807          me->aliases[0] = "hpcmips";          me->aliases[0] = "hpcmips";
         me->aliases[1] = "hpc";  
5808          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
5809              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);
5810          me->subtype[0]->aliases[0] = "be-300";          me->subtype[0]->aliases[0] = "be-300";
# Line 5277  void machine_init(void) Line 5837  void machine_init(void)
5837                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5838          }          }
5839    
5840            /*  HPCarm:  */
5841            me = machine_entry_new("Handheld ARM (HPCarm)",
5842                ARCH_ARM, MACHINE_HPCARM, 1, 2);
5843            me->aliases[0] = "hpcarm";
5844            me->subtype[0] = machine_entry_subtype_new("Ipaq",
5845                MACHINE_HPCARM_IPAQ, 1);
5846            me->subtype[0]->aliases[0] = "ipaq";
5847            me->subtype[1] = machine_entry_subtype_new(
5848                "Jornada 720", MACHINE_HPCARM_JORNADA720, 1);
5849            me->subtype[1]->aliases[0] = "jornada720";
5850            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5851                    me->next = first_machine_entry; first_machine_entry = me;
5852            }
5853    
5854          /*  Generic "bare" X86 machine:  */          /*  Generic "bare" X86 machine:  */
5855          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
5856              MACHINE_BAREX86, 1, 0);              MACHINE_BAREX86, 1, 0);
# Line 5285  void machine_init(void) Line 5859  void machine_init(void)
5859                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5860          }          }
5861    
         /*  Generic "bare" URISC machine:  */  
         me = machine_entry_new("Generic \"bare\" URISC machine", ARCH_URISC,  
             MACHINE_BAREURISC, 1, 0);  
         me->aliases[0] = "bareurisc";  
         if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {  
                 me->next = first_machine_entry; first_machine_entry = me;  
         }  
   
5862          /*  Generic "bare" SPARC machine:  */          /*  Generic "bare" SPARC machine:  */
5863          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,
5864              MACHINE_BARESPARC, 1, 0);              MACHINE_BARESPARC, 1, 0);
# Line 5301  void machine_init(void) Line 5867  void machine_init(void)
5867                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5868          }          }
5869    
5870            /*  Generic "bare" SH machine:  */
5871            me = machine_entry_new("Generic \"bare\" SH machine", ARCH_SH,
5872                MACHINE_BARESH, 1, 0);
5873            me->aliases[0] = "baresh";
5874            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5875                    me->next = first_machine_entry; first_machine_entry = me;
5876            }
5877    
5878          /*  Generic "bare" PPC machine:  */          /*  Generic "bare" PPC machine:  */
5879          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
5880              MACHINE_BAREPPC, 1, 0);              MACHINE_BAREPPC, 1, 0);
# Line 5317  void machine_init(void) Line 5891  void machine_init(void)
5891                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5892          }          }
5893    
5894            /*  Generic "bare" M68K machine:  */
5895            me = machine_entry_new("Generic \"bare\" M68K machine", ARCH_M68K,
5896                MACHINE_BAREM68K, 1, 0);
5897            me->aliases[0] = "barem68k";
5898            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
5899                    me->next = first_machine_entry; first_machine_entry = me;
5900            }
5901    
5902            /*  Generic "bare" IA64 machine:  */
5903            me = machine_entry_new("Generic \"bare\" IA64 machine", ARCH_IA64,
5904                MACHINE_BAREIA64, 1, 0);
5905            me->aliases[0] = "bareia64";
5906            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
5907                    me->next = first_machine_entry; first_machine_entry = me;
5908            }
5909    
5910            /*  Generic "bare" i960 machine:  */
5911            me = machine_entry_new("Generic \"bare\" i960 machine", ARCH_I960,
5912                MACHINE_BAREI960, 1, 0);
5913            me->aliases[0] = "barei960";
5914            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5915                    me->next = first_machine_entry; first_machine_entry = me;
5916            }
5917    
5918          /*  Generic "bare" HPPA machine:  */          /*  Generic "bare" HPPA machine:  */
5919          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
5920              MACHINE_BAREHPPA, 1, 0);              MACHINE_BAREHPPA, 1, 0);
# Line 5325  void machine_init(void) Line 5923  void machine_init(void)
5923                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5924          }          }
5925    
5926            /*  Generic "bare" Atmel AVR machine:  */
5927            me = machine_entry_new("Generic \"bare\" Atmel AVR machine", ARCH_AVR,
5928                MACHINE_BAREAVR, 1, 0);
5929            me->aliases[0] = "bareavr";
5930            if (cpu_family_ptr_by_number(ARCH_AVR) != NULL) {
5931                    me->next = first_machine_entry; first_machine_entry = me;
5932            }
5933    
5934            /*  Generic "bare" ARM machine:  */
5935            me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
5936                MACHINE_BAREARM, 1, 0);
5937            me->aliases[0] = "barearm";
5938            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5939                    me->next = first_machine_entry; first_machine_entry = me;
5940            }
5941    
5942          /*  Generic "bare" Alpha machine:  */          /*  Generic "bare" Alpha machine:  */
5943          me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA,          me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA,
5944              MACHINE_BAREALPHA, 1, 0);              MACHINE_BAREALPHA, 1, 0);
# Line 5333  void machine_init(void) Line 5947  void machine_init(void)
5947                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5948          }          }
5949    
5950            /*  Evaluation Boards (MALTA etc):  */
5951            me = machine_entry_new("Evaluation boards (evbmips)", ARCH_MIPS,
5952                MACHINE_EVBMIPS, 1, 3);
5953            me->aliases[0] = "evbmips";
5954            me->subtype[0] = machine_entry_subtype_new("Malta",
5955                MACHINE_EVBMIPS_MALTA, 1);
5956            me->subtype[0]->aliases[0] = "malta";
5957            me->subtype[1] = machine_entry_subtype_new("Malta (Big-Endian)",
5958                MACHINE_EVBMIPS_MALTA_BE, 1);
5959            me->subtype[1]->aliases[0] = "maltabe";
5960            me->subtype[2] = machine_entry_subtype_new("PB1000",
5961                MACHINE_EVBMIPS_PB1000, 1);
5962            me->subtype[2]->aliases[0] = "pb1000";
5963            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5964                    me->next = first_machine_entry; first_machine_entry = me;
5965            }
5966    
5967            /*  Digital DNARD ("Shark"):  */
5968            me = machine_entry_new("Digital DNARD (\"Shark\")", ARCH_ARM,
5969                MACHINE_SHARK, 2, 0);
5970            me->aliases[0] = "shark";
5971            me->aliases[1] = "dnard";
5972            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5973                    me->next = first_machine_entry; first_machine_entry = me;
5974            }
5975    
5976          /*  DECstation:  */          /*  DECstation:  */
5977          me = machine_entry_new("DECstation/DECsystem",          me = machine_entry_new("DECstation/DECsystem",
5978              ARCH_MIPS, MACHINE_DEC, 3, 9);              ARCH_MIPS, MACHINE_DEC, 3, 9);
# Line 5400  void machine_init(void) Line 6040  void machine_init(void)
6040                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6041          }          }
6042    
6043            /*  CATS (ARM) evaluation board:  */
6044            me = machine_entry_new("CATS evaluation board (ARM)", ARCH_ARM,
6045                MACHINE_CATS, 1, 0);
6046            me->aliases[0] = "cats";
6047            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6048                    me->next = first_machine_entry; first_machine_entry = me;
6049            }
6050    
6051          /*  BeBox: (NetBSD/bebox)  */          /*  BeBox: (NetBSD/bebox)  */
6052          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
6053          me->aliases[0] = "bebox";          me->aliases[0] = "bebox";
# Line 5464  void machine_init(void) Line 6112  void machine_init(void)
6112          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
6113                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6114          }          }
6115    
6116            /*  Alpha:  */
6117            me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6118            me->aliases[0] = "alpha";
6119            me->subtype[0] = machine_entry_subtype_new(
6120                "DEC 3000/300", ST_DEC_3000_300, 1);
6121            me->subtype[0]->aliases[0] = "3000/300";
6122            me->subtype[1] = machine_entry_subtype_new(
6123                "EB164", ST_EB164, 1);
6124            me->subtype[1]->aliases[0] = "eb164";
6125            if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
6126                    me->next = first_machine_entry; first_machine_entry = me;
6127            }
6128  }  }
6129    

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

  ViewVC Help
Powered by ViewVC 1.1.26