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.3 by gbeauche, 2003-10-12T05:44:11Z vs.
Revision 1.12 by gbeauche, 2004-05-31T11:00:13Z

# 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 260 | Line 261 | void EmulOp(M68kRegisters *r, uint32 pc,
261                          // Patch MakeExecutable()
262                          MakeExecutableTvec = (uint32 *)FindLibSymbol("\023PrivateInterfaceLib", "\016MakeExecutable");
263                          D(bug("MakeExecutable TVECT at %p\n", MakeExecutableTvec));
264 < #if EMULATED_PPC
265 <                        MakeExecutableTvec[0] = POWERPC_NATIVE_OP_FUNC(NATIVE_MAKE_EXECUTABLE);
265 < #else
266 < #ifdef __BEOS__
267 <                        MakeExecutableTvec[0] = ((uint32 *)MakeExecutable)[0];
268 < #else
269 <                        MakeExecutableTvec[0] = (uint32)MakeExecutable;
270 < #endif
264 >                        MakeExecutableTvec[0] = htonl(NativeFunction(NATIVE_MAKE_EXECUTABLE));
265 > #if !EMULATED_PPC
266                          MakeExecutableTvec[1] = (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,
272 <                                0x4e, 0x74,                     // rtd  #4
273 <                                0x00, 0x04
270 >                        static const uint16 proc[] = {
271 >                                PW(M68K_EMUL_OP_DEBUG_STR),
272 >                                PW(0x4e74),                     // rtd  #4
273 >                                PW(0x0004)
274                          };
275                          WriteMacInt32(0x1dfc, (uint32)proc);
276                          break;
# Line 293 | Line 288 | void EmulOp(M68kRegisters *r, uint32 pc,
288                          MacOSUtilReset();
289                          AudioReset();
290   #if 0
291 <                        printf("DR activated\n");
291 >                        // Enable DR emulator
292 >                        D(bug("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);
296 >                        WriteMacInt32(KernelDataAddr + 0x1b04, DR_CACHE_BASE);
297 >                        WriteMacInt32(KernelDataAddr + 0x1b00, DR_EMULATOR_BASE);
298 >                        memcpy((void *)DR_EMULATOR_BASE, (void *)(ROM_BASE + 0x370000), DR_EMULATOR_SIZE);
299 >                        MakeExecutable(0, (void *)DR_EMULATOR_BASE, DR_EMULATOR_SIZE);
300   #endif
301                          break;
302  
# Line 312 | Line 309 | void EmulOp(M68kRegisters *r, uint32 pc,
309   #if !PRECISE_TIMING
310                                          TimerInterrupt();
311   #endif
315 #if EMULATED_PPC
312                                          ExecuteNative(NATIVE_VIDEO_VBL);
317 #else
318                                        ExecutePPC(VideoVBL);
319 #endif
313  
314                                          static int tick_counter = 0;
315                                          if (++tick_counter >= 60) {
# Line 334 | Line 327 | void EmulOp(M68kRegisters *r, uint32 pc,
327                                  }
328                                  if (InterruptFlags & INTFLAG_ETHER) {
329                                          ClearInterruptFlag(INTFLAG_ETHER);
337 #if EMULATED_PPC
330                                          ExecuteNative(NATIVE_ETHER_IRQ);
339 #else
340                                        ExecutePPC(EtherIRQ);
341 #endif
331                                  }
332                                  if (InterruptFlags & INTFLAG_TIMER) {
333                                          ClearInterruptFlag(INTFLAG_TIMER);
# Line 469 | Line 458 | void EmulOp(M68kRegisters *r, uint32 pc,
458                          break;
459  
460                  case OP_IDLE_TIME:
472 #if __BEOS__
461                          // Sleep if no events pending
462 <                        if (ReadMacInt32(0x14c) == 0) {
463 <                                sleep(16667);
476 <                        }
477 < #endif
462 >                        if (ReadMacInt32(0x14c) == 0)
463 >                                Delay_usec(16667);
464                          r->a[0] = ReadMacInt32(0x2b6);
465                          break;
466  
467 +                case OP_IDLE_TIME_2:
468 +                        // Sleep if no events pending
469 +                        if (ReadMacInt32(0x14c) == 0)
470 +                                Delay_usec(16667);
471 +                        r->d[0] = (uint32)-2;
472 +                        break;
473 +
474                  default:
475                          printf("FATAL: EMUL_OP called with bogus selector %08x\n", selector);
476                          QuitEmulator();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines