/[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 9 by dpavlin, Mon Oct 8 16:18:19 2007 UTC revision 10 by dpavlin, Mon Oct 8 16:18:27 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: machine.c,v 1.453 2005/06/12 12:31:54 debug Exp $   *  $Id: machine.c,v 1.470 2005/06/26 11:36:28 debug Exp $
29   *   *
30   *  Emulation of specific machines.   *  Emulation of specific machines.
31   *   *
# Line 83  Line 83 
83  #include "hpc_bootinfo.h"  #include "hpc_bootinfo.h"
84  #include "vripreg.h"  #include "vripreg.h"
85    
86    #define BOOTSTR_BUFLEN          1000
87    #define BOOTARG_BUFLEN          2000
88    #define ETHERNET_STRING_MAXLEN  40
89    
90  struct machine_entry_subtype {  struct machine_entry_subtype {
91          int                     machine_subtype;/*  Old-style subtype  */          int                     machine_subtype;/*  Old-style subtype  */
# Line 137  struct machine *machine_new(char *name, Line 140  struct machine *machine_new(char *name,
140          m->name = strdup(name);          m->name = strdup(name);
141    
142          /*  Sane default values:  */          /*  Sane default values:  */
143          m->serial_nr = 0;          m->serial_nr = 1;
144          m->machine_type = MACHINE_NONE;          m->machine_type = MACHINE_NONE;
145          m->machine_subtype = MACHINE_NONE;          m->machine_subtype = MACHINE_NONE;
146    #ifdef BINTRANS
147          m->bintrans_enable = 1;          m->bintrans_enable = 1;
148            m->old_bintrans_enable = 1;
149    #endif
150          m->prom_emulation = 1;          m->prom_emulation = 1;
151          m->speed_tricks = 1;          m->speed_tricks = 1;
152          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;          m->byte_order_override = NO_BYTE_ORDER_OVERRIDE;
# Line 1053  void sgi_ip32_interrupt(struct machine * Line 1059  void sgi_ip32_interrupt(struct machine *
1059           *  interrupt 2 should be asserted.           *  interrupt 2 should be asserted.
1060           *           *
1061           *  TODO:  how should all this be done nicely?           *  TODO:  how should all this be done nicely?
          *  
          *  TODO:  mace interrupt mask  
1062           */           */
1063    
1064          uint64_t crime_addr = CRIME_INTSTAT;          uint64_t crime_addr = CRIME_INTSTAT;
1065          uint64_t mace_addr = 0x14;          uint64_t mace_addr = 0x10;
1066          uint64_t crime_interrupts, crime_interrupts_mask, mace_interrupts;          uint64_t crime_interrupts, crime_interrupts_mask;
1067            uint64_t mace_interrupts, mace_interrupt_mask;
1068          unsigned int i;          unsigned int i;
1069          unsigned char x[8];          unsigned char x[8];
1070    
1071            /*  Read current MACE interrupt assertions:  */
1072            memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr,
1073                sizeof(uint64_t));
1074            mace_interrupts = 0;
1075            for (i=0; i<sizeof(uint64_t); i++) {
1076                    mace_interrupts <<= 8;
1077                    mace_interrupts |= x[i];
1078            }
1079    
1080            /*  Read current MACE interrupt mask:  */
1081            memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr + 8,
1082                sizeof(uint64_t));
1083            mace_interrupt_mask = 0;
1084            for (i=0; i<sizeof(uint64_t); i++) {
1085                    mace_interrupt_mask <<= 8;
1086                    mace_interrupt_mask |= x[i];
1087            }
1088    
1089          /*          /*
1090           *  This mapping of both MACE and CRIME interrupts into the same           *  This mapping of both MACE and CRIME interrupts into the same
1091           *  'int' is really ugly.           *  'int' is really ugly.
# Line 1074  void sgi_ip32_interrupt(struct machine * Line 1097  void sgi_ip32_interrupt(struct machine *
1097           *  TODO: fix.           *  TODO: fix.
1098           */           */
1099          if (irq_nr & MACE_PERIPH_SERIAL) {          if (irq_nr & MACE_PERIPH_SERIAL) {
                 /*  Read current MACE interrupt bits:  */  
                 memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr, sizeof(uint32_t));  
                 mace_interrupts = 0;  
                 for (i=0; i<sizeof(uint32_t); i++) {  
                         /*  SGI is big-endian...  */  
                         mace_interrupts <<= 8;  
                         mace_interrupts |= x[i];  
                 }  
   
1100                  if (assrt)                  if (assrt)
1101                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_SERIAL);                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_SERIAL);
1102                  else                  else
1103                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_SERIAL);                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_SERIAL);
1104    
                 /*  Write back MACE interrupt bits:  */  
                 for (i=0; i<4; i++)  
                         x[3-i] = mace_interrupts >> (i*8);  
                 memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint32_t));  
   
1105                  irq_nr = MACE_PERIPH_SERIAL;                  irq_nr = MACE_PERIPH_SERIAL;
1106                  if (mace_interrupts == 0)                  if ((mace_interrupts & mace_interrupt_mask) == 0)
1107                          assrt = 0;                          assrt = 0;
1108                  else                  else
1109                          assrt = 1;                          assrt = 1;
# Line 1102  void sgi_ip32_interrupt(struct machine * Line 1111  void sgi_ip32_interrupt(struct machine *
1111    
1112          /*  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.  */
1113          if (irq_nr & MACE_PERIPH_MISC) {          if (irq_nr & MACE_PERIPH_MISC) {
                 /*  Read current MACE interrupt bits:  */  
                 memcpy(x, m->md_int.ip32.mace_data->reg + mace_addr, sizeof(uint32_t));  
                 mace_interrupts = 0;  
                 for (i=0; i<sizeof(uint32_t); i++) {  
                         /*  SGI is big-endian...  */  
                         mace_interrupts <<= 8;  
                         mace_interrupts |= x[i];  
                 }  
   
1114                  if (assrt)                  if (assrt)
1115                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_MISC);                          mace_interrupts |= (irq_nr & ~MACE_PERIPH_MISC);
1116                  else                  else
1117                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_MISC);                          mace_interrupts &= ~(irq_nr & ~MACE_PERIPH_MISC);
1118    
                 /*  Write back MACE interrupt bits:  */  
                 for (i=0; i<4; i++)  
                         x[3-i] = mace_interrupts >> (i*8);  
                 memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint32_t));  
   
1119                  irq_nr = MACE_PERIPH_MISC;                  irq_nr = MACE_PERIPH_MISC;
1120                  if (mace_interrupts == 0)                  if ((mace_interrupts & mace_interrupt_mask) == 0)
1121                          assrt = 0;                          assrt = 0;
1122                  else                  else
1123                          assrt = 1;                          assrt = 1;
1124          }          }
1125    
1126            /*  Write back MACE interrupt assertions:  */
1127            for (i=0; i<sizeof(uint64_t); i++)
1128                    x[7-i] = mace_interrupts >> (i*8);
1129            memcpy(m->md_int.ip32.mace_data->reg + mace_addr, x, sizeof(uint64_t));
1130    
1131          /*  Read CRIME_INTSTAT:  */          /*  Read CRIME_INTSTAT:  */
1132          memcpy(x, m->md_int.ip32.crime_data->reg + crime_addr, sizeof(uint64_t));          memcpy(x, m->md_int.ip32.crime_data->reg + crime_addr,
1133                sizeof(uint64_t));
1134          crime_interrupts = 0;          crime_interrupts = 0;
1135          for (i=0; i<8; i++) {          for (i=0; i<sizeof(uint64_t); i++) {
                 /*  SGI is big-endian...  */  
1136                  crime_interrupts <<= 8;                  crime_interrupts <<= 8;
1137                  crime_interrupts |= x[i];                  crime_interrupts |= x[i];
1138          }          }
# Line 1143  void sgi_ip32_interrupt(struct machine * Line 1143  void sgi_ip32_interrupt(struct machine *
1143                  crime_interrupts &= ~irq_nr;                  crime_interrupts &= ~irq_nr;
1144    
1145          /*  Write back CRIME_INTSTAT:  */          /*  Write back CRIME_INTSTAT:  */
1146          for (i=0; i<8; i++)          for (i=0; i<sizeof(uint64_t); i++)
1147                  x[7-i] = crime_interrupts >> (i*8);                  x[7-i] = crime_interrupts >> (i*8);
1148          memcpy(m->md_int.ip32.crime_data->reg + crime_addr, x, sizeof(uint64_t));          memcpy(m->md_int.ip32.crime_data->reg + crime_addr, x,
1149                sizeof(uint64_t));
1150    
1151          /*  Read CRIME_INTMASK:  */          /*  Read CRIME_INTMASK:  */
1152          memcpy(x, m->md_int.ip32.crime_data->reg + CRIME_INTMASK, sizeof(uint64_t));          memcpy(x, m->md_int.ip32.crime_data->reg + CRIME_INTMASK,
1153                sizeof(uint64_t));
1154          crime_interrupts_mask = 0;          crime_interrupts_mask = 0;
1155          for (i=0; i<8; i++) {          for (i=0; i<sizeof(uint64_t); i++) {
1156                  crime_interrupts_mask <<= 8;                  crime_interrupts_mask <<= 8;
1157                  crime_interrupts_mask |= x[i];                  crime_interrupts_mask |= x[i];
1158          }          }
# Line 1160  void sgi_ip32_interrupt(struct machine * Line 1162  void sgi_ip32_interrupt(struct machine *
1162          else          else
1163                  cpu_interrupt(cpu, 2);                  cpu_interrupt(cpu, 2);
1164    
1165          /*  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",
1166                assrt, irq_nr, crime_interrupts);  */
1167  }  }
1168    
1169    
# Line 1213  void au1x00_interrupt(struct machine *m, Line 1216  void au1x00_interrupt(struct machine *m,
1216    
1217    
1218  /*  /*
1219     *  Malta (evbmips) interrupts:
1220     *
1221     *  ISA interrupts.
1222     *  (irq_nr = 16+8 can be used to just reassert/deassert interrupts.)
1223     */
1224    void malta_interrupt(struct machine *m, struct cpu *cpu, int irq_nr,
1225            int assrt)
1226    {
1227            int mask;
1228    
1229            irq_nr -= 8;
1230            mask = 1 << (irq_nr & 7);
1231    
1232            if (irq_nr < 8) {
1233                    if (assrt)
1234                            m->md_int.malta_data->assert_lo |= mask;
1235                    else
1236                            m->md_int.malta_data->assert_lo &= ~mask;
1237            } else if (irq_nr < 16) {
1238                    if (assrt)
1239                            m->md_int.malta_data->assert_hi |= mask;
1240                    else
1241                            m->md_int.malta_data->assert_hi &= ~mask;
1242            }
1243    
1244            /*  Any interrupt assertions on PIC2 go to irq 2 on PIC1  */
1245            if (m->md_int.malta_data->assert_hi &
1246                ~m->md_int.malta_data->disable_hi)
1247                    m->md_int.malta_data->assert_lo |= 0x04;
1248            else
1249                    m->md_int.malta_data->assert_lo &= ~0x04;
1250    
1251            /*  Now, PIC1:  */
1252            if (m->md_int.malta_data->assert_lo &
1253                ~m->md_int.malta_data->disable_lo)
1254                    cpu_interrupt(cpu, 2);
1255            else
1256                    cpu_interrupt_ack(cpu, 2);
1257    }
1258    
1259    
1260    /*
1261   *  x86 (PC) interrupts:   *  x86 (PC) interrupts:
1262   *   *
1263   *  (irq_nr = 16 can be used to just reassert/deassert interrupts.)   *  (irq_nr = 16 can be used to just reassert/deassert interrupts.)
# Line 1358  void machine_setup(struct machine *machi Line 1403  void machine_setup(struct machine *machi
1403    
1404          case MACHINE_TESTMIPS:          case MACHINE_TESTMIPS:
1405                  /*                  /*
1406                   *  A MIPS test machine (which happens to work with my                   *  A MIPS test machine (which happens to work with the
1407                   *  thesis work).                   *  code in my master's thesis).  :-)
1408                   */                   */
1409                  cpu->byte_order = EMUL_BIG_ENDIAN;                  cpu->byte_order = EMUL_BIG_ENDIAN;
1410                  machine->machine_name = "MIPS test machine";                  machine->machine_name = "MIPS test machine";
# Line 1927  void machine_setup(struct machine *machi Line 1972  void machine_setup(struct machine *machi
1972    
1973  #if 0  #if 0
1974                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)                          if (machine->machine_subtype == MACHINE_DEC_PMAX_3100)
1975                                  strcpy(bootpath, "rz(0,0,0)");                                  strlcpy(bootpath, "rz(0,0,0)", sizeof(bootpath));
1976                          else                          else
1977  #endif  #endif
1978                                  strcpy(bootpath, "5/rz1/");                                  strlcpy(bootpath, "5/rz1/", sizeof(bootpath));
1979    
1980                          if (bootdev_id < 0 || machine->force_netboot) {                          if (bootdev_id < 0 || machine->force_netboot) {
1981                                  /*  tftp boot:  */                                  /*  tftp boot:  */
1982                                  strcpy(bootpath, "5/tftp/");                                  strlcpy(bootpath, "5/tftp/", sizeof(bootpath));
1983                                  bootpath[0] = '0' + boot_net_boardnumber;                                  bootpath[0] = '0' + boot_net_boardnumber;
1984                          } else {                          } else {
1985                                  /*  disk boot:  */                                  /*  disk boot:  */
# Line 1948  void machine_setup(struct machine *machi Line 1993  void machine_setup(struct machine *machi
1993                          init_bootpath = bootpath;                          init_bootpath = bootpath;
1994                  }                  }
1995    
1996                  bootarg = malloc(strlen(init_bootpath) +                  bootarg = malloc(BOOTARG_BUFLEN);
1997                      strlen(machine->boot_kernel_filename) + 1 +                  if (bootarg == NULL) {
1998                      strlen(machine->boot_string_argument) + 1);                          fprintf(stderr, "out of memory\n");
1999                  strcpy(bootarg, init_bootpath);                          exit(1);
2000                  strcat(bootarg, machine->boot_kernel_filename);                  }
2001                    strlcpy(bootarg, init_bootpath, BOOTARG_BUFLEN);
2002                    if (strlcat(bootarg, machine->boot_kernel_filename,
2003                        BOOTARG_BUFLEN) > BOOTARG_BUFLEN) {
2004                            fprintf(stderr, "bootarg truncated?\n");
2005                            exit(1);
2006                    }
2007    
2008                  bootstr = "boot";                  bootstr = "boot";
2009    
# Line 1967  void machine_setup(struct machine *machi Line 2018  void machine_setup(struct machine *machi
2018                          cpu->cd.mips.gpr[MIPS_GPR_A0] --;                          cpu->cd.mips.gpr[MIPS_GPR_A0] --;
2019    
2020                  if (machine->boot_string_argument[0] != '\0') {                  if (machine->boot_string_argument[0] != '\0') {
2021                          strcat(bootarg, " ");                          strlcat(bootarg, " ", BOOTARG_BUFLEN);
2022                          strcat(bootarg, machine->boot_string_argument);                          if (strlcat(bootarg, machine->boot_string_argument,
2023                                BOOTARG_BUFLEN) >= BOOTARG_BUFLEN) {
2024                                    fprintf(stderr, "bootstr truncated?\n");
2025                                    exit(1);
2026                            }
2027                  }                  }
2028    
2029                  xx.a.common.next = (char *)&xx.b - (char *)&xx;                  xx.a.common.next = (char *)&xx.b - (char *)&xx;
# Line 1977  void machine_setup(struct machine *machi Line 2032  void machine_setup(struct machine *machi
2032    
2033                  xx.b.common.next = (char *)&xx.c - (char *)&xx.b;                  xx.b.common.next = (char *)&xx.c - (char *)&xx.b;
2034                  xx.b.common.type = BTINFO_BOOTPATH;                  xx.b.common.type = BTINFO_BOOTPATH;
2035                  strcpy(xx.b.bootpath, bootstr);                  strlcpy(xx.b.bootpath, bootstr, sizeof(xx.b.bootpath));
2036    
2037                  xx.c.common.next = 0;                  xx.c.common.next = 0;
2038                  xx.c.common.type = BTINFO_SYMTAB;                  xx.c.common.type = BTINFO_SYMTAB;
# Line 2018  void machine_setup(struct machine *machi Line 2073  void machine_setup(struct machine *machi
2073                   */                   */
2074                  {                  {
2075                          char tmps[300];                          char tmps[300];
2076                          sprintf(tmps, "cca=%x",                          snprintf(tmps, sizeof(tmps), "cca=%x",
2077                              (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));                              (int)(DEC_DECCCA_BASEADDR + 0xa0000000ULL));
2078                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, tmps, &addr);
2079                  }                  }
2080    
2081                  /*  These are needed for Sprite to boot:  */                  /*  These are needed for Sprite to boot:  */
2082                  {                  {
2083                          char tmps[300];                          char tmps[500];
2084    
2085                          sprintf(tmps, "boot=%s", bootarg);                          snprintf(tmps, sizeof(tmps), "boot=%s", bootarg);
2086                            tmps[sizeof(tmps)-1] = '\0';
2087                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, tmps, &addr);
2088    
2089                          sprintf(tmps, "bitmap=0x%x", (uint32_t)((                          snprintf(tmps, sizeof(tmps), "bitmap=0x%x", (uint32_t)((
2090                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))                              DEC_MEMMAP_ADDR + sizeof(memmap.pagesize))
2091                              & 0xffffffffULL));                              & 0xffffffffULL));
2092                            tmps[sizeof(tmps)-1] = '\0';
2093                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, tmps, &addr);
2094    
2095                          sprintf(tmps, "bitmaplen=0x%x",                          snprintf(tmps, sizeof(tmps), "bitmaplen=0x%x",
2096                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);                              machine->physical_ram_in_mb * 1048576 / 4096 / 8);
2097                            tmps[sizeof(tmps)-1] = '\0';
2098                          add_environment_string(cpu, tmps, &addr);                          add_environment_string(cpu, tmps, &addr);
2099                  }                  }
2100    
# Line 2095  void machine_setup(struct machine *machi Line 2153  void machine_setup(struct machine *machi
2153                   *  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
2154                   *  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
2155                   */                   */
2156                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 6); /*  7 for PCI, not 6?  */                  pci_data = dev_gt_init(machine, mem, 0x14000000, 2, 6, 11);     /*  7 for PCI, not 6?  */
2157                  /*  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);  */
2158                  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  */
2159                  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);
# Line 2519  void machine_setup(struct machine *machi Line 2577  void machine_setup(struct machine *machi
2577                                  exit(1);                                  exit(1);
2578                          }                          }
2579    
2580                          strcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60");                          strlcpy(tmp, "root=/dev/hda1 crtmode=vesa0,60", tmplen);
2581    
2582                          if (machine->boot_string_argument[0])                          if (machine->boot_string_argument[0])
2583                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),                                  snprintf(tmp+strlen(tmp), tmplen-strlen(tmp),
# Line 2562  void machine_setup(struct machine *machi Line 2620  void machine_setup(struct machine *machi
2620                   *  detailed list of IP ("Inhouse Processor") model numbers.                   *  detailed list of IP ("Inhouse Processor") model numbers.
2621                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)                   *  (Or http://hardware.majix.org/computers/sgi/iptable.shtml)
2622                   */                   */
2623                  machine->machine_name = malloc(500);                  machine->machine_name = malloc(MACHINE_NAME_MAXBUF);
2624                  if (machine->machine_name == NULL) {                  if (machine->machine_name == NULL) {
2625                          fprintf(stderr, "out of memory\n");                          fprintf(stderr, "out of memory\n");
2626                          exit(1);                          exit(1);
# Line 2570  void machine_setup(struct machine *machi Line 2628  void machine_setup(struct machine *machi
2628    
2629                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2630                          cpu->byte_order = EMUL_BIG_ENDIAN;                          cpu->byte_order = EMUL_BIG_ENDIAN;
2631                          sprintf(machine->machine_name, "SGI-IP%i", machine->machine_subtype);                          snprintf(machine->machine_name, MACHINE_NAME_MAXBUF,
2632                                "SGI-IP%i", machine->machine_subtype);
2633    
2634                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;                          sgi_ram_offset = 1048576 * machine->memory_offset_in_mb;
2635    
# Line 2588  void machine_setup(struct machine *machi Line 2647  void machine_setup(struct machine *machi
2647                          }                          }
2648                  } else {                  } else {
2649                          cpu->byte_order = EMUL_LITTLE_ENDIAN;                          cpu->byte_order = EMUL_LITTLE_ENDIAN;
2650                          sprintf(machine->machine_name, "ARC");                          snprintf(machine->machine_name,
2651                                MACHINE_NAME_MAXBUF, "ARC");
2652                  }                  }
2653    
2654                  if (machine->machine_type == MACHINE_SGI) {                  if (machine->machine_type == MACHINE_SGI) {
2655                          /*  TODO:  Other SGI machine types?  */                          /*  TODO:  Other SGI machine types?  */
2656                          switch (machine->machine_subtype) {                          switch (machine->machine_subtype) {
2657                          case 12:                          case 12:
2658                                  strcat(machine->machine_name, " (Iris Indigo IP12)");                                  strlcat(machine->machine_name,
2659                                        " (Iris Indigo IP12)", MACHINE_NAME_MAXBUF);
2660    
2661                                  /*  TODO  */                                  /*  TODO  */
2662                                  /*  33 MHz R3000, according to http://www.irisindigo.com/  */                                  /*  33 MHz R3000, according to http://www.irisindigo.com/  */
# Line 2603  void machine_setup(struct machine *machi Line 2664  void machine_setup(struct machine *machi
2664    
2665                                  break;                                  break;
2666                          case 19:                          case 19:
2667                                  strcat(machine->machine_name, " (Everest IP19)");                                  strlcat(machine->machine_name,
2668                                        " (Everest IP19)", MACHINE_NAME_MAXBUF);
2669                                  machine->main_console_handle =                                  machine->main_console_handle =
2670                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */                                      dev_zs_init(machine, mem, 0x1fbd9830, 0, 1, "serial zs");   /*  serial? netbsd?  */
2671                                  dev_scc_init(machine, mem, 0x10086000, 0, machine->use_x11, 0, 8);      /*  serial? irix?  */                                  dev_scc_init(machine, mem, 0x10086000, 0, machine->use_x11, 0, 8);      /*  serial? irix?  */
# Line 2623  void machine_setup(struct machine *machi Line 2685  void machine_setup(struct machine *machi
2685    
2686                                  break;                                  break;
2687                          case 20:                          case 20:
2688                                  strcat(machine->machine_name, " (Indigo)");                                  strlcat(machine->machine_name,
2689                                        " (Indigo)", MACHINE_NAME_MAXBUF);
2690    
2691                                  /*                                  /*
2692                                   *  Guesses based on NetBSD 2.0 beta, 20040606.                                   *  Guesses based on NetBSD 2.0 beta, 20040606.
# Line 2668  void machine_setup(struct machine *machi Line 2731  void machine_setup(struct machine *machi
2731    
2732                                  break;                                  break;
2733                          case 21:                          case 21:
2734                                  strcat(machine->machine_name, " (uknown SGI-IP21 ?)");  /*  TODO  */                                  strlcat(machine->machine_name,  /*  TODO  */
2735                                        " (uknown SGI-IP21 ?)", MACHINE_NAME_MAXBUF);
2736                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2737                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2738    
# Line 2678  void machine_setup(struct machine *machi Line 2742  void machine_setup(struct machine *machi
2742                          case 22:                          case 22:
2743                          case 24:                          case 24:
2744                                  if (machine->machine_subtype == 22) {                                  if (machine->machine_subtype == 22) {
2745                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Full-house)");                                          strlcat(machine->machine_name,
2746                                                " (Indy, Indigo2, Challenge S; Full-house)",
2747                                                MACHINE_NAME_MAXBUF);
2748                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9000, 0);
2749                                  } else {                                  } else {
2750                                          strcat(machine->machine_name, " (Indy, Indigo2, Challenge S; Guiness)");                                          strlcat(machine->machine_name,
2751                                                " (Indy, Indigo2, Challenge S; Guiness)",
2752                                                MACHINE_NAME_MAXBUF);
2753                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);                                          machine->md_int.sgi_ip22_data = dev_sgi_ip22_init(machine, mem, 0x1fbd9880, 1);
2754                                  }                                  }
2755    
# Line 2754  Why is this here? TODO Line 2822  Why is this here? TODO
2822                          case 25:                          case 25:
2823                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2824                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2825                                  strcat(machine->machine_name, " (Everest IP25)");                                  strlcat(machine->machine_name,
2826                                        " (Everest IP25)", MACHINE_NAME_MAXBUF);
2827    
2828                                   /*  serial? irix?  */                                   /*  serial? irix?  */
2829                                  dev_scc_init(machine, mem,                                  dev_scc_init(machine, mem,
# Line 2775  Why is this here? TODO Line 2844  Why is this here? TODO
2844                          case 26:                          case 26:
2845                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2846                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2847                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
2848                                      " (uknown SGI-IP26 ?)");    /*  TODO  */                                      " (uknown SGI-IP26 ?)",
2849                                        MACHINE_NAME_MAXBUF);       /*  TODO  */
2850                                  machine->main_console_handle =                                  machine->main_console_handle =
2851                                      dev_zs_init(machine, mem, 0x1fbd9830,                                      dev_zs_init(machine, mem, 0x1fbd9830,
2852                                      0, 1, "zs console");                                      0, 1, "zs console");
2853                                  break;                                  break;
2854                          case 27:                          case 27:
2855                                  strcat(machine->machine_name,                                  strlcat(machine->machine_name,
2856                                      " (Origin 200/2000, Onyx2)");                                      " (Origin 200/2000, Onyx2)",
2857                                        MACHINE_NAME_MAXBUF);
2858                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2859                                  /*  2 cpus per node  */                                  /*  2 cpus per node  */
2860    
# Line 2794  Why is this here? TODO Line 2865  Why is this here? TODO
2865                          case 28:                          case 28:
2866                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2867                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2868                                  strcat(machine->machine_name, " (Impact Indigo2 ?)");                                  strlcat(machine->machine_name,
2869                                        " (Impact Indigo2 ?)", MACHINE_NAME_MAXBUF);
2870    
2871                                  device_add(machine, "random addr=0x1fbe0000, len=1");                                  device_add(machine, "random addr=0x1fbe0000, len=1");
2872    
# Line 2804  Why is this here? TODO Line 2876  Why is this here? TODO
2876                          case 30:                          case 30:
2877                                  /*  NOTE:  Special case for arc_wordlen:  */                                  /*  NOTE:  Special case for arc_wordlen:  */
2878                                  arc_wordlen = sizeof(uint64_t);                                  arc_wordlen = sizeof(uint64_t);
2879                                  strcat(machine->machine_name, " (Octane)");                                  strlcat(machine->machine_name,
2880                                        " (Octane)", MACHINE_NAME_MAXBUF);
2881    
2882                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);                                  machine->md_int.sgi_ip30_data = dev_sgi_ip30_init(machine, mem, 0x0ff00000);
2883                                  machine->md_interrupt = sgi_ip30_interrupt;                                  machine->md_interrupt = sgi_ip30_interrupt;
# Line 2838  Why is this here? TODO Line 2911  Why is this here? TODO
2911    
2912                                  break;                                  break;
2913                          case 32:                          case 32:
2914                                  strcat(machine->machine_name, " (O2)");                                  strlcat(machine->machine_name,
2915                                        " (O2)", MACHINE_NAME_MAXBUF);
2916    
2917                                  /*  TODO:  Find out where the physical ram is actually located.  */                                  /*  TODO:  Find out where the physical ram is actually located.  */
2918                                  dev_ram_init(mem, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);                                  dev_ram_init(mem, 0x07ffff00ULL,           256, DEV_RAM_MIRROR, 0x03ffff00);
# Line 2893  Why is this here? TODO Line 2967  Why is this here? TODO
2967                                   *  intr 7 = MACE_PCI_BRIDGE                                   *  intr 7 = MACE_PCI_BRIDGE
2968                                   */                                   */
2969    
2970    #if 0
2971                                  i = dev_pckbc_init(machine, mem, 0x1f320000,                                  i = dev_pckbc_init(machine, mem, 0x1f320000,
2972                                      PCKBC_8242, 0x200 + MACE_PERIPH_MISC,                                      PCKBC_8242, 0x200 + MACE_PERIPH_MISC,
2973                                      0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);                                      0x800 + MACE_PERIPH_MISC, machine->use_x11, 0);
2974                                                          /*  keyb+mouse (mace irq numbers)  */                                                          /*  keyb+mouse (mace irq numbers)  */
2975    #endif
2976    
2977                                  net_generate_unique_mac(machine, macaddr);                                  net_generate_unique_mac(machine, macaddr);
2978                                  eaddr_string = malloc(30);                                  eaddr_string = malloc(ETHERNET_STRING_MAXLEN);
2979                                  if (eaddr_string == NULL) {                                  if (eaddr_string == NULL) {
2980                                          fprintf(stderr, "out of memory\n");                                          fprintf(stderr, "out of memory\n");
2981                                          exit(1);                                          exit(1);
2982                                  }                                  }
2983                                  sprintf(eaddr_string, "eaddr=%02x:%02x:"                                  snprintf(eaddr_string, ETHERNET_STRING_MAXLEN,
2984                                      "%02x:%02x:%02x:%02x",                                      "eaddr=%02x:%02x:%02x:%02x:%02x:%02x",
2985                                      macaddr[0], macaddr[1], macaddr[2],                                      macaddr[0], macaddr[1], macaddr[2],
2986                                      macaddr[3], macaddr[4], macaddr[5]);                                      macaddr[3], macaddr[4], macaddr[5]);
2987                                  dev_sgi_mec_init(machine, mem, 0x1f280000, MACE_ETHERNET, macaddr);                                  dev_sgi_mec_init(machine, mem, 0x1f280000,
2988                                        MACE_ETHERNET, macaddr);
2989    
2990                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */                                  dev_sgi_ust_init(mem, 0x1f340000);  /*  ust?  */
2991    
# Line 2919  Why is this here? TODO Line 2996  Why is this here? TODO
2996                                      (1<<26) + MACE_PERIPH_SERIAL, 0x100,                                      (1<<26) + MACE_PERIPH_SERIAL, 0x100,
2997                                      0, "serial 1");                             /*  com1  */                                      0, "serial 1");                             /*  com1  */
2998    
2999    #if 0
3000                                  if (machine->use_x11)                                  if (machine->use_x11)
3001                                          machine->main_console_handle = i;                                          machine->main_console_handle = i;
3002                                  else                                  else
3003    #endif
3004                                          machine->main_console_handle = j;                                          machine->main_console_handle = j;
3005    
3006                                  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  */
# Line 2954  Why is this here? TODO Line 3033  Why is this here? TODO
3033    
3034                                  break;                                  break;
3035                          case 35:                          case 35:
3036                                  strcat(machine->machine_name, " (Origin 3000)");                                  strlcat(machine->machine_name,
3037                                        " (Origin 3000)", MACHINE_NAME_MAXBUF);
3038                                  /*  4 cpus per node  */                                  /*  4 cpus per node  */
3039    
3040                                  machine->main_console_handle =                                  machine->main_console_handle =
# Line 2962  Why is this here? TODO Line 3042  Why is this here? TODO
3042                                      0, 1, "zs console");                                      0, 1, "zs console");
3043                                  break;                                  break;
3044                          case 53:                          case 53:
3045                                  strcat(machine->machine_name, " (Origin 350)");                                  strlcat(machine->machine_name,
3046                                        " (Origin 350)", MACHINE_NAME_MAXBUF);
3047                                  /*                                  /*
3048                                   *  According to http://kumba.drachentekh.net/xml/myguide.html                                   *  According to http://kumba.drachentekh.net/xml/myguide.html
3049                                   *  Origin 350, Tezro IP53 R16000                                   *  Origin 350, Tezro IP53 R16000
# Line 2989  Why is this here? TODO Line 3070  Why is this here? TODO
3070    
3071                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3072                                  case MACHINE_ARC_NEC_RD94:                                  case MACHINE_ARC_NEC_RD94:
3073                                          strcat(machine->machine_name, " (NEC-RD94, NEC RISCstation 2250)");                                          strlcat(machine->machine_name,
3074                                                " (NEC-RD94, NEC RISCstation 2250)",
3075                                                MACHINE_NAME_MAXBUF);
3076                                          break;                                          break;
3077                                  case MACHINE_ARC_NEC_R94:                                  case MACHINE_ARC_NEC_R94:
3078                                          strcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)");                                          strlcat(machine->machine_name, " (NEC-R94; NEC RISCstation 2200)",
3079                                                MACHINE_NAME_MAXBUF);
3080                                          break;                                          break;
3081                                  case MACHINE_ARC_NEC_R96:                                  case MACHINE_ARC_NEC_R96:
3082                                          strcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)");                                          strlcat(machine->machine_name, " (NEC-R96; NEC Express RISCserver)",
3083                                                MACHINE_NAME_MAXBUF);
3084                                          break;                                          break;
3085                                  }                                  }
3086    
# Line 3049  Why is this here? TODO Line 3134  Why is this here? TODO
3134                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"                                   *  Parallel at "start: 0x 0 18c10278, length: 0x1000, level: 5, vector: 5"
3135                                   */                                   */
3136    
3137                                  strcat(machine->machine_name, " (NEC-R98; NEC RISCserver 4200)");                                  strlcat(machine->machine_name,
3138                                        " (NEC-R98; NEC RISCserver 4200)",
3139                                        MACHINE_NAME_MAXBUF);
3140    
3141                                  /*                                  /*
3142                                   *  Windows NT access stuff at these addresses:                                   *  Windows NT access stuff at these addresses:
# Line 3105  Why is this here? TODO Line 3192  Why is this here? TODO
3192    
3193                                  switch (machine->machine_subtype) {                                  switch (machine->machine_subtype) {
3194                                  case MACHINE_ARC_JAZZ_PICA:                                  case MACHINE_ARC_JAZZ_PICA:
3195                                          strcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, Acer PICA-61)",
3196                                                MACHINE_NAME_MAXBUF);
3197                                          break;                                          break;
3198                                  case MACHINE_ARC_JAZZ_MAGNUM:                                  case MACHINE_ARC_JAZZ_MAGNUM:
3199                                          strcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)");                                          strlcat(machine->machine_name, " (Microsoft Jazz, MIPS Magnum)",
3200                                                MACHINE_NAME_MAXBUF);
3201                                          break;                                          break;
3202                                  default:                                  default:
3203                                          fatal("error in machine.c. jazz\n");                                          fatal("error in machine.c. jazz\n");
# Line 3186  Not yet. Line 3275  Not yet.
3275                                   *  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.
3276                                   */                                   */
3277    
3278                                  strcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)");                                  strlcat(machine->machine_name, " (Microsoft Jazz, Olivetti M700)",
3279                                        MACHINE_NAME_MAXBUF);
3280    
3281                                  machine->md_int.jazz_data = device_add(machine,                                  machine->md_int.jazz_data = device_add(machine,
3282                                      "jazz addr=0x80000000");                                      "jazz addr=0x80000000");
# Line 3224  Not yet. Line 3314  Not yet.
3314                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html                                   *  http://mail-index.netbsd.org/port-arc/2000/10/14/0000.html
3315                                   */                                   */
3316    
3317                                  strcat(machine->machine_name, " (Deskstation Tyne)");                                  strlcat(machine->machine_name, " (Deskstation Tyne)",
3318                                        MACHINE_NAME_MAXBUF);
3319    
3320                                  i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");                                  i = dev_ns16550_init(machine, mem, 0x9000003f8ULL, 0, 1, machine->use_x11? 0 : 1, "serial 0");
3321                                  dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1");                                  dev_ns16550_init(machine, mem, 0x9000002f8ULL, 0, 1, 0, "serial 1");
# Line 3300  Not yet. Line 3391  Not yet.
3391                          /*  TODO: Make this nicer.  */                          /*  TODO: Make this nicer.  */
3392                          if (machine->machine_type == MACHINE_SGI) {                          if (machine->machine_type == MACHINE_SGI) {
3393                                  if (machine->machine_subtype == 30)                                  if (machine->machine_subtype == 30)
3394                                          strcat(init_bootpath, "xio(0)pci(15)");                                          strlcat(init_bootpath, "xio(0)pci(15)",
3395                                                MACHINE_NAME_MAXBUF);
3396                                  if (machine->machine_subtype == 32)                                  if (machine->machine_subtype == 32)
3397                                          strcat(init_bootpath, "pci(0)");                                          strlcat(init_bootpath, "pci(0)",
3398                                                MACHINE_NAME_MAXBUF);
3399                          }                          }
3400    
3401                          if (diskimage_is_a_cdrom(machine, bootdev_id,                          if (diskimage_is_a_cdrom(machine, bootdev_id,
# Line 3316  Not yet. Line 3409  Not yet.
3409                  }                  }
3410    
3411                  if (machine->machine_type == MACHINE_ARC)                  if (machine->machine_type == MACHINE_ARC)
3412                          strcat(init_bootpath, "\\");                          strlcat(init_bootpath, "\\", MACHINE_NAME_MAXBUF);
3413    
3414                  bootstr = malloc(strlen(init_bootpath) +                  bootstr = malloc(BOOTSTR_BUFLEN);
3415                      strlen(machine->boot_kernel_filename) + 1);                  if (bootstr == NULL) {
3416                  strcpy(bootstr, init_bootpath);                          fprintf(stderr, "out of memory\n");
3417                  strcat(bootstr, machine->boot_kernel_filename);                          exit(1);
3418                    }
3419                    strlcpy(bootstr, init_bootpath, BOOTSTR_BUFLEN);
3420                    if (strlcat(bootstr, machine->boot_kernel_filename,
3421                        BOOTSTR_BUFLEN) >= BOOTSTR_BUFLEN) {
3422                            fprintf(stderr, "boot string too long?\n");
3423                            exit(1);
3424                    }
3425    
3426                  /*  Boot args., eg "-a"  */                  /*  Boot args., eg "-a"  */
3427                  bootarg = machine->boot_string_argument;                  bootarg = machine->boot_string_argument;
# Line 3449  Not yet. Line 3549  Not yet.
3549                          add_environment_string(cpu, "kernname=unix", &addr);                          add_environment_string(cpu, "kernname=unix", &addr);
3550                  } else {                  } else {
3551                          char *tmp;                          char *tmp;
3552                          tmp = malloc(strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2);                          size_t mlen = strlen(bootarg) + strlen("OSLOADOPTIONS=") + 2;
3553                          sprintf(tmp, "OSLOADOPTIONS=%s", bootarg);                          tmp = malloc(mlen);
3554                            snprintf(tmp, mlen, "OSLOADOPTIONS=%s", bootarg);
3555                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));                          store_pointer_and_advance(cpu, &addr2, addr, arc_wordlen==sizeof(uint64_t));
3556                          add_environment_string(cpu, tmp, &addr);                          add_environment_string(cpu, tmp, &addr);
3557    
# Line 3570  no_arc_prom_emulation:         /*  TODO: ugly, Line 3671  no_arc_prom_emulation:         /*  TODO: ugly,
3671                  break;                  break;
3672    
3673          case MACHINE_EVBMIPS:          case MACHINE_EVBMIPS:
3674                  /*                  /*  http://www.netbsd.org/Ports/evbmips/  */
3675                   *  http://www.netbsd.org/Ports/evbmips/                  cpu->byte_order = EMUL_LITTLE_ENDIAN;
3676                   */  
3677                  switch (machine->machine_subtype) {                  switch (machine->machine_subtype) {
3678                  case MACHINE_EVBMIPS_MALTA:                  case MACHINE_EVBMIPS_MALTA:
3679                          machine->machine_name = "MALTA (evbmips)";                          machine->machine_name = "MALTA (evbmips)";
3680    
3681                            machine->md_int.malta_data =
3682                                device_add(machine, "malta addr=0x18000020");
3683                            machine->md_interrupt = malta_interrupt;
3684    
3685                            dev_mc146818_init(machine, mem, 0x18000070,
3686                                8 + 8, MC146818_PC_CMOS, 1);
3687                            machine->main_console_handle = dev_ns16550_init(machine, mem,
3688                                0x180003f8, 8 + 4, 1, 1, "serial console");
3689    
3690                            /*  TODO: Irqs  */
3691                            pci_data = dev_gt_init(machine, mem, 0x1be00000,
3692                                8+16, 8+16, 120);
3693    
3694                            /*  TODO: Haha, this is bogus. Just a cut&paste
3695                                from the Cobalt emulation above.  */
3696                            bus_pci_add(machine, pci_data, mem, 0,  9, 0,
3697                                pci_vt82c586_isa_init, pci_vt82c586_isa_rr);
3698                            bus_pci_add(machine, pci_data, mem, 0,  9, 1,
3699                                pci_vt82c586_ide_init, pci_vt82c586_ide_rr);
3700    
3701                            device_add(machine, "malta_lcd addr=0x1f000400");
3702                          break;                          break;
3703                  case MACHINE_EVBMIPS_PB1000:                  case MACHINE_EVBMIPS_PB1000:
3704                          machine->machine_name = "PB1000 (evbmips)";                          machine->machine_name = "PB1000 (evbmips)";
3705                            machine->md_interrupt = au1x00_interrupt;
3706                            machine->md_int.au1x00_ic_data =
3707                                dev_au1x00_init(machine, mem);
3708                          break;                          break;
3709                  default:                  default:
3710                          fatal("Unimplemented EVBMIPS model.\n");                          fatal("Unimplemented EVBMIPS model.\n");
# Line 3586  no_arc_prom_emulation:         /*  TODO: ugly, Line 3712  no_arc_prom_emulation:         /*  TODO: ugly,
3712                  }                  }
3713    
3714                  /*  This is just a test.  TODO  */                  /*  This is just a test.  TODO  */
3715                  {                  for (i=0; i<32; i++)
3716                          int i;                          cpu->cd.mips.gpr[i] =
3717                          for (i=0; i<32; i++)                              0x01230000 + (i << 8) + 0x55;
                                 cpu->cd.mips.gpr[i] =  
                                     0x01230000 + (i << 8) + 0x55;  
                 }  
3718    
3719                  /*  TODO: Yamon emulation. 0x9fc00504 = putchar? etc.  */                  /*  NetBSD/evbmips wants these: (at least for Malta)  */
3720    
3721                    /*  a0 = argc  */
3722                    cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
3723    
3724                    /*  a1 = argv  */
3725                    cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
3726                    store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
3727                    store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
3728    
3729                    bootstr = strdup(machine->boot_kernel_filename);
3730                    bootarg = strdup(machine->boot_string_argument);
3731                    store_string(cpu, (int32_t)0x9fc01040, bootstr);
3732                    store_string(cpu, (int32_t)0x9fc01200, bootarg);
3733    
3734                    /*  a2 = (yamon_env_var *)envp  */
3735                    cpu->cd.mips.gpr[MIPS_GPR_A2] = 0;
3736    
3737                    /*  a3 = memsize  */
3738                    cpu->cd.mips.gpr[MIPS_GPR_A3] =
3739                        machine->physical_ram_in_mb * 1048576;
3740    
3741                    /*  Yamon emulation vectors at 0x9fc005xx:  */
3742                    for (i=0; i<0x100; i+=4)
3743                            store_32bit_word(cpu, (int64_t)(int32_t)0x9fc00500 + i,
3744                                (int64_t)(int32_t)0x9fc00800 + i);
3745                    break;
3746    
3747            case MACHINE_PSP:
3748                    /*
3749                     *  The Playstation Portable seems to be a strange beast.
3750                     *
3751                     *  http://yun.cup.com/psppg004.html (in Japanese) seems to
3752                     *  suggest that virtual addresses are not displaced by
3753                     *  0x80000000 as on normal CPUs, but by 0x40000000?
3754                     */
3755                    machine->machine_name = "Playstation Portable";
3756                    cpu->byte_order = EMUL_LITTLE_ENDIAN;
3757    
3758                    if (!machine->use_x11 && !quiet_mode)
3759                            fprintf(stderr, "-------------------------------------"
3760                                "------------------------------------------\n"
3761                                "\n  WARNING! You are emulating a PSP without -X. "
3762                                "You will miss graphical output!\n\n"
3763                                "-------------------------------------"
3764                                "------------------------------------------\n");
3765    
3766                    /*  480 x 272 pixels framebuffer (512 bytes per line)  */
3767                    fb = dev_fb_init(machine, mem, 0x04000000, VFB_HPCMIPS,
3768                        480,272, 512,1088, -15, "Playstation Portable", 0);
3769    
3770                    /*
3771                     *  TODO/NOTE: This is ugly, but necessary since GXemul doesn't
3772                     *  emulate any MIPS CPU without MMU right now.
3773                     */
3774                    mips_coproc_tlb_set_entry(cpu, 0, 1048576*16,
3775                        0x44000000 /*vaddr*/, 0x4000000, 0x4000000 + 1048576*16,
3776                        1,1,1,1,1, 0, 2, 2);
3777                    mips_coproc_tlb_set_entry(cpu, 1, 1048576*16,
3778                        0x8000000 /*vaddr*/, 0x0, 0x0 + 1048576*16,
3779                        1,1,1,1,1, 0, 2, 2);
3780                    mips_coproc_tlb_set_entry(cpu, 2, 1048576*16,
3781                        0x9000000 /*vaddr*/, 0x01000000, 0x01000000 + 1048576*16,
3782                        1,1,1,1,1, 0, 2, 2);
3783                    mips_coproc_tlb_set_entry(cpu, 3, 1048576*16,
3784                        0x0 /*vaddr*/, 0, 0 + 1048576*16, 1,1,1,1,1, 0, 2, 2);
3785    
3786                    cpu->cd.mips.gpr[MIPS_GPR_SP] = 0xfff0;
3787    
3788                  break;                  break;
3789    
# Line 3823  no_arc_prom_emulation:         /*  TODO: ugly, Line 4013  no_arc_prom_emulation:         /*  TODO: ugly,
4013          case MACHINE_TESTARM:          case MACHINE_TESTARM:
4014                  machine->machine_name = "ARM test machine";                  machine->machine_name = "ARM test machine";
4015    
4016                  /*  TODO  */                  machine->main_console_handle = dev_cons_init(
4017                        machine, mem, DEV_CONS_ADDRESS, "console", 2);
4018    
4019                    fb = dev_fb_init(machine, mem, 0x12000000, VFB_GENERIC,
4020                        640,480, 640,480, 24, "generic", 1);
4021                  break;                  break;
4022    
4023          case MACHINE_BAREX86:          case MACHINE_BAREX86:
# Line 3965  void machine_memsize_fix(struct machine Line 4159  void machine_memsize_fix(struct machine
4159                  case MACHINE_NETGEAR:                  case MACHINE_NETGEAR:
4160                          m->physical_ram_in_mb = 16;                          m->physical_ram_in_mb = 16;
4161                          break;                          break;
4162                    case MACHINE_EVBMIPS:
4163                            m->physical_ram_in_mb = 64;
4164                            break;
4165                    case MACHINE_PSP:
4166                            /*
4167                             *  According to
4168                             *  http://wiki.ps2dev.org/psp:memory_map:
4169                             *      0×08000000 = 8 MB kernel memory
4170                             *      0×08800000 = 24 MB user memory
4171                             */
4172                            m->physical_ram_in_mb = 8 + 24;
4173                            break;
4174                  case MACHINE_ARC:                  case MACHINE_ARC:
4175                          switch (m->machine_subtype) {                          switch (m->machine_subtype) {
4176                          case MACHINE_ARC_JAZZ_PICA:                          case MACHINE_ARC_JAZZ_PICA:
# Line 4061  void machine_default_cputype(struct mach Line 4267  void machine_default_cputype(struct mach
4267          case MACHINE_SONYNEWS:          case MACHINE_SONYNEWS:
4268                  m->cpu_name = strdup("R3000");                  m->cpu_name = strdup("R3000");
4269                  break;                  break;
         case MACHINE_EVBMIPS:  
                 switch (m->machine_subtype) {  
                 case MACHINE_EVBMIPS_MALTA:  
                         m->cpu_name = strdup("5Kc");  
                         break;  
                 case MACHINE_EVBMIPS_PB1000:  
                         m->cpu_name = strdup("AU1000");  
                         break;  
                 default:fatal("Unimpl. evbmips.\n");  
                         exit(1);  
                 }  
                 break;  
4270          case MACHINE_HPCMIPS:          case MACHINE_HPCMIPS:
4271                  switch (m->machine_subtype) {                  switch (m->machine_subtype) {
4272                  case MACHINE_HPCMIPS_CASIO_BE300:                  case MACHINE_HPCMIPS_CASIO_BE300:
# Line 4140  void machine_default_cputype(struct mach Line 4334  void machine_default_cputype(struct mach
4334                  if (m->cpu_name == NULL)                  if (m->cpu_name == NULL)
4335                          m->cpu_name = strdup("R4400");                          m->cpu_name = strdup("R4400");
4336                  break;                  break;
4337            case MACHINE_EVBMIPS:
4338                    switch (m->machine_subtype) {
4339                    case MACHINE_EVBMIPS_MALTA:
4340                            m->cpu_name = strdup("5Kc");
4341                            break;
4342                    case MACHINE_EVBMIPS_PB1000:
4343                            m->cpu_name = strdup("AU1000");
4344                            break;
4345                    default:fatal("Unimpl. evbmips.\n");
4346                            exit(1);
4347                    }
4348                    break;
4349            case MACHINE_PSP:
4350                    m->cpu_name = strdup("Allegrex");
4351                    break;
4352    
4353          /*  PowerPC:  */          /*  PowerPC:  */
4354          case MACHINE_BAREPPC:          case MACHINE_BAREPPC:
# Line 4608  void machine_init(void) Line 4817  void machine_init(void)
4817                  me->next = first_machine_entry; first_machine_entry = me;                  me->next = first_machine_entry; first_machine_entry = me;
4818          }          }
4819    
4820            /*  Playstation Portable:  */
4821            me = machine_entry_new("Playstation Portable", ARCH_MIPS,
4822                MACHINE_PSP, 1, 0);
4823            me->aliases[0] = "psp";
4824            if (cpu_family_ptr_by_number(ARCH_MIPS) != NULL) {
4825                    me->next = first_machine_entry; first_machine_entry = me;
4826            }
4827    
4828          /*  NetGear:  */          /*  NetGear:  */
4829          me = machine_entry_new("NetGear WG602", ARCH_MIPS,          me = machine_entry_new("NetGear WG602", ARCH_MIPS,
4830              MACHINE_NETGEAR, 2, 0);              MACHINE_NETGEAR, 2, 0);

Legend:
Removed from v.9  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26