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

Diff of /trunk/src/machine.c

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

revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 18 by dpavlin, Mon Oct 8 16:19:11 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.577 2005/10/27 14:01:12 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 1240  void machine_setup(struct machine *machi Line 1528  void machine_setup(struct machine *machi
1528                  struct btinfo_symtab c;                  struct btinfo_symtab c;
1529          } xx;          } xx;
1530          struct hpc_bootinfo hpc_bootinfo;          struct hpc_bootinfo hpc_bootinfo;
1531          uint64_t hpcmips_fb_addr = 0;          int hpc_platid_flags = 0, hpc_platid_cpu_submodel = 0,
1532          int hpcmips_fb_bits = 0, hpcmips_fb_encoding = 0;              hpc_platid_cpu_model = 0, hpc_platid_cpu_series = 0,
1533          int hpcmips_fb_xsize = 0;              hpc_platid_cpu_arch = 0,
1534          int hpcmips_fb_ysize = 0;              hpc_platid_submodel = 0, hpc_platid_model = 0,
1535          int hpcmips_fb_xsize_mem = 0;              hpc_platid_series = 0, hpc_platid_vendor = 0;
1536          int hpcmips_fb_ysize_mem = 0;          uint64_t hpc_fb_addr = 0;
1537            int hpc_fb_bits = 0, hpc_fb_encoding = 0;
1538            int hpc_fb_xsize = 0;
1539            int hpc_fb_ysize = 0;
1540            int hpc_fb_xsize_mem = 0;
1541            int hpc_fb_ysize_mem = 0;
1542    
1543          /*  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;  
1544          uint64_t sgi_ram_offset = 0;          uint64_t sgi_ram_offset = 0;
         uint64_t arc_reserved;  
1545          int arc_wordlen = sizeof(uint32_t);          int arc_wordlen = sizeof(uint32_t);
         char *short_machine_name = NULL;  
1546          char *eaddr_string = "eaddr=10:20:30:40:50:60";   /*  nonsense  */          char *eaddr_string = "eaddr=10:20:30:40:50:60";   /*  nonsense  */
1547          unsigned char macaddr[6];          unsigned char macaddr[6];
1548    
1549          /*  Generic bootstring stuff:  */          /*  Generic bootstring stuff:  */
1550          int bootdev_id = diskimage_bootdev(machine);          int bootdev_type = 0;
1551            int bootdev_id;
1552          char *bootstr = NULL;          char *bootstr = NULL;
1553          char *bootarg = NULL;          char *bootarg = NULL;
1554          char *init_bootpath;          char *init_bootpath;
1555    
1556          /*  PCI stuff:  */          /*  PCI stuff:  */
1557          struct pci_data *pci_data;          struct pci_data *pci_data = NULL;
1558    
1559          /*  Framebuffer stuff:  */          /*  Framebuffer stuff:  */
1560          struct vfb_data *fb;          struct vfb_data *fb = NULL;
1561    
1562          /*  Abreviation:  :-)  */          /*  Abreviation:  :-)  */
1563          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];          struct cpu *cpu = machine->cpus[machine->bootstrap_cpu];
1564    
1565    
1566            bootdev_id = diskimage_bootdev(machine, &bootdev_type);
1567    
1568          mem = cpu->mem;          mem = cpu->mem;
1569          machine->machine_name = NULL;          machine->machine_name = NULL;
1570    
# Line 1286  void machine_setup(struct machine *machi Line 1574  void machine_setup(struct machine *machi
1574                  case MACHINE_ARC:                  case MACHINE_ARC:
1575                          machine->boot_string_argument = "-aN";                          machine->boot_string_argument = "-aN";
1576                          break;                          break;
1577                    case MACHINE_CATS:
1578                            machine->boot_string_argument = "-A";
1579                            break;
1580                  case MACHINE_DEC:                  case MACHINE_DEC:
1581                          machine->boot_string_argument = "-a";                          machine->boot_string_argument = "-a";
1582                          break;                          break;
# Line 1302  void machine_setup(struct machine *machi Line 1593  void machine_setup(struct machine *machi
1593                  printf("\nNo emulation type specified.\n");                  printf("\nNo emulation type specified.\n");
1594                  exit(1);                  exit(1);
1595    
1596    #ifdef ENABLE_MIPS
1597          case MACHINE_BAREMIPS:          case MACHINE_BAREMIPS:
1598                  /*                  /*
1599                   *  A "bare" MIPS test machine.                   *  A "bare" MIPS test machine.
# Line 1314  void machine_setup(struct machine *machi Line 1606  void machine_setup(struct machine *machi
1606    
1607          case MACHINE_TESTMIPS:          case MACHINE_TESTMIPS:
1608                  /*                  /*
1609                   *  A MIPS test machine (which happens to work with my                   *  A MIPS test machine (which happens to work with the
1610                   *  thesis work).                   *  code in my master's thesis).  :-)
1611                     *
1612                     *  IRQ map:
1613                     *      7       CPU counter
1614                     *      6       SMP IPIs
1615                     *      5       not used yet
1616                     *      4       not used yet
1617                     *      3       ethernet
1618                     *      2       serial console
1619                   */                   */
1620                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
1621                  machine->machine_name = "MIPS test machine";                  machine->machine_name = "MIPS test machine";
1622    
1623                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=2",
1624                      machine, mem, DEV_CONS_ADDRESS, "console", 2);                      (long long)DEV_CONS_ADDRESS);
1625                    cons_data = device_add(machine, tmpstr);
1626                    machine->main_console_handle = cons_data->console_handle;
1627    
1628                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
1629                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
1630                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
1631    
1632                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
1633                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testmips generic");
1634    
1635                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
1636                        (long long)DEV_DISK_ADDRESS);
1637                    device_add(machine, tmpstr);
1638    
1639                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=3",
1640                        (long long)DEV_ETHER_ADDRESS);
1641                    device_add(machine, tmpstr);
1642    
1643                  break;                  break;
1644    
1645          case MACHINE_DEC:          case MACHINE_DEC:
# Line 1370  void machine_setup(struct machine *machi Line 1681  void machine_setup(struct machine *machi
1681                           */                           */
1682                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,                          fb = dev_fb_init(machine, mem, KN01_PHYS_FBUF_START,
1683                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,                              color_fb_flag? VFB_DEC_VFB02 : VFB_DEC_VFB01,
1684                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01", 1);                              0,0,0,0,0, color_fb_flag? "VFB02":"VFB01");
1685                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);                          dev_colorplanemask_init(mem, KN01_PHYS_COLMASK_START, &fb->color_plane_mask);
1686                          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);
1687                          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 1771  void machine_setup(struct machine *machi
1771                          dev_mc146818_init(machine, mem,                          dev_mc146818_init(machine, mem,
1772                              KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1);                              KN02_SYS_CLOCK, KN02_INT_CLOCK, MC146818_DEC, 1);
1773    
1774                          machine->kn02_csr =                          machine->md_int.kn02_csr =
1775                              dev_kn02_init(cpu, mem, KN02_SYS_CSR);                              dev_kn02_init(cpu, mem, KN02_SYS_CSR);
1776    
1777                          framebuffer_console_name = "osconsole=0,7";                          framebuffer_console_name = "osconsole=0,7";
# Line 1494  void machine_setup(struct machine *machi Line 1805  void machine_setup(struct machine *machi
1805                           *  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
1806                           *  dma for asc0                                                (0x1c380000) slot 14                           *  dma for asc0                                                (0x1c380000) slot 14
1807                           */                           */
1808                          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);
1809                          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);
1810                          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);
1811                          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 1871  void machine_setup(struct machine *machi
1871                           *  mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000)                           *  mcclock0 at ioasic0 offset 0x200000: mc146818 or compatible (0x1fa00000)
1872                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000)                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7 (0x1fb00000)
1873                           */                           */
1874                          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);
1875    
1876                          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);
1877    
1878                          machine->dec_ioasic_data->dma_func[3] = dev_scc_dma_func;                          machine->md_int.dec_ioasic_data->dma_func[3] = dev_scc_dma_func;
1879                          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);
1880                          machine->dec_ioasic_data->dma_func[2] = dev_scc_dma_func;                          machine->md_int.dec_ioasic_data->dma_func[2] = dev_scc_dma_func;
1881                          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);
1882    
1883                          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);
1884                          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 1937  void machine_setup(struct machine *machi
1937                           *  Clock uses interrupt 3 (shared with XMI?).                           *  Clock uses interrupt 3 (shared with XMI?).
1938                           */                           */
1939    
1940                          machine->dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000);                          machine->md_int.dec5800_csr = dev_dec5800_init(machine, mem, 0x10000000);
1941                          dev_decbi_init(mem, 0x10000000);                          dev_decbi_init(mem, 0x10000000);
1942                          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);
1943                          dev_decxmi_init(mem, 0x11800000);                          dev_decxmi_init(mem, 0x11800000);
1944                          dev_deccca_init(mem, DEC_DECCCA_BASEADDR);                          dev_deccca_init(mem, DEC_DECCCA_BASEADDR);
1945    
# Line 1697  void machine_setup(struct machine *machi Line 2008  void machine_setup(struct machine *machi
2008                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7         (0x1c300000)                           *  asc0 at ioasic0 offset 0x300000: NCR53C94, 25MHz, SCSI ID 7         (0x1c300000)
2009                           *  xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer     (0xa000000)                           *  xcfb0 at tc0 slot 2 offset 0x0: 1024x768x8 built-in framebuffer     (0xa000000)
2010                           */                           */
2011                          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);
2012    
2013                          /*  TURBOchannel slots (0 and 1):  */                          /*  TURBOchannel slots (0 and 1):  */
2014                          dev_turbochannel_init(machine, mem, 0,                          dev_turbochannel_init(machine, mem, 0,
# Line 1802  void machine_setup(struct machine *machi Line 2113  void machine_setup(struct machine *machi
2113                          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);
2114                          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);
2115    
2116                          snprintf(tmpstr, sizeof(tmpstr) - 1,                          snprintf(tmpstr, sizeof(tmpstr),
2117                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);                              "kn230 addr=0x%llx", (long long)KN230_SYS_ICSR);
2118                          machine->kn230_csr = device_add(machine, tmpstr);                          machine->md_int.kn230_csr = device_add(machine, tmpstr);
2119    
2120                          serial_console_name = "osconsole=0";                          serial_console_name = "osconsole=0";
2121                          break;                          break;
# Line 1815  void machine_setup(struct machine *machi Line 2126  void machine_setup(struct machine *machi
2126    
2127                  /*                  /*
2128                   *  Most OSes on DECstation use physical addresses below                   *  Most OSes on DECstation use physical addresses below
2129                   *  0x20000000, but OSF/1 seems to use 0xbe...... as if it was                   *  0x20000000, but both OSF/1 and Sprite use 0xbe...... as if
2130                   *  0x1e......, so we need this hack:                   *  it was 0x1e......, so we need this hack:
2131                   */                   */
2132                  dev_ram_init(mem, 0xa0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);                  dev_ram_init(machine, 0xa0000000, 0x20000000,
2133                        DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2134    
2135                  /*  DECstation PROM stuff:  (TODO: endianness)  */                  if (machine->prom_emulation) {
2136                  for (i=0; i<100; i++)                          /*  DECstation PROM stuff:  (TODO: endianness)  */
2137                          store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,                          for (i=0; i<100; i++)
2138                              DEC_PROM_EMULATION + i*8);                                  store_32bit_word(cpu, DEC_PROM_CALLBACK_STRUCT + i*4,
2139                                        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  */  
                 }  
2140    
2141                  /*                          /*  Fill PROM with dummy return instructions:  (TODO: make this nicer)  */
2142                   *  According to dec_prom.h from NetBSD:                          for (i=0; i<100; i++) {
2143                   *                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8,
2144                   *  "Programs loaded by the new PROMs pass the following arguments:                                      0x03e00008);        /*  return  */
2145                   *      a0      argc                                  store_32bit_word(cpu, DEC_PROM_EMULATION + i*8 + 4,
2146                   *      a1      argv                                      0x00000000);        /*  nop  */
2147                   *      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.  
                  */  
2148    
2149                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;                          /*
2150                  cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;                           *  According to dec_prom.h from NetBSD:
2151                  cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;                           *
2152                  cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;                           *  "Programs loaded by the new PROMs pass the following arguments:
2153                             *      a0      argc
2154                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,                           *      a1      argv
2155                      BOOTINFO_MAGIC);                           *      a2      DEC_PROM_MAGIC
2156                  store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,                           *      a3      The callback vector defined below"
2157                      BOOTINFO_ADDR);                           *
2158                             *  So we try to emulate a PROM, even though no such thing has been
2159                  store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,                           *  loaded.
2160                      (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);  
2161    
2162                  /*                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 3;
2163                   *  NetBSD and Ultrix expect the boot args to be like this:                          cpu->cd.mips.gpr[MIPS_GPR_A1] = DEC_PROM_INITIAL_ARGV;
2164                   *                          cpu->cd.mips.gpr[MIPS_GPR_A2] = DEC_PROM_MAGIC;
2165                   *      "boot" "bootdev" [args?]                          cpu->cd.mips.gpr[MIPS_GPR_A3] = DEC_PROM_CALLBACK_STRUCT;
2166                   *  
2167                   *  where bootdev is supposed to be "rz(0,0,0)netbsd" for                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x10,
2168                   *  3100/2100 (although that crashes Ultrix :-/), and                              BOOTINFO_MAGIC);
2169                   *  "5/rz0a/netbsd" for all others.  The number '5' is the                          store_32bit_word(cpu, INITIAL_STACK_POINTER + 0x14,
2170                   *  slot number of the boot device.                              BOOTINFO_ADDR);
2171                   *  
2172                   *  'rz' for disks, 'tz' for tapes.                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV,
2173                   *                              (DEC_PROM_INITIAL_ARGV + 0x10));
2174                   *  TODO:  Make this nicer.                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+4,
2175                   */                              (DEC_PROM_INITIAL_ARGV + 0x70));
2176                  {                          store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+8,
2177                          char bootpath[200];                              (DEC_PROM_INITIAL_ARGV + 0xe0));
2178                            store_32bit_word(cpu, DEC_PROM_INITIAL_ARGV+12, 0);
2179    
2180                            /*
2181                             *  NetBSD and Ultrix expect the boot args to be like this:
2182                             *
2183                             *      "boot" "bootdev" [args?]
2184                             *
2185                             *  where bootdev is supposed to be "rz(0,0,0)netbsd" for
2186                             *  3100/2100 (although that crashes Ultrix :-/), and
2187                             *  "5/rz0a/netbsd" for all others.  The number '5' is the
2188                             *  slot number of the boot device.
2189                             *
2190                             *  'rz' for disks, 'tz' for tapes.
2191                             *
2192                             *  TODO:  Make this nicer.
2193                             */
2194                            {
2195                            char bootpath[200];
2196  #if 0  #if 0
2197                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
2198                                  strcpy(bootpath, "rz(0,0,0)");                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
2199                          else                          else
2200  #endif  #endif
2201                                  strcpy(bootpath, "5/rz1/");                                  strlcpy(bootpath, "5/rz1/", sizeof(bootpath));
2202    
2203                          if (bootdev_id < 0 || machine->force_netboot) {                          if (bootdev_id < 0 || machine->force_netboot) {
2204                                  /*  tftp boot:  */                                  /*  tftp boot:  */
2205                                  strcpy(bootpath, "5/tftp/");                                  strlcpy(bootpath, "5/tftp/", sizeof(bootpath));
2206                                  bootpath[0] = '0' + boot_net_boardnumber;                                  bootpath[0] = '0' + boot_net_boardnumber;
2207                          } else {                          } else {
2208                                  /*  disk boot:  */                                  /*  disk boot:  */
2209                                  bootpath[0] = '0' + boot_scsi_boardnumber;                                  bootpath[0] = '0' + boot_scsi_boardnumber;
2210                                  if (diskimage_is_a_tape(machine, bootdev_id))                                  if (diskimage_is_a_tape(machine, bootdev_id,
2211                                        bootdev_type))
2212                                          bootpath[2] = 't';                                          bootpath[2] = 't';
2213                                  bootpath[4] = '0' + bootdev_id;                                  bootpath[4] = '0' + bootdev_id;
2214                          }                          }
2215    
2216                          init_bootpath = bootpath;                          init_bootpath = bootpath;
2217                  }                          }
2218    
2219                  bootarg = malloc(strlen(init_bootpath) +                          bootarg = malloc(BOOTARG_BUFLEN);
2220                      strlen(machine->boot_kernel_filename) + 1 +                          if (bootarg == NULL) {
2221                      strlen(machine->boot_string_argument) + 1);                                  fprintf(stderr, "out of memory\n");
2222                  strcpy(bootarg, init_bootpath);                                  exit(1);
2223                  strcat(bootarg, machine->boot_kernel_filename);                          }
2224                            strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2225                  bootstr = "boot";                          if (strlcat(bootarg, machine->boot_kernel_filename,
2226                                BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2227                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);                                  fprintf(stderr, "bootarg truncated?\n");
2228                  store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);                                  exit(1);
2229                  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;  
2230    
2231                  store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));                          bootstr = "boot";
2232    
2233                  /*                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x10, bootstr);
2234                   *  The system's memmap:  (memmap is a global variable, in                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0x70, bootarg);
2235                   *  dec_prom.h)                          store_string(cpu, DEC_PROM_INITIAL_ARGV+0xe0,
2236                   */                              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);  
2237    
2238                  /*                          /*  Decrease the nr of args, if there are no args :-)  */
2239                   *  The KN5800 (SMP system) uses a CCA (console communications                          if (machine->boot_string_argument == NULL ||
2240                   *  area):  (See VAX 6000 documentation for details.)                              machine->boot_string_argument[0] == '\0')
2241                   */                                  cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2242                  {  
2243                          char tmps[300];                          if (machine->boot_string_argument[0] != '\0') {
2244                          sprintf(tmps, "cca=%x",                                  strlcat(bootarg, " ", BOOTARG_BUFLEN);
2245                              (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));                                  if (strlcat(bootarg, machine->boot_string_argument,
2246                          add_environment_string(cpu, tmps, &addr);                                      BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2247                  }                                          fprintf(stderr, "bootstr truncated?\n");
2248                                            exit(1);
2249                                    }
2250                            }
2251    
2252                  /*  These are needed for Sprite to boot:  */                          xx.a.common.next = (char *)&xx.b - (char *)&xx;
2253                  {                          xx.a.common.type = BTINFO_MAGIC;
2254                          char tmps[300];                          xx.a.magic = BOOTINFO_MAGIC;
2255    
2256                            xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2257                            xx.b.common.type = BTINFO_BOOTPATH;
2258                            strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2259    
2260                            xx.c.common.next = 0;
2261                            xx.c.common.type = BTINFO_SYMTAB;
2262                            xx.c.nsym = 0;
2263                            xx.c.ssym = 0;
2264                            xx.c.esym = machine->file_loaded_end_addr;
2265    
2266                          sprintf(tmps, "boot=%s", bootarg);                          store_buf(cpu, BOOTINFO_ADDR, (char *)&xx, sizeof(xx));
                         add_environment_string(cpu, tmps, &addr);  
2267    
2268                          sprintf(tmps, "bitmap=0x%x", (uint32_t)((                          /*
2269                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))                           *  The system's memmap:  (memmap is a global variable, in
2270                              & 0xffffffffULL));                           *  dec_prom.h)
2271                          add_environment_string(cpu, tmps, &addr);                           */
2272                            store_32bit_word_in_host(cpu,
2273                          sprintf(tmps, "bitmaplen=0x%x",                              (unsigned char *)&memmap.pagesize, 4096);
2274                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                          {
2275                          add_environment_string(cpu, tmps, &addr);                                  unsigned int i;
2276                  }                                  for (i=0; i<sizeof(memmap.bitmap); i++)
2277                                            memmap.bitmap[i] = ((int)i * 4096*8 <
2278                  add_environment_string(cpu, "scsiid0=7", &addr);                                              1048576*machine->physical_ram_in_mb)?
2279                  add_environment_string(cpu, "bootmode=a", &addr);                                              0xff : 0x00;
2280                  add_environment_string(cpu, "testaction=q", &addr);                          }
2281                  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);  
2282    
2283                  /*  The end:  */                          /*  Environment variables:  */
2284                  add_environment_string(cpu, "", &addr);                          addr = DEC_PROM_STRINGS;
2285    
2286                            if (machine->use_x11 && machine->n_gfx_cards > 0)
2287                                    /*  (0,3)  Keyboard and Framebuffer  */
2288                                    add_environment_string(cpu, framebuffer_console_name, &addr);
2289                            else
2290                                    /*  Serial console  */
2291                                    add_environment_string(cpu, serial_console_name, &addr);
2292    
2293                            /*
2294                             *  The KN5800 (SMP system) uses a CCA (console communications
2295                             *  area):  (See VAX 6000 documentation for details.)
2296                             */
2297                            {
2298                                    char tmps[300];
2299                                    snprintf(tmps, sizeof(tmps), "cca=%x",
2300                                        (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2301                                    add_environment_string(cpu, tmps, &addr);
2302                            }
2303    
2304                            /*  These are needed for Sprite to boot:  */
2305                            {
2306                                    char tmps[500];
2307    
2308                                    snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2309                                    tmps[sizeof(tmps)-1] = '\0';
2310                                    add_environment_string(cpu, tmps, &addr);
2311    
2312                                    snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2313                                        DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2314                                        & 0xffffffffULL));
2315                                    tmps[sizeof(tmps)-1] = '\0';
2316                                    add_environment_string(cpu, tmps, &addr);
2317    
2318                                    snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2319                                        machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2320                                    tmps[sizeof(tmps)-1] = '\0';
2321                                    add_environment_string(cpu, tmps, &addr);
2322                            }
2323    
2324                            add_environment_string(cpu, "scsiid0=7", &addr);
2325                            add_environment_string(cpu, "bootmode=a", &addr);
2326                            add_environment_string(cpu, "testaction=q", &addr);
2327                            add_environment_string(cpu, "haltaction=h", &addr);
2328                            add_environment_string(cpu, "more=24", &addr);
2329    
2330                            /*  Used in at least Ultrix on the 5100:  */
2331                            add_environment_string(cpu, "scsiid=7", &addr);
2332                            add_environment_string(cpu, "baud0=9600", &addr);
2333                            add_environment_string(cpu, "baud1=9600", &addr);
2334                            add_environment_string(cpu, "baud2=9600", &addr);
2335                            add_environment_string(cpu, "baud3=9600", &addr);
2336                            add_environment_string(cpu, "iooption=0x1", &addr);
2337    
2338                            /*  The end:  */
2339                            add_environment_string(cpu, "", &addr);
2340                    }
2341    
2342                  break;                  break;
2343    
# Line 2027  void machine_setup(struct machine *machi Line 2354  void machine_setup(struct machine *machi
2354                   *      4       Tulip 1                   *      4       Tulip 1
2355                   *      5       16550 UART (serial console)                   *      5       16550 UART (serial console)
2356                   *      6       VIA southbridge PIC                   *      6       VIA southbridge PIC
2357                   *      7       PCI                   *      7       PCI  (Note: Not used. The PCI controller
2358                     *              interrupts at ISA interrupt 9.)
2359                   */                   */
2360  /*              dev_XXX_init(cpu, mem, 0x10000000, machine->emulated_hz);       */  
2361                    /*  ISA interrupt controllers:  */
2362                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x10000020");
2363                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
2364                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x100000a0");
2365                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
2366                    machine->md_interrupt = cobalt_interrupt;
2367    
2368                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);                  dev_mc146818_init(machine, mem, 0x10000070, 0, MC146818_PC_CMOS, 4);
2369                  machine->main_console_handle = dev_ns16550_init(machine, mem,  
2370                      0x1c800000, 5, 1, 1, "serial console");                  machine->main_console_handle = (size_t)
2371                        device_add(machine, "ns16550 irq=5 addr=0x1c800000 name2=tty0 in_use=1");
2372    
2373    #if 0
2374                    device_add(machine, "ns16550 irq=0 addr=0x1f000010 name2=tty1 in_use=0");
2375    #endif
2376    
2377                  /*                  /*
2378                   *  According to NetBSD/cobalt:                   *  According to NetBSD/cobalt:
# Line 2043  void machine_setup(struct machine *machi Line 2383  void machine_setup(struct machine *machi
2383                   *  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
2384                   *  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
2385                   *  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
2386                     *
2387                     *  The PCI controller interrupts at ISA interrupt 9.
2388                   */                   */
2389                  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);
2390                  /*  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);  */
2391                  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  */
2392                  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);
2393                  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);
2394                  /*  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);  */
2395    
2396                  /*                  if (machine->prom_emulation) {
2397                   *  NetBSD/cobalt expects memsize in a0, but it seems that what                          /*
2398                   *  it really wants is the end of memory + 0x80000000.                           *  NetBSD/cobalt expects memsize in a0, but it seems that what
2399                   *                           *  it really wants is the end of memory + 0x80000000.
2400                   *  The bootstring should be stored starting 512 bytes before end                           *
2401                   *  of physical ram.                           *  The bootstring is stored 512 bytes before the end of
2402                   */                           *  physical ram.
2403                  cpu->cd.mips.gpr[MIPS_GPR_A0] = machine->physical_ram_in_mb * 1048576 + 0x80000000;                           */
2404                  bootstr = "root=/dev/hda1 ro";                          cpu->cd.mips.gpr[MIPS_GPR_A0] =
2405                  /*  bootstr = "nfsroot=/usr/cobalt/";  */                              machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL;
2406                  store_string(cpu, 0xffffffff80000000ULL +                          bootstr = "root=/dev/hda1 ro";
2407                      machine->physical_ram_in_mb * 1048576 - 512, bootstr);                          /*  bootstr = "nfsroot=/usr/cobalt/";  */
2408                            /*  TODO: bootarg, and/or automagic boot device detection  */
2409                            store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, bootstr);
2410                    }
2411                  break;                  break;
2412    
2413          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
2414                  cpu->byte_order = EMUL_LITTLE_ENDIAN;                  cpu->byte_order = EMUL_LITTLE_ENDIAN;
2415                  memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));                  memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));
                 /*  TODO:  set platid from netbsd/usr/src/sys/arch/hpc/include/platid*  */  
                 /*  
                 #define PLATID_FLAGS_SHIFT              0  
                 #define PLATID_CPU_SUBMODEL_SHIFT       8  
                 #define PLATID_CPU_MODEL_SHIFT          14  
                 #define PLATID_CPU_SERIES_SHIFT         20  
                 #define PLATID_CPU_ARCH_SHIFT           26  
   
                 #define PLATID_SUBMODEL_SHIFT           0  
                 #define PLATID_MODEL_SHIFT              8  
                 #define PLATID_SERIES_SHIFT             16  
                 #define PLATID_VENDOR_SHIFT             22  
                 */  
   
2416                  /*                  /*
2417                  NOTE: See http://forums.projectmayo.com/viewtopic.php?topic=2743&forum=23                  NOTE: See http://forums.projectmayo.com/viewtopic.php?topic=2743&forum=23
2418                  for info on framebuffer addresses.                  for info on framebuffer addresses.
# Line 2091  void machine_setup(struct machine *machi Line 2422  void machine_setup(struct machine *machi
2422                  case MACHINE_HPCMIPS_CASIO_BE300:                  case MACHINE_HPCMIPS_CASIO_BE300:
2423                          /*  166MHz VR4131  */                          /*  166MHz VR4131  */
2424                          machine->machine_name = "Casio Cassiopeia BE-300";                          machine->machine_name = "Casio Cassiopeia BE-300";
2425                          hpcmips_fb_addr = 0x0a200000;                          hpc_fb_addr = 0x0a200000;
2426                          hpcmips_fb_xsize = 240;                          hpc_fb_xsize = 240;
2427                          hpcmips_fb_ysize = 320;                          hpc_fb_ysize = 320;
2428                          hpcmips_fb_xsize_mem = 256;                          hpc_fb_xsize_mem = 256;
2429                          hpcmips_fb_ysize_mem = 320;                          hpc_fb_ysize_mem = 320;
2430                          hpcmips_fb_bits = 15;                          hpc_fb_bits = 15;
2431                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2432    
2433                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2434                              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);
2435                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2436                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4131);  
2437                            machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4131);
2438                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2439    
2440                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2441                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2442                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2443                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 6;    /*  VR4131  */
2444                              + (6 <<  8)         /*  6 = VR4131  */                          hpc_platid_vendor = 3;          /*  Casio  */
2445                              );                          hpc_platid_series = 1;          /*  CASSIOPEIAE  */
2446                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  EXXX  */
2447                                (3 << 22)         /*  22: vendor  3=casio */                          hpc_platid_submodel = 3;        /*  E500  */
                             + (1 << 16)         /*  16: series  1=CASSIOPEIAE*/  
                             + (2 <<  8)         /*   8: model   2=EXXX*/  
                             + (3)               /*   0: submodel 3=E500 */  
                             );  
2448                          /*  TODO: Don't use model number for E500, it's a BE300!  */                          /*  TODO: Don't use model number for E500, it's a BE300!  */
2449                          break;                          break;
2450                  case MACHINE_HPCMIPS_CASIO_E105:                  case MACHINE_HPCMIPS_CASIO_E105:
2451                          /*  131MHz VR4121  */                          /*  131MHz VR4121  */
2452                          machine->machine_name = "Casio Cassiopeia E-105";                          machine->machine_name = "Casio Cassiopeia E-105";
2453                          hpcmips_fb_addr = 0x0a200000;   /*  TODO?  */                          hpc_fb_addr = 0x0a200000;       /*  TODO?  */
2454                          hpcmips_fb_xsize = 240;                          hpc_fb_xsize = 240;
2455                          hpcmips_fb_ysize = 320;                          hpc_fb_ysize = 320;
2456                          hpcmips_fb_xsize_mem = 256;                          hpc_fb_xsize_mem = 256;
2457                          hpcmips_fb_ysize_mem = 320;                          hpc_fb_ysize_mem = 320;
2458                          hpcmips_fb_bits = 16;                          hpc_fb_bits = 16;
2459                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2460    
2461                          machine->main_console_handle = dev_ns16550_init(                          /*  TODO: irq?  */
2462                              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);
2463                              machine->use_x11? 0 : 1, "serial console");  /*  TODO: irq?  */                          machine->main_console_handle = (size_t)device_add(machine, tmpstr);
2464                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);  
2465                            machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2466                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2467    
2468                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2469                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2470                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2471                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2472                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 3;          /*  Casio  */
2473                              );                          hpc_platid_series = 1;          /*  CASSIOPEIAE  */
2474                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  EXXX  */
2475                                (3 << 22)         /*  22: vendor  3=casio */                          hpc_platid_submodel = 2;        /*  E105  */
                             + (1 << 16)         /*  16: series  1=CASSIOPEIAE*/  
                             + (2 <<  8)         /*   8: model   2=EXXX*/  
                             + (2)               /*   0: submodel 2=E105  */  
                             );  
2476                          break;                          break;
2477                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_770:
2478                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2479                          machine->machine_name = "NEC MobilePro 770";                          machine->machine_name = "NEC MobilePro 770";
2480                          /*  TODO:  */                          hpc_fb_addr = 0xa000000;
2481                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_xsize = 640;
2482                          hpcmips_fb_xsize = 640;                          hpc_fb_ysize = 240;
2483                          hpcmips_fb_ysize = 240;                          hpc_fb_xsize_mem = 800;
2484                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 240;
2485                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_bits = 16;
2486                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2487    
2488                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2489                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2490    
2491                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2492                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2493                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2494                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2495                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2496                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2497                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  MCR 5XX  */
2498                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 4;        /*  MCR 520A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (2 <<  8)         /*   8: model   2="MCR 5XX" */  
                             + (4)               /*   0: submodel 4="MCR 520A" */  
                             );  
2499                          break;                          break;
2500                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_780:
2501                          /*  166 (or 168) MHz VR4121  */                          /*  166 (or 168) MHz VR4121  */
2502                          machine->machine_name = "NEC MobilePro 780";                          machine->machine_name = "NEC MobilePro 780";
2503                          /*  TODO:  */                          hpc_fb_addr = 0xa180100;
2504                          hpcmips_fb_addr = 0xa180100;                          hpc_fb_xsize = 640;
2505                          hpcmips_fb_xsize = 640;                          hpc_fb_ysize = 240;
2506                          hpcmips_fb_ysize = 240;                          hpc_fb_xsize_mem = 640;
2507                          hpcmips_fb_xsize_mem = 640;                          hpc_fb_ysize_mem = 240;
2508                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_bits = 16;
2509                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2510    
2511                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2512                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2513    
2514                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2515                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2516                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2517                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2518                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2519                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2520                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 2;           /*  MCR 5XX  */
2521                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 8;        /*  MCR 530A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (2 <<  8)         /*   8: model   2="MCR 5XX" */  
                             + (8)               /*   0: submodel 8="MCR 530A" */  
                             );  
2522                          break;                          break;
2523                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_800:
2524                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2525                          machine->machine_name = "NEC MobilePro 800";                          machine->machine_name = "NEC MobilePro 800";
2526                          /*  TODO:  */                          hpc_fb_addr = 0xa000000;
2527                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_xsize = 800;
2528                          hpcmips_fb_xsize = 800;                          hpc_fb_ysize = 600;
2529                          hpcmips_fb_ysize = 600;                          hpc_fb_xsize_mem = 800;
2530                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 600;
2531                          hpcmips_fb_ysize_mem = 600;                          hpc_fb_bits = 16;
2532                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2533    
2534                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2535                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2536    
2537                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2538                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2539                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2540                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2541                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2542                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2543                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 3;           /*  MCR 7XX  */
2544                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 2;        /*  MCR 700A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (3 <<  8)         /*   8: model   3="MCR 7XX" */  
                             + (2)               /*   0: submodel 2="MCR 700A" */  
                             );  
2545                          break;                          break;
2546                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:                  case MACHINE_HPCMIPS_NEC_MOBILEPRO_880:
2547                          /*  168 MHz VR4121  */                          /*  168 MHz VR4121  */
2548                          machine->machine_name = "NEC MobilePro 880";                          machine->machine_name = "NEC MobilePro 880";
2549                          /*  TODO:  */                          hpc_fb_addr = 0xa0ea600;
2550                          hpcmips_fb_addr = 0xa0ea600;                          hpc_fb_xsize = 800;
2551                          hpcmips_fb_xsize = 800;                          hpc_fb_ysize = 600;
2552                          hpcmips_fb_ysize = 600;                          hpc_fb_xsize_mem = 800;
2553                          hpcmips_fb_xsize_mem = 800;                          hpc_fb_ysize_mem = 600;
2554                          hpcmips_fb_ysize_mem = 600;                          hpc_fb_bits = 16;
2555                          hpcmips_fb_bits = 16;                          hpc_fb_encoding = BIFB_D16_0000;
                         hpcmips_fb_encoding = BIFB_D16_0000;  
2556    
2557                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2558                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2559    
2560                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2561                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2562                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2563                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2564                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 1;          /*  NEC  */
2565                              );                          hpc_platid_series = 2;          /*  NEC MCR  */
2566                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 3;           /*  MCR 7XX  */
2567                                (1 << 22)         /*  22: vendor  1=NEC  */                          hpc_platid_submodel = 4;        /*  MCR 730A  */
                             + (2 << 16)         /*  16: series  2="NEC MCR" */  
                             + (3 <<  8)         /*   8: model   3="MCR 7XX" */  
                             + (4)               /*   0: submodel 4="MCR 730A" */  
                             );  
2568                          break;                          break;
2569                  case MACHINE_HPCMIPS_AGENDA_VR3:                  case MACHINE_HPCMIPS_AGENDA_VR3:
2570                          /*  66 MHz VR4181  */                          /*  66 MHz VR4181  */
2571                          machine->machine_name = "Agenda VR3";                          machine->machine_name = "Agenda VR3";
2572                          /*  TODO:  */                          /*  TODO:  */
2573                          hpcmips_fb_addr = 0x1000;                          hpc_fb_addr = 0x1000;
2574                          hpcmips_fb_xsize = 160;                          hpc_fb_xsize = 160;
2575                          hpcmips_fb_ysize = 240;                          hpc_fb_ysize = 240;
2576                          hpcmips_fb_xsize_mem = 160;                          hpc_fb_xsize_mem = 160;
2577                          hpcmips_fb_ysize_mem = 240;                          hpc_fb_ysize_mem = 240;
2578                          hpcmips_fb_bits = 4;                          hpc_fb_bits = 4;
2579                          hpcmips_fb_encoding = BIFB_D4_M2L_F;                          hpc_fb_encoding = BIFB_D4_M2L_F;
2580    
2581                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4181);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4181);
2582                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2583    
2584                          /*  TODO: Hm... irq 17 according to linux, but                          /*  TODO: Hm... irq 17 according to linux, but
2585                              VRIP_INTR_SIU (=9) here?  */                              VRIP_INTR_SIU (=9) here?  */
2586                          {                          {
2587                                  int x;                                  int x;
2588                                  x = dev_ns16550_init(machine, mem, 0x0c000010,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x0c000010", 8 + VRIP_INTR_SIU);
2589                                      8 + VRIP_INTR_SIU, 1, 1, "serial 0");                                  x = (size_t)device_add(machine, tmpstr);
2590    
2591                                  if (!machine->use_x11)                                  if (!machine->use_x11)
2592                                          machine->main_console_handle = x;                                          machine->main_console_handle = x;
2593                          }                          }
2594    
2595                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2596                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2597                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2598                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 4;    /*  VR4181  */
2599                              + (4 <<  8)         /*  4 = VR4181  */                          hpc_platid_vendor = 15;         /*  Agenda  */
2600                              );                          hpc_platid_series = 1;          /*  VR  */
2601                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 1;           /*  VR3  */
2602                                (15 << 22)        /*  22: vendor  15=Agenda  */                          hpc_platid_submodel = 0;        /*  -  */
                             + (1 << 16)         /*  16: series  2=VR */  
                             + (1 <<  8)         /*   8: model   1=VR3  */  
                             + (0)               /*   0: submodel 0="VR3" */  
                             );  
2603    
2604                          dev_ram_init(mem, 0x0f000000, 0x01000000, DEV_RAM_MIRROR, 0x0);                          dev_ram_init(machine, 0x0f000000, 0x01000000,
2605                                DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2606                          break;                          break;
2607                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:                  case MACHINE_HPCMIPS_IBM_WORKPAD_Z50:
2608                          /*  131 MHz VR4121  */                          /*  131 MHz VR4121  */
2609                          machine->machine_name = "Agenda VR3";                          machine->machine_name = "IBM Workpad Z50";
2610                          /*  TODO:  */                          /*  TODO:  */
2611                          hpcmips_fb_addr = 0xa000000;                          hpc_fb_addr = 0xa000000;
2612                          hpcmips_fb_xsize = 640;                          hpc_fb_xsize = 640;
2613                          hpcmips_fb_ysize = 480;                          hpc_fb_ysize = 480;
2614                          hpcmips_fb_xsize_mem = 640;                          hpc_fb_xsize_mem = 640;
2615                          hpcmips_fb_ysize_mem = 480;                          hpc_fb_ysize_mem = 480;
2616                          hpcmips_fb_bits = 16;                          hpc_fb_bits = 16;
2617                          hpcmips_fb_encoding = BIFB_D16_0000;                          hpc_fb_encoding = BIFB_D16_0000;
2618    
2619                          machine->vr41xx_data = dev_vr41xx_init(machine, mem, 4121);                          machine->md_int.vr41xx_data = dev_vr41xx_init(machine, mem, 4121);
2620                          machine->md_interrupt = vr41xx_interrupt;                          machine->md_interrupt = vr41xx_interrupt;
2621    
2622                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,                          hpc_platid_cpu_arch = 1;        /*  MIPS  */
2623                                (1 << 26)         /*  1 = MIPS  */                          hpc_platid_cpu_series = 1;      /*  VR  */
2624                              + (1 << 20)         /*  1 = VR  */                          hpc_platid_cpu_model = 1;       /*  VR41XX  */
2625                              + (1 << 14)         /*  1 = VR41XX  */                          hpc_platid_cpu_submodel = 3;    /*  VR4121  */
2626                              + (3 <<  8)         /*  3 = VR4121  */                          hpc_platid_vendor = 9;          /*  IBM  */
2627                              );                          hpc_platid_series = 1;          /*  WorkPad  */
2628                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,                          hpc_platid_model = 1;           /*  Z50  */
2629                                (9 << 22)         /*  22: vendor  9=IBM  */                          hpc_platid_submodel = 0;        /*  0  */
                             + (1 << 16)         /*  16: series  1=WorkPad */  
                             + (1 <<  8)         /*   8: model   1=Z50  */  
                             + (0)               /*   0: submodel 0 */  
                             );  
2630                          break;                          break;
2631                  default:                  default:
2632                          printf("Unimplemented hpcmips machine number.\n");                          printf("Unimplemented hpcmips machine number.\n");
2633                          exit(1);                          exit(1);
2634                  }                  }
2635    
2636                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
2637                          (hpc_platid_cpu_arch << 26) + (hpc_platid_cpu_series << 20)
2638                        + (hpc_platid_cpu_model << 14) + (hpc_platid_cpu_submodel <<  8)
2639                        + hpc_platid_flags);
2640                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
2641                          (hpc_platid_vendor << 22) + (hpc_platid_series << 16)
2642                        + (hpc_platid_model <<  8) + hpc_platid_submodel);
2643    
2644                  if (machine->use_x11)                  if (machine->use_x11)
2645                          machine->main_console_handle =                          machine->main_console_handle =
2646                              machine->vr41xx_data->kiu_console_handle;                              machine->md_int.vr41xx_data->kiu_console_handle;
2647    
2648                  /*  NetBSD/hpcmips and possibly others expects the following:  */                  if (machine->prom_emulation) {
2649                            /*  NetBSD/hpcmips and possibly others expects the following:  */
2650    
2651                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;      /*  argc  */
2652                  cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576                          cpu->cd.mips.gpr[MIPS_GPR_A1] = machine->physical_ram_in_mb * 1048576
2653                      + 0xffffffff80000000ULL - 512;      /*  argv  */                              + 0xffffffff80000000ULL - 512;      /*  argv  */
2654                  cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576                          cpu->cd.mips.gpr[MIPS_GPR_A2] = machine->physical_ram_in_mb * 1048576
2655                      + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */                              + 0xffffffff80000000ULL - 256;      /*  ptr to hpc_bootinfo  */
2656    
2657                  bootstr = machine->boot_kernel_filename;                          bootstr = machine->boot_kernel_filename;
2658                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16);                          store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512,
2659                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);                              0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16);
2660                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);                          store_32bit_word(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
2661                            store_string(cpu, 0xffffffff80000000ULL + machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
2662                  /*  Special case for the Agenda VR3:  */  
2663                  if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {                          /*  Special case for the Agenda VR3:  */
2664                          const int tmplen = 1000;                          if (machine->machine_subtype == MACHINE_HPCMIPS_AGENDA_VR3) {
2665                          char *tmp = malloc(tmplen);                                  const int tmplen = 1000;
2666                                    char *tmp = malloc(tmplen);
2667    
2668                                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */
2669    
2670                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2671                                    store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2672    
2673                                    snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"
2674                                        "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");
2675                                    tmp[tmplen-1] = '\0';
2676    
2677                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;      /*  argc  */                                  if (!machine->use_x11)
2678                                            snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");
2679                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  tmp[tmplen-1] = '\0';
                         store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);  
   
                         snprintf(tmp, tmplen, "root=/dev/rom video=vr4181fb:xres:160,yres:240,bpp:4,"  
                             "gray,hpck:3084,inv ether=0,0x03fe0300,eth0");  
                         tmp[tmplen-1] = '\0';  
   
                         if (!machine->use_x11)  
                                 snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " console=ttyS0,115200");  
                         tmp[tmplen-1] = '\0';  
2680    
2681                          if (machine->boot_string_argument[0])                                  if (machine->boot_string_argument[0])
2682                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);                                          snprintf(tmp+strlen(tmp), tmplen-strlen(tmp), " %s", machine->boot_string_argument);
2683                          tmp[tmplen-1] = '\0';                                  tmp[tmplen-1] = '\0';
2684    
2685                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64, tmp);
2686    
2687                          bootarg = tmp;                                  bootarg = tmp;
2688                  } else if (machine->boot_string_argument[0]) {                          } else if (machine->boot_string_argument[0]) {
2689                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */                                  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;       /*  argc  */
2690    
2691                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 4, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64);
2692                          store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);                                  store_32bit_word(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
2693    
2694                          store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,                                  store_string(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 512 + 64,
2695                              machine->boot_string_argument);                                      machine->boot_string_argument);
2696    
2697                          bootarg = machine->boot_string_argument;                                  bootarg = machine->boot_string_argument;
2698                  }                          }
2699    
2700                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
2701                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
2702                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpcmips_fb_addr);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, 0x80000000 + hpc_fb_addr);
2703                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpcmips_fb_xsize_mem * (((hpcmips_fb_bits-1)|7)+1) / 8);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpc_fb_xsize_mem * (((hpc_fb_bits-1)|7)+1) / 8);
2704                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpcmips_fb_xsize);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpc_fb_xsize);
2705                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpcmips_fb_ysize);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpc_fb_ysize);
2706                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpcmips_fb_encoding);                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpc_fb_encoding);
2707                  store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */                          store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse, BI_CNUSE_BUILTIN);  /*  _BUILTIN or _SERIAL  */
2708    
2709                  /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);                          /*  printf("hpc_bootinfo.platid_cpu     = 0x%08x\n", hpc_bootinfo.platid_cpu);
2710                      printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */                              printf("hpc_bootinfo.platid_machine = 0x%08x\n", hpc_bootinfo.platid_machine);  */
2711                  store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);                          store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
2712                  store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));                          store_buf(cpu, 0x80000000 + machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
2713                    }
2714                  if (hpcmips_fb_addr != 0) {  
2715                          dev_fb_init(machine, mem, hpcmips_fb_addr, VFB_HPCMIPS,                  if (hpc_fb_addr != 0) {
2716                              hpcmips_fb_xsize, hpcmips_fb_ysize,                          dev_fb_init(machine, mem, hpc_fb_addr, VFB_HPC,
2717                              hpcmips_fb_xsize_mem, hpcmips_fb_ysize_mem,                              hpc_fb_xsize, hpc_fb_ysize,
2718                              hpcmips_fb_bits, "HPCmips", 0);                              hpc_fb_xsize_mem, hpc_fb_ysize_mem,
2719                                hpc_fb_bits, machine->machine_name);
2720    
2721                          /*  NetBSD/hpcmips uses framebuffer at physical                          /*  NetBSD/hpcmips uses framebuffer at physical
2722                              address 0x8.......:  */                              address 0x8.......:  */
2723                          dev_ram_init(mem, 0x80000000, 0x20000000,                          dev_ram_init(machine, 0x80000000, 0x20000000,
2724                              DEV_RAM_MIRROR, 0x0);                              DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x0);
2725                  }                  }
2726    
2727                  break;                  break;
# Line 2437  void machine_setup(struct machine *machi Line 2746  void machine_setup(struct machine *machi
2746                   *      ohci0: OHCI version 1.0                   *      ohci0: OHCI version 1.0
2747                   */                   */
2748    
2749                  machine->ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);                  machine->md_int.ps2_data = dev_ps2_stuff_init(machine, mem, 0x10000000);
2750                  device_add(machine, "ps2_gs addr=0x12000000");                  device_add(machine, "ps2_gs addr=0x12000000");
2751                  device_add(machine, "ps2_ether addr=0x14001000");                  device_add(machine, "ps2_ether addr=0x14001000");
2752                  dev_ram_init(mem, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0);     /*  TODO: how much?  */                  dev_ram_init(machine, 0x1c000000, 4 * 1048576, DEV_RAM_RAM, 0); /*  TODO: how much?  */
2753                  /*  irq = 8 + 32 + 1 (SBUS/USB)  */                  /*  irq = 8 + 32 + 1 (SBUS/USB)  */
2754                  device_add(machine, "ohci addr=0x1f801600 irq=41");                  device_add(machine, "ohci addr=0x1f801600 irq=41");
2755    
2756                  machine->md_interrupt = ps2_interrupt;                  machine->md_interrupt = ps2_interrupt;
2757    
                 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);  
   
2758                  /*  Set the Harddisk controller present flag, if either                  /*  Set the Harddisk controller present flag, if either
2759                      disk 0 or 1 is present:  */                      disk 0 or 1 is present:  */
2760                  if (diskimage_exist(machine, 0) || diskimage_exist(machine, 1)) {                  if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
2761                          store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);                      diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
2762                            if (machine->prom_emulation)
2763                                    store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x0, 0x100);
2764                          dev_ps2_spd_init(machine, mem, 0x14000000);                          dev_ps2_spd_init(machine, mem, 0x14000000);
2765                  }                  }
2766    
2767                  store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);                  if (machine->prom_emulation) {
                 {  
2768                          int tmplen = 1000;                          int tmplen = 1000;
2769                          char *tmp = malloc(tmplen);                          char *tmp = malloc(tmplen);
2770                            time_t timet;
2771                            struct tm *tm_ptr;
2772    
2773                            add_symbol_name(&machine->symbol_context,
2774                                PLAYSTATION2_SIFBIOS, 0x10000, "[SIFBIOS entry]", 0, 0);
2775                            store_32bit_word(cpu, PLAYSTATION2_BDA + 0, PLAYSTATION2_SIFBIOS);
2776                            store_buf(cpu, PLAYSTATION2_BDA + 4, "PS2b", 4);
2777    
2778                            store_32bit_word(cpu, 0xa0000000 + machine->physical_ram_in_mb*1048576 - 0x1000 + 0x4, PLAYSTATION2_OPTARGS);
2779                          if (tmp == NULL) {                          if (tmp == NULL) {
2780                                  fprintf(stderr, "out of memory\n");                                  fprintf(stderr, "out of memory\n");
2781                                  exit(1);                                  exit(1);
2782                          }                          }
2783    
2784                          strcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60");                          strlcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60", tmplen);
2785    
2786                          if (machine->boot_string_argument[0])                          if (machine->boot_string_argument[0])
2787                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),
# Line 2476  void machine_setup(struct machine *machi Line 2790  void machine_setup(struct machine *machi
2790    
2791                          bootstr = tmp;                          bootstr = tmp;
2792                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);                          store_string(cpu, PLAYSTATION2_OPTARGS, bootstr);
                 }  
2793    
2794                  /*  TODO:  netbsd's bootinfo.h, for symbolic names  */                          /*  TODO:  netbsd's bootinfo.h, for symbolic names  */
                 {  
                         time_t timet;  
                         struct tm *tmp;  
2795    
2796                          /*  RTC data given by the BIOS:  */                          /*  RTC data given by the BIOS:  */
2797                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */                          timet = time(NULL) + 9*3600;    /*  PS2 uses Japanese time  */
2798                          tmp = gmtime(&timet);                          tm_ptr = gmtime(&timet);
2799                          /*  TODO:  are these 0- or 1-based?  */                          /*  TODO:  are these 0- or 1-based?  */
2800                          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));
2801                          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));
2802                          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));
2803                          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));
2804                          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));
2805                          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));
                 }  
2806    
2807                  /*  "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.  */
2808                  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);
2809                    }
2810    
2811                  break;                  break;
2812    
# Line 2510  void machine_setup(struct machine *machi Line 2820  void machine_setup(struct machine *machi
2820                   *  detailed list of IP ("Inhouse Processor") model numbers.                   *  detailed list of IP ("Inhouse Processor") model numbers.
2821                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)
2822                   */                   */
2823                  machine->machine_name = malloc(500);                  machine->machine_name = malloc(MACHINE_NAME_MAXBUF);
2824                  if (machine->machine_name == NULL) {                  if (machine->machine_name == NULL) {
2825                          fprintf(stderr, "out of memory\n");                          fprintf(stderr, "out of memory\n");
2826                          exit(1);                          exit(1);
2827                  }                  }
                 short_machine_name = malloc(500);  
                 if (short_machine_name == NULL) {  
                         fprintf(stderr, "out of memory\n");  
                         exit(1);  
                 }  
2828    
2829                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2830                          cpu->byte_order = EMUL_BIG_ENDIAN;                          cpu->byte_order = EMUL_BIG_ENDIAN;
2831                          sprintf(short_machine_name, "SGI-IP%i", machine->machine_subtype);                          snprintf(machine->machine_name, MACHINE_NAME_MAXBUF,
2832                          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");  
2833    
2834                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;
2835    
2836                          /*  Special cases for IP20,22,24,26 memory offset:  */                          /*  Special cases for IP20,22,24,26 memory offset:  */
2837                          if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||                          if (machine->machine_subtype == 20 || machine->machine_subtype == 22 ||
2838                              machine->machine_subtype == 24 || machine->machine_subtype == 26) {                              machine->machine_subtype == 24 || machine->machine_subtype == 26) {
2839                                  dev_ram_init(mem, 0x00000000, 0x10000, DEV_RAM_MIRROR, sgi_ram_offset);                                  dev_ram_init(machine, 0x00000000, 0x10000, DEV_RAM_MIRROR
2840                                  dev_ram_init(mem, 0x00050000, sgi_ram_offset-0x50000, DEV_RAM_MIRROR, sgi_ram_offset + 0x50000);                                      | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
2841                                    dev_ram_init(machine, 0x00050000, sgi_ram_offset-0x50000,
2842                                        DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset + 0x50000);
2843                          }                          }
2844    
2845                          /*  Special cases for IP28,30 memory offset:  */                          /*  Special cases for IP28,30 memory offset:  */
2846                          if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {                          if (machine->machine_subtype == 28 || machine->machine_subtype == 30) {
2847                                  /*  TODO: length below should maybe not be 128MB?  */                                  /*  TODO: length below should maybe not be 128MB?  */
2848                                  dev_ram_init(mem, 0x00000000, 128*1048576, DEV_RAM_MIRROR, sgi_ram_offset);                                  dev_ram_init(machine, 0x00000000, 128*1048576, DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, sgi_ram_offset);
2849                          }                          }
2850                  } else {                  } else {
2851                          cpu->byte_order = EMUL_LITTLE_ENDIAN;                          cpu->byte_order = EMUL_LITTLE_ENDIAN;
2852                          sprintf(short_machine_name, "ARC");                          snprintf(machine->machine_name,
2853                          sprintf(machine->machine_name, "ARC");                              MACHINE_NAME_MAXBUF, "ARC");
2854                  }                  }
2855    
2856                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2857                          /*  TODO:  Other SGI machine types?  */                          /*  TODO:  Other SGI machine types?  */
2858                          switch (machine->machine_subtype) {                          switch (machine->machine_subtype) {
2859                            case 10:
2860                                    strlcat(machine->machine_name, " (4D/25)", MACHINE_NAME_MAXBUF);
2861                                    /*  TODO  */
2862                                    break;
2863                          case 12:                          case 12:
2864                                  strcat(machine->machine_name, " (Iris Indigo IP12)");                                  strlcat(machine->machine_name,
2865                                        " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);
2866    
2867                                  /*  TODO  */                                  /*  TODO  */
2868                                  /*  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 2870  void machine_setup(struct machine *machi
2870    
2871                                  break;                                  break;
2872                          case 19:                          case 19:
2873                                  strcat(machine->machine_name, " (Everest IP19)");                                  strlcat(machine->machine_name,
2874                                        " (Everest IP19)", MACHINE_NAME_MAXBUF);
2875                                  machine->main_console_handle =                                  machine->main_console_handle =
2876                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */
2877                                  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 2891  void machine_setup(struct machine *machi
2891    
2892                                  break;                                  break;
2893                          case 20:                          case 20:
2894                                  strcat(machine->machine_name, " (Indigo)");                                  strlcat(machine->machine_name,
2895                                        " (Indigo)", MACHINE_NAME_MAXBUF);
2896    
2897                                  /*                                  /*
2898                                   *  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 2912  void machine_setup(struct machine *machi
2912                                   */                                   */
2913    
2914                                  /*  int0 at mainbus0 addr 0x1fb801c0  */                                  /*  int0 at mainbus0 addr 0x1fb801c0  */
2915                                  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);
2916    
2917                                  /*  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?)  */
2918    
# Line 2627  void machine_setup(struct machine *machi Line 2937  void machine_setup(struct machine *machi
2937    
2938                                  break;                                  break;
2939                          case 21:                          case 21:
2940                                  strcat(machine->machine_name, " (uknown SGI-IP21 ?)");  /*  TODO  */                                  strlcat(machine->machine_name,  /*  TODO  */
2941                                        " (uknown SGI-IP21 ?)", MACHINE_NAME_MAXBUF);
2942                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2943                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2944    
# Line 2637  void machine_setup(struct machine *machi Line 2948  void machine_setup(struct machine *machi
2948                          case 22:                          case 22:
2949                          case 24:                          case 24:
2950                                  if (machine->machine_subtype == 22) {                                  if (machine->machine_subtype == 22) {
2951                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Full-house)");                                          strlcat(machine->machine_name,
2952                                          machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);                                              " (Indy, Indigo2, Challenge S; Full-house)",
2953                                                MACHINE_NAME_MAXBUF);
2954                                            machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);
2955                                  } else {                                  } else {
2956                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Guiness)");                                          strlcat(machine->machine_name,
2957                                          machine->sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);                                              " (Indy, Indigo2, Challenge S; Guiness)",
2958                                                MACHINE_NAME_MAXBUF);
2959                                            machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);
2960                                  }                                  }
2961    
2962  /*  /*
2963  Why is this here? TODO  Why is this here? TODO
2964                                  dev_ram_init(mem, 0x88000000ULL,                                  dev_ram_init(machine, 0x88000000ULL,
2965                                      128 * 1048576, DEV_RAM_MIRROR, 0x08000000);                                      128 * 1048576, DEV_RAM_MIRROR, 0x08000000);
2966  */  */
2967                                  machine->md_interrupt = sgi_ip22_interrupt;                                  machine->md_interrupt = sgi_ip22_interrupt;
# Line 2684  Why is this here? TODO Line 2999  Why is this here? TODO
2999    
3000                                  /*  Not supported by NetBSD 1.6.2, but by 2.0_BETA:  */                                  /*  Not supported by NetBSD 1.6.2, but by 2.0_BETA:  */
3001                                  j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,                                  j = dev_pckbc_init(machine, mem, 0x1fbd9840, PCKBC_8242,
3002                                      0, 0, machine->use_x11);  /*  TODO: irq numbers  */                                      0, 0, machine->use_x11, 0);  /*  TODO: irq numbers  */
3003    
3004                                  if (machine->use_x11)                                  if (machine->use_x11)
3005                                          machine->main_console_handle = j;                                          machine->main_console_handle = j;
# Line 2713  Why is this here? TODO Line 3028  Why is this here? TODO
3028                          case 25:                          case 25:
3029                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3030                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3031                                  strcat(machine->machine_name, " (Everest IP25)");                                  strlcat(machine->machine_name,
3032                                        " (Everest IP25)", MACHINE_NAME_MAXBUF);
3033    
3034                                   /*  serial? irix?  */                                   /*  serial? irix?  */
3035                                  dev_scc_init(machine, mem,                                  dev_scc_init(machine, mem,
# Line 2734  Why is this here? TODO Line 3050  Why is this here? TODO
3050                          case 26:                          case 26:
3051                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3052                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3053                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
3054                                      " (uknown SGI-IP26 ?)");    /*  TODO  */                                      " (uknown SGI-IP26 ?)",
3055                                        MACHINE_NAME_MAXBUF);       /*  TODO  */
3056                                  machine->main_console_handle =                                  machine->main_console_handle =
3057                                      dev_zs_init(machine, mem, 0x1fbd9830,                                      dev_zs_init(machine, mem, 0x1fbd9830,
3058                                      0, 1, "zs console");                                      0, 1, "zs console");
3059                                  break;                                  break;
3060                          case 27:                          case 27:
3061                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
3062                                      " (Origin 200/2000, Onyx2)");                                      " (Origin 200/2000, Onyx2)",
3063                                        MACHINE_NAME_MAXBUF);
3064                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3065                                  /*  2 cpus per node  */                                  /*  2 cpus per node  */
3066    
# Line 2753  Why is this here? TODO Line 3071  Why is this here? TODO
3071                          case 28:                          case 28:
3072                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3073                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3074                                  strcat(machine->machine_name, " (Impact Indigo2 ?)");                                  strlcat(machine->machine_name,
3075                                        " (Impact Indigo2 ?)", MACHINE_NAME_MAXBUF);
3076    
3077                                  device_add(machine, "random addr=0x1fbe0000, len=1");                                  device_add(machine, "random addr=0x1fbe0000, len=1");
3078    
# Line 2763  Why is this here? TODO Line 3082  Why is this here? TODO
3082                          case 30:                          case 30:
3083                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
3084                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
3085                                  strcat(machine->machine_name, " (Octane)");                                  strlcat(machine->machine_name,
3086                                        " (Octane)", MACHINE_NAME_MAXBUF);
3087    
3088                                  machine->sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);
3089                                  machine->md_interrupt = sgi_ip30_interrupt;                                  machine->md_interrupt = sgi_ip30_interrupt;
3090    
3091                                  dev_ram_init(mem,    0xa0000000ULL,                                  dev_ram_init(machine,    0xa0000000ULL,
3092                                      128 * 1048576, DEV_RAM_MIRROR, 0x00000000);                                      128 * 1048576, DEV_RAM_MIRROR
3093                                        | DEV_RAM_MIGHT_POINT_TO_DEVICES,
3094                                        0x00000000);
3095    
3096                                  dev_ram_init(mem,    0x80000000ULL,                                  dev_ram_init(machine,    0x80000000ULL,
3097                                      32 * 1048576, DEV_RAM_RAM, 0x00000000);                                      32 * 1048576, DEV_RAM_RAM, 0x00000000);
3098    
3099                                  /*                                  /*
# Line 2787  Why is this here? TODO Line 3109  Why is this here? TODO
3109                                   *  program dumps something there, but it doesn't look like                                   *  program dumps something there, but it doesn't look like
3110                                   *  readable text.  (TODO)                                   *  readable text.  (TODO)
3111                                   */                                   */
3112                                  machine->main_console_handle = dev_ns16550_init(machine, mem, 0x1f620170, 0, 1,  
3113                                      machine->use_x11? 0 : 1, "serial 0");  /*  TODO: irq?  */                                  /*  TODO: irq!  */
3114                                  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);
3115                                      0, "serial 1");  /*  TODO: irq?  */                                  machine->main_console_handle = (size_t)device_add(machine, tmpstr);
3116                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x1f620178 name2=tty1 in_use=0");
3117                                    device_add(machine, tmpstr);
3118    
3119                                  /*  MardiGras graphics:  */                                  /*  MardiGras graphics:  */
3120                                  device_add(machine, "sgi_mardigras addr=0x1c000000");                                  device_add(machine, "sgi_mardigras addr=0x1c000000");
3121    
3122                                  break;                                  break;
3123                          case 32:                          case 32:
3124                                  strcat(machine->machine_name, " (O2)");                                  strlcat(machine->machine_name,
3125                                        " (O2)", MACHINE_NAME_MAXBUF);
3126    
3127                                  /*  TODO:  Find out where the physical ram is actually located.  */                                  /*  TODO:  Find out where the physical ram is actually located.  */
3128                                  dev_ram_init(mem, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(machine, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
3129                                  dev_ram_init(mem, 0x10000000ULL,           256, DEV_RAM_MIRROR, 0x00000000);                                  dev_ram_init(machine, 0x10000000ULL,           256, DEV_RAM_MIRROR, 0x00000000);
3130                                  dev_ram_init(mem, 0x11ffff00ULL,           256, DEV_RAM_MIRROR, 0x01ffff00);                                  dev_ram_init(machine, 0x11ffff00ULL,           256, DEV_RAM_MIRROR, 0x01ffff00);
3131                                  dev_ram_init(mem, 0x12000000ULL,           256, DEV_RAM_MIRROR, 0x02000000);                                  dev_ram_init(machine, 0x12000000ULL,           256, DEV_RAM_MIRROR, 0x02000000);
3132                                  dev_ram_init(mem, 0x17ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(machine, 0x17ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
3133                                  dev_ram_init(mem, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);                                  dev_ram_init(machine, 0x20000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x00000000);
3134                                  dev_ram_init(mem, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);                                  dev_ram_init(machine, 0x40000000ULL, 128 * 1048576, DEV_RAM_MIRROR, 0x10000000);
3135    
3136                                  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  */
3137                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */                                  dev_sgi_mte_init(mem, 0x15000000);                      /*  mte ??? memory thing  */
3138                                  dev_sgi_gbe_init(machine, mem, 0x16000000);     /*  gbe?  framebuffer?  */                                  dev_sgi_gbe_init(machine, mem, 0x16000000);     /*  gbe?  framebuffer?  */
3139    
# Line 2835  Why is this here? TODO Line 3160  Why is this here? TODO
3160                                   *        1f3a0000        mcclock0                                   *        1f3a0000        mcclock0
3161                                   */                                   */
3162    
3163                                  machine->mace_data = dev_mace_init(mem, 0x1f310000, 2);                                  machine->md_int.ip32.mace_data = dev_mace_init(mem, 0x1f310000, 2);
3164                                  machine->md_interrupt = sgi_ip32_interrupt;                                  machine->md_interrupt = sgi_ip32_interrupt;
3165    
3166                                  /*                                  /*
# Line 2852  Why is this here? TODO Line 3177  Why is this here? TODO
3177                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
3178                                   */                                   */
3179    
                                 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)  */  
   
3180                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
3181                                  eaddr_string = malloc(30);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
3182                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
3183                                          fprintf(stderr, "out of memory\n");                                          fprintf(stderr, "out of memory\n");
3184                                          exit(1);                                          exit(1);
3185                                  }                                  }
3186                                  sprintf(eaddr_string, "eaddr=%02x:%02x:"                                  snprintf(eaddr_string, ETHERNET_STRING_MAXLEN,
3187                                      "%02x:%02x:%02x:%02x",                                      "eaddr=%02x:%02x:%02x:%02x:%02x:%02x",
3188                                      macaddr[0], macaddr[1], macaddr[2],                                      macaddr[0], macaddr[1], macaddr[2],
3189                                      macaddr[3], macaddr[4], macaddr[5]);                                      macaddr[3], macaddr[4], macaddr[5]);
3190                                  dev_sgi_mec_init(machine, mem, 0x1f280000, MACE_ETHERNET, macaddr);                                  dev_sgi_mec_init(machine, mem, 0x1f280000,
3191                                        MACE_ETHERNET, macaddr);
3192    
3193                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */
3194    
3195                                  j = dev_ns16550_init(machine, mem, 0x1f390000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f390000 addr_mult=0x100 in_use=%i name2=tty0",
3196                                      (1<<20) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<20) + MACE_PERIPH_SERIAL, machine->use_x11? 0 : 1);
3197                                      machine->use_x11? 0 : 1, "serial 0");       /*  com0  */                                  j = (size_t)device_add(machine, tmpstr);
3198                                  dev_ns16550_init(machine, mem, 0x1f398000,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%i addr=0x1f398000 addr_mult=0x100 in_use=%i name2=tty1",
3199                                      (1<<26) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<26) + MACE_PERIPH_SERIAL, 0);
3200                                      0, "serial 1");                             /*  com1  */                                  device_add(machine, tmpstr);
3201    
3202                                  if (machine->use_x11)                                  machine->main_console_handle = j;
3203    
3204                                    /*  TODO: Once this works, it should be enabled
3205                                        always, not just when using X!  */
3206                                    if (machine->use_x11) {
3207                                            i = dev_pckbc_init(machine, mem, 0x1f320000,
3208                                                PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
3209                                                0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
3210                                                    /*  keyb+mouse (mace irq numbers)  */
3211                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3212                                  else                                  }
                                         machine->main_console_handle = j;  
3213    
3214                                  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  */
3215                                  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 3224  Why is this here? TODO
3224    
3225                                  pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE);  /*  macepci0  */                                  pci_data = dev_macepci_init(mem, 0x1f080000, MACE_PCI_BRIDGE);  /*  macepci0  */
3226                                  /*  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  */
3227  #if 1  
3228                                  bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr);                                  /*  TODO: make this nicer  */
3229  #endif                                  if (diskimage_exist(machine, 0, DISKIMAGE_SCSI) ||
3230                                        diskimage_exist(machine, 1, DISKIMAGE_SCSI) ||
3231                                        diskimage_exist(machine, 2, DISKIMAGE_SCSI) ||
3232                                        diskimage_exist(machine, 3, DISKIMAGE_SCSI) ||
3233                                        diskimage_exist(machine, 4, DISKIMAGE_SCSI) ||
3234                                        diskimage_exist(machine, 5, DISKIMAGE_SCSI) ||
3235                                        diskimage_exist(machine, 6, DISKIMAGE_SCSI) ||
3236                                        diskimage_exist(machine, 7, DISKIMAGE_SCSI))
3237                                            bus_pci_add(machine, pci_data, mem, 0, 1, 0, pci_ahc_init, pci_ahc_rr);
3238    
3239                                    /*  TODO: second ahc  */
3240                                  /*  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);  */
3241    
3242                                  break;                                  break;
3243                          case 35:                          case 35:
3244                                  strcat(machine->machine_name, " (Origin 3000)");                                  strlcat(machine->machine_name,
3245                                        " (Origin 3000)", MACHINE_NAME_MAXBUF);
3246                                  /*  4 cpus per node  */                                  /*  4 cpus per node  */
3247    
3248                                  machine->main_console_handle =                                  machine->main_console_handle =
# Line 2911  Why is this here? TODO Line 3250  Why is this here? TODO
3250                                      0, 1, "zs console");                                      0, 1, "zs console");
3251                                  break;                                  break;
3252                          case 53:                          case 53:
3253                                  strcat(machine->machine_name, " (Origin 350)");                                  strlcat(machine->machine_name,
3254                                        " (Origin 350)", MACHINE_NAME_MAXBUF);
3255                                  /*                                  /*
3256                                   *  According to http://kumba.drachentekh.net/xml/myguide.html                                   *  According to http://kumba.drachentekh.net/xml/myguide.html
3257                                   *  Origin 350, Tezro IP53 R16000                                   *  Origin 350, Tezro IP53 R16000
# Line 2938  Why is this here? TODO Line 3278  Why is this here? TODO
3278    
3279                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3280                                  case MACHINE_ARC_NEC_RD94:                                  case MACHINE_ARC_NEC_RD94:
3281                                          strcat(machine->machine_name, " (NEC-RD94, NEC RISCstation 2250)");                                          strlcat(machine->machine_name,
3282                                                " (NEC-RD94, NEC RISCstation 2250)",
3283                                                MACHINE_NAME_MAXBUF);
3284                                          break;                                          break;
3285                                  case MACHINE_ARC_NEC_R94:                                  case MACHINE_ARC_NEC_R94:
3286                                          strcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)");                                          strlcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)",
3287                                                MACHINE_NAME_MAXBUF);
3288                                          break;                                          break;
3289                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3290                                          strcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)");                                          strlcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)",
3291                                                MACHINE_NAME_MAXBUF);
3292                                          break;                                          break;
3293                                  }                                  }
3294    
# Line 2955  Why is this here? TODO Line 3299  Why is this here? TODO
3299    
3300                                  device_add(machine, "sn addr=0x80001000 irq=0");                                  device_add(machine, "sn addr=0x80001000 irq=0");
3301                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);                                  dev_mc146818_init(machine, mem, 0x80004000ULL, 0, MC146818_ARC_NEC, 1);
3302                                  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);
3303                                  j = dev_ns16550_init(machine, mem, 0x80006000ULL,  
3304                                      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);
3305                                  dev_ns16550_init(machine, mem, 0x80007000ULL,                                  j = (size_t)device_add(machine, tmpstr);
3306                                      0, 1, 0, "serial 1"); /*  com1  */                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x80007000 in_use=%i name2=tty1", 0);
3307                                    device_add(machine, tmpstr);
3308    
3309                                  if (machine->use_x11)                                  if (machine->use_x11)
3310                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 2979  Why is this here? TODO Line 3324  Why is this here? TODO
3324                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3325                                          dev_fb_init(machine, mem, 0x100e00000ULL,                                          dev_fb_init(machine, mem, 0x100e00000ULL,
3326                                              VFB_GENERIC, 640,480, 1024,480,                                              VFB_GENERIC, 640,480, 1024,480,
3327                                              8, "necvdfrb", 1);                                              8, "necvdfrb");
3328                                          break;                                          break;
3329                                  }                                  }
3330                                  break;                                  break;
# Line 2998  Why is this here? TODO Line 3343  Why is this here? TODO
3343                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"
3344                                   */                                   */
3345    
3346                                  strcat(machine->machine_name, " (NEC-R98; NEC RISCserver 4200)");                                  strlcat(machine->machine_name,
3347                                        " (NEC-R98; NEC RISCserver 4200)",
3348                                        MACHINE_NAME_MAXBUF);
3349    
3350                                  /*                                  /*
3351                                   *  Windows NT access stuff at these addresses:                                   *  Windows NT access stuff at these addresses:
# Line 3054  Why is this here? TODO Line 3401  Why is this here? TODO
3401    
3402                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3403                                  case MACHINE_ARC_JAZZ_PICA:                                  case MACHINE_ARC_JAZZ_PICA:
3404                                          strcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)",
3405                                                MACHINE_NAME_MAXBUF);
3406                                          break;                                          break;
3407                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3408                                          strcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)",
3409                                                MACHINE_NAME_MAXBUF);
3410                                          break;                                          break;
3411                                  default:                                  default:
3412                                          fatal("error in machine.c. jazz\n");                                          fatal("error in machine.c. jazz\n");
3413                                          exit(1);                                          exit(1);
3414                                  }                                  }
3415    
3416                                  machine->jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3417                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
3418                                  machine->md_interrupt = jazz_interrupt;                                  machine->md_interrupt = jazz_interrupt;
3419    
3420                                    i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3421                                        PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3422    
3423                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3424                                    j = (size_t)device_add(machine, tmpstr);
3425                                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3426                                    device_add(machine, tmpstr);
3427    
3428                                    if (machine->use_x11)
3429                                            machine->main_console_handle = i;
3430                                    else
3431                                            machine->main_console_handle = j;
3432    
3433                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3434                                  case MACHINE_ARC_JAZZ_PICA:                                  case MACHINE_ARC_JAZZ_PICA:
3435                                          dev_vga_init(machine, mem,                                          if (machine->use_x11) {
3436                                              0x400b8000ULL, 0x600003c0ULL,                                                  dev_vga_init(machine, mem,
3437                                              ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);                                                      0x400a0000ULL, 0x600003c0ULL,
3438                                          arcbios_console_init(cpu, 0x400b8000ULL,                                                      machine->machine_name);
3439                                              0x600003c0ULL, ARC_CONSOLE_MAX_X,                                                  arcbios_console_init(machine,
3440                                              ARC_CONSOLE_MAX_Y);                                                      0x400b8000ULL, 0x600003c0ULL);
3441                                            }
3442                                          break;                                          break;
3443                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3444                                          /*  PROM mirror?  */                                          /*  PROM mirror?  */
3445                                          dev_ram_init(mem, 0xfff00000, 0x100000,                                          dev_ram_init(machine, 0xfff00000, 0x100000,
3446                                              DEV_RAM_MIRROR, 0x1fc00000);                                              DEV_RAM_MIRROR | DEV_RAM_MIGHT_POINT_TO_DEVICES, 0x1fc00000);
3447    
3448                                          /*  VXL. TODO  */                                          /*  VXL. TODO  */
3449                                          /*  control at 0x60100000?  */                                          /*  control at 0x60100000?  */
3450                                          dev_fb_init(machine, mem, 0x60200000ULL,                                          dev_fb_init(machine, mem, 0x60200000ULL,
3451                                              VFB_GENERIC, 1024,768, 1024,768,                                              VFB_GENERIC, 1024,768, 1024,768,
3452                                              8, "VXL", 1);                                              8, "VXL");
3453                                          break;                                          break;
3454                                  }                                  }
3455    
# Line 3095  Why is this here? TODO Line 3458  Why is this here? TODO
3458    
3459                                  dev_asc_init(machine, mem,                                  dev_asc_init(machine, mem,
3460                                      0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA,                                      0x80002000ULL, 8 + 5, NULL, DEV_ASC_PICA,
3461                                      dev_jazz_dma_controller, machine->jazz_data);                                      dev_jazz_dma_controller,
3462                                        machine->md_int.jazz_data);
3463    
3464                                  device_add(machine, "fdc addr=0x80003000, irq=0");                                  device_add(machine, "fdc addr=0x80003000, irq=0");
3465    
3466                                  dev_mc146818_init(machine, mem,                                  dev_mc146818_init(machine, mem,
3467                                      0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);                                      0x80004000ULL, 2, MC146818_ARC_JAZZ, 1);
3468    
                                 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;  
   
3469  #if 0  #if 0
3470  Not yet.  Not yet.
3471                                  dev_wdc_init(machine, mem, 0x900001f0ULL, 8+16 + 14, 0);                                  /*  irq = 8+16 + 14  */
3472                                    device_add(machine, "wdc addr=0x900001f0, irq=38");
3473  #endif  #endif
3474    
3475                                  break;                                  break;
# Line 3133  Not yet. Line 3484  Not yet.
3484                                   *  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.
3485                                   */                                   */
3486    
3487                                  strcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)");                                  strlcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)",
3488                                        MACHINE_NAME_MAXBUF);
3489    
3490                                  machine->jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3491                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
3492                                  machine->md_interrupt = jazz_interrupt;                                  machine->md_interrupt = jazz_interrupt;
3493    
# Line 3145  Not yet. Line 3497  Not yet.
3497                                  i = 0;          /*  TODO: Yuck!  */                                  i = 0;          /*  TODO: Yuck!  */
3498  #if 0  #if 0
3499                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,                                  i = dev_pckbc_init(machine, mem, 0x80005000ULL,
3500                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11);                                      PCKBC_JAZZ, 8 + 6, 8 + 7, machine->use_x11, 0);
3501  #endif  #endif
3502                                  j = dev_ns16550_init(machine, mem,  
3503                                      0x80006000ULL, 8 + 8, 1,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=16 addr=0x80006000 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3504                                      machine->use_x11? 0 : 1, "serial 0");                                  j = (size_t)device_add(machine, tmpstr);
3505                                  dev_ns16550_init(machine, mem,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=17 addr=0x80007000 in_use=%i name2=tty1", 0);
3506                                      0x80007000ULL, 8 + 9, 1, 0, "serial 1");                                  device_add(machine, tmpstr);
3507    
3508                                  if (machine->use_x11)                                  if (machine->use_x11)
3509                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
# Line 3171  Not yet. Line 3523  Not yet.
3523                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html
3524                                   */                                   */
3525    
3526                                  strcat(machine->machine_name, " (Deskstation Tyne)");                                  strlcat(machine->machine_name, " (Deskstation Tyne)",
3527                                        MACHINE_NAME_MAXBUF);
3528    
3529                                  dev_vga_init(machine, mem, 0x1000b8000ULL, 0x9000003c0ULL,                                  snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=0 addr=0x9000003f8 in_use=%i name2=tty0", machine->use_x11? 0 : 1);
3530                                      ARC_CONSOLE_MAX_X, ARC_CONSOLE_MAX_Y, machine->machine_name);                                  i = (size_t)device_add(machine, tmpstr);
3531                                    device_add(machine, "ns16550 irq=0 addr=0x9000002f8 in_use=0 name2=tty1");
3532                                  arcbios_console_init(cpu, 0x1000b8000ULL,                                  device_add(machine, "ns16550 irq=0 addr=0x9000003e8 in_use=0 name2=tty2");
3533                                      0x9000003c0ULL, ARC_CONSOLE_MAX_X,                                  device_add(machine, "ns16550 irq=0 addr=0x9000002e8 in_use=0 name2=tty3");
                                     ARC_CONSOLE_MAX_Y);  
   
                                 i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");  
                                 dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1");  
                                 dev_ns16550_init(machine, mem, 0x9000003e8ULL, 0, 1, 0, "serial 2");  
                                 dev_ns16550_init(machine, mem, 0x9000002e8ULL, 0, 1, 0, "serial 3");  
3534    
3535                                  dev_mc146818_init(machine, mem,                                  dev_mc146818_init(machine, mem,
3536                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);                                      0x900000070ULL, 2, MC146818_PC_CMOS, 1);
3537    
3538  #if 0  #if 0
3539                                  dev_wdc_init(machine, mem, 0x9000001f0ULL, 0, 0);                                  /*  TODO: irq, etc  */
3540                                  dev_wdc_init(machine, mem, 0x900000170ULL, 0, 2);                                  device_add(machine, "wdc addr=0x9000001f0, irq=0");
3541                                    device_add(machine, "wdc addr=0x900000170, irq=0");
3542  #endif  #endif
3543                                  /*  PC kbd  */                                  /*  PC kbd  */
3544                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,                                  j = dev_pckbc_init(machine, mem, 0x900000060ULL,
3545                                      PCKBC_8042, 0, 0, machine->use_x11);                                      PCKBC_8042, 0, 0, machine->use_x11, 0);
3546    
3547                                  if (machine->use_x11)                                  if (machine->use_x11)
3548                                          machine->main_console_handle = j;                                          machine->main_console_handle = j;
3549                                  else                                  else
3550                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3551    
3552                                    if (machine->use_x11) {
3553                                            dev_vga_init(machine, mem, 0x1000a0000ULL,
3554                                                0x9000003c0ULL, machine->machine_name);
3555    
3556                                            arcbios_console_init(machine,
3557                                                0x1000b8000ULL, 0x9000003c0ULL);
3558                                    }
3559                                  break;                                  break;
3560    
3561                          default:                          default:
# Line 3210  Not yet. Line 3565  Not yet.
3565                          }                          }
3566                  }                  }
3567    
   
                 if (!machine->prom_emulation)  
                         goto no_arc_prom_emulation;     /*  TODO: ugly  */  
   
   
3568                  /*                  /*
3569                   *  This is important:  :-)                   *  This is important:  :-)
3570                   *                   *
3571                   *  TODO:  There should not be any use of                   *  TODO:  There should not be any use of ARCBIOS before this
3572                   *  ARCBIOS before this statement.                   *  point.
3573                   */                   */
                 if (arc_wordlen == sizeof(uint64_t))  
                         arcbios_set_64bit_mode(1);  
3574    
3575                  if (machine->physical_ram_in_mb < 16)                  if (machine->prom_emulation) {
3576                          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),
3577                                sgi_ram_offset);
3578    
3579                  arcbios_set_default_exception_handler(cpu);                          /*
3580                             *  TODO: How to build the component tree intermixed with
3581                             *  the rest of device initialization?
3582                             */
3583    
3584                  memset(&arcbios_sysid, 0, sizeof(arcbios_sysid));                          /*
3585                  if (machine->machine_type == MACHINE_SGI) {                           *  Boot string in ARC format:
3586                          /*  Vendor ID, max 8 chars:  */                           *
3587                          strncpy(arcbios_sysid.VendorId,  "SGI", 3);                           *  TODO: How about floppies? multi()disk()fdisk()
3588                          switch (machine->machine_subtype) {                           *        Is tftp() good for netbooting?
3589                          case 22:                           */
3590                                  strncpy(arcbios_sysid.ProductId,                          init_bootpath = malloc(500);
3591                                      "87654321", 8);     /*  some kind of ID?  */                          if (init_bootpath == NULL) {
3592                                  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");  
3593                                  exit(1);                                  exit(1);
3594                          }                          }
3595                  }                          init_bootpath[0] = '\0';
                 store_buf(cpu, SGI_SYSID_ADDR, (char *)&arcbios_sysid, sizeof(arcbios_sysid));  
3596    
3597                  arcbios_get_dsp_stat(cpu, &arcbios_dsp_stat);                          if (bootdev_id < 0 || machine->force_netboot) {
3598                  store_buf(cpu, ARC_DSPSTAT_ADDR, (char *)&arcbios_dsp_stat, sizeof(arcbios_dsp_stat));                                  snprintf(init_bootpath, 400, "tftp()");
3599                            } else {
3600                  /*                                  /*  TODO: Make this nicer.  */
3601                   *  The first 12 MBs of RAM are simply reserved... this simplifies things a lot.                                  if (machine->machine_type == MACHINE_SGI) {
3602                   *  If there's more than 512MB of RAM, it has to be split in two, according to                                          if (machine->machine_subtype == 30)
3603                   *  the ARC spec.  This code creates a number of chunks of at most 512MB each.                                                  strlcat(init_bootpath, "xio(0)pci(15)",
3604                   *                                                      MACHINE_NAME_MAXBUF);
3605                   *  NOTE:  The region of physical address space between 0x10000000 and 0x1fffffff                                          if (machine->machine_subtype == 32)
3606                   *  (256 - 512 MB) is usually occupied by memory mapped devices, so that portion is "lost".                                                  strlcat(init_bootpath, "pci(0)",
3607                   */                                                      MACHINE_NAME_MAXBUF);
3608                                    }
3609    
3610                  arc_reserved = 0x2000;                                  if (diskimage_is_a_cdrom(machine, bootdev_id,
3611                  if (machine->machine_type == MACHINE_SGI)                                      bootdev_type))
3612                          arc_reserved = 0x4000;                                          snprintf(init_bootpath + strlen(init_bootpath),
3613                                                400,"scsi(0)cdrom(%i)fdisk(0)", bootdev_id);
3614                  arcbios_add_memory_descriptor(cpu, 0, arc_reserved, ARCBIOS_MEM_FirmwarePermanent);                                  else
3615                  arcbios_add_memory_descriptor(cpu, sgi_ram_offset + arc_reserved, 0x60000-arc_reserved, ARCBIOS_MEM_FirmwareTemporary);                                          snprintf(init_bootpath + strlen(init_bootpath),
3616                                                400,"scsi(0)disk(%i)rdisk(0)partition(1)",
3617                  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;  
3618                          }                          }
3619    
3620                          /*  At most 512MB per descriptor (at least the first 512MB                          if (machine->machine_type == MACHINE_ARC)
3621                              must be separated this way, according to the ARC spec)  */                                  strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
                         if (mem_count > 512)  
                                 mem_count = 512;  
   
                         arcbios_add_memory_descriptor(cpu, mem_base * 1048576,  
                             mem_count * 1048576, ARCBIOS_MEM_FreeMemory);  
   
                         mem_base += mem_count;  
   
                         /*  Skip the devices:  */  
                         if (mem_base == 256)  
                                 mem_base = 512;  
                 }  
   
   
                 /*  
                  *  Components:   (this is an example of what a system could look like)  
                  *  
                  *  [System]  
                  *      [CPU]  (one for each cpu)  
                  *          [FPU]  (one for each cpu)  
                  *          [CPU Caches]  
                  *      [Memory]  
                  *      [Ethernet]  
                  *      [Serial]  
                  *      [SCSI]  
                  *          [Disk]  
                  *  
                  *  Here's a good list of what hardware is in different IP-models:  
                  *  http://www.linux-mips.org/archives/linux-mips/2001-03/msg00101.html  
                  */  
3622    
3623                  if (machine->machine_name == NULL)                          bootstr = malloc(BOOTSTR_BUFLEN);
3624                          fatal("ERROR: machine_name == NULL\n");                          if (bootstr == NULL) {
3625                  if (short_machine_name == NULL)                                  fprintf(stderr, "out of memory\n");
                         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);  
3626                                  exit(1);                                  exit(1);
3627                          }                          }
3628                  }                          strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3629                            if (strlcat(bootstr, machine->boot_kernel_filename,
3630                                BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3631                  /*                                  fprintf(stderr, "boot string too long?\n");
3632                   *  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);  
3633                          }                          }
                 }  
3634    
3635                            /*  Boot args., eg "-a"  */
3636                            bootarg = machine->boot_string_argument;
3637    
3638                  /*                          /*  argc, argv, envp in a0, a1, a2:  */
3639                   *  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?  
                  */  
   
                 if (machine->machine_type == MACHINE_SGI) {  
                         /*  TODO: On which models is this required?  */  
                         mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,  
                             0xc000000000000000ULL,  
                             0x0, 1048576*16,  
                             1, 1, 1, 1, 1, 0, 2, 2);  
                 }  
   
                 if (machine->machine_type == MACHINE_ARC &&  
                     ( machine->machine_subtype == MACHINE_ARC_NEC_RD94 ||  
                     machine->machine_subtype == MACHINE_ARC_NEC_R94 ||  
                     machine->machine_subtype == MACHINE_ARC_NEC_R96 )) {  
                         uint64_t jazzbus, eisa, other;  
   
                         jazzbus = arcbios_addchild_manual(cpu,  
                             COMPONENT_CLASS_AdapterClass,  
                             COMPONENT_TYPE_MultiFunctionAdapter,  
                             0, 1, 2, 0, 0xffffffff, "Jazz-Internal Bus",  
                             system, NULL, 0);  
3640    
3641                          switch (machine->machine_subtype) {                          /*  TODO:  not needed?  */
3642                          case MACHINE_ARC_NEC_RD94:                          cpu->cd.mips.gpr[MIPS_GPR_SP] = (int64_t)(int32_t)
3643                          case MACHINE_ARC_NEC_R94:                              (machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080);
3644                                  if (machine->use_x11)  
3645                                          arcbios_addchild_manual(cpu,                          /*  Set up argc/argv:  */
3646                                              COMPONENT_CLASS_ControllerClass,                          addr = ARC_ENV_STRINGS;
3647                                              COMPONENT_TYPE_DisplayController,                          addr2 = ARC_ARGV_START;
3648                                              0, 1, 2, 0, 0x0, "10110004",                          cpu->cd.mips.gpr[MIPS_GPR_A1] = addr2;
                                             system, NULL, 0);  
                                 break;  
                         case MACHINE_ARC_NEC_R96:  
                                 if (machine->use_x11) {  
                                         uint64_t x;  
                                         x = arcbios_addchild_manual(cpu,  
                                             COMPONENT_CLASS_ControllerClass,  
                                             COMPONENT_TYPE_DisplayController,  
                                             COMPONENT_FLAG_ConsoleOut |  
                                               COMPONENT_FLAG_Output,  
                                             1, 2, 0, 0x0, "necvdfrb",  
                                             jazzbus, NULL, 0);  
                                         arcbios_addchild_manual(cpu,  
                                             COMPONENT_CLASS_PeripheralClass,  
                                             COMPONENT_TYPE_MonitorPeripheral,  
                                             COMPONENT_FLAG_ConsoleOut |  
                                                 COMPONENT_FLAG_Output,  
                                             1, 2, 0, 0xffffffff, "640x480",  
                                             x, NULL, 0);  
                                 }  
3649    
3650                                  /*  TODO: R[D]94 too?  */                          /*  bootstr:  */
3651                                  eisa = arcbios_addchild_manual(cpu,                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3652                                      COMPONENT_CLASS_AdapterClass,                          add_environment_string(cpu, bootstr, &addr);
3653                                      COMPONENT_TYPE_EISAAdapter,                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
                                     0, 1, 2, 0, 0xffffffff, "EISA",  
                                     system, NULL, 0);  
   
                                 other = arcbios_addchild_manual(cpu,  
                                     COMPONENT_CLASS_ControllerClass,  
                                     COMPONENT_TYPE_OtherController,  
                                     0, 1, 2, 0, 0xffffffff, "NEC1C01",  
                                     eisa, NULL, 0);  
3654    
3655                                  break;                          /*  bootarg:  */
3656                            if (bootarg[0] != '\0') {
3657                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3658                                    add_environment_string(cpu, bootarg, &addr);
3659                                    cpu->cd.mips.gpr[MIPS_GPR_A0] ++;
3660                          }                          }
                 }  
3661    
3662                  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);  
3663    
3664                          /*                          /*
3665                           *  DisplayController, needed by NetBSD:                           *  Add environment variables.  For each variable, add it
3666                           *  TODO: NetBSD still doesn't use it :(                           *  as a string using add_environment_string(), and add a
3667                             *  pointer to it to the ARC_ENV_POINTERS array.
3668                           */                           */
3669                          switch (machine->machine_subtype) {                          if (machine->use_x11) {
3670                          case MACHINE_ARC_JAZZ_PICA:                                  if (machine->machine_type == MACHINE_ARC) {
3671                                  /*  Default TLB entries on PICA-61:  */                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3672                                            add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);
3673                                  /* 7: 256K, asid: 0x0, v: 0xe1000000,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3674                                     p0: 0xfff00000(2.VG), p1: 0x0(0..G)  */                                          add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);
3675                                  mips_coproc_tlb_set_entry(cpu, 7, 262144,                                  } else {
3676                                      0xffffffffe1000000ULL,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3677                                      0x0fff00000ULL, 0,                                          add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);
3678                                      1, 0, 0, 0, 1, 0, 2, 0);                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3679                                            add_environment_string(cpu, "ConsoleOut=video()", &addr);
3680                                  /* 8: 64K, asid: 0x0, v: 0xe0000000,  
3681                                     p0: 0x80000000(2DVG), p1: 0x0(0..G) */                                          /*  g for graphical mode. G for graphical mode
3682                                  mips_coproc_tlb_set_entry(cpu, 8, 65536,                                              with SGI logo visible on Irix?  */
3683                                      0xffffffffe0000000ULL,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3684                                      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);  
3685                                  }                                  }
3686                                  break;                          } else {
3687                          case MACHINE_ARC_JAZZ_MAGNUM:                                  if (machine->machine_type == MACHINE_ARC) {
3688                                  if (machine->use_x11) {                                          /*  TODO: serial console for ARC?  */
3689                                          vxl = arcbios_addchild_manual(cpu,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3690                                              COMPONENT_CLASS_ControllerClass,                                          add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);
3691                                              COMPONENT_TYPE_DisplayController,                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3692                                              COMPONENT_FLAG_ConsoleOut |                                          add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);
3693                                                  COMPONENT_FLAG_Output,                                  } else {
3694                                              1, 2, 0, 0xffffffff, "VXL",                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3695                                              jazzbus, NULL, 0);                                          add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);
3696                                            store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3697                                          arcbios_addchild_manual(cpu,                                          add_environment_string(cpu, "ConsoleOut=serial(0)", &addr);
3698                                              COMPONENT_CLASS_PeripheralClass,  
3699                                              COMPONENT_TYPE_MonitorPeripheral,                                          /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */
3700                                              COMPONENT_FLAG_ConsoleOut |                                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3701                                                  COMPONENT_FLAG_Output,                                          add_environment_string(cpu, "console=d", &addr);                /*  d2 = serial?  */
                                             1, 2, 0, 0xffffffff, "1024x768",  
                                             vxl, NULL, 0);  
3702                                  }                                  }
                                 break;  
3703                          }                          }
3704    
                         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.  */  
3705                          if (machine->machine_type == MACHINE_SGI) {                          if (machine->machine_type == MACHINE_SGI) {
3706                                  if (machine->machine_subtype == 30)                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3707                                          strcat(init_bootpath, "xio(0)pci(15)");                                  add_environment_string(cpu, "AutoLoad=No", &addr);
3708                                  if (machine->machine_subtype == 32)                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3709                                          strcat(init_bootpath, "pci(0)");                                  add_environment_string(cpu, "diskless=0", &addr);
3710                          }                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3711                                    add_environment_string(cpu, "volume=80", &addr);
3712                          if (diskimage_is_a_cdrom(machine, bootdev_id))                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3713                                  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  */  
3714    
3715                  /*  TODO:  not needed?  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3716                  cpu->cd.mips.gpr[MIPS_GPR_SP] = machine->physical_ram_in_mb * 1048576 + 0x80000000 - 0x2080;                                  add_environment_string(cpu, "monitor=h", &addr);
3717                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3718                                    add_environment_string(cpu, "TimeZone=GMT", &addr);
3719                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3720                                    add_environment_string(cpu, "nogfxkbd=1", &addr);
3721    
3722                  /*  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;  
3723    
3724                  /*  bootstr:  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3725                  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);
3726                  add_environment_string(cpu, bootstr, &addr);                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3727                  cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                                  add_environment_string(cpu, "OSLoadPartition=pci(0)scsi(0)disk(2)rdisk(0)partition(0)", &addr);
3728                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3729                                    add_environment_string(cpu, "OSLoadFilename=/unix", &addr);
3730                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3731                                    add_environment_string(cpu, "OSLoader=sash", &addr);
3732    
3733                  /*  bootarg:  */                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3734                  if (bootarg[0] != '\0') {                                  add_environment_string(cpu, "rbaud=9600", &addr);
3735                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3736                          add_environment_string(cpu, bootarg, &addr);                                  add_environment_string(cpu, "rebound=y", &addr);
3737                          cpu->cd.mips.gpr[MIPS_GPR_A0] ++;                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3738                  }                                  add_environment_string(cpu, "crt_option=1", &addr);
3739                                    store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3740                                    add_environment_string(cpu, "netaddr=10.0.0.1", &addr);
3741    
3742                  cpu->cd.mips.gpr[MIPS_GPR_A2] = addr2;                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3743                                    add_environment_string(cpu, "keybd=US", &addr);
3744    
                 /*  
                  *  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) {  
3745                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3746                                  add_environment_string(cpu, "CONSOLEIN=multi()key()keyboard()console()", &addr);                                  add_environment_string(cpu, "cpufreq=3", &addr);
3747                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3748                                  add_environment_string(cpu, "CONSOLEOUT=multi()video()monitor()console()", &addr);                                  add_environment_string(cpu, "dbaud=9600", &addr);
                         } else {  
3749                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3750                                  add_environment_string(cpu, "ConsoleIn=keyboard()", &addr);                                  add_environment_string(cpu, eaddr_string, &addr);
3751                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3752                                  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?  */  
3753                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3754                                  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?  */  
3755                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3756                                  add_environment_string(cpu, "CONSOLEIN=multi()serial(0)", &addr);                                  add_environment_string(cpu, "diagmode=v", &addr);
3757                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3758                                  add_environment_string(cpu, "CONSOLEOUT=multi()serial(0)", &addr);                                  add_environment_string(cpu, "kernname=unix", &addr);
3759                          } else {                          } else {
3760                                    char *tmp;
3761                                    size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3762                                    tmp = malloc(mlen);
3763                                    snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3764                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3765                                  add_environment_string(cpu, "ConsoleIn=serial(0)", &addr);                                  add_environment_string(cpu, tmp, &addr);
3766    
3767                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3768                                  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);
3769    
                                 /*  'd' or 'd2' in Irix, 'ttyS0' in Linux?  */  
3770                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                                  store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3771                                  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);
3772                          }                          }
                 }  
   
                 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);  
3773    
3774                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  End the environment strings with an empty zero-terminated
3775                          add_environment_string(cpu, "rbaud=9600", &addr);                              string, and the envp array with a NULL pointer.  */
3776                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          add_environment_string(cpu, "", &addr); /*  the end  */
3777                          add_environment_string(cpu, "rebound=y", &addr);                          store_pointer_and_advance(cpu, &addr2,
3778                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                              0, 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);  
3779    
3780                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          /*  Return address:  (0x20 = ReturnFromMain())  */
3781                          add_environment_string(cpu, "keybd=US", &addr);                          cpu->cd.mips.gpr[MIPS_GPR_RA] = ARC_FIRMWARE_ENTRIES + 0x20;
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "cpufreq=3", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "dbaud=9600", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, eaddr_string, &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "verbose=istrue", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "showconfig=istrue", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "diagmode=v", &addr);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "kernname=unix", &addr);  
                 } else {  
                         char *tmp;  
                         tmp = malloc(strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2);  
                         sprintf(tmp, "OSLOADOPTIONS=%s", bootarg);  
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, tmp, &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "OSLOADPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);  
   
                         store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));  
                         add_environment_string(cpu, "SYSTEMPARTITION=scsi(0)cdrom(6)fdisk(0);scsi(0)disk(0)rdisk(0)partition(1)", &addr);  
3782                  }                  }
3783    
                 /*  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;  
   
3784                  break;                  break;
3785    
3786          case MACHINE_MESHCUBE:          case MACHINE_MESHCUBE:
# Line 4136  no_arc_prom_emulation:         /*  TODO: ugly, Line 3793  no_arc_prom_emulation:         /*  TODO: ugly,
3793    
3794                  /*  First of all, the MeshCube has an Au1500 in it:  */                  /*  First of all, the MeshCube has an Au1500 in it:  */
3795                  machine->md_interrupt = au1x00_interrupt;                  machine->md_interrupt = au1x00_interrupt;
3796                  machine->au1x00_ic_data = dev_au1x00_init(machine, mem);                  machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem);
3797    
3798                  /*                  /*
3799                   *  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 3810  no_arc_prom_emulation:         /*  TODO: ugly,
3810    
3811                  device_add(machine, "random addr=0x1017fffc len=4");                  device_add(machine, "random addr=0x1017fffc len=4");
3812    
3813                  /*                  if (machine->prom_emulation) {
3814                   *  TODO:  A Linux kernel wants "memsize" from somewhere... I                          /*
3815                   *  haven't found any docs on how it is used though.                           *  TODO:  A Linux kernel wants "memsize" from somewhere... I
3816                   */                           *  haven't found any docs on how it is used though.
3817                             */
3818                  cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;                          cpu->cd.mips.gpr[MIPS_GPR_A0] = 1;
3819                  cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;                          cpu->cd.mips.gpr[MIPS_GPR_A1] = 0xa0001000ULL;
3820                  store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],                          store_32bit_word(cpu, cpu->cd.mips.gpr[MIPS_GPR_A1],
3821                      0xa0002000ULL);                              0xa0002000ULL);
3822                  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");  
3823    
3824                            cpu->cd.mips.gpr[MIPS_GPR_A2] = 0xa0003000ULL;
3825                            store_string(cpu, 0xa0002000ULL, "hello=world\n");
3826                    }
3827                  break;                  break;
3828    
3829          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
3830                  machine->machine_name = "NetGear WG602";                  machine->machine_name = "NetGear WG602v1";
3831    
3832                  if (machine->use_x11)                  if (machine->use_x11)
3833                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");                          fprintf(stderr, "WARNING! NetGear with -X is meaningless. Continuing anyway.\n");
3834                  if (machine->physical_ram_in_mb != 16)                  if (machine->physical_ram_in_mb != 16)
3835                          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");
3836    
3837                  /*                  /*
3838                   *  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 3841  no_arc_prom_emulation:         /*  TODO: ugly,
3841                  device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0");                  device_add(machine, "8250 addr=0x18000800 addr_mult=4 irq=0");
3842                  break;                  break;
3843    
         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;  
   
3844          case MACHINE_SONYNEWS:          case MACHINE_SONYNEWS:
3845                  /*                  /*
3846                   *  There are several models, according to                   *  There are several models, according to
# Line 4248  for (i=0; i<32; i++) Line 3865  for (i=0; i<32; i++)
3865                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
3866                  machine->machine_name = "Sony NeWS (NET WORK STATION)";                  machine->machine_name = "Sony NeWS (NET WORK STATION)";
3867    
3868                  /*  This is just a test.  TODO  */                  if (machine->prom_emulation) {
3869                  {                          /*  This is just a test.  TODO  */
3870                          int i;                          int i;
3871                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
3872                                  cpu->cd.mips.gpr[i] =                                  cpu->cd.mips.gpr[i] =
# Line 4261  for (i=0; i<32; i++) Line 3878  for (i=0; i<32; i++)
3878    
3879                  break;                  break;
3880    
3881            case MACHINE_EVBMIPS:
3882                    /*  http://www.netbsd.org/Ports/evbmips/  */
3883                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
3884    
3885                    switch (machine->machine_subtype) {
3886                    case MACHINE_EVBMIPS_MALTA:
3887                    case MACHINE_EVBMIPS_MALTA_BE:
3888                            machine->machine_name = "MALTA (evbmips, little endian)";
3889                            cpu->byte_order = EMUL_LITTLE_ENDIAN;
3890    
3891                            if (machine->machine_subtype == MACHINE_EVBMIPS_MALTA_BE) {
3892                                    machine->machine_name = "MALTA (evbmips, big endian)";
3893                                    cpu->byte_order = EMUL_BIG_ENDIAN;
3894                            }
3895    
3896                            /*  ISA interrupt controllers:  */
3897                            snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x18000020");
3898                            machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
3899                            snprintf(tmpstr, sizeof(tmpstr), "8259 irq=24 addr=0x180000a0");
3900                            machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
3901                            machine->md_interrupt = malta_interrupt;
3902    
3903                            dev_mc146818_init(machine, mem, 0x18000070, 8 + 8, MC146818_PC_CMOS, 1);
3904    
3905                            machine->main_console_handle = (size_t)
3906                                device_add(machine, "ns16550 irq=12 addr=0x180003f8 name2=tty0");
3907                            device_add(machine, "ns16550 irq=11 addr=0x180002f8 name2=tty1");
3908    
3909                            snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%x name2=tty2", MALTA_CBUSUART);
3910                            device_add(machine, tmpstr);
3911                            /*  TODO: Irqs  */
3912                            pci_data = dev_gt_init(machine, mem, 0x1be00000, 8+9, 8+9, 120);
3913    
3914                            /*  TODO: Haha, this is bogus. Just a cut&paste
3915                                from the Cobalt emulation above.  */
3916                            bus_pci_add(machine, pci_data, mem, 0,  9, 0, pci_vt82c586_isa_init, pci_vt82c586_isa_rr);
3917                            bus_pci_add(machine, pci_data, mem, 0,  9, 1, pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
3918    
3919                            device_add(machine, "malta_lcd addr=0x1f000400");
3920                            break;
3921                    case MACHINE_EVBMIPS_PB1000:
3922                            machine->machine_name = "PB1000 (evbmips)";
3923                            cpu->byte_order = EMUL_BIG_ENDIAN;
3924    
3925                            machine->md_interrupt = au1x00_interrupt;
3926                            machine->md_int.au1x00_ic_data = dev_au1x00_init(machine, mem);
3927                            /*  TODO  */
3928                            break;
3929                    default:
3930                            fatal("Unimplemented EVBMIPS model.\n");
3931                            exit(1);
3932                    }
3933    
3934                    if (machine->prom_emulation) {
3935                            /*  This is just a test.  TODO  */
3936                            for (i=0; i<32; i++)
3937                                    cpu->cd.mips.gpr[i] =
3938                                        0x01230000 + (i << 8) + 0x55;
3939    
3940                            /*  NetBSD/evbmips wants these: (at least for Malta)  */
3941    
3942                            /*  a0 = argc  */
3943                            cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
3944    
3945                            /*  a1 = argv  */
3946                            cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
3947                            store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
3948                            store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
3949                            store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
3950    
3951                            bootstr = strdup(machine->boot_kernel_filename);
3952                            bootarg = strdup(machine->boot_string_argument);
3953                            store_string(cpu, (int32_t)0x9fc01040, bootstr);
3954                            store_string(cpu, (int32_t)0x9fc01200, bootarg);
3955    
3956                            /*  a2 = (yamon_env_var *)envp  */
3957                            cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
3958                            {
3959                                    uint64_t env = cpu->cd.mips.gpr[MIPS_GPR_A2];
3960                                    uint64_t tmpptr = 0xffffffff9fc01c00ULL;
3961                                    char tmps[50];
3962    
3963                                    snprintf(tmps, sizeof(tmps), "0x%08x",
3964                                        machine->physical_ram_in_mb * 1048576);
3965                                    add_environment_string_dual(cpu,
3966                                        &env, &tmpptr, "memsize", tmps);
3967    
3968                                    add_environment_string_dual(cpu,
3969                                        &env, &tmpptr, "yamonrev", "02.06");
3970    
3971                                    /*  End of env:  */
3972                                    tmpptr = 0;
3973                                    add_environment_string_dual(cpu,
3974                                        &env, &tmpptr, NULL, NULL);
3975                            }
3976    
3977                            /*  a3 = memsize  */
3978                            cpu->cd.mips.gpr[MIPS_GPR_A3] =
3979                                machine->physical_ram_in_mb * 1048576;
3980                            /*  Hm. Linux ignores a3.  */
3981    
3982                            /*
3983                             *  TODO:
3984                             *      Core ID numbers.
3985                             *      How much of this is not valid for PBxxxx?
3986                             *
3987                             *  See maltareg.h for more info.
3988                             */
3989                            store_32bit_word(cpu, (int32_t)(0x80000000 + MALTA_REVISION), (1 << 10) + 0x26);
3990    
3991                            /*  Call vectors at 0x9fc005xx:  */
3992                            for (i=0; i<0x100; i+=4)
3993                                    store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,
3994                                        (int64_t)(int32_t)0x9fc00800 + i);
3995                    }
3996                    break;
3997    
3998            case MACHINE_PSP:
3999                    /*
4000                     *  The Playstation Portable seems to be a strange beast.
4001                     *
4002                     *  http://yun.cup.com/psppg004.html (in Japanese) seems to
4003                     *  suggest that virtual addresses are not displaced by
4004                     *  0x80000000 as on normal CPUs, but by 0x40000000?
4005                     */
4006                    machine->machine_name = "Playstation Portable";
4007                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
4008    
4009                    if (!machine->use_x11 && !quiet_mode)
4010                            fprintf(stderr, "-------------------------------------"
4011                                "------------------------------------------\n"
4012                                "\n  WARNING! You are emulating a PSP without -X. "
4013                                "You will miss graphical output!\n\n"
4014                                "-------------------------------------"
4015                                "------------------------------------------\n");
4016    
4017                    /*  480 x 272 pixels framebuffer (512 bytes per line)  */
4018                    fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPC,
4019                        480,272, 512,1088, -15, "Playstation Portable");
4020    
4021                    /*
4022                     *  TODO/NOTE: This is ugly, but necessary since GXemul doesn't
4023                     *  emulate any MIPS CPU without MMU right now.
4024                     */
4025                    mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,
4026                        0x44000000 /*vaddr*/, 0x4000000, 0x4000000 + 1048576*16,
4027                        1,1,1,1,1, 0, 2, 2);
4028                    mips_coproc_tlb_set_entry(cpu, 1, 1048576*16,
4029                        0x8000000 /*vaddr*/, 0x0, 0x0 + 1048576*16,
4030                        1,1,1,1,1, 0, 2, 2);
4031                    mips_coproc_tlb_set_entry(cpu, 2, 1048576*16,
4032                        0x9000000 /*vaddr*/, 0x01000000, 0x01000000 + 1048576*16,
4033                        1,1,1,1,1, 0, 2, 2);
4034                    mips_coproc_tlb_set_entry(cpu, 3, 1048576*16,
4035                        0x0 /*vaddr*/, 0, 0 + 1048576*16, 1,1,1,1,1, 0, 2, 2);
4036    
4037                    cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;
4038    
4039                    break;
4040    #endif  /*  ENABLE_MIPS  */
4041    
4042    #ifdef ENABLE_PPC
4043          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
4044                  /*                  /*
4045                   *  A "bare" PPC machine.                   *  A "bare" PPC machine.
# Line 4277  for (i=0; i<32; i++) Line 4056  for (i=0; i<32; i++)
4056                  machine->machine_name = "PPC test machine";                  machine->machine_name = "PPC test machine";
4057    
4058                  /*  TODO: interrupt for PPC?  */                  /*  TODO: interrupt for PPC?  */
4059                  machine->main_console_handle = dev_cons_init(                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4060                      machine, mem, DEV_CONS_ADDRESS, "console", 0);                      (long long)DEV_CONS_ADDRESS);
4061                    cons_data = device_add(machine, tmpstr);
4062                    machine->main_console_handle = cons_data->console_handle;
4063    
4064                  snprintf(tmpstr, sizeof(tmpstr) - 1, "mp addr=0x%llx",                  snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4065                      (long long)DEV_MP_ADDRESS);                      (long long)DEV_MP_ADDRESS);
4066                  device_add(machine, tmpstr);                  device_add(machine, tmpstr);
4067    
4068                  fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4069                      640,480, 640,480, 24, "generic", 1);                      640,480, 640,480, 24, "testppc generic");
4070    
4071                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4072                        (long long)DEV_DISK_ADDRESS);
4073                    device_add(machine, tmpstr);
4074    
4075                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4076                        (long long)DEV_ETHER_ADDRESS);
4077                    device_add(machine, tmpstr);
4078    
4079                  break;                  break;
4080    
4081          case MACHINE_WALNUT:          case MACHINE_WALNUT:
# Line 4305  for (i=0; i<32; i++) Line 4095  for (i=0; i<32; i++)
4095                  dev_pmppc_init(mem);                  dev_pmppc_init(mem);
4096    
4097                  /*  com0 = 0xff600300, com1 = 0xff600400  */                  /*  com0 = 0xff600300, com1 = 0xff600400  */
4098                  machine->main_console_handle = dev_ns16550_init(machine, mem,  
4099                      0xff600300, 0, 1, 1, "serial 0");                  machine->main_console_handle = (size_t)device_add(machine, "ns16550 irq=0 addr=0xff600300 name2=tty0");
4100                  dev_ns16550_init(machine, mem,                  device_add(machine, "ns16550 irq=0 addr=0xff600400 in_use=0 name2=tty1");
                     0xff600400, 0, 1, 0, "serial 1");  
4101    
4102                  break;                  break;
4103    
# Line 4335  for (i=0; i<32; i++) Line 4124  for (i=0; i<32; i++)
4124    
4125                  device_add(machine, "bebox");                  device_add(machine, "bebox");
4126    
4127                  /*  Serial, used by NetBSD:  */                  machine->main_console_handle = (size_t)
4128                  machine->main_console_handle = dev_ns16550_init(machine, mem,                      device_add(machine, "ns16550 irq=0 addr=0x800003f8 name2=tty0");
4129                      0x800003f8, 0, 1, 1, "serial 0");                  device_add(machine, "ns16550 irq=0 addr=0x800002f8 name2=tty1 in_use=0");
4130    
4131                  /*  Serial, used by Linux:  */                  dev_pckbc_init(machine, mem, 0x80000060, PCKBC_8042,
4132                  dev_ns16550_init(machine, mem, 0x800002f8, 0, 1, 0, "serial 1");                      1, 12, machine->use_x11, 1);
   
                 /*  This is used by Linux too:  */  
                 dev_vga_init(machine, mem, 0xc00b8000ULL, 0x800003c0ULL, 80, 25,  
                     machine->machine_name);  
   
                 store_32bit_word(cpu, 0x3010,  
                     machine->physical_ram_in_mb * 1048576);  
   
                 /*  TODO: List of stuff, see http://www.beatjapan.org/  
                     mirror/www.be.com/aboutbe/benewsletter/  
                     Issue27.html#Cookbook  for the details.  */  
                 store_32bit_word(cpu, 0x301c, 0);  
   
                 /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,  
                     r5 = args, r6 = ptr to bootinfo?  */  
                 cpu->cd.ppc.gpr[3] = 0x3100;  
                 cpu->cd.ppc.gpr[4] = 0x200000;  
                 cpu->cd.ppc.gpr[5] = 0x2000;  
                 store_string(cpu, cpu->cd.ppc.gpr[5], "-a");  
                 cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576  
                     - 0x100;  
   
                 /*  See NetBSD's bebox/include/bootinfo.h for details  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,  
                     machine->physical_ram_in_mb * 1048576);  
   
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */  
                 store_buf(cpu, cpu->cd.ppc.gpr[6] + 20, "com", 4);  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */  
   
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */  
                 store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);  
4133    
4134                    if (machine->use_x11)
4135                            dev_vga_init(machine, mem, 0xc00a0000ULL, 0x800003c0ULL,
4136                                machine->machine_name);
4137    
4138                    if (machine->prom_emulation) {
4139                            store_32bit_word(cpu, 0x3010, machine->physical_ram_in_mb * 1048576);
4140    
4141                            /*  TODO: List of stuff, see http://www.beatjapan.org/
4142                                mirror/www.be.com/aboutbe/benewsletter/
4143                                Issue27.html#Cookbook  for the details.  */
4144                            store_32bit_word(cpu, 0x301c, 0);
4145    
4146                            /*  NetBSD/bebox: r3 = startkernel, r4 = endkernel,
4147                                r5 = args, r6 = ptr to bootinfo?  */
4148                            cpu->cd.ppc.gpr[3] = 0x3100;
4149                            cpu->cd.ppc.gpr[4] = 0x200000;
4150                            cpu->cd.ppc.gpr[5] = 0x2000;
4151                            store_string(cpu, cpu->cd.ppc.gpr[5], "-a");
4152                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x100;
4153    
4154                            /*  See NetBSD's bebox/include/bootinfo.h for details  */
4155                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 0, 12);  /*  next  */
4156                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 4, 0);  /*  mem  */
4157                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 8,
4158                                machine->physical_ram_in_mb * 1048576);
4159    
4160                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 12, 20);  /* next */
4161                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 16, 1); /* console */
4162                            store_buf(cpu, cpu->cd.ppc.gpr[6] + 20,
4163                                machine->use_x11? "vga" : "com", 4);
4164                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 24, 0x3f8);/* addr */
4165                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 28, 9600);/* speed */
4166    
4167                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 32, 0);  /*  next  */
4168                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 36, 2);  /*  clock */
4169                            store_32bit_word(cpu, cpu->cd.ppc.gpr[6] + 40, 100);
4170                    }
4171                  break;                  break;
4172    
4173          case MACHINE_PREP:          case MACHINE_PREP:
# Line 4387  for (i=0; i<32; i++) Line 4176  for (i=0; i<32; i++)
4176                   */                   */
4177                  machine->machine_name = "PowerPC Reference Platform";                  machine->machine_name = "PowerPC Reference Platform";
4178    
4179                  {                  if (machine->prom_emulation) {
4180                          int i;                          /*  Linux on PReP has 0xdeadc0de at address 0? (See
4181                          for (i=0; i<32; i++)                              http://joshua.raleigh.nc.us/docs/linux-2.4.10_html/113568.html)  */
4182                                  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;  
4183    
4184                            /*  r6 should point to "residual data"?  */
4185                            cpu->cd.ppc.gpr[6] = machine->physical_ram_in_mb * 1048576 - 0x1000;
4186                    }
4187                  break;                  break;
4188    
4189          case MACHINE_MACPPC:          case MACHINE_MACPPC:
# Line 4411  for (i=0; i<32; i++) Line 4193  for (i=0; i<32; i++)
4193                   */                   */
4194                  machine->machine_name = "Macintosh (PPC)";                  machine->machine_name = "Macintosh (PPC)";
4195    
4196                  /*  r5 = OpenFirmware entry point  */                  if (machine->prom_emulation) {
4197                  cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;                          uint64_t b = 8 * 1048576, a = b - 0x800;
4198                            int i;
4199                            /*
4200                             *  r3 = pointer to boot_args (for the Mach kernel).
4201                             *  See http://darwinsource.opendarwin.org/10.3/
4202                             *  BootX-59/bootx.tproj/include.subproj/boot_args.h
4203                             *  for more info.
4204                             */
4205                            cpu->cd.ppc.gpr[3] = a;
4206                            store_16bit_word(cpu, a + 0x0000, 1);   /*  revision  */
4207                            store_16bit_word(cpu, a + 0x0002, 2);   /*  version  */
4208                            store_buf(cpu, a + 0x0004, machine->boot_string_argument, 256);
4209                            /*  26 dram banks; "long base; long size"  */
4210                            store_32bit_word(cpu, a + 0x0104, 0);   /*  base  */
4211                            store_32bit_word(cpu, a + 0x0108, machine->physical_ram_in_mb
4212                                * 256);             /*  size (in pages)  */
4213                            for (i=8; i<26*8; i+= 4)
4214                                    store_32bit_word(cpu, a + 0x0104 + i, 0);
4215                            a += (0x104 + 26 * 8);
4216                            /*  Video info:  */
4217                            store_32bit_word(cpu, a+0, 0xd0000000); /*  video base  */
4218                            store_32bit_word(cpu, a+4, 0);          /*  display code (?)  */
4219                            store_32bit_word(cpu, a+8, 800);        /*  bytes per pixel row  */
4220                            store_32bit_word(cpu, a+12, 800);       /*  width  */
4221                            store_32bit_word(cpu, a+16, 600);       /*  height  */
4222                            store_32bit_word(cpu, a+20, 8);         /*  pixel depth  */
4223                            a += 24;
4224                            store_32bit_word(cpu, a+0, 127);        /*  gestalt number (TODO)  */
4225                            store_32bit_word(cpu, a+4, 0);          /*  device tree pointer (TODO)  */
4226                            store_32bit_word(cpu, a+8, 0);          /*  device tree length  */
4227                            store_32bit_word(cpu, a+12, b);         /*  last address of kernel data area  */
4228    
4229                            /*  r4 = "MOSX" (0x4D4F5358)  */
4230                            cpu->cd.ppc.gpr[4] = 0x4D4F5358;
4231    
4232                            /*
4233                             *  r5 = OpenFirmware entry point.  NOTE: See
4234                             *  cpu_ppc.c for the rest of this semi-ugly hack.
4235                             */
4236                            dev_ram_init(machine, cpu->cd.ppc.of_emul_addr,
4237                                0x1000, DEV_RAM_RAM, 0x0);
4238                            store_32bit_word(cpu, cpu->cd.ppc.of_emul_addr,
4239                                0x44ee0002);
4240                            cpu->cd.ppc.gpr[5] = cpu->cd.ppc.of_emul_addr;
4241                    }
4242                  break;                  break;
4243    
4244          case MACHINE_DB64360:          case MACHINE_DB64360:
4245                  /*  For playing with PMON2000 for PPC:  */                  /*  For playing with PMON2000 for PPC:  */
4246                  machine->machine_name = "DB64360";                  machine->machine_name = "DB64360";
4247    
4248                  machine->main_console_handle = dev_ns16550_init(machine, mem,                  machine->main_console_handle = (size_t)device_add(machine,
4249                      0x1d000020, 0, 4, 1, "serial console");                      "ns16550 irq=0 addr=0x1d000020 addr_mult=4");
4250    
4251                  {                  if (machine->prom_emulation) {
4252                          int i;                          int i;
4253                          for (i=0; i<32; i++)                          for (i=0; i<32; i++)
4254                                  cpu->cd.ppc.gpr[i] =                                  cpu->cd.ppc.gpr[i] =
# Line 4431  for (i=0; i<32; i++) Line 4256  for (i=0; i<32; i++)
4256                  }                  }
4257    
4258                  break;                  break;
4259    #endif  /*  ENABLE_PPC  */
4260    
4261    #ifdef ENABLE_SH
4262            case MACHINE_BARESH:
4263                    /*  A bare SH machine, with no devices.  */
4264                    machine->machine_name = "\"Bare\" SH machine";
4265                    break;
4266    
4267            case MACHINE_TESTSH:
4268                    machine->machine_name = "SH test machine";
4269    
4270                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4271                        (long long)DEV_CONS_ADDRESS);
4272                    cons_data = device_add(machine, tmpstr);
4273                    machine->main_console_handle = cons_data->console_handle;
4274    
4275                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4276                        (long long)DEV_MP_ADDRESS);
4277                    device_add(machine, tmpstr);
4278    
4279                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4280                        640,480, 640,480, 24, "testsh generic");
4281    
4282                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4283                        (long long)DEV_DISK_ADDRESS);
4284                    device_add(machine, tmpstr);
4285    
4286                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4287                        (long long)DEV_ETHER_ADDRESS);
4288                    device_add(machine, tmpstr);
4289    
4290                    break;
4291    
4292            case MACHINE_HPCSH:
4293                    /*  Handheld SH-based machines:  */
4294                    machine->machine_name = "HPCsh";
4295    
4296                    /*  TODO  */
4297    
4298                    break;
4299    #endif  /*  ENABLE_SH  */
4300    
4301    #ifdef ENABLE_HPPA
4302            case MACHINE_BAREHPPA:
4303                    /*  A bare HPPA machine, with no devices.  */
4304                    machine->machine_name = "\"Bare\" HPPA machine";
4305                    break;
4306    
4307            case MACHINE_TESTHPPA:
4308                    machine->machine_name = "HPPA test machine";
4309    
4310                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4311                        (long long)DEV_CONS_ADDRESS);
4312                    cons_data = device_add(machine, tmpstr);
4313                    machine->main_console_handle = cons_data->console_handle;
4314    
4315                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4316                        (long long)DEV_MP_ADDRESS);
4317                    device_add(machine, tmpstr);
4318    
4319                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4320                        640,480, 640,480, 24, "testhppa generic");
4321    
4322                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4323                        (long long)DEV_DISK_ADDRESS);
4324                    device_add(machine, tmpstr);
4325    
4326                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4327                        (long long)DEV_ETHER_ADDRESS);
4328                    device_add(machine, tmpstr);
4329    
4330                    break;
4331    #endif  /*  ENABLE_HPPA  */
4332    
4333    #ifdef ENABLE_I960
4334            case MACHINE_BAREI960:
4335                    /*  A bare I960 machine, with no devices.  */
4336                    machine->machine_name = "\"Bare\" i960 machine";
4337                    break;
4338    
4339            case MACHINE_TESTI960:
4340                    machine->machine_name = "i960 test machine";
4341    
4342                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4343                        (long long)DEV_CONS_ADDRESS);
4344                    cons_data = device_add(machine, tmpstr);
4345                    machine->main_console_handle = cons_data->console_handle;
4346    
4347                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4348                        (long long)DEV_MP_ADDRESS);
4349                    device_add(machine, tmpstr);
4350    
4351                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4352                        640,480, 640,480, 24, "testi960 generic");
4353    
4354                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4355                        (long long)DEV_DISK_ADDRESS);
4356                    device_add(machine, tmpstr);
4357    
4358                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4359                        (long long)DEV_ETHER_ADDRESS);
4360                    device_add(machine, tmpstr);
4361    
4362                    break;
4363    #endif  /*  ENABLE_I960  */
4364    
4365    #ifdef ENABLE_SPARC
4366          case MACHINE_BARESPARC:          case MACHINE_BARESPARC:
4367                  /*  A bare SPARC machine, with no devices.  */                  /*  A bare SPARC machine, with no devices.  */
4368                  machine->machine_name = "\"Bare\" SPARC machine";                  machine->machine_name = "\"Bare\" SPARC machine";
4369                  break;                  break;
4370    
4371            case MACHINE_TESTSPARC:
4372                    machine->machine_name = "SPARC test machine";
4373    
4374                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4375                        (long long)DEV_CONS_ADDRESS);
4376                    cons_data = device_add(machine, tmpstr);
4377                    machine->main_console_handle = cons_data->console_handle;
4378    
4379                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4380                        (long long)DEV_MP_ADDRESS);
4381                    device_add(machine, tmpstr);
4382    
4383                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4384                        640,480, 640,480, 24, "testsparc generic");
4385    
4386                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4387                        (long long)DEV_DISK_ADDRESS);
4388                    device_add(machine, tmpstr);
4389    
4390                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4391                        (long long)DEV_ETHER_ADDRESS);
4392                    device_add(machine, tmpstr);
4393    
4394                    break;
4395    
4396          case MACHINE_ULTRA1:          case MACHINE_ULTRA1:
4397                  /*                  /*
4398                   *  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 4400  for (i=0; i<32; i++)
4400                   */                   */
4401                  machine->machine_name = "Sun Ultra1";                  machine->machine_name = "Sun Ultra1";
4402                  break;                  break;
4403    #endif  /*  ENABLE_SPARC  */
4404    
4405          case MACHINE_BAREURISC:  #ifdef ENABLE_ALPHA
4406                  machine->machine_name = "\"Bare\" URISC machine";          case MACHINE_BAREALPHA:
4407                    machine->machine_name = "\"Bare\" Alpha machine";
4408                  break;                  break;
4409    
4410          case MACHINE_TESTURISC:          case MACHINE_TESTALPHA:
4411                  machine->machine_name = "URISC test machine";                  machine->machine_name = "Alpha test machine";
4412    
4413                  /*  TODO  */                  snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4414                  /*  A special "device" for accessing normal devices                      (long long)DEV_CONS_ADDRESS);
4415                      using urisc accesses?  */                  cons_data = device_add(machine, tmpstr);
4416                    machine->main_console_handle = cons_data->console_handle;
4417    
4418                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4419                        (long long)DEV_MP_ADDRESS);
4420                    device_add(machine, tmpstr);
4421    
4422                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4423                        640,480, 640,480, 24, "testalpha generic");
4424    
4425                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4426                        (long long)DEV_DISK_ADDRESS);
4427                    device_add(machine, tmpstr);
4428    
4429                  device_add(machine, "urisc addr=0x12341234");                  snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4430                        (long long)DEV_ETHER_ADDRESS);
4431                    device_add(machine, tmpstr);
4432    
4433                  break;                  break;
4434    
4435          case MACHINE_BAREHPPA:          case MACHINE_ALPHA:
4436                  machine->machine_name = "\"Bare\" HPPA machine";                  if (machine->prom_emulation) {
4437                            struct rpb rpb;
4438                            struct crb crb;
4439                            struct ctb ctb;
4440    
4441                            /*  TODO:  Most of these... They are used by NetBSD/alpha:  */
4442                            /*  a0 = First free Page Frame Number  */
4443                            /*  a1 = PFN of current Level 1 page table  */
4444                            /*  a2 = Bootinfo magic  */
4445                            /*  a3 = Bootinfo pointer  */
4446                            /*  a4 = Bootinfo version  */
4447                            cpu->cd.alpha.r[ALPHA_A0] = 16*1024*1024 / 8192;
4448                            cpu->cd.alpha.r[ALPHA_A1] = 0;
4449                            cpu->cd.alpha.r[ALPHA_A2] = 0;
4450                            cpu->cd.alpha.r[ALPHA_A3] = 0;
4451                            cpu->cd.alpha.r[ALPHA_A4] = 0;
4452    
4453                            /*  HWRPB: Hardware Restart Parameter Block  */
4454                            memset(&rpb, 0, sizeof(struct rpb));
4455                            store_64bit_word_in_host(cpu, (unsigned char *)
4456                                &(rpb.rpb_phys), HWRPB_ADDR);
4457                            strlcpy((char *)&(rpb.rpb_magic), "HWRPB", 8);
4458                            store_64bit_word_in_host(cpu, (unsigned char *)
4459                                &(rpb.rpb_size), sizeof(struct rpb));
4460                            store_64bit_word_in_host(cpu, (unsigned char *)
4461                                &(rpb.rpb_page_size), 8192);
4462                            store_64bit_word_in_host(cpu, (unsigned char *)
4463                                &(rpb.rpb_type), machine->machine_subtype);
4464                            store_64bit_word_in_host(cpu, (unsigned char *)
4465                                &(rpb.rpb_cc_freq), 100000000);
4466                            store_64bit_word_in_host(cpu, (unsigned char *)
4467                                &(rpb.rpb_ctb_off), CTB_ADDR - HWRPB_ADDR);
4468                            store_64bit_word_in_host(cpu, (unsigned char *)
4469                                &(rpb.rpb_crb_off), CRB_ADDR - HWRPB_ADDR);
4470    
4471                            /*  CTB: Console Terminal Block  */
4472                            memset(&ctb, 0, sizeof(struct ctb));
4473                            store_64bit_word_in_host(cpu, (unsigned char *)
4474                                &(ctb.ctb_term_type), machine->use_x11?
4475                                CTB_GRAPHICS : CTB_PRINTERPORT);
4476    
4477                            /*  CRB: Console Routine Block  */
4478                            memset(&crb, 0, sizeof(struct crb));
4479                            store_64bit_word_in_host(cpu, (unsigned char *)
4480                                &(crb.crb_v_dispatch), CRB_ADDR - 0x100);
4481                            store_64bit_word(cpu, CRB_ADDR - 0x100 + 8, 0x10000);
4482    
4483                            /*
4484                             *  Place a special "hack" palcode call at 0x10000:
4485                             *  (Hopefully nothing else will be there.)
4486                             */
4487                            store_32bit_word(cpu, 0x10000, 0x3fffffe);
4488    
4489                            store_buf(cpu, HWRPB_ADDR, (char *)&rpb, sizeof(struct rpb));
4490                            store_buf(cpu, CTB_ADDR, (char *)&ctb, sizeof(struct ctb));
4491                            store_buf(cpu, CRB_ADDR, (char *)&crb, sizeof(struct crb));
4492                    }
4493    
4494                    switch (machine->machine_subtype) {
4495                    case ST_DEC_3000_300:
4496                            machine->machine_name = "DEC 3000/300";
4497                            machine->main_console_handle =
4498                                dev_zs_init(machine, mem, 0x1b0200000ULL,
4499                                0, 4, "serial zs"); /*  serial? netbsd?  */
4500                            break;
4501                    case ST_EB164:
4502                            machine->machine_name = "EB164";
4503                            break;
4504                    default:fatal("Unimplemented Alpha machine type %i\n",
4505                                machine->machine_subtype);
4506                            exit(1);
4507                    }
4508    
4509                  break;                  break;
4510    #endif  /*  ENABLE_ALPHA  */
4511    
4512          case MACHINE_TESTHPPA:  #ifdef ENABLE_ARM
4513                  machine->machine_name = "HPPA test machine";          case MACHINE_BAREARM:
4514                    machine->machine_name = "\"Bare\" ARM machine";
4515                    break;
4516    
4517                  /*  TODO  */          case MACHINE_TESTARM:
4518                    machine->machine_name = "ARM test machine";
4519    
4520                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4521                        (long long)DEV_CONS_ADDRESS);
4522                    cons_data = device_add(machine, tmpstr);
4523                    machine->main_console_handle = cons_data->console_handle;
4524    
4525                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4526                        (long long)DEV_MP_ADDRESS);
4527                    device_add(machine, tmpstr);
4528    
4529                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4530                        640,480, 640,480, 24, "testarm generic");
4531    
4532                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4533                        (long long)DEV_DISK_ADDRESS);
4534                    device_add(machine, tmpstr);
4535    
4536                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4537                        (long long)DEV_ETHER_ADDRESS);
4538                    device_add(machine, tmpstr);
4539    
4540                    /*  Place a tiny stub at end of memory, and set the link
4541                        register to point to it. This stub halts the machine.  */
4542                    cpu->cd.arm.r[ARM_SP] =
4543                        machine->physical_ram_in_mb * 1048576 - 4096;
4544                    cpu->cd.arm.r[ARM_LR] = cpu->cd.arm.r[ARM_SP] + 32;
4545                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 0, 0xe3a00201);
4546                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 4, 0xe5c00010);
4547                    store_32bit_word(cpu, cpu->cd.arm.r[ARM_LR] + 8,
4548                        0xeafffffe);
4549                  break;                  break;
4550    
4551          case MACHINE_BAREALPHA:          case MACHINE_CATS:
4552                  machine->machine_name = "\"Bare\" Alpha machine";                  machine->machine_name = "CATS evaluation board";
4553    
4554                    if (machine->emulated_hz == 0)
4555                            machine->emulated_hz = 50000000;
4556    
4557                    if (machine->physical_ram_in_mb > 256)
4558                            fprintf(stderr, "WARNING! Real CATS machines cannot"
4559                                " have more than 256 MB RAM. Continuing anyway.\n");
4560    
4561                    machine->md_int.footbridge_data =
4562                        device_add(machine, "footbridge addr=0x42000000");
4563                    machine->md_interrupt = footbridge_interrupt;
4564    
4565                    /*  NetBSD and OpenBSD clean their caches here:  */
4566                    dev_ram_init(machine, 0x50000000, 0x4000, DEV_RAM_RAM, 0);
4567    
4568                    /*  Interrupt ack space?  */
4569                    dev_ram_init(machine, 0x80000000, 0x1000, DEV_RAM_RAM, 0);
4570    
4571                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4572                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4573                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4574                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4575    
4576                    device_add(machine, "pccmos addr=0x7c000070");
4577    
4578                    if (machine->use_x11) {
4579                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4580                                mem, 0xc0, 8, 0, pci_s3_virge_init, pci_s3_virge_rr);
4581                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4582                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4583                                32 + 1, 32 + 12, machine->use_x11, 0);
4584                            machine->main_console_handle = j;
4585                    }
4586    
4587                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0 in_use=0");
4588                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1 in_use=0");
4589    
4590                    device_add(machine, "lpt irq=39 addr=0x7c000378 name2=lpt in_use=0");
4591    
4592                    if (machine->prom_emulation) {
4593                            struct ebsaboot ebsaboot;
4594                            char bs[300];
4595                            int boot_id = bootdev_id >= 0? bootdev_id : 0;
4596    
4597                            cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
4598                                7 * 1048576 - 0x1000;
4599    
4600                            memset(&ebsaboot, 0, sizeof(struct ebsaboot));
4601                            store_32bit_word_in_host(cpu, (unsigned char *)
4602                                &(ebsaboot.bt_magic), BT_MAGIC_NUMBER_CATS);
4603                            store_32bit_word_in_host(cpu, (unsigned char *)
4604                                &(ebsaboot.bt_vargp), 0);
4605                            store_32bit_word_in_host(cpu, (unsigned char *)
4606                                &(ebsaboot.bt_pargp), 0);
4607                            store_32bit_word_in_host(cpu, (unsigned char *)
4608                                &(ebsaboot.bt_args), cpu->cd.arm.r[0]
4609                                + sizeof(struct ebsaboot));
4610                            store_32bit_word_in_host(cpu, (unsigned char *)
4611                                &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
4612                            store_32bit_word_in_host(cpu, (unsigned char *)
4613                                &(ebsaboot.bt_memstart), 0);
4614                            store_32bit_word_in_host(cpu, (unsigned char *)
4615                                &(ebsaboot.bt_memend),
4616                                machine->physical_ram_in_mb * 1048576);
4617                            store_32bit_word_in_host(cpu, (unsigned char *)
4618                                &(ebsaboot.bt_memavail), 7 * 1048576);
4619                            store_32bit_word_in_host(cpu, (unsigned char *)
4620                                &(ebsaboot.bt_fclk), 50 * 1000000);
4621                            store_32bit_word_in_host(cpu, (unsigned char *)
4622                                &(ebsaboot.bt_pciclk), 66 * 1000000);
4623                            /*  TODO: bt_vers  */
4624                            /*  TODO: bt_features  */
4625    
4626                            store_buf(cpu, cpu->cd.arm.r[0],
4627                                (char *)&ebsaboot, sizeof(struct ebsaboot));
4628    
4629                            snprintf(bs, sizeof(bs), "(hd%i)%s%s%s",
4630                                boot_id, machine->boot_kernel_filename,
4631                                (machine->boot_string_argument[0])? " " : "",
4632                                machine->boot_string_argument);
4633    
4634                            store_string(cpu, cpu->cd.arm.r[0] +
4635                                sizeof(struct ebsaboot), bs);
4636    
4637                            arm_setup_initial_translation_table(cpu,
4638                                7 * 1048576 - 32768);
4639                    }
4640                  break;                  break;
4641    
4642          case MACHINE_TESTALPHA:          case MACHINE_HPCARM:
4643                  machine->machine_name = "Alpha test machine";                  cpu->byte_order = EMUL_LITTLE_ENDIAN;
4644                    memset(&hpc_bootinfo, 0, sizeof(hpc_bootinfo));
4645                    switch (machine->machine_subtype) {
4646                    case MACHINE_HPCARM_IPAQ:
4647                            /*  SA-1110 206MHz  */
4648                            machine->machine_name = "Compaq iPAQ H3600";
4649                            hpc_fb_addr = 0x48200000;       /*  TODO  */
4650                            hpc_fb_xsize = 240;
4651                            hpc_fb_ysize = 320;
4652                            hpc_fb_xsize_mem = 256;
4653                            hpc_fb_ysize_mem = 320;
4654                            hpc_fb_bits = 15;
4655                            hpc_fb_encoding = BIFB_D16_0000;
4656                            hpc_platid_cpu_arch = 3;        /*  ARM  */
4657                            hpc_platid_cpu_series = 1;      /*  StrongARM  */
4658                            hpc_platid_cpu_model = 2;       /*  SA-1110  */
4659                            hpc_platid_cpu_submodel = 0;
4660                            hpc_platid_vendor = 7;          /*  Compaq  */
4661                            hpc_platid_series = 4;          /*  IPAQ  */
4662                            hpc_platid_model = 2;           /*  H36xx  */
4663                            hpc_platid_submodel = 1;        /*  H3600  */
4664                            break;
4665                    case MACHINE_HPCARM_JORNADA720:
4666                            /*  SA-1110 206MHz  */
4667                            machine->machine_name = "Jornada 720";
4668                            hpc_fb_addr = 0x48200000;
4669                            hpc_fb_xsize = 640;
4670                            hpc_fb_ysize = 240;
4671                            hpc_fb_xsize_mem = 640;
4672                            hpc_fb_ysize_mem = 240;
4673                            hpc_fb_bits = 16;
4674                            hpc_fb_encoding = BIFB_D16_0000;
4675                            hpc_platid_cpu_arch = 3;        /*  ARM  */
4676                            hpc_platid_cpu_series = 1;      /*  StrongARM  */
4677                            hpc_platid_cpu_model = 2;       /*  SA-1110  */
4678                            hpc_platid_cpu_submodel = 0;
4679                            hpc_platid_vendor = 11;         /*  HP  */
4680                            hpc_platid_series = 2;          /*  Jornada  */
4681                            hpc_platid_model = 2;           /*  7xx  */
4682                            hpc_platid_submodel = 1;        /*  720  */
4683                            break;
4684                    default:
4685                            printf("Unimplemented hpcarm machine number.\n");
4686                            exit(1);
4687                    }
4688    
4689                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_cpu,
4690                          (hpc_platid_cpu_arch << 26) + (hpc_platid_cpu_series << 20)
4691                        + (hpc_platid_cpu_model << 14) + (hpc_platid_cpu_submodel <<  8)
4692                        + hpc_platid_flags);
4693                    store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.platid_machine,
4694                          (hpc_platid_vendor << 22) + (hpc_platid_series << 16)
4695                        + (hpc_platid_model <<  8) + hpc_platid_submodel);
4696    
4697                    if (machine->prom_emulation) {
4698                            /*  NetBSD/hpcarm and possibly others expects the following:  */
4699    
4700                            cpu->cd.arm.r[0] = 1;   /*  argc  */
4701                            cpu->cd.arm.r[1] = machine->physical_ram_in_mb * 1048576 - 512; /*  argv  */
4702                            cpu->cd.arm.r[2] = machine->physical_ram_in_mb * 1048576 - 256; /*  ptr to hpc_bootinfo  */
4703    
4704                            bootstr = machine->boot_kernel_filename;
4705                            store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512,
4706                                machine->physical_ram_in_mb * 1048576 - 512 + 16);
4707                            store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 4, 0);
4708                            store_string(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 16, bootstr);
4709    
4710                            if (machine->boot_string_argument[0]) {
4711                                    cpu->cd.arm.r[0] ++;    /*  argc  */
4712    
4713                                    store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 4, machine->physical_ram_in_mb * 1048576 - 512 + 64);
4714                                    store_32bit_word(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 8, 0);
4715    
4716                                    store_string(cpu, machine->physical_ram_in_mb * 1048576 - 512 + 64,
4717                                        machine->boot_string_argument);
4718    
4719                                    bootarg = machine->boot_string_argument;
4720                            }
4721    
4722                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.length, sizeof(hpc_bootinfo));
4723                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.magic, HPC_BOOTINFO_MAGIC);
4724                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_addr, hpc_fb_addr);
4725                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_line_bytes, hpc_fb_xsize_mem * (((hpc_fb_bits-1)|7)+1) / 8);
4726                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_width, hpc_fb_xsize);
4727                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_height, hpc_fb_ysize);
4728                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.fb_type, hpc_fb_encoding);
4729                            store_16bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.bi_cnuse,
4730                                machine->use_x11? BI_CNUSE_BUILTIN : BI_CNUSE_SERIAL);
4731    
4732                            store_32bit_word_in_host(cpu, (unsigned char *)&hpc_bootinfo.timezone, 0);
4733                            store_buf(cpu, machine->physical_ram_in_mb * 1048576 - 256, (char *)&hpc_bootinfo, sizeof(hpc_bootinfo));
4734    
4735                            /*
4736                             *  TODO: ugly hack, only works with small NetBSD
4737                             *        kernels!
4738                             */
4739                            cpu->cd.arm.r[ARM_SP] = 0xc02c0000;
4740                    }
4741    
4742                    /*  Physical RAM at 0xc0000000:  */
4743                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4744                        DEV_RAM_MIRROR, 0x0);
4745    
4746                    /*  Cache flush region:  */
4747                    dev_ram_init(machine, 0xe0000000, 0x10000, DEV_RAM_RAM, 0x0);
4748    
4749                    if (hpc_fb_addr != 0) {
4750                            dev_fb_init(machine, mem, hpc_fb_addr, VFB_HPC,
4751                                hpc_fb_xsize, hpc_fb_ysize,
4752                                hpc_fb_xsize_mem, hpc_fb_ysize_mem,
4753                                hpc_fb_bits, machine->machine_name);
4754                    }
4755                    break;
4756    
4757            case MACHINE_ZAURUS:
4758                    machine->machine_name = "Zaurus";
4759                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4760                        DEV_RAM_MIRROR, 0x0);
4761                    device_add(machine, "ns16550 irq=0 addr=0x40100000 addr_mult=4");
4762                  /*  TODO  */                  /*  TODO  */
4763                    if (machine->prom_emulation) {
4764                            arm_setup_initial_translation_table(cpu, 0x4000);
4765                    }
4766                  break;                  break;
4767    
4768          case MACHINE_BAREX86:          case MACHINE_NETWINDER:
4769                  machine->machine_name = "\"Bare\" x86 machine";                  machine->machine_name = "NetWinder";
4770    
4771                    if (machine->physical_ram_in_mb > 256)
4772                            fprintf(stderr, "WARNING! Real NetWinders cannot"
4773                                " have more than 256 MB RAM. Continuing anyway.\n");
4774    
4775                    machine->md_int.footbridge_data =
4776                        device_add(machine, "footbridge addr=0x42000000");
4777                    machine->md_interrupt = footbridge_interrupt;
4778    
4779                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c000020");
4780                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4781                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=64 addr=0x7c0000a0");
4782                    machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4783    
4784                    device_add(machine, "ns16550 irq=36 addr=0x7c0003f8 name2=com0");
4785                    device_add(machine, "ns16550 irq=35 addr=0x7c0002f8 name2=com1");
4786    
4787                    if (machine->use_x11) {
4788                            bus_pci_add(machine, machine->md_int.footbridge_data->pcibus,
4789                                mem, 0xc0, 8, 0, pci_igsfb_init, pci_igsfb_rr);
4790                            dev_vga_init(machine, mem, 0x800a0000ULL, 0x7c0003c0, machine->machine_name);
4791                            j = dev_pckbc_init(machine, mem, 0x7c000060, PCKBC_8042,
4792                                32 + 1, 32 + 12, machine->use_x11, 0);
4793                            machine->main_console_handle = j;
4794                    }
4795    
4796                    if (machine->prom_emulation) {
4797                            arm_setup_initial_translation_table(cpu, 0x4000);
4798                    }
4799                  break;                  break;
4800    
4801          case MACHINE_X86:          case MACHINE_SHARK:
4802                  machine->machine_name = "Generic x86 PC";                  machine->machine_name = "Digital DNARD (\"Shark\")";
4803                    if (machine->prom_emulation) {
4804                            arm_setup_initial_translation_table(cpu,
4805                                machine->physical_ram_in_mb * 1048576 - 65536);
4806    
4807                  if (!machine->use_x11)                          /*
4808                          fprintf(stderr, "WARNING! You are emulating a PC "                           *  r0 = OpenFirmware entry point.  NOTE: See
4809                              "without -X. You will miss any output going\n"                           *  cpu_arm.c for the rest of this semi-ugly hack.
4810                              "to the screen!\n\n");                           */
4811                            cpu->cd.arm.r[0] = cpu->cd.arm.of_emul_addr;
4812                    }
4813                    break;
4814    
4815            case MACHINE_IQ80321:
4816                  /*                  /*
4817                   *  Initialize all 16-bit interrupt vectors to point to                   *  Intel IQ80321. See http://sources.redhat.com/ecos/docs-latest/redboot/iq80321.html
4818                   *  somewhere within the PC BIOS area (0xf000:0x8yyy):                   *  for more details about the memory map.
4819                   */                   */
4820                  for (i=0; i<256; i++) {                  machine->machine_name = "Intel IQ80321 (ARM)";
4821                          store_16bit_word(cpu, i*4, 0x8000 + i);                  cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4822                          store_16bit_word(cpu, i*4 + 2, 0xf000);                  cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4823                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4824    
4825                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
4826                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4827                        DEV_RAM_MIRROR, 0x0);
4828                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4829                        DEV_RAM_MIRROR, 0x0);
4830    
4831                    /*  0xe0000000 and 0xff000000 = cache flush regions  */
4832                    dev_ram_init(machine, 0xe0000000, 0x100000, DEV_RAM_RAM, 0x0);
4833                    dev_ram_init(machine, 0xff000000, 0x100000, DEV_RAM_RAM, 0x0);
4834    
4835                    device_add(machine, "i80321 addr=0xffffe000");
4836    
4837                    if (machine->prom_emulation) {
4838                            arm_setup_initial_translation_table(cpu, 0x4000);
4839                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
4840                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
4841                            arm_translation_table_set_l1(cpu, 0xe0000000, 0xe0000000);
4842                            arm_translation_table_set_l1(cpu, 0xf0000000, 0xf0000000);
4843                  }                  }
4844                    break;
4845    
4846                  dev_vga_init(machine, mem, 0xb8000ULL, 0x1000003c0ULL, 80, 25,          case MACHINE_IYONIX:
4847                      "Generic x86 PC");                  machine->machine_name = "Iyonix";
4848                    cpu->cd.arm.coproc[6] = arm_coproc_i80321;
4849                    cpu->cd.arm.coproc[14] = arm_coproc_i80321_14;
4850    
4851                    device_add(machine, "ns16550 irq=0 addr=0xfe800000");
4852    
4853                    /*  0xa0000000 = physical ram, 0xc0000000 = uncached  */
4854                    dev_ram_init(machine, 0xa0000000, 0x20000000,
4855                        DEV_RAM_MIRROR, 0x0);
4856                    dev_ram_init(machine, 0xc0000000, 0x20000000,
4857                        DEV_RAM_MIRROR, 0x0);
4858    
4859                    device_add(machine, "i80321 addr=0xffffe000");
4860    
4861                    if (machine->prom_emulation) {
4862                            arm_setup_initial_translation_table(cpu,
4863                                machine->physical_ram_in_mb * 1048576 - 65536);
4864                            arm_translation_table_set_l1(cpu, 0xa0000000, 0xa0000000);
4865                            arm_translation_table_set_l1(cpu, 0xc0000000, 0xa0000000);
4866                            arm_translation_table_set_l1_b(cpu, 0xff000000, 0xff000000);
4867                    }
4868                    break;
4869    #endif  /*  ENABLE_ARM  */
4870    
4871    #ifdef ENABLE_AVR
4872            case MACHINE_BAREAVR:
4873                    /*  A bare Atmel AVR machine, with no devices.  */
4874                    machine->machine_name = "\"Bare\" Atmel AVR machine";
4875                    break;
4876    #endif  /*  ENABLE_AVR  */
4877    
4878    #ifdef ENABLE_IA64
4879            case MACHINE_BAREIA64:
4880                    machine->machine_name = "\"Bare\" IA64 machine";
4881                    break;
4882    
4883            case MACHINE_TESTIA64:
4884                    machine->machine_name = "IA64 test machine";
4885    
4886                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4887                        (long long)DEV_CONS_ADDRESS);
4888                    cons_data = device_add(machine, tmpstr);
4889                    machine->main_console_handle = cons_data->console_handle;
4890    
4891                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4892                        (long long)DEV_MP_ADDRESS);
4893                    device_add(machine, tmpstr);
4894    
4895                    fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4896                        640,480, 640,480, 24, "testia64 generic");
4897    
4898                    snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4899                        (long long)DEV_DISK_ADDRESS);
4900                    device_add(machine, tmpstr);
4901    
4902                    snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4903                        (long long)DEV_ETHER_ADDRESS);
4904                    device_add(machine, tmpstr);
4905    
4906                    break;
4907    #endif  /*  ENABLE_IA64  */
4908    
4909    #ifdef ENABLE_M68K
4910            case MACHINE_BAREM68K:
4911                    machine->machine_name = "\"Bare\" M68K machine";
4912                    break;
4913    
4914            case MACHINE_TESTM68K:
4915                    machine->machine_name = "M68K test machine";
4916    
4917                    snprintf(tmpstr, sizeof(tmpstr), "cons addr=0x%llx irq=0",
4918                        (long long)DEV_CONS_ADDRESS);
4919                    cons_data = device_add(machine, tmpstr);
4920                    machine->main_console_handle = cons_data->console_handle;
4921    
4922                    snprintf(tmpstr, sizeof(tmpstr), "mp addr=0x%llx",
4923                        (long long)DEV_MP_ADDRESS);
4924                    device_add(machine, tmpstr);
4925    
4926                  dev_wdc_init(machine, mem, 0x1000001f0ULL, 14, 0);                  fb = dev_fb_init(machine, mem, DEV_FB_ADDRESS, VFB_GENERIC,
4927                        640,480, 640,480, 24, "testm68k generic");
4928    
4929                  /*  TODO: disable the "enable" flag when a keyboard has                  snprintf(tmpstr, sizeof(tmpstr), "disk addr=0x%llx",
4930                      been added:  */                      (long long)DEV_DISK_ADDRESS);
4931                  machine->main_console_handle = dev_ns16550_init(machine, mem,                  device_add(machine, tmpstr);
4932                      0x1000003f8ULL, 4, 1, 1, "com1");  
4933                  dev_ns16550_init(machine, mem, 0x100000378ULL, 3, 1, 0, "com2");                  snprintf(tmpstr, sizeof(tmpstr), "ether addr=0x%llx irq=0",
4934                        (long long)DEV_ETHER_ADDRESS);
4935                    device_add(machine, tmpstr);
4936    
4937                    break;
4938    #endif  /*  ENABLE_M68K  */
4939    
4940    #ifdef ENABLE_X86
4941            case MACHINE_BAREX86:
4942                    machine->machine_name = "\"Bare\" x86 machine";
4943                  break;                  break;
4944    
4945            case MACHINE_X86:
4946                    if (machine->machine_subtype == MACHINE_X86_XT)
4947                            machine->machine_name = "PC XT";
4948                    else
4949                            machine->machine_name = "Generic x86 PC";
4950    
4951                    /*  Interrupt controllers:  */
4952                    snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx",
4953                        (long long)(X86_IO_BASE + 0x20));
4954                    machine->isa_pic_data.pic1 = device_add(machine, tmpstr);
4955                    if (machine->machine_subtype != MACHINE_X86_XT) {
4956                            snprintf(tmpstr, sizeof(tmpstr), "8259 irq=16 addr=0x%llx irq=2",
4957                                (long long)(X86_IO_BASE + 0xa0));
4958                            machine->isa_pic_data.pic2 = device_add(machine, tmpstr);
4959                    }
4960    
4961                    machine->md_interrupt = x86_pc_interrupt;
4962    
4963                    /*  Timer:  */
4964                    snprintf(tmpstr, sizeof(tmpstr), "8253 addr=0x%llx irq=0",
4965                        (long long)(X86_IO_BASE + 0x40));
4966                    device_add(machine, tmpstr);
4967    
4968                    snprintf(tmpstr, sizeof(tmpstr), "pccmos addr=0x%llx",
4969                        (long long)(X86_IO_BASE + 0x70));
4970                    device_add(machine, tmpstr);
4971    
4972                    /*  TODO: IRQ when emulating a PC XT?  */
4973    
4974                    /*  IDE controllers:  */
4975                    if (diskimage_exist(machine, 0, DISKIMAGE_IDE) ||
4976                        diskimage_exist(machine, 1, DISKIMAGE_IDE)) {
4977                            snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4978                                X86_IO_BASE + 0x1f0, 14);
4979                            device_add(machine, tmpstr);
4980                    }
4981                    if (diskimage_exist(machine, 2, DISKIMAGE_IDE) ||
4982                        diskimage_exist(machine, 3, DISKIMAGE_IDE)) {
4983                            snprintf(tmpstr, sizeof(tmpstr), "wdc addr=0x%llx irq=%i",
4984                                X86_IO_BASE + 0x170, 15);
4985                            device_add(machine, tmpstr);
4986                    }
4987    
4988                    /*  Floppy controller at irq 6  */
4989                    snprintf(tmpstr, sizeof(tmpstr), "fdc addr=0x%llx irq=6",
4990                        (long long)(X86_IO_BASE + 0x3f0));
4991                    device_add(machine, tmpstr);
4992    
4993                    /*  TODO: sound blaster (eventually) at irq 7?  */
4994    
4995                    /*  TODO: parallel port  */
4996    
4997                    /*  Serial ports:  (TODO: 8250 for PC XT?)  */
4998    
4999                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=4 addr=0x%llx name2=com1 in_use=0",
5000                        (long long)X86_IO_BASE + 0x3f8);
5001                    device_add(machine, tmpstr);
5002                    snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=3 addr=0x%llx name2=com2 in_use=0",
5003                        (long long)X86_IO_BASE + 0x2f8);
5004                    device_add(machine, tmpstr);
5005    
5006                    /*  VGA + keyboard:  */
5007                    dev_vga_init(machine, mem, 0xa0000ULL, X86_IO_BASE + 0x3c0,
5008                        "Generic x86 PC");
5009                    machine->main_console_handle = dev_pckbc_init(machine,
5010                        mem, X86_IO_BASE + 0x60, PCKBC_8042, 1, 12, 1, 1);
5011    
5012                    if (machine->prom_emulation)
5013                            pc_bios_init(cpu);
5014    
5015                    if (!machine->use_x11 && !quiet_mode)
5016                            fprintf(stderr, "-------------------------------------"
5017                                "------------------------------------------\n"
5018                                "\n  WARNING! You are emulating a PC without -X. "
5019                                "You will miss graphical output!\n\n"
5020                                "-------------------------------------"
5021                                "------------------------------------------\n");
5022                    break;
5023    #endif  /*  ENABLE_X86  */
5024    
5025          default:          default:
5026                  fatal("Unknown emulation type %i\n", machine->machine_type);                  fatal("Unknown emulation type %i\n", machine->machine_type);
5027                  exit(1);                  exit(1);
# Line 4581  void machine_memsize_fix(struct machine Line 5089  void machine_memsize_fix(struct machine
5089                  case MACHINE_NETGEAR:                  case MACHINE_NETGEAR:
5090                          m->physical_ram_in_mb = 16;                          m->physical_ram_in_mb = 16;
5091                          break;                          break;
5092                  case MACHINE_WRT54G:                  case MACHINE_EVBMIPS:
5093                          m->physical_ram_in_mb = 32;                          m->physical_ram_in_mb = 64;
5094                            break;
5095                    case MACHINE_PSP:
5096                            /*
5097                             *  According to
5098                             *  http://wiki.ps2dev.org/psp:memory_map:
5099                             *      0×08000000 = 8 MB kernel memory
5100                             *      0×08800000 = 24 MB user memory
5101                             */
5102                            m->physical_ram_in_mb = 8 + 24;
5103                          break;                          break;
5104                  case MACHINE_ARC:                  case MACHINE_ARC:
5105                          switch (m->machine_subtype) {                          switch (m->machine_subtype) {
# Line 4605  void machine_memsize_fix(struct machine Line 5122  void machine_memsize_fix(struct machine
5122                                  m->physical_ram_in_mb = 32;                                  m->physical_ram_in_mb = 32;
5123                          }                          }
5124                          break;                          break;
5125                    case MACHINE_ALPHA:
5126                            m->physical_ram_in_mb = 64;
5127                            break;
5128                  case MACHINE_BEBOX:                  case MACHINE_BEBOX:
5129                          m->physical_ram_in_mb = 64;                          m->physical_ram_in_mb = 64;
5130                          break;                          break;
5131                  case MACHINE_BAREURISC:                  case MACHINE_CATS:
5132                  case MACHINE_TESTURISC:                          m->physical_ram_in_mb = 64;
5133                          m->physical_ram_in_mb = 2;                          break;
5134                    case MACHINE_ZAURUS:
5135                            m->physical_ram_in_mb = 64;
5136                            break;
5137                    case MACHINE_HPCARM:
5138                            m->physical_ram_in_mb = 32;
5139                            break;
5140                    case MACHINE_NETWINDER:
5141                            m->physical_ram_in_mb = 16;
5142                            break;
5143                    case MACHINE_X86:
5144                            if (m->machine_subtype == MACHINE_X86_XT)
5145                                    m->physical_ram_in_mb = 1;
5146                          break;                          break;
5147                  }                  }
5148          }          }
5149    
5150          /*  Special hack for WRT54G and hpcmips machines:  */          /*  Special hack for hpcmips machines:  */
5151          if (m->machine_type == MACHINE_WRT54G ||          if (m->machine_type == MACHINE_HPCMIPS) {
             m->machine_type == MACHINE_HPCMIPS) {  
5152                  m->dbe_on_nonexistant_memaccess = 0;                  m->dbe_on_nonexistant_memaccess = 0;
5153          }          }
5154    
# Line 4713  void machine_default_cputype(struct mach Line 5244  void machine_default_cputype(struct mach
5244          case MACHINE_NETGEAR:          case MACHINE_NETGEAR:
5245                  m->cpu_name = strdup("RC32334");                  m->cpu_name = strdup("RC32334");
5246                  break;                  break;
         case MACHINE_WRT54G:  
                 m->cpu_name = strdup("BCM4712");  
                 break;  
5247          case MACHINE_ARC:          case MACHINE_ARC:
5248                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5249                  case MACHINE_ARC_JAZZ_PICA:                  case MACHINE_ARC_JAZZ_PICA:
# Line 4747  void machine_default_cputype(struct mach Line 5275  void machine_default_cputype(struct mach
5275                  if (m->cpu_name == NULL)                  if (m->cpu_name == NULL)
5276                          m->cpu_name = strdup("R4400");                          m->cpu_name = strdup("R4400");
5277                  break;                  break;
5278            case MACHINE_EVBMIPS:
5279                    switch (m->machine_subtype) {
5280                    case MACHINE_EVBMIPS_MALTA:
5281                    case MACHINE_EVBMIPS_MALTA_BE:
5282                            m->cpu_name = strdup("5Kc");
5283                            break;
5284                    case MACHINE_EVBMIPS_PB1000:
5285                            m->cpu_name = strdup("AU1000");
5286                            break;
5287                    default:fatal("Unimpl. evbmips.\n");
5288                            exit(1);
5289                    }
5290                    break;
5291            case MACHINE_PSP:
5292                    m->cpu_name = strdup("Allegrex");
5293                    break;
5294    
5295          /*  PowerPC:  */          /*  PowerPC:  */
5296          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
# Line 4781  void machine_default_cputype(struct mach Line 5325  void machine_default_cputype(struct mach
5325          case MACHINE_MACPPC:          case MACHINE_MACPPC:
5326                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
5327                  case MACHINE_MACPPC_G4:                  case MACHINE_MACPPC_G4:
5328                          m->cpu_name = strdup("G4e");                          m->cpu_name = strdup("PPC750");
5329                          break;                          break;
5330                  case MACHINE_MACPPC_G5:                  case MACHINE_MACPPC_G5:
5331                          m->cpu_name = strdup("PPC970");                          m->cpu_name = strdup("PPC970");
# Line 4792  void machine_default_cputype(struct mach Line 5336  void machine_default_cputype(struct mach
5336                  m->cpu_name = strdup("PPC750");                  m->cpu_name = strdup("PPC750");
5337                  break;                  break;
5338    
5339          /*  SPARC:  */          /*  SH:  */
5340          case MACHINE_BARESPARC:          case MACHINE_BARESH:
5341                  m->cpu_name = strdup("SPARCV9");          case MACHINE_TESTSH:
5342                  break;          case MACHINE_HPCSH:
5343          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");  
5344                  break;                  break;
5345    
5346          /*  HPPA:  */          /*  HPPA:  */
5347          case MACHINE_BAREHPPA:          case MACHINE_BAREHPPA:
5348          case MACHINE_TESTHPPA:          case MACHINE_TESTHPPA:
5349                  m->cpu_name = strdup("HPPA2.0");                  m->cpu_name = strdup("HPPA");
5350                    break;
5351    
5352            /*  i960:  */
5353            case MACHINE_BAREI960:
5354            case MACHINE_TESTI960:
5355                    m->cpu_name = strdup("i960");
5356                    break;
5357    
5358            /*  SPARC:  */
5359            case MACHINE_BARESPARC:
5360            case MACHINE_TESTSPARC:
5361            case MACHINE_ULTRA1:
5362                    m->cpu_name = strdup("SPARCv9");
5363                  break;                  break;
5364    
5365          /*  Alpha:  */          /*  Alpha:  */
5366          case MACHINE_BAREALPHA:          case MACHINE_BAREALPHA:
5367          case MACHINE_TESTALPHA:          case MACHINE_TESTALPHA:
5368                  m->cpu_name = strdup("EV4");          case MACHINE_ALPHA:
5369                    m->cpu_name = strdup("Alpha");
5370                    break;
5371    
5372            /*  ARM:  */
5373            case MACHINE_BAREARM:
5374            case MACHINE_TESTARM:
5375            case MACHINE_HPCARM:
5376                    m->cpu_name = strdup("SA1110");
5377                    break;
5378            case MACHINE_IQ80321:
5379            case MACHINE_IYONIX:
5380                    m->cpu_name = strdup("80321_600_B0");
5381                    break;
5382            case MACHINE_CATS:
5383            case MACHINE_NETWINDER:
5384            case MACHINE_SHARK:
5385                    m->cpu_name = strdup("SA110");
5386                    break;
5387            case MACHINE_ZAURUS:
5388                    m->cpu_name = strdup("PXA210");
5389                    break;
5390    
5391            /*  AVR:  */
5392            case MACHINE_BAREAVR:
5393                    m->cpu_name = strdup("AVR");
5394                    break;
5395    
5396            /*  IA64:  */
5397            case MACHINE_BAREIA64:
5398            case MACHINE_TESTIA64:
5399                    m->cpu_name = strdup("IA64");
5400                    break;
5401    
5402            /*  M68K:  */
5403            case MACHINE_BAREM68K:
5404            case MACHINE_TESTM68K:
5405                    m->cpu_name = strdup("68020");
5406                  break;                  break;
5407    
5408          /*  x86:  */          /*  x86:  */
5409          case MACHINE_BAREX86:          case MACHINE_BAREX86:
5410          case MACHINE_X86:          case MACHINE_X86:
5411                  m->cpu_name = strdup("PENTIUM");                  if (m->machine_subtype == MACHINE_X86_XT)
5412                            m->cpu_name = strdup("8086");
5413                    else
5414                            m->cpu_name = strdup("AMD64");
5415                  break;                  break;
5416          }          }
5417    
# Line 4861  void machine_dumpinfo(struct machine *m) Line 5451  void machine_dumpinfo(struct machine *m)
5451          if (m->single_step_on_bad_addr)          if (m->single_step_on_bad_addr)
5452                  debug("single-step on bad addresses\n");                  debug("single-step on bad addresses\n");
5453    
5454          if (m->bintrans_enable)          if (m->arch == ARCH_MIPS) {
5455                  debug("bintrans enabled (%i MB cache)\n",                  if (m->bintrans_enable)
5456                      (int) (m->bintrans_size / 1048576));                          debug("bintrans enabled (%i MB cache)\n",
5457          else                              (int) (m->bintrans_size / 1048576));
5458                  debug("bintrans disabled, other speedtricks %s\n",                  else
5459                      m->speed_tricks? "enabled" : "disabled");                          debug("bintrans disabled, other speedtricks %s\n",
5460                                m->speed_tricks? "enabled" : "disabled");
5461            }
5462    
5463          debug("clock: ");          debug("clock: ");
5464          if (m->automatic_clock_adjustment)          if (m->automatic_clock_adjustment)
# Line 5053  void machine_list_available_types_and_cp Line 5645  void machine_list_available_types_and_cp
5645          debug("\n");          debug("\n");
5646    
5647          useremul_list_emuls();          useremul_list_emuls();
5648            debug("Userland emulation works for programs with the complexity"
5649                " of Hello World,\nbut not much more.\n");
5650  }  }
5651    
5652    
# Line 5071  void machine_init(void) Line 5665  void machine_init(void)
5665           *  entries will appear in normal order when listed.  :-)           *  entries will appear in normal order when listed.  :-)
5666           */           */
5667    
5668            /*  Zaurus:  */
5669            me = machine_entry_new("Zaurus (ARM)",
5670                ARCH_ARM, MACHINE_ZAURUS, 1, 0);
5671            me->aliases[0] = "zaurus";
5672            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5673                    me->next = first_machine_entry; first_machine_entry = me;
5674            }
5675    
5676          /*  X86 machine:  */          /*  X86 machine:  */
5677          me = machine_entry_new("x86 (generic PC-style machine)", ARCH_X86,          me = machine_entry_new("x86-based PC", ARCH_X86,
5678              MACHINE_X86, 2, 0);              MACHINE_X86, 2, 2);
5679          me->aliases[0] = "pc";          me->aliases[0] = "pc";
5680          me->aliases[1] = "x86";          me->aliases[1] = "x86";
5681            me->subtype[0] = machine_entry_subtype_new("Generic PC",
5682                MACHINE_X86_GENERIC, 1);
5683            me->subtype[0]->aliases[0] = "generic";
5684            me->subtype[1] = machine_entry_subtype_new("PC XT", MACHINE_X86_XT, 1);
5685            me->subtype[1]->aliases[0] = "xt";
5686          if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {          if (cpu_family_ptr_by_number(ARCH_X86) != NULL) {
5687                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5688          }          }
# Line 5089  void machine_init(void) Line 5696  void machine_init(void)
5696                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5697          }          }
5698    
5699          /*  Test-machine for URISC:  */          /*  Test-machine for SPARC:  */
5700          me = machine_entry_new("Test-machine for URISC", ARCH_URISC,          me = machine_entry_new("Test-machine for SPARC", ARCH_SPARC,
5701              MACHINE_TESTURISC, 1, 0);              MACHINE_TESTSPARC, 1, 0);
5702          me->aliases[0] = "testurisc";          me->aliases[0] = "testsparc";
5703          if (cpu_family_ptr_by_number(ARCH_URISC) != NULL) {          if (cpu_family_ptr_by_number(ARCH_SPARC) != NULL) {
5704                    me->next = first_machine_entry; first_machine_entry = me;
5705            }
5706    
5707            /*  Test-machine for SH:  */
5708            me = machine_entry_new("Test-machine for SH", ARCH_SH,
5709                MACHINE_TESTSH, 1, 0);
5710            me->aliases[0] = "testsh";
5711            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5712                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5713          }          }
5714    
# Line 5113  void machine_init(void) Line 5728  void machine_init(void)
5728                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5729          }          }
5730    
5731            /*  Test-machine for M68K:  */
5732            me = machine_entry_new("Test-machine for M68K", ARCH_M68K,
5733                MACHINE_TESTM68K, 1, 0);
5734            me->aliases[0] = "testm68k";
5735            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
5736                    me->next = first_machine_entry; first_machine_entry = me;
5737            }
5738    
5739            /*  Test-machine for IA64:  */
5740            me = machine_entry_new("Test-machine for IA64", ARCH_IA64,
5741                MACHINE_TESTIA64, 1, 0);
5742            me->aliases[0] = "testia64";
5743            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
5744                    me->next = first_machine_entry; first_machine_entry = me;
5745            }
5746    
5747            /*  Test-machine for i960:  */
5748            me = machine_entry_new("Test-machine for i960", ARCH_I960,
5749                MACHINE_TESTI960, 1, 0);
5750            me->aliases[0] = "testi960";
5751            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
5752                    me->next = first_machine_entry; first_machine_entry = me;
5753            }
5754    
5755          /*  Test-machine for HPPA:  */          /*  Test-machine for HPPA:  */
5756          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,          me = machine_entry_new("Test-machine for HPPA", ARCH_HPPA,
5757              MACHINE_TESTHPPA, 1, 0);              MACHINE_TESTHPPA, 1, 0);
# Line 5121  void machine_init(void) Line 5760  void machine_init(void)
5760                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5761          }          }
5762    
5763            /*  Test-machine for ARM:  */
5764            me = machine_entry_new("Test-machine for ARM", ARCH_ARM,
5765                MACHINE_TESTARM, 1, 0);
5766            me->aliases[0] = "testarm";
5767            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5768                    me->next = first_machine_entry; first_machine_entry = me;
5769            }
5770    
5771          /*  Test-machine for Alpha:  */          /*  Test-machine for Alpha:  */
5772          me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA,          me = machine_entry_new("Test-machine for Alpha", ARCH_ALPHA,
5773              MACHINE_TESTALPHA, 1, 0);              MACHINE_TESTALPHA, 1, 0);
# Line 5155  void machine_init(void) Line 5802  void machine_init(void)
5802          }          }
5803    
5804          /*  SGI:  */          /*  SGI:  */
5805          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 9);          me = machine_entry_new("SGI", ARCH_MIPS, MACHINE_SGI, 2, 10);
5806          me->aliases[0] = "silicon graphics";          me->aliases[0] = "silicon graphics";
5807          me->aliases[1] = "sgi";          me->aliases[1] = "sgi";
5808          me->subtype[0] = machine_entry_subtype_new("IP19", 19, 1);          me->subtype[0] = machine_entry_subtype_new("IP12", 12, 1);
5809          me->subtype[0]->aliases[0] = "ip19";          me->subtype[0]->aliases[0] = "ip12";
5810          me->subtype[1] = machine_entry_subtype_new("IP20", 20, 1);          me->subtype[1] = machine_entry_subtype_new("IP19", 19, 1);
5811          me->subtype[1]->aliases[0] = "ip20";          me->subtype[1]->aliases[0] = "ip19";
5812          me->subtype[2] = machine_entry_subtype_new("IP22", 22, 2);          me->subtype[2] = machine_entry_subtype_new("IP20", 20, 1);
5813          me->subtype[2]->aliases[0] = "ip22";          me->subtype[2]->aliases[0] = "ip20";
5814          me->subtype[2]->aliases[1] = "indy";          me->subtype[3] = machine_entry_subtype_new("IP22", 22, 2);
5815          me->subtype[3] = machine_entry_subtype_new("IP24", 24, 1);          me->subtype[3]->aliases[0] = "ip22";
5816          me->subtype[3]->aliases[0] = "ip24";          me->subtype[3]->aliases[1] = "indy";
5817          me->subtype[4] = machine_entry_subtype_new("IP27", 27, 3);          me->subtype[4] = machine_entry_subtype_new("IP24", 24, 1);
5818          me->subtype[4]->aliases[0] = "ip27";          me->subtype[4]->aliases[0] = "ip24";
5819          me->subtype[4]->aliases[1] = "origin 200";          me->subtype[5] = machine_entry_subtype_new("IP27", 27, 3);
5820          me->subtype[4]->aliases[2] = "origin 2000";          me->subtype[5]->aliases[0] = "ip27";
5821          me->subtype[5] = machine_entry_subtype_new("IP28", 28, 1);          me->subtype[5]->aliases[1] = "origin 200";
5822          me->subtype[5]->aliases[0] = "ip28";          me->subtype[5]->aliases[2] = "origin 2000";
5823          me->subtype[6] = machine_entry_subtype_new("IP30", 30, 2);          me->subtype[6] = machine_entry_subtype_new("IP28", 28, 1);
5824          me->subtype[6]->aliases[0] = "ip30";          me->subtype[6]->aliases[0] = "ip28";
5825          me->subtype[6]->aliases[1] = "octane";          me->subtype[7] = machine_entry_subtype_new("IP30", 30, 2);
5826          me->subtype[7] = machine_entry_subtype_new("IP32", 32, 2);          me->subtype[7]->aliases[0] = "ip30";
5827          me->subtype[7]->aliases[0] = "ip32";          me->subtype[7]->aliases[1] = "octane";
5828          me->subtype[7]->aliases[1] = "o2";          me->subtype[8] = machine_entry_subtype_new("IP32", 32, 2);
5829          me->subtype[8] = machine_entry_subtype_new("IP35", 35, 1);          me->subtype[8]->aliases[0] = "ip32";
5830          me->subtype[8]->aliases[0] = "ip35";          me->subtype[8]->aliases[1] = "o2";
5831            me->subtype[9] = machine_entry_subtype_new("IP35", 35, 1);
5832            me->subtype[9]->aliases[0] = "ip35";
5833          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5834                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5835          }          }
# Line 5193  void machine_init(void) Line 5842  void machine_init(void)
5842                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5843          }          }
5844    
5845            /*  Playstation Portable:  */
5846            me = machine_entry_new("Playstation Portable", ARCH_MIPS,
5847                MACHINE_PSP, 1, 0);
5848            me->aliases[0] = "psp";
5849            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5850                    me->next = first_machine_entry; first_machine_entry = me;
5851            }
5852    
5853            /*  NetWinder:  */
5854            me = machine_entry_new("NetWinder", ARCH_ARM, MACHINE_NETWINDER, 1, 0);
5855            me->aliases[0] = "netwinder";
5856            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5857                    me->next = first_machine_entry; first_machine_entry = me;
5858            }
5859    
5860          /*  NetGear:  */          /*  NetGear:  */
5861          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602v1", ARCH_MIPS,
5862              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);
5863          me->aliases[0] = "netgear";          me->aliases[0] = "netgear";
5864          me->aliases[1] = "wg602";          me->aliases[1] = "wg602v1";
5865          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
5866                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5867          }          }
# Line 5231  void machine_init(void) Line 5895  void machine_init(void)
5895                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5896          }          }
5897    
5898          /*  Linksys:  */          /*  Iyonix:  */
5899          me = machine_entry_new("Linksys WRT54G", ARCH_MIPS,          me = machine_entry_new("Iyonix", ARCH_ARM,
5900              MACHINE_WRT54G, 2, 0);              MACHINE_IYONIX, 1, 0);
5901          me->aliases[0] = "linksys";          me->aliases[0] = "iyonix";
5902          me->aliases[1] = "wrt54g";          if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5903          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {                  me->next = first_machine_entry; first_machine_entry = me;
5904            }
5905    
5906            /*  Intel IQ80321 (ARM):  */
5907            me = machine_entry_new("Intel IQ80321 (ARM)", ARCH_ARM,
5908                MACHINE_IQ80321, 1, 0);
5909            me->aliases[0] = "iq80321";
5910            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5911                    me->next = first_machine_entry; first_machine_entry = me;
5912            }
5913    
5914            /*  HPCarm:  */
5915            me = machine_entry_new("Handheld SH (HPCsh)",
5916                ARCH_SH, MACHINE_HPCSH, 1, 2);
5917            me->aliases[0] = "hpcsh";
5918            me->subtype[0] = machine_entry_subtype_new("Jornada 680",
5919                MACHINE_HPCSH_JORNADA680, 1);
5920            me->subtype[0]->aliases[0] = "jornada680";
5921            me->subtype[1] = machine_entry_subtype_new(
5922                "Jornada 690", MACHINE_HPCSH_JORNADA690, 1);
5923            me->subtype[1]->aliases[0] = "jornada690";
5924            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5925                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5926          }          }
5927    
5928          /*  HPCmips:  */          /*  HPCmips:  */
5929          me = machine_entry_new("Handheld MIPS (HPC)",          me = machine_entry_new("Handheld MIPS (HPCmips)",
5930              ARCH_MIPS, MACHINE_HPCMIPS, 2, 8);              ARCH_MIPS, MACHINE_HPCMIPS, 1, 8);
5931          me->aliases[0] = "hpcmips";          me->aliases[0] = "hpcmips";
         me->aliases[1] = "hpc";  
5932          me->subtype[0] = machine_entry_subtype_new(          me->subtype[0] = machine_entry_subtype_new(
5933              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);              "Casio Cassiopeia BE-300", MACHINE_HPCMIPS_CASIO_BE300, 2);
5934          me->subtype[0]->aliases[0] = "be-300";          me->subtype[0]->aliases[0] = "be-300";
# Line 5277  void machine_init(void) Line 5961  void machine_init(void)
5961                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5962          }          }
5963    
5964            /*  HPCarm:  */
5965            me = machine_entry_new("Handheld ARM (HPCarm)",
5966                ARCH_ARM, MACHINE_HPCARM, 1, 2);
5967            me->aliases[0] = "hpcarm";
5968            me->subtype[0] = machine_entry_subtype_new("Ipaq",
5969                MACHINE_HPCARM_IPAQ, 1);
5970            me->subtype[0]->aliases[0] = "ipaq";
5971            me->subtype[1] = machine_entry_subtype_new(
5972                "Jornada 720", MACHINE_HPCARM_JORNADA720, 1);
5973            me->subtype[1]->aliases[0] = "jornada720";
5974            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
5975                    me->next = first_machine_entry; first_machine_entry = me;
5976            }
5977    
5978          /*  Generic "bare" X86 machine:  */          /*  Generic "bare" X86 machine:  */
5979          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,          me = machine_entry_new("Generic \"bare\" X86 machine", ARCH_X86,
5980              MACHINE_BAREX86, 1, 0);              MACHINE_BAREX86, 1, 0);
# Line 5285  void machine_init(void) Line 5983  void machine_init(void)
5983                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5984          }          }
5985    
         /*  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;  
         }  
   
5986          /*  Generic "bare" SPARC machine:  */          /*  Generic "bare" SPARC machine:  */
5987          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,          me = machine_entry_new("Generic \"bare\" SPARC machine", ARCH_SPARC,
5988              MACHINE_BARESPARC, 1, 0);              MACHINE_BARESPARC, 1, 0);
# Line 5301  void machine_init(void) Line 5991  void machine_init(void)
5991                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
5992          }          }
5993    
5994            /*  Generic "bare" SH machine:  */
5995            me = machine_entry_new("Generic \"bare\" SH machine", ARCH_SH,
5996                MACHINE_BARESH, 1, 0);
5997            me->aliases[0] = "baresh";
5998            if (cpu_family_ptr_by_number(ARCH_SH) != NULL) {
5999                    me->next = first_machine_entry; first_machine_entry = me;
6000            }
6001    
6002          /*  Generic "bare" PPC machine:  */          /*  Generic "bare" PPC machine:  */
6003          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,          me = machine_entry_new("Generic \"bare\" PPC machine", ARCH_PPC,
6004              MACHINE_BAREPPC, 1, 0);              MACHINE_BAREPPC, 1, 0);
# Line 5317  void machine_init(void) Line 6015  void machine_init(void)
6015                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6016          }          }
6017    
6018            /*  Generic "bare" M68K machine:  */
6019            me = machine_entry_new("Generic \"bare\" M68K machine", ARCH_M68K,
6020                MACHINE_BAREM68K, 1, 0);
6021            me->aliases[0] = "barem68k";
6022            if (cpu_family_ptr_by_number(ARCH_M68K) != NULL) {
6023                    me->next = first_machine_entry; first_machine_entry = me;
6024            }
6025    
6026            /*  Generic "bare" IA64 machine:  */
6027            me = machine_entry_new("Generic \"bare\" IA64 machine", ARCH_IA64,
6028                MACHINE_BAREIA64, 1, 0);
6029            me->aliases[0] = "bareia64";
6030            if (cpu_family_ptr_by_number(ARCH_IA64) != NULL) {
6031                    me->next = first_machine_entry; first_machine_entry = me;
6032            }
6033    
6034            /*  Generic "bare" i960 machine:  */
6035            me = machine_entry_new("Generic \"bare\" i960 machine", ARCH_I960,
6036                MACHINE_BAREI960, 1, 0);
6037            me->aliases[0] = "barei960";
6038            if (cpu_family_ptr_by_number(ARCH_I960) != NULL) {
6039                    me->next = first_machine_entry; first_machine_entry = me;
6040            }
6041    
6042          /*  Generic "bare" HPPA machine:  */          /*  Generic "bare" HPPA machine:  */
6043          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,          me = machine_entry_new("Generic \"bare\" HPPA machine", ARCH_HPPA,
6044              MACHINE_BAREHPPA, 1, 0);              MACHINE_BAREHPPA, 1, 0);
# Line 5325  void machine_init(void) Line 6047  void machine_init(void)
6047                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6048          }          }
6049    
6050            /*  Generic "bare" Atmel AVR machine:  */
6051            me = machine_entry_new("Generic \"bare\" Atmel AVR machine", ARCH_AVR,
6052                MACHINE_BAREAVR, 1, 0);
6053            me->aliases[0] = "bareavr";
6054            if (cpu_family_ptr_by_number(ARCH_AVR) != NULL) {
6055                    me->next = first_machine_entry; first_machine_entry = me;
6056            }
6057    
6058            /*  Generic "bare" ARM machine:  */
6059            me = machine_entry_new("Generic \"bare\" ARM machine", ARCH_ARM,
6060                MACHINE_BAREARM, 1, 0);
6061            me->aliases[0] = "barearm";
6062            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6063                    me->next = first_machine_entry; first_machine_entry = me;
6064            }
6065    
6066          /*  Generic "bare" Alpha machine:  */          /*  Generic "bare" Alpha machine:  */
6067          me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA,          me = machine_entry_new("Generic \"bare\" Alpha machine", ARCH_ALPHA,
6068              MACHINE_BAREALPHA, 1, 0);              MACHINE_BAREALPHA, 1, 0);
# Line 5333  void machine_init(void) Line 6071  void machine_init(void)
6071                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6072          }          }
6073    
6074            /*  Evaluation Boards (MALTA etc):  */
6075            me = machine_entry_new("Evaluation boards (evbmips)", ARCH_MIPS,
6076                MACHINE_EVBMIPS, 1, 3);
6077            me->aliases[0] = "evbmips";
6078            me->subtype[0] = machine_entry_subtype_new("Malta",
6079                MACHINE_EVBMIPS_MALTA, 1);
6080            me->subtype[0]->aliases[0] = "malta";
6081            me->subtype[1] = machine_entry_subtype_new("Malta (Big-Endian)",
6082                MACHINE_EVBMIPS_MALTA_BE, 1);
6083            me->subtype[1]->aliases[0] = "maltabe";
6084            me->subtype[2] = machine_entry_subtype_new("PB1000",
6085                MACHINE_EVBMIPS_PB1000, 1);
6086            me->subtype[2]->aliases[0] = "pb1000";
6087            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
6088                    me->next = first_machine_entry; first_machine_entry = me;
6089            }
6090    
6091            /*  Digital DNARD ("Shark"):  */
6092            me = machine_entry_new("Digital DNARD (\"Shark\")", ARCH_ARM,
6093                MACHINE_SHARK, 2, 0);
6094            me->aliases[0] = "shark";
6095            me->aliases[1] = "dnard";
6096            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6097                    me->next = first_machine_entry; first_machine_entry = me;
6098            }
6099    
6100          /*  DECstation:  */          /*  DECstation:  */
6101          me = machine_entry_new("DECstation/DECsystem",          me = machine_entry_new("DECstation/DECsystem",
6102              ARCH_MIPS, MACHINE_DEC, 3, 9);              ARCH_MIPS, MACHINE_DEC, 3, 9);
# Line 5400  void machine_init(void) Line 6164  void machine_init(void)
6164                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6165          }          }
6166    
6167            /*  CATS (ARM) evaluation board:  */
6168            me = machine_entry_new("CATS evaluation board (ARM)", ARCH_ARM,
6169                MACHINE_CATS, 1, 0);
6170            me->aliases[0] = "cats";
6171            if (cpu_family_ptr_by_number(ARCH_ARM) != NULL) {
6172                    me->next = first_machine_entry; first_machine_entry = me;
6173            }
6174    
6175          /*  BeBox: (NetBSD/bebox)  */          /*  BeBox: (NetBSD/bebox)  */
6176          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);          me = machine_entry_new("BeBox", ARCH_PPC, MACHINE_BEBOX, 1, 0);
6177          me->aliases[0] = "bebox";          me->aliases[0] = "bebox";
# Line 5464  void machine_init(void) Line 6236  void machine_init(void)
6236          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {          if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
6237                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
6238          }          }
6239    
6240            /*  Alpha:  */
6241            me = machine_entry_new("Alpha", ARCH_ALPHA, MACHINE_ALPHA, 1, 2);
6242            me->aliases[0] = "alpha";
6243            me->subtype[0] = machine_entry_subtype_new(
6244                "DEC 3000/300", ST_DEC_3000_300, 1);
6245            me->subtype[0]->aliases[0] = "3000/300";
6246            me->subtype[1] = machine_entry_subtype_new(
6247                "EB164", ST_EB164, 1);
6248            me->subtype[1]->aliases[0] = "eb164";
6249            if (cpu_family_ptr_by_number(ARCH_ALPHA) != NULL) {
6250                    me->next = first_machine_entry; first_machine_entry = me;
6251            }
6252  }  }
6253    

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

  ViewVC Help
Powered by ViewVC 1.1.26