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

Comparing SheepShaver/src/emul_op.cpp (file contents):
Revision 1.1 by cebix, 2002-02-04T16:58:13Z vs.
Revision 1.15 by gbeauche, 2004-11-13T14:09:15Z

# Line 1 | Line 1
1   /*
2   *  emul_op.cpp - 68k opcodes for ROM patches
3   *
4 < *  SheepShaver (C) 1997-2002 Christian Bauer and Marc Hellwig
4 > *  SheepShaver (C) 1997-2004 Christian Bauer and Marc Hellwig
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 45 | Line 45
45   #include "name_registry.h"
46   #include "user_strings.h"
47   #include "emul_op.h"
48 + #include "thunks.h"
49  
50   #define DEBUG 0
51   #include "debug.h"
# Line 58 | Line 59
59  
60  
61   // TVector of MakeExecutable
62 < static uint32 *MakeExecutableTvec;
62 > static uint32 MakeExecutableTvec;
63  
64  
65   /*
# Line 67 | Line 68 | static uint32 *MakeExecutableTvec;
68  
69   void EmulOp(M68kRegisters *r, uint32 pc, int selector)
70   {
70
71          D(bug("EmulOp %04x at %08x\n", selector, pc));
72          switch (selector) {
73                  case OP_BREAK:                          // Breakpoint
# Line 258 | Line 258 | void EmulOp(M68kRegisters *r, uint32 pc,
258                          // Install drivers
259                          InstallDrivers();
260  
261 #if !EMULATED_PPC
261                          // Patch MakeExecutable()
262 <                        MakeExecutableTvec = (uint32 *)FindLibSymbol("\023PrivateInterfaceLib", "\016MakeExecutable");
263 <                        D(bug("MakeExecutable TVECT at %p\n", MakeExecutableTvec));
264 < #ifdef __BEOS__
265 <                        MakeExecutableTvec[0] = ((uint32 *)MakeExecutable)[0];
266 < #else
268 <                        MakeExecutableTvec[0] = (uint32)MakeExecutable;
269 < #endif
270 <                        MakeExecutableTvec[1] = (uint32)TOC;
262 >                        MakeExecutableTvec = (uint32)FindLibSymbol("\023PrivateInterfaceLib", "\016MakeExecutable");
263 >                        D(bug("MakeExecutable TVECT at %08x\n", MakeExecutableTvec));
264 >                        WriteMacInt32(MakeExecutableTvec, NativeFunction(NATIVE_MAKE_EXECUTABLE));
265 > #if !EMULATED_PPC
266 >                        WriteMacInt32(MakeExecutableTvec + 4, (uint32)TOC);
267   #endif
268  
269                          // Patch DebugStr()
270                          static const uint16 proc[] = {
271 <                                M68K_EMUL_OP_DEBUG_STR,
272 <                                0x4e74,                 // rtd  #4
273 <                                0x0004
271 >                                PW(M68K_EMUL_OP_DEBUG_STR),
272 >                                PW(0x4e74),                     // rtd  #4
273 >                                PW(0x0004)
274                          };
275 <                        WriteMacInt32(0x1dfc, (uint32)proc);
275 >                        WriteMacInt32(0x1dfc, Host2MacAddr((uint8 *)proc));
276                          break;
277                  }
278  
# Line 291 | Line 287 | void EmulOp(M68kRegisters *r, uint32 pc,
287                          TimerReset();
288                          MacOSUtilReset();
289                          AudioReset();
290 < #if 0
291 <                        printf("DR activated\n");
292 <                        WriteMacInt32(KernelDataAddr + 0x17a0, 3);              // Prepare for DR emulator activation
293 <                        WriteMacInt32(KernelDataAddr + 0x17c0, DR_CACHE_BASE);
294 <                        WriteMacInt32(KernelDataAddr + 0x17c4, DR_CACHE_SIZE);
295 <                        WriteMacInt32(KernelDataAddr + 0x1b00, DR_CACHE_BASE + 0x10000);
296 <                        memcpy((void *)(DR_CACHE_BASE + 0x10000), (void *)(ROM_BASE + 0x370000), 0x10000);
297 <                        clear_caches((void *)(DR_CACHE_BASE + 0x10000), 0x10000, B_INVALIDATE_ICACHE | B_FLUSH_DCACHE);
298 < #endif
290 >
291 >                        // Enable DR emulator
292 >                        if (PrefsFindBool("jit68k")) {
293 >                                D(bug("DR activated\n"));
294 >                                WriteMacInt32(KernelDataAddr + 0x17a0, 3);              // Prepare for DR emulator activation
295 >                                WriteMacInt32(KernelDataAddr + 0x17c0, DR_CACHE_BASE);
296 >                                WriteMacInt32(KernelDataAddr + 0x17c4, DR_CACHE_SIZE);
297 >                                WriteMacInt32(KernelDataAddr + 0x1b04, DR_CACHE_BASE);
298 >                                WriteMacInt32(KernelDataAddr + 0x1b00, DR_EMULATOR_BASE);
299 >                                memcpy((void *)DR_EMULATOR_BASE, (void *)(ROM_BASE + 0x370000), DR_EMULATOR_SIZE);
300 >                                MakeExecutable(0, DR_EMULATOR_BASE, DR_EMULATOR_SIZE);
301 >                        }
302                          break;
303  
304                  case OP_IRQ:                    // Level 1 interrupt
# Line 311 | Line 310 | void EmulOp(M68kRegisters *r, uint32 pc,
310   #if !PRECISE_TIMING
311                                          TimerInterrupt();
312   #endif
313 <                                        ExecutePPC(VideoVBL);
313 >                                        ExecuteNative(NATIVE_VIDEO_VBL);
314  
315                                          static int tick_counter = 0;
316                                          if (++tick_counter >= 60) {
# Line 329 | Line 328 | void EmulOp(M68kRegisters *r, uint32 pc,
328                                  }
329                                  if (InterruptFlags & INTFLAG_ETHER) {
330                                          ClearInterruptFlag(INTFLAG_ETHER);
331 <                                        ExecutePPC(EtherIRQ);
331 >                                        ExecuteNative(NATIVE_ETHER_IRQ);
332                                  }
333                                  if (InterruptFlags & INTFLAG_TIMER) {
334                                          ClearInterruptFlag(INTFLAG_TIMER);
# Line 436 | Line 435 | void EmulOp(M68kRegisters *r, uint32 pc,
435                                  PatchNativeResourceManager();
436                          break;
437  
438 +                case OP_NTRB_17_PATCH4:
439 +                        r->d[0] = ReadMacInt16(r->a[7]);
440 +                        r->a[7] += 2;
441 +                        D(bug("%d %d\n", ReadMacInt16(r->a[2]), ReadMacInt16(r->a[2] + 6)));
442 +                        if (ReadMacInt16(r->a[2]) == 11 && ReadMacInt16(r->a[2] + 6) == 17)
443 +                                PatchNativeResourceManager();
444 +                        break;
445 +
446                  case OP_CHECKLOAD: {            // vCheckLoad() patch
447                          uint32 type = ReadMacInt32(r->a[7]);
448                          r->a[7] += 4;
# Line 460 | Line 467 | void EmulOp(M68kRegisters *r, uint32 pc,
467                          break;
468  
469                  case OP_IDLE_TIME:
463 #if __BEOS__
470                          // Sleep if no events pending
471 <                        if (ReadMacInt32(0x14c) == 0) {
472 <                                sleep(16667);
467 <                        }
468 < #endif
471 >                        if (ReadMacInt32(0x14c) == 0)
472 >                                Delay_usec(16667);
473                          r->a[0] = ReadMacInt32(0x2b6);
474                          break;
475  
476 +                case OP_IDLE_TIME_2:
477 +                        // Sleep if no events pending
478 +                        if (ReadMacInt32(0x14c) == 0)
479 +                                Delay_usec(16667);
480 +                        r->d[0] = (uint32)-2;
481 +                        break;
482 +
483                  default:
484                          printf("FATAL: EMUL_OP called with bogus selector %08x\n", selector);
485                          QuitEmulator();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines