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.5 by gbeauche, 2003-12-04T17:26:35Z vs.
Revision 1.16 by gbeauche, 2004-11-22T22:04:38Z

# 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 59 | Line 59
59  
60  
61   // TVector of MakeExecutable
62 < static uint32 *MakeExecutableTvec;
62 > static uint32 MakeExecutableTvec;
63  
64  
65   /*
# Line 259 | Line 259 | void EmulOp(M68kRegisters *r, uint32 pc,
259                          InstallDrivers();
260  
261                          // Patch MakeExecutable()
262 <                        MakeExecutableTvec = (uint32 *)FindLibSymbol("\023PrivateInterfaceLib", "\016MakeExecutable");
263 <                        D(bug("MakeExecutable TVECT at %p\n", MakeExecutableTvec));
264 <                        MakeExecutableTvec[0] = htonl(NativeFunction(NATIVE_MAKE_EXECUTABLE));
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 <                        MakeExecutableTvec[1] = (uint32)TOC;
266 >                        WriteMacInt32(MakeExecutableTvec + 4, (uint32)TOC);
267   #endif
268  
269                          // Patch DebugStr()
270 <                        static const uint8 proc[] = {
271 <                                M68K_EMUL_OP_DEBUG_STR >> 8, M68K_EMUL_OP_DEBUG_STR & 0xff,
270 >                        static const uint8 proc_template[] = {
271 >                                M68K_EMUL_OP_DEBUG_STR >> 8, M68K_EMUL_OP_DEBUG_STR,
272                                  0x4e, 0x74,                     // rtd  #4
273                                  0x00, 0x04
274                          };
275 <                        WriteMacInt32(0x1dfc, (uint32)proc);
275 >                        BUILD_SHEEPSHAVER_PROCEDURE(proc);
276 >                        WriteMacInt32(0x1dfc, proc);
277                          break;
278                  }
279  
# Line 287 | Line 288 | void EmulOp(M68kRegisters *r, uint32 pc,
288                          TimerReset();
289                          MacOSUtilReset();
290                          AudioReset();
291 < #if 0
292 <                        printf("DR activated\n");
293 <                        WriteMacInt32(KernelDataAddr + 0x17a0, 3);              // Prepare for DR emulator activation
294 <                        WriteMacInt32(KernelDataAddr + 0x17c0, DR_CACHE_BASE);
295 <                        WriteMacInt32(KernelDataAddr + 0x17c4, DR_CACHE_SIZE);
296 <                        WriteMacInt32(KernelDataAddr + 0x1b00, DR_CACHE_BASE + 0x10000);
297 <                        memcpy((void *)(DR_CACHE_BASE + 0x10000), (void *)(ROM_BASE + 0x370000), 0x10000);
298 <                        clear_caches((void *)(DR_CACHE_BASE + 0x10000), 0x10000, B_INVALIDATE_ICACHE | B_FLUSH_DCACHE);
299 < #endif
291 >
292 >                        // Enable DR emulator
293 >                        if (PrefsFindBool("jit68k")) {
294 >                                D(bug("DR activated\n"));
295 >                                WriteMacInt32(KernelDataAddr + 0x17a0, 3);              // Prepare for DR emulator activation
296 >                                WriteMacInt32(KernelDataAddr + 0x17c0, DR_CACHE_BASE);
297 >                                WriteMacInt32(KernelDataAddr + 0x17c4, DR_CACHE_SIZE);
298 >                                WriteMacInt32(KernelDataAddr + 0x1b04, DR_CACHE_BASE);
299 >                                WriteMacInt32(KernelDataAddr + 0x1b00, DR_EMULATOR_BASE);
300 >                                memcpy((void *)DR_EMULATOR_BASE, (void *)(ROM_BASE + 0x370000), DR_EMULATOR_SIZE);
301 >                                MakeExecutable(0, DR_EMULATOR_BASE, DR_EMULATOR_SIZE);
302 >                        }
303                          break;
304  
305                  case OP_IRQ:                    // Level 1 interrupt
# Line 307 | Line 311 | void EmulOp(M68kRegisters *r, uint32 pc,
311   #if !PRECISE_TIMING
312                                          TimerInterrupt();
313   #endif
310 #if EMULATED_PPC
314                                          ExecuteNative(NATIVE_VIDEO_VBL);
312 #else
313                                        ExecutePPC(VideoVBL);
314 #endif
315  
316                                          static int tick_counter = 0;
317                                          if (++tick_counter >= 60) {
# Line 329 | Line 329 | void EmulOp(M68kRegisters *r, uint32 pc,
329                                  }
330                                  if (InterruptFlags & INTFLAG_ETHER) {
331                                          ClearInterruptFlag(INTFLAG_ETHER);
332 #if EMULATED_PPC
332                                          ExecuteNative(NATIVE_ETHER_IRQ);
334 #else
335                                        ExecutePPC(EtherIRQ);
336 #endif
333                                  }
334                                  if (InterruptFlags & INTFLAG_TIMER) {
335                                          ClearInterruptFlag(INTFLAG_TIMER);
# Line 440 | Line 436 | void EmulOp(M68kRegisters *r, uint32 pc,
436                                  PatchNativeResourceManager();
437                          break;
438  
439 +                case OP_NTRB_17_PATCH4:
440 +                        r->d[0] = ReadMacInt16(r->a[7]);
441 +                        r->a[7] += 2;
442 +                        D(bug("%d %d\n", ReadMacInt16(r->a[2]), ReadMacInt16(r->a[2] + 6)));
443 +                        if (ReadMacInt16(r->a[2]) == 11 && ReadMacInt16(r->a[2] + 6) == 17)
444 +                                PatchNativeResourceManager();
445 +                        break;
446 +
447                  case OP_CHECKLOAD: {            // vCheckLoad() patch
448                          uint32 type = ReadMacInt32(r->a[7]);
449                          r->a[7] += 4;
# Line 464 | Line 468 | void EmulOp(M68kRegisters *r, uint32 pc,
468                          break;
469  
470                  case OP_IDLE_TIME:
467 #if __BEOS__
471                          // Sleep if no events pending
472 <                        if (ReadMacInt32(0x14c) == 0) {
473 <                                sleep(16667);
471 <                        }
472 < #endif
472 >                        if (ReadMacInt32(0x14c) == 0)
473 >                                Delay_usec(16667);
474                          r->a[0] = ReadMacInt32(0x2b6);
475                          break;
476  
477 +                case OP_IDLE_TIME_2:
478 +                        // Sleep if no events pending
479 +                        if (ReadMacInt32(0x14c) == 0)
480 +                                Delay_usec(16667);
481 +                        r->d[0] = (uint32)-2;
482 +                        break;
483 +
484                  default:
485                          printf("FATAL: EMUL_OP called with bogus selector %08x\n", selector);
486                          QuitEmulator();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines