/[gxemul]/trunk/src/emul.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/emul.c

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

revision 12 by dpavlin, Mon Oct 8 16:18:38 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: emul.c,v 1.225 2005/08/14 19:35:54 debug Exp $   *  $Id: emul.c,v 1.247 2006/02/04 12:27:12 debug Exp $
29   *   *
30   *  Emulation startup and misc. routines.   *  Emulation startup and misc. routines.
31   */   */
# Line 70  extern struct diskimage *diskimages[]; Line 70  extern struct diskimage *diskimages[];
70  static char *diskimage_types[] = DISKIMAGE_TYPES;  static char *diskimage_types[] = DISKIMAGE_TYPES;
71    
72    
73    static void print_separator(void)
74    {
75            int i = 79;
76            while (i-- > 0)
77                    debug("-");
78            debug("\n");
79    }
80    
81    
82  /*  /*
83   *  add_dump_points():   *  add_dump_points():
84   *   *
# Line 112  static void add_dump_points(struct machi Line 121  static void add_dump_points(struct machi
121                   *  were automatically converted into the correct address.                   *  were automatically converted into the correct address.
122                   */                   */
123    
124                  if ((dp >> 32) == 0 && ((dp >> 31) & 1))                  if (m->arch == ARCH_MIPS) {
125                          dp |= 0xffffffff00000000ULL;                          if ((dp >> 32) == 0 && ((dp >> 31) & 1))
126                                    dp |= 0xffffffff00000000ULL;
127                    }
128    
129                  m->breakpoint_addr[i] = dp;                  m->breakpoint_addr[i] = dp;
130    
131                  debug("breakpoint %i: 0x%016llx", i, (long long)dp);                  debug("breakpoint %i: 0x%llx", i, (long long)dp);
132                  if (string_flag)                  if (string_flag)
133                          debug(" (%s)", m->breakpoint_string[i]);                          debug(" (%s)", m->breakpoint_string[i]);
134                  debug("\n");                  debug("\n");
# Line 149  static int iso_load_bootblock(struct mac Line 161  static int iso_load_bootblock(struct mac
161          int *n_loadp, char ***load_namesp)          int *n_loadp, char ***load_namesp)
162  {  {
163          char str[35];          char str[35];
164          int filenr, i, ofs, dirlen, res = 0, res2, iadd = 4;          int filenr, i, ofs, dirlen, res = 0, res2, iadd = DEBUG_INDENTATION;
165          int found_dir;          int found_dir;
166          uint64_t dirofs;          uint64_t dirofs;
167          uint64_t fileofs, filelen;          uint64_t fileofs, filelen;
# Line 158  static int iso_load_bootblock(struct mac Line 170  static int iso_load_bootblock(struct mac
170          char *p, *filename_orig;          char *p, *filename_orig;
171          char *filename = strdup(cpu->machine->boot_kernel_filename);          char *filename = strdup(cpu->machine->boot_kernel_filename);
172          unsigned char *filebuf = NULL;          unsigned char *filebuf = NULL;
173          char *tmpfilename = NULL;          char *tmpfname = NULL;
174          char **new_array;          char **new_array;
175          int tmpfile_handle;          int tmpfile_handle;
176    
# Line 204  static int iso_load_bootblock(struct mac Line 216  static int iso_load_bootblock(struct mac
216                  fatal("WARNING: Root directory length mismatch?\n");                  fatal("WARNING: Root directory length mismatch?\n");
217    
218          dirofs = (int64_t)(buf[0x8c] + (buf[0x8d] << 8) + (buf[0x8e] << 16) +          dirofs = (int64_t)(buf[0x8c] + (buf[0x8d] << 8) + (buf[0x8e] << 16) +
219              (buf[0x8f] << 24)) * 2048;              ((uint64_t)buf[0x8f] << 24)) * 2048;
220    
221          /*  debug("root = %i bytes at 0x%llx\n", dirlen, (long long)dirofs);  */          /*  debug("root = %i bytes at 0x%llx\n", dirlen, (long long)dirofs);  */
222    
# Line 225  static int iso_load_bootblock(struct mac Line 237  static int iso_load_bootblock(struct mac
237          dp = dirbuf; filenr = 1;          dp = dirbuf; filenr = 1;
238          p = NULL;          p = NULL;
239          while (dp < dirbuf + dirlen) {          while (dp < dirbuf + dirlen) {
240                  int i, nlen = dp[0];                  size_t i, nlen = dp[0];
241                  int x = dp[2] + (dp[3] << 8) + (dp[4] << 16) + (dp[5] << 24);                  int x = dp[2] + (dp[3] << 8) + (dp[4] << 16) +
242                        ((uint64_t)dp[5] << 24);
243                  int y = dp[6] + (dp[7] << 8);                  int y = dp[6] + (dp[7] << 8);
244                  char direntry[65];                  char direntry[65];
245    
# Line 296  static int iso_load_bootblock(struct mac Line 309  static int iso_load_bootblock(struct mac
309          }          }
310    
311          for (;;) {          for (;;) {
312                  int len, i;                  size_t len, i;
313    
314                  /*  Too close to another sector? Then realign.  */                  /*  Too close to another sector? Then realign.  */
315                  if ((dirofs & 2047) + 70 > 2047) {                  if ((dirofs & 2047) + 70 > 2047) {
# Line 361  static int iso_load_bootblock(struct mac Line 374  static int iso_load_bootblock(struct mac
374          }          }
375    
376          fileofs = match_entry[2] + (match_entry[3] << 8) +          fileofs = match_entry[2] + (match_entry[3] << 8) +
377              (match_entry[4] << 16) + (match_entry[5] << 24);              (match_entry[4] << 16) + ((uint64_t)match_entry[5] << 24);
378          filelen = match_entry[10] + (match_entry[11] << 8) +          filelen = match_entry[10] + (match_entry[11] << 8) +
379              (match_entry[12] << 16) + (match_entry[13] << 24);              (match_entry[12] << 16) + ((uint64_t)match_entry[13] << 24);
380          fileofs *= 2048;          fileofs *= 2048;
381    
382          /*  debug("filelen=%llx fileofs=%llx\n", (long long)filelen,          /*  debug("filelen=%llx fileofs=%llx\n", (long long)filelen,
# Line 376  static int iso_load_bootblock(struct mac Line 389  static int iso_load_bootblock(struct mac
389                  goto ret;                  goto ret;
390          }          }
391    
392          tmpfilename = strdup("/tmp/gxemul.XXXXXXXXXXXX");          tmpfname = strdup("/tmp/gxemul.XXXXXXXXXXXX");
   
         debug("extracting %lli bytes into %s\n",  
             (long long)filelen, tmpfilename);  
393    
394          res2 = diskimage_access(m, disk_id, disk_type, 0, fileofs, filebuf,          res2 = diskimage_access(m, disk_id, disk_type, 0, fileofs, filebuf,
395              filelen);              filelen);
# Line 388  static int iso_load_bootblock(struct mac Line 398  static int iso_load_bootblock(struct mac
398                  goto ret;                  goto ret;
399          }          }
400    
401          tmpfile_handle = mkstemp(tmpfilename);          tmpfile_handle = mkstemp(tmpfname);
402          if (tmpfile_handle < 0) {          if (tmpfile_handle < 0) {
403                  fatal("could not create %s\n", tmpfilename);                  fatal("could not create %s\n", tmpfname);
404                  exit(1);                  exit(1);
405          }          }
406          write(tmpfile_handle, filebuf, filelen);          write(tmpfile_handle, filebuf, filelen);
407          close(tmpfile_handle);          close(tmpfile_handle);
408    
409            debug("extracted %lli bytes into %s\n", (long long)filelen, tmpfname);
410    
411          /*  Add the temporary filename to the load_namesp array:  */          /*  Add the temporary filename to the load_namesp array:  */
412          (*n_loadp)++;          (*n_loadp)++;
413          new_array = malloc(sizeof(char *) * (*n_loadp));          new_array = malloc(sizeof(char *) * (*n_loadp));
# Line 409  static int iso_load_bootblock(struct mac Line 421  static int iso_load_bootblock(struct mac
421          /*  This adds a Backspace char in front of the filename; this          /*  This adds a Backspace char in front of the filename; this
422              is a special hack which causes the file to be removed once              is a special hack which causes the file to be removed once
423              it has been loaded.  */              it has been loaded.  */
424          tmpfilename = realloc(tmpfilename, strlen(tmpfilename) + 2);          tmpfname = realloc(tmpfname, strlen(tmpfname) + 2);
425          memmove(tmpfilename + 1, tmpfilename, strlen(tmpfilename) + 1);          memmove(tmpfname + 1, tmpfname, strlen(tmpfname) + 1);
426          tmpfilename[0] = 8;          tmpfname[0] = 8;
427    
428          (*load_namesp)[*n_loadp - 1] = tmpfilename;          (*load_namesp)[*n_loadp - 1] = tmpfname;
429    
430          res = 1;          res = 1;
431    
# Line 435  ret: Line 447  ret:
447    
448    
449  /*  /*
450     *  apple_load_bootblock():
451     *
452     *  Try to load a kernel from a disk image with an Apple Partition Table.
453     *
454     *  TODO: This function uses too many magic offsets and so on; it should be
455     *  cleaned up some day. See http://www.awprofessional.com/articles/
456     *      article.asp?p=376123&seqNum=3&rl=1  for some info on the Apple
457     *  partition format.
458     *
459     *  Returns 1 on success, 0 on failure.
460     */
461    static int apple_load_bootblock(struct machine *m, struct cpu *cpu,
462            int disk_id, int disk_type, int *n_loadp, char ***load_namesp)
463    {
464            unsigned char buf[0x8000];
465            int res, partnr, n_partitions = 0, n_hfs_partitions = 0;
466            uint64_t hfs_start, hfs_length;
467    
468            res = diskimage_access(m, disk_id, disk_type, 0, 0x0, buf, sizeof(buf));
469            if (!res) {
470                    fatal("apple_load_bootblock: couldn't read the disk "
471                        "image. Aborting.\n");
472                    return 0;
473            }
474    
475            partnr = 0;
476            do {
477                    int start, length;
478                    int ofs = 0x200 * (partnr + 1);
479                    if (partnr == 0)
480                            n_partitions = buf[ofs + 7];
481                    start = ((uint64_t)buf[ofs + 8] << 24) + (buf[ofs + 9] << 16) +
482                        (buf[ofs + 10] << 8) + buf[ofs + 11];
483                    length = ((uint64_t)buf[ofs+12] << 24) + (buf[ofs + 13] << 16) +
484                        (buf[ofs + 14] << 8) + buf[ofs + 15];
485    
486                    debug("partition %i: '%s', type '%s', start %i, length %i\n",
487                        partnr, buf + ofs + 0x10, buf + ofs + 0x30,
488                        start, length);
489    
490                    if (strcmp((char *)buf + ofs + 0x30, "Apple_HFS") == 0) {
491                            n_hfs_partitions ++;
492                            hfs_start = 512 * start;
493                            hfs_length = 512 * length;
494                    }
495    
496                    /*  Any more partitions?  */
497                    partnr ++;
498            } while (partnr < n_partitions);
499    
500            if (n_hfs_partitions == 0) {
501                    fatal("Error: No HFS partition found! TODO\n");
502                    return 0;
503            }
504            if (n_hfs_partitions >= 2) {
505                    fatal("Error: Too many HFS partitions found! TODO\n");
506                    return 0;
507            }
508    
509            return 0;
510    }
511    
512    
513    /*
514   *  load_bootblock():   *  load_bootblock():
515   *   *
516   *  For some emulation modes, it is possible to boot from a harddisk image by   *  For some emulation modes, it is possible to boot from a harddisk image by
# Line 459  static int load_bootblock(struct machine Line 535  static int load_bootblock(struct machine
535                  return 0;                  return 0;
536    
537          switch (m->machine_type) {          switch (m->machine_type) {
538          case MACHINE_DEC:          case MACHINE_PMAX:
539                  /*                  /*
540                   *  The first few bytes of a disk contains information about                   *  The first few bytes of a disk contains information about
541                   *  where the bootblock(s) are located. (These are all 32-bit                   *  where the bootblock(s) are located. (These are all 32-bit
# Line 480  static int load_bootblock(struct machine Line 556  static int load_bootblock(struct machine
556                      minibuf, sizeof(minibuf));                      minibuf, sizeof(minibuf));
557    
558                  bootblock_loadaddr = minibuf[0x10] + (minibuf[0x11] << 8)                  bootblock_loadaddr = minibuf[0x10] + (minibuf[0x11] << 8)
559                    + (minibuf[0x12] << 16) + (minibuf[0x13] << 24);                    + (minibuf[0x12] << 16) + ((uint64_t)minibuf[0x13] << 24);
560    
561                  /*  Convert loadaddr to uncached:  */                  /*  Convert loadaddr to uncached:  */
562                  if ((bootblock_loadaddr & 0xf0000000ULL) != 0x80000000 &&                  if ((bootblock_loadaddr & 0xf0000000ULL) != 0x80000000 &&
# Line 491  static int load_bootblock(struct machine Line 567  static int load_bootblock(struct machine
567                  bootblock_loadaddr |= 0xffffffffa0000000ULL;                  bootblock_loadaddr |= 0xffffffffa0000000ULL;
568    
569                  bootblock_pc = minibuf[0x14] + (minibuf[0x15] << 8)                  bootblock_pc = minibuf[0x14] + (minibuf[0x15] << 8)
570                    + (minibuf[0x16] << 16) + (minibuf[0x17] << 24);                    + (minibuf[0x16] << 16) + ((uint64_t)minibuf[0x17] << 24);
571    
572                  bootblock_pc &= 0x0fffffffULL;                  bootblock_pc &= 0x0fffffffULL;
573                  bootblock_pc |= 0xffffffffa0000000ULL;                  bootblock_pc |= 0xffffffffa0000000ULL;
# Line 512  static int load_bootblock(struct machine Line 588  static int load_bootblock(struct machine
588                          }                          }
589    
590                          n_blocks = minibuf[0] + (minibuf[1] << 8)                          n_blocks = minibuf[0] + (minibuf[1] << 8)
591                            + (minibuf[2] << 16) + (minibuf[3] << 24);                            + (minibuf[2] << 16) + ((uint64_t)minibuf[3] << 24);
592    
593                          bootblock_offset = (minibuf[4] + (minibuf[5] << 8)                          bootblock_offset = (minibuf[4] + (minibuf[5] << 8) +
594                            + (minibuf[6] << 16) + (minibuf[7] << 24)) * 512;                            (minibuf[6]<<16) + ((uint64_t)minibuf[7]<<24)) * 512;
595    
596                          if (n_blocks < 1)                          if (n_blocks < 1)
597                                  break;                                  break;
# Line 586  static int load_bootblock(struct machine Line 662  static int load_bootblock(struct machine
662    
663          /*          /*
664           *  Try reading a kernel manually from the disk. The code here           *  Try reading a kernel manually from the disk. The code here
665           *  does not rely on machine-dependant boot blocks etc.           *  does not rely on machine-dependent boot blocks etc.
666           */           */
667          /*  ISO9660: (0x800 bytes at 0x8000)  */          /*  ISO9660: (0x800 bytes at 0x8000)  */
668          bootblock_buf = malloc(0x800);          bootblock_buf = malloc(0x800);
# Line 623  static int load_bootblock(struct machine Line 699  static int load_bootblock(struct machine
699                              n_loadp, load_namesp);                              n_loadp, load_namesp);
700          }          }
701    
702            if (retval != 0)
703                    goto ret_ok;
704    
705            /*  Apple parition table:  */
706            res = diskimage_access(m, boot_disk_id, boot_disk_type,
707                0, 0x0, bootblock_buf, 0x800);
708            if (!res) {
709                    fatal("Couldn't read the disk image. Aborting.\n");
710                    return 0;
711            }
712            if (bootblock_buf[0x000] == 'E' && bootblock_buf[0x001] == 'R' &&
713                bootblock_buf[0x200] == 'P' && bootblock_buf[0x201] == 'M') {
714                    /*  We can't load a kernel if the name
715                        isn't specified.  */
716                    if (cpu->machine->boot_kernel_filename == NULL ||
717                        cpu->machine->boot_kernel_filename[0] == '\0')
718                            fatal("\nApple partition table, but no kernel "
719                                "specified? (Use the -j option.)\n");
720                    else
721                            retval = apple_load_bootblock(m, cpu, boot_disk_id,
722                                boot_disk_type, n_loadp, load_namesp);
723            }
724    
725    ret_ok:
726          free(bootblock_buf);          free(bootblock_buf);
727          return retval;          return retval;
728  }  }
# Line 812  static void add_arc_components(struct ma Line 912  static void add_arc_components(struct ma
912  void emul_machine_setup(struct machine *m, int n_load, char **load_names,  void emul_machine_setup(struct machine *m, int n_load, char **load_names,
913          int n_devices, char **device_names)          int n_devices, char **device_names)
914  {  {
         struct emul *emul;  
915          struct cpu *cpu;          struct cpu *cpu;
916          int i, iadd=4;          int i, iadd = DEBUG_INDENTATION;
917          uint64_t memory_amount, entrypoint = 0, gp = 0, toc = 0;          uint64_t memory_amount, entrypoint = 0, gp = 0, toc = 0;
918          int byte_order;          int byte_order;
919    
         emul = m->emul;  
   
920          debug("machine \"%s\":\n", m->name);          debug("machine \"%s\":\n", m->name);
921          debug_indentation(iadd);          debug_indentation(iadd);
922    
# Line 972  void emul_machine_setup(struct machine * Line 1069  void emul_machine_setup(struct machine *
1069          }          }
1070    
1071          diskimage_dump_info(m);          diskimage_dump_info(m);
1072            console_debug_dump(m);
1073    
1074          /*  Load files (ROM code, boot code, ...) into memory:  */          /*  Load files (ROM code, boot code, ...) into memory:  */
1075          if (n_load == 0) {          if (n_load == 0) {
# Line 1120  void emul_machine_setup(struct machine * Line 1218  void emul_machine_setup(struct machine *
1218                  cpu->pc = entrypoint;                  cpu->pc = entrypoint;
1219    
1220                  switch (m->arch) {                  switch (m->arch) {
1221    
1222                    case ARCH_ALPHA:
1223                            /*  For position-independent code:  */
1224                            cpu->cd.alpha.r[ALPHA_T12] = cpu->pc;
1225                            break;
1226    
1227                    case ARCH_ARM:
1228                            if (cpu->pc & 3) {
1229                                    fatal("ARM: lowest bits of pc set: TODO\n");
1230                                    exit(1);
1231                            }
1232                            cpu->pc &= 0xfffffffc;
1233                            break;
1234    
1235                    case ARCH_AVR:
1236                            cpu->pc &= 0xfffff;
1237                            if (cpu->pc & 1) {
1238                                    fatal("AVR: lowest bit of pc set: TODO\n");
1239                                    exit(1);
1240                            }
1241                            break;
1242    
1243                    case ARCH_HPPA:
1244                            break;
1245    
1246                    case ARCH_I960:
1247                            break;
1248    
1249                    case ARCH_IA64:
1250                            break;
1251    
1252                    case ARCH_M68K:
1253                            break;
1254    
1255                  case ARCH_MIPS:                  case ARCH_MIPS:
1256                          if ((cpu->pc >> 32) == 0                          if ((cpu->pc >> 32) == 0 && (cpu->pc & 0x80000000ULL))
                             && (cpu->pc & 0x80000000ULL))  
1257                                  cpu->pc |= 0xffffffff00000000ULL;                                  cpu->pc |= 0xffffffff00000000ULL;
1258    
1259                          cpu->cd.mips.gpr[MIPS_GPR_GP] = gp;                          cpu->cd.mips.gpr[MIPS_GPR_GP] = gp;
# Line 1138  void emul_machine_setup(struct machine * Line 1269  void emul_machine_setup(struct machine *
1269                              spec/x458.html for more info.  */                              spec/x458.html for more info.  */
1270                          cpu->cd.ppc.gpr[2] = toc;                          cpu->cd.ppc.gpr[2] = toc;
1271                          /*  TODO  */                          /*  TODO  */
1272                            if (cpu->cd.ppc.bits == 32)
1273                                    cpu->pc &= 0xffffffffULL;
1274                          break;                          break;
1275    
1276                  case ARCH_ALPHA:                  case ARCH_SH:
1277                          /*  For position-independant code:  */                          if (cpu->cd.sh.bits == 32)
1278                          cpu->cd.alpha.r[ALPHA_T12] = cpu->pc;                                  cpu->pc &= 0xffffffffULL;
1279                            cpu->pc &= ~1;
1280                          break;                          break;
1281    
1282                  case ARCH_SPARC:                  case ARCH_SPARC:
1283                          break;                          break;
1284    
                 case ARCH_IA64:  
                         break;  
   
                 case ARCH_M68K:  
                         break;  
   
                 case ARCH_ARM:  
                         cpu->pc &= 0xfffffffc;  
                         cpu->cd.arm.r[ARM_PC] = cpu->pc;  
                         break;  
   
1285                  case ARCH_X86:                  case ARCH_X86:
1286                          /*                          /*
1287                           *  NOTE: The toc field is used to indicate an ELF32                           *  NOTE: The toc field is used to indicate an ELF32
# Line 1225  void emul_machine_setup(struct machine * Line 1348  void emul_machine_setup(struct machine *
1348          add_dump_points(m);          add_dump_points(m);
1349    
1350          /*  TODO: This is MIPS-specific!  */          /*  TODO: This is MIPS-specific!  */
1351          if (m->machine_type == MACHINE_DEC &&          if (m->machine_type == MACHINE_PMAX &&
1352              cpu->cd.mips.cpu_type.mmu_model == MMU3K)              cpu->cd.mips.cpu_type.mmu_model == MMU3K)
1353                  add_symbol_name(&m->symbol_context,                  add_symbol_name(&m->symbol_context,
1354                      0x9fff0000, 0x10000, "r2k3k_cache", 0, 0);                      0x9fff0000, 0x10000, "r2k3k_cache", 0, 0);
# Line 1243  void emul_machine_setup(struct machine * Line 1366  void emul_machine_setup(struct machine *
1366    
1367          debug("starting cpu%i at ", m->bootstrap_cpu);          debug("starting cpu%i at ", m->bootstrap_cpu);
1368          switch (m->arch) {          switch (m->arch) {
1369    
1370            case ARCH_ARM:
1371                    /*  ARM cpus aren't 64-bit:  */
1372                    debug("0x%08x", (int)entrypoint);
1373                    break;
1374    
1375            case ARCH_AVR:
1376                    /*  Atmel AVR uses a 16-bit or 22-bit program counter:  */
1377                    debug("0x%04x", (int)entrypoint);
1378                    break;
1379    
1380          case ARCH_MIPS:          case ARCH_MIPS:
1381                  if (cpu->is_32bit) {                  if (cpu->is_32bit) {
1382                          debug("0x%08x", (int)m->cpus[                          debug("0x%08x", (int)m->cpus[
# Line 1259  void emul_machine_setup(struct machine * Line 1393  void emul_machine_setup(struct machine *
1393                                      cpu->cd.mips.gpr[MIPS_GPR_GP]);                                      cpu->cd.mips.gpr[MIPS_GPR_GP]);
1394                  }                  }
1395                  break;                  break;
1396    
1397          case ARCH_PPC:          case ARCH_PPC:
1398                  if (cpu->cd.ppc.bits == 32)                  if (cpu->cd.ppc.bits == 32)
1399                          debug("0x%08x", (int)entrypoint);                          debug("0x%08x", (int)entrypoint);
1400                  else                  else
1401                          debug("0x%016llx", (long long)entrypoint);                          debug("0x%016llx", (long long)entrypoint);
1402                  break;                  break;
1403          case ARCH_ARM:  
                 /*  ARM cpus aren't 64-bit:  */  
                 debug("0x%08x", (int)entrypoint);  
                 break;  
1404          case ARCH_X86:          case ARCH_X86:
1405                  debug("0x%04x:0x%llx", cpu->cd.x86.s[X86_S_CS],                  debug("0x%04x:0x%llx", cpu->cd.x86.s[X86_S_CS],
1406                      (long long)cpu->pc);                      (long long)cpu->pc);
1407                  break;                  break;
1408    
1409          default:          default:
1410                  debug("0x%016llx", (long long)cpu->pc);                  if (cpu->is_32bit)
1411                            debug("0x%08x", (int)cpu->pc);
1412                    else
1413                            debug("0x%016llx", (long long)cpu->pc);
1414          }          }
1415          debug("\n");          debug("\n");
1416    
# Line 1289  void emul_machine_setup(struct machine * Line 1425  void emul_machine_setup(struct machine *
1425   */   */
1426  void emul_dumpinfo(struct emul *e)  void emul_dumpinfo(struct emul *e)
1427  {  {
1428          int j, nm, iadd = 4;          int j, nm, iadd = DEBUG_INDENTATION;
1429    
1430          if (e->net != NULL)          if (e->net != NULL)
1431                  net_dumpinfo(e->net);                  net_dumpinfo(e->net);
# Line 1318  void emul_dumpinfo(struct emul *e) Line 1454  void emul_dumpinfo(struct emul *e)
1454   */   */
1455  void emul_simple_init(struct emul *emul)  void emul_simple_init(struct emul *emul)
1456  {  {
1457          int iadd=4;          int iadd = DEBUG_INDENTATION;
1458          struct machine *m;          struct machine *m;
1459    
1460          if (emul->n_machines != 1) {          if (emul->n_machines != 1) {
# Line 1355  void emul_simple_init(struct emul *emul) Line 1491  void emul_simple_init(struct emul *emul)
1491   */   */
1492  struct emul *emul_create_from_configfile(char *fname)  struct emul *emul_create_from_configfile(char *fname)
1493  {  {
1494          int iadd = 4;          int iadd = DEBUG_INDENTATION;
1495          struct emul *e = emul_new(fname);          struct emul *e = emul_new(fname);
1496          FILE *f;          FILE *f;
1497          char buf[128];          char buf[128];
# Line 1409  void emul_run(struct emul **emuls, int n Line 1545  void emul_run(struct emul **emuls, int n
1545    
1546          atexit(fix_console);          atexit(fix_console);
1547    
         i = 79;  
         while (i-- > 0)  
                 debug("-");  
         debug("\n\n");  
   
1548          /*  Initialize the interactive debugger:  */          /*  Initialize the interactive debugger:  */
1549          debugger_init(emuls, n_emuls);          debugger_init(emuls, n_emuls);
1550    
1551            /*  Run any additional debugger commands before starting:  */
1552            for (i=0; i<n_emuls; i++) {
1553                    struct emul *emul = emuls[i];
1554                    if (emul->n_debugger_cmds > 0) {
1555                            int j;
1556                            if (i == 0)
1557                                    print_separator();
1558                            for (j = 0; j < emul->n_debugger_cmds; j ++) {
1559                                    debug("> %s\n", emul->debugger_cmds[j]);
1560                                    debugger_execute_cmd(emul->debugger_cmds[j],
1561                                        strlen(emul->debugger_cmds[j]));
1562                            }
1563                    }
1564            }
1565    
1566            print_separator();
1567            debug("\n");
1568    
1569    
1570          /*          /*
1571           *  console_init_main() makes sure that the terminal is in a           *  console_init_main() makes sure that the terminal is in a
1572           *  reasonable state.           *  reasonable state.

Legend:
Removed from v.12  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26