ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/BeOS/main_beos.cpp
(Generate patch)

Comparing SheepShaver/src/BeOS/main_beos.cpp (file contents):
Revision 1.19 by gbeauche, 2008-01-01T09:47:38Z vs.
Revision 1.22 by asvitkine, 2009-08-26T00:11:56Z

# Line 110 | Line 110 | const char DR_CACHE_AREA_NAME[] = "Macin
110   const char DR_EMULATOR_AREA_NAME[] = "Macintosh DR Emulator";
111   const char SHEEP_AREA_NAME[] = "SheepShaver Virtual Stack";
112  
113 + const uintptr ROM_BASE = 0x40800000;            // Base address of ROM
114 +
115   const uint32 SIG_STACK_SIZE = 8192;                     // Size of signal stack
116  
117   const uint32 MSG_START = 'strt';                        // Emulator start message
# Line 202 | Line 204 | void *TOC;                             // TOC pointer
204   #endif
205   uint32 RAMBase;                 // Base address of Mac RAM
206   uint32 RAMSize;                 // Size of Mac RAM
207 + uint32 ROMBase;                 // Base address of Mac ROM
208   uint32 KernelDataAddr;  // Address of Kernel Data
209   uint32 BootGlobsAddr;   // Address of BootGlobs structure at top of Mac RAM
210   uint32 DRCacheAddr;             // Address of DR Cache
# Line 318 | Line 321 | void SheepShaver::ReadyToRun(void)
321          // Read preferences
322          int argc = 0;
323          char **argv = NULL;
324 <        PrefsInit(argc, argv);
324 >        PrefsInit(NULL, argc, argv);
325  
326          // Init system routines
327          SysInit();
# Line 600 | Line 603 | void SheepShaver::init_rom(void)
603          page_size = B_PAGE_SIZE;
604  
605          // Create area for ROM
606 <        ROMBaseHost = (uint8 *)ROM_BASE;
607 <        rom_area = create_area(ROM_AREA_NAME, (void **)&ROMBaseHost, B_EXACT_ADDRESS, ROM_AREA_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
606 >        ROMBase = ROM_BASE;
607 >        rom_area = create_area(ROM_AREA_NAME, (void **)&ROMBase, B_EXACT_ADDRESS, ROM_AREA_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
608          if (rom_area < 0)
609                  throw area_error();
610 +        ROMBaseHost = (uint8 *)ROMBase;
611          D(bug("ROM area %ld at %p\n", rom_area, rom_addr));
612  
613          // Load ROM
# Line 624 | Line 628 | void SheepShaver::load_rom(void)
628          const char *rom_path = PrefsFindString("rom");
629  
630          // Try to open ROM file
631 <        BFile file(rom_path ? rom_path : ROM_FILE_NAME, B_READ_ONLY);
631 >        BFile file(rom_path && *rom_path ? rom_path : ROM_FILE_NAME, B_READ_ONLY);
632          if (file.InitCheck() != B_NO_ERROR) {
633  
634                  // Failed, then ask memory_mess driver for ROM
635                  uint8 *rom = new uint8[ROM_SIZE];       // Reading directly into the area doesn't work
636                  ssize_t actual = read(sheep_fd, (void *)rom, ROM_SIZE);
637                  if (actual == ROM_SIZE) {
638 <                        memcpy((void *)ROM_BASE, rom, ROM_SIZE);
638 >                        memcpy(ROMBaseHost, rom, ROM_SIZE);
639                          delete[] rom;
640                          return;
641                  } else
# Line 702 | Line 706 | status_t SheepShaver::emul_func(void *ar
706  
707          // Jump to ROM boot routine
708          D(bug("Jumping to ROM\n"));
709 <        obj->jump_to_rom(ROM_BASE + 0x310000);
709 >        obj->jump_to_rom(ROMBase + 0x310000);
710          D(bug("Returned from ROM\n"));
711  
712          // We're no longer ready to receive signals
# Line 1185 | Line 1189 | void Dump68kRegs(M68kRegisters *r)
1189  
1190   void MakeExecutable(int dummy, uint32 start, uint32 length)
1191   {
1192 <        if ((start >= ROM_BASE) && (start < (ROM_BASE + ROM_SIZE)))
1192 >        if ((start >= ROMBase) && (start < (ROMBase + ROM_SIZE)))
1193                  return;
1194          clear_caches((void *)start, length, B_INVALIDATE_ICACHE | B_FLUSH_DCACHE);
1195   }
# Line 1400 | Line 1404 | void SheepShaver::sigusr1_handler(vregs
1404                                  // Execute nanokernel interrupt routine (this will activate the 68k emulator)
1405                                  atomic_add((int32 *)XLM_IRQ_NEST, 1);
1406                                  if (ROMType == ROMTYPE_NEWWORLD)
1407 <                                        ppc_interrupt(ROM_BASE + 0x312b1c);
1407 >                                        ppc_interrupt(ROMBase + 0x312b1c);
1408                                  else
1409 <                                        ppc_interrupt(ROM_BASE + 0x312a3c);
1409 >                                        ppc_interrupt(ROMBase + 0x312a3c);
1410                          }
1411                          break;
1412   #endif
# Line 1506 | Line 1510 | static void sigsegv_handler(vregs *r)
1510          uint32 imm = opcode & 0xffff;
1511  
1512          // Fault in Mac ROM or RAM?
1513 <        bool mac_fault = (r->pc >= ROM_BASE) && (r->pc < (ROM_BASE + ROM_AREA_SIZE)) || (r->pc >= RAMBase) && (r->pc < (RAMBase + RAMSize));
1513 >        bool mac_fault = (r->pc >= ROMBase) && (r->pc < (ROMBase + ROM_AREA_SIZE)) || (r->pc >= RAMBase) && (r->pc < (RAMBase + RAMSize));
1514          if (mac_fault) {
1515  
1516                  // "VM settings" during MacOS 8 installation
1517 <                if (r->pc == ROM_BASE + 0x488160 && segv_r[20] == 0xf8000000) {
1517 >                if (r->pc == ROMBase + 0x488160 && segv_r[20] == 0xf8000000) {
1518                          r->pc += 4;
1519                          segv_r[8] = 0;
1520                          goto rti;
1521  
1522                  // MacOS 8.5 installation
1523 <                } else if (r->pc == ROM_BASE + 0x488140 && segv_r[16] == 0xf8000000) {
1523 >                } else if (r->pc == ROMBase + 0x488140 && segv_r[16] == 0xf8000000) {
1524                          r->pc += 4;
1525                          segv_r[8] = 0;
1526                          goto rti;
1527  
1528                  // MacOS 8 serial drivers on startup
1529 <                } else if (r->pc == ROM_BASE + 0x48e080 && (segv_r[8] == 0xf3012002 || segv_r[8] == 0xf3012000)) {
1529 >                } else if (r->pc == ROMBase + 0x48e080 && (segv_r[8] == 0xf3012002 || segv_r[8] == 0xf3012000)) {
1530                          r->pc += 4;
1531                          segv_r[8] = 0;
1532                          goto rti;
1533  
1534                  // MacOS 8.1 serial drivers on startup
1535 <                } else if (r->pc == ROM_BASE + 0x48c5e0 && (segv_r[20] == 0xf3012002 || segv_r[20] == 0xf3012000)) {
1535 >                } else if (r->pc == ROMBase + 0x48c5e0 && (segv_r[20] == 0xf3012002 || segv_r[20] == 0xf3012000)) {
1536                          r->pc += 4;
1537                          goto rti;
1538 <                } else if (r->pc == ROM_BASE + 0x4a10a0 && (segv_r[20] == 0xf3012002 || segv_r[20] == 0xf3012000)) {
1538 >                } else if (r->pc == ROMBase + 0x4a10a0 && (segv_r[20] == 0xf3012002 || segv_r[20] == 0xf3012000)) {
1539                          r->pc += 4;
1540                          goto rti;
1541                  }
# Line 1642 | Line 1646 | static void sigsegv_handler(vregs *r)
1646          }
1647  
1648          // Ignore ROM writes
1649 <        if (transfer_type == TYPE_STORE && addr >= ROM_BASE && addr < ROM_BASE + ROM_SIZE) {
1649 >        if (transfer_type == TYPE_STORE && addr >= ROMBase && addr < ROMBase + ROM_SIZE) {
1650                  D(bug("WARNING: %s write access to ROM at %p, pc %p\n", transfer_size == SIZE_BYTE ? "Byte" : transfer_size == SIZE_HALFWORD ? "Halfword" : "Word", addr, r->pc));
1651                  if (addr_mode == MODE_U || addr_mode == MODE_UX)
1652                          segv_r[ra] = addr;
# Line 1777 | Line 1781 | static void sigill_handler(vregs *r)
1781          uint32 imm = opcode & 0xffff;
1782  
1783          // Fault in Mac ROM or RAM?
1784 <        bool mac_fault = (r->pc >= ROM_BASE) && (r->pc < (ROM_BASE + ROM_AREA_SIZE)) || (r->pc >= RAMBase) && (r->pc < (RAMBase + RAMSize));
1784 >        bool mac_fault = (r->pc >= ROMBase) && (r->pc < (ROMBase + ROM_AREA_SIZE)) || (r->pc >= RAMBase) && (r->pc < (RAMBase + RAMSize));
1785          if (mac_fault) {
1786  
1787                  switch (primop) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines