/[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 2 by dpavlin, Mon Oct 8 16:17:48 2007 UTC revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: emul.c,v 1.179 2005/03/14 19:14:04 debug Exp $   *  $Id: emul.c,v 1.184 2005/04/20 04:43:52 debug Exp $
29   *   *
30   *  Emulation startup and misc. routines.   *  Emulation startup and misc. routines.
31   */   */
# Line 41  Line 41 
41  #include "arcbios.h"  #include "arcbios.h"
42  #include "bintrans.h"  #include "bintrans.h"
43  #include "cpu.h"  #include "cpu.h"
 #include "cpu_mips.h"  
44  #include "emul.h"  #include "emul.h"
45  #include "console.h"  #include "console.h"
46  #include "debugger.h"  #include "debugger.h"
# Line 244  static void load_bootblock(struct machin Line 243  static void load_bootblock(struct machin
243    
244                  debug(readofs == 0x18? ": no blocks?\n" : " blocks\n");                  debug(readofs == 0x18? ": no blocks?\n" : " blocks\n");
245                  break;                  break;
246    
247            case MACHINE_X86:
248                    cpu->cd.x86.mode = 16;
249                    cpu->pc = 0x7c00;
250    
251                    bootblock_buf = malloc(512);
252                    if (bootblock_buf == NULL) {
253                            fprintf(stderr, "Out of memory.\n");
254                            exit(1);
255                    }
256    
257                    res = diskimage_access(m, boot_disk_id, 0, 0,
258                        bootblock_buf, 512);
259                    if (!res) {
260                            printf("Couldn't read the disk image. Aborting.\n");
261                            exit(1);
262                    }
263    
264                    debug("loading PC bootsector from disk %i\n", boot_disk_id);
265                    if (bootblock_buf[510] != 0x55 || bootblock_buf[511] != 0xaa)
266                            debug("WARNING! The 0x55,0xAA marker is missing! "
267                                "Booting anyway.\n");
268                    store_buf(cpu, 0x7c00, (char *)bootblock_buf, 512);
269                    free(bootblock_buf);
270                    break;
271    
272          default:          default:
273                  fatal("Booting from disk without a separate kernel "                  fatal("Booting from disk without a separate kernel "
274                      "doesn't work in this emulation mode.\n");                      "doesn't work in this emulation mode.\n");
# Line 604  void emul_machine_setup(struct machine * Line 629  void emul_machine_setup(struct machine *
629                                  cpu->cd.mips.gpr[MIPS_GPR_GP] |=                                  cpu->cd.mips.gpr[MIPS_GPR_GP] |=
630                                      0xffffffff00000000ULL;                                      0xffffffff00000000ULL;
631                          break;                          break;
632    
633                  case ARCH_PPC:                  case ARCH_PPC:
634                          cpu->cd.ppc.gpr[2] = toc;                          cpu->cd.ppc.gpr[2] = toc;
635                          break;                          break;
636    
637                    case ARCH_ALPHA:
638                    case ARCH_HPPA:
639                  case ARCH_SPARC:                  case ARCH_SPARC:
                         break;  
640                  case ARCH_URISC:                  case ARCH_URISC:
641                          break;                          break;
642                  case ARCH_HPPA:  
643                          break;                  case ARCH_X86:
644                  case ARCH_ALPHA:                          /*
645                             *  NOTE: The toc field is used to indicate an ELF64
646                             *  load, on AMD64!
647                             */
648                            if (toc != 0) {
649                                    cpu->cd.x86.mode = 64;
650                            } else
651                                    cpu->pc &= 0xffffffffULL;
652                          break;                          break;
653    
654                  default:                  default:
655                          fatal("emul_machine_setup(): Internal error: "                          fatal("emul_machine_setup(): Internal error: "
656                              "Unimplemented arch %i\n", m->arch);                              "Unimplemented arch %i\n", m->arch);
# Line 727  void emul_machine_setup(struct machine * Line 763  void emul_machine_setup(struct machine *
763                          cpu->pc = entrypoint;                          cpu->pc = entrypoint;
764                  }                  }
765                  break;                  break;
766            case ARCH_X86:
767                    if (cpu->cd.x86.mode == 16)
768                            debug("0x%04x:0x%04x", cpu->cd.x86.s[X86_S_CS],
769                                (int)cpu->pc);
770                    else if (cpu->cd.x86.mode == 32)
771                            debug("0x%08x", (int)cpu->pc);
772                    else
773                            debug("0x%016llx", (long long)cpu->pc);
774                    break;
775          default:          default:
776                  debug("0x%016llx", (long long)entrypoint);                  debug("0x%016llx", (long long)cpu->pc);
777          }          }
778          debug("\n");          debug("\n");
779    

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

  ViewVC Help
Powered by ViewVC 1.1.26