28 |
|
#include "macos_util.h" |
29 |
|
#include "block-alloc.hpp" |
30 |
|
#include "sigsegv.h" |
31 |
– |
#include "spcflags.h" |
31 |
|
#include "cpu/ppc/ppc-cpu.hpp" |
32 |
|
#include "cpu/ppc/ppc-operations.hpp" |
33 |
+ |
#include "cpu/ppc/ppc-instructions.hpp" |
34 |
+ |
#include "thunks.h" |
35 |
|
|
36 |
|
// Used for NativeOp trampolines |
37 |
|
#include "video.h" |
38 |
|
#include "name_registry.h" |
39 |
|
#include "serial.h" |
40 |
+ |
#include "ether.h" |
41 |
|
|
42 |
|
#include <stdio.h> |
43 |
|
|
49 |
|
#define DEBUG 0 |
50 |
|
#include "debug.h" |
51 |
|
|
52 |
+ |
// Emulation time statistics |
53 |
+ |
#define EMUL_TIME_STATS 1 |
54 |
+ |
|
55 |
+ |
#if EMUL_TIME_STATS |
56 |
+ |
static clock_t emul_start_time; |
57 |
+ |
static uint32 interrupt_count = 0; |
58 |
+ |
static clock_t interrupt_time = 0; |
59 |
+ |
static uint32 exec68k_count = 0; |
60 |
+ |
static clock_t exec68k_time = 0; |
61 |
+ |
static uint32 native_exec_count = 0; |
62 |
+ |
static clock_t native_exec_time = 0; |
63 |
+ |
static uint32 macos_exec_count = 0; |
64 |
+ |
static clock_t macos_exec_time = 0; |
65 |
+ |
#endif |
66 |
+ |
|
67 |
|
static void enter_mon(void) |
68 |
|
{ |
69 |
|
// Start up mon in real-mode |
73 |
|
#endif |
74 |
|
} |
75 |
|
|
76 |
+ |
// From main_*.cpp |
77 |
+ |
extern uintptr SignalStackBase(); |
78 |
+ |
|
79 |
+ |
// PowerPC EmulOp to exit from emulation looop |
80 |
+ |
const uint32 POWERPC_EXEC_RETURN = POWERPC_EMUL_OP | 1; |
81 |
+ |
|
82 |
|
// Enable multicore (main/interrupts) cpu emulation? |
83 |
|
#define MULTICORE_CPU (ASYNC_IRQ ? 1 : 0) |
84 |
|
|
97 |
|
// Pointer to Kernel Data |
98 |
|
static KernelData * const kernel_data = (KernelData *)KERNEL_DATA_BASE; |
99 |
|
|
100 |
+ |
// SIGSEGV handler |
101 |
+ |
static sigsegv_return_t sigsegv_handler(sigsegv_address_t, sigsegv_address_t); |
102 |
+ |
|
103 |
+ |
// JIT Compiler enabled? |
104 |
+ |
static inline bool enable_jit_p() |
105 |
+ |
{ |
106 |
+ |
return PrefsFindBool("jit"); |
107 |
+ |
} |
108 |
+ |
|
109 |
|
|
110 |
|
/** |
111 |
|
* PowerPC emulator glue with special 'sheep' opcodes |
112 |
|
**/ |
113 |
|
|
114 |
< |
struct sheepshaver_exec_return { }; |
114 |
> |
enum { |
115 |
> |
PPC_I(SHEEP) = PPC_I(MAX), |
116 |
> |
PPC_I(SHEEP_MAX) |
117 |
> |
}; |
118 |
|
|
119 |
|
class sheepshaver_cpu |
120 |
|
: public powerpc_cpu |
131 |
|
uint32 get_cr() const { return cr().get(); } |
132 |
|
void set_cr(uint32 v) { cr().set(v); } |
133 |
|
|
99 |
– |
// Execution loop |
100 |
– |
void execute(uint32 entry, bool enable_cache = false); |
101 |
– |
|
134 |
|
// Execute 68k routine |
135 |
|
void execute_68k(uint32 entry, M68kRegisters *r); |
136 |
|
|
147 |
|
void interrupt(uint32 entry); |
148 |
|
void handle_interrupt(); |
149 |
|
|
118 |
– |
// spcflags for interrupts handling |
119 |
– |
static uint32 spcflags; |
120 |
– |
|
150 |
|
// Lazy memory allocator (one item at a time) |
151 |
|
void *operator new(size_t size) |
152 |
|
{ return allocator_helper< sheepshaver_cpu, lazy_allocator >::allocate(); } |
155 |
|
// FIXME: really make surre array allocation fail at link time? |
156 |
|
void *operator new[](size_t); |
157 |
|
void operator delete[](void *p); |
158 |
+ |
|
159 |
+ |
// Make sure the SIGSEGV handler can access CPU registers |
160 |
+ |
friend sigsegv_return_t sigsegv_handler(sigsegv_address_t, sigsegv_address_t); |
161 |
|
}; |
162 |
|
|
131 |
– |
uint32 sheepshaver_cpu::spcflags = 0; |
163 |
|
lazy_allocator< sheepshaver_cpu > allocator_helper< sheepshaver_cpu, lazy_allocator >::allocator; |
164 |
|
|
165 |
|
sheepshaver_cpu::sheepshaver_cpu() |
166 |
< |
: powerpc_cpu() |
166 |
> |
: powerpc_cpu(enable_jit_p()) |
167 |
|
{ |
168 |
|
init_decoder(); |
169 |
|
} |
179 |
|
|
180 |
|
static const instr_info_t sheep_ii_table[] = { |
181 |
|
{ "sheep", |
182 |
< |
(execute_fn)&sheepshaver_cpu::execute_sheep, |
182 |
> |
(execute_pmf)&sheepshaver_cpu::execute_sheep, |
183 |
|
NULL, |
184 |
+ |
PPC_I(SHEEP), |
185 |
|
D_form, 6, 0, CFLOW_JUMP | CFLOW_TRAP |
186 |
|
} |
187 |
|
}; |
221 |
|
break; |
222 |
|
|
223 |
|
case 1: // EXEC_RETURN |
224 |
< |
throw sheepshaver_exec_return(); |
224 |
> |
spcflags().set(SPCFLAG_CPU_EXEC_RETURN); |
225 |
|
break; |
226 |
|
|
227 |
|
case 2: // EXEC_NATIVE |
254 |
|
} |
255 |
|
} |
256 |
|
|
225 |
– |
// Execution loop |
226 |
– |
void sheepshaver_cpu::execute(uint32 entry, bool enable_cache) |
227 |
– |
{ |
228 |
– |
try { |
229 |
– |
powerpc_cpu::execute(entry, enable_cache); |
230 |
– |
} |
231 |
– |
catch (sheepshaver_exec_return const &) { |
232 |
– |
// Nothing, simply return |
233 |
– |
} |
234 |
– |
catch (...) { |
235 |
– |
printf("ERROR: execute() received an unknown exception!\n"); |
236 |
– |
QuitEmulator(); |
237 |
– |
} |
238 |
– |
} |
239 |
– |
|
257 |
|
// Handle MacOS interrupt |
258 |
|
void sheepshaver_cpu::interrupt(uint32 entry) |
259 |
|
{ |
260 |
+ |
#if EMUL_TIME_STATS |
261 |
+ |
interrupt_count++; |
262 |
+ |
const clock_t interrupt_start = clock(); |
263 |
+ |
#endif |
264 |
+ |
|
265 |
|
#if !MULTICORE_CPU |
266 |
|
// Save program counters and branch registers |
267 |
|
uint32 saved_pc = pc(); |
271 |
|
#endif |
272 |
|
|
273 |
|
// Initialize stack pointer to SheepShaver alternate stack base |
274 |
< |
gpr(1) = SheepStack1Base - 64; |
274 |
> |
gpr(1) = SignalStackBase() - 64; |
275 |
|
|
276 |
|
// Build trampoline to return from interrupt |
277 |
< |
uint32 trampoline[] = { htonl(POWERPC_EMUL_OP | 1) }; |
277 |
> |
SheepVar32 trampoline = POWERPC_EXEC_RETURN; |
278 |
|
|
279 |
|
// Prepare registers for nanokernel interrupt routine |
280 |
|
kernel_data->v[0x004 >> 2] = htonl(gpr(1)); |
293 |
|
gpr(1) = KernelDataAddr; |
294 |
|
gpr(7) = ntohl(kernel_data->v[0x660 >> 2]); |
295 |
|
gpr(8) = 0; |
296 |
< |
gpr(10) = (uint32)trampoline; |
297 |
< |
gpr(12) = (uint32)trampoline; |
296 |
> |
gpr(10) = trampoline.addr(); |
297 |
> |
gpr(12) = trampoline.addr(); |
298 |
|
gpr(13) = get_cr(); |
299 |
|
|
300 |
|
// rlwimi. r7,r7,8,0,0 |
315 |
|
ctr()= saved_ctr; |
316 |
|
gpr(1) = saved_sp; |
317 |
|
#endif |
318 |
+ |
|
319 |
+ |
#if EMUL_TIME_STATS |
320 |
+ |
interrupt_time += (clock() - interrupt_start); |
321 |
+ |
#endif |
322 |
|
} |
323 |
|
|
324 |
|
// Execute 68k routine |
325 |
|
void sheepshaver_cpu::execute_68k(uint32 entry, M68kRegisters *r) |
326 |
|
{ |
327 |
+ |
#if EMUL_TIME_STATS |
328 |
+ |
exec68k_count++; |
329 |
+ |
const clock_t exec68k_start = clock(); |
330 |
+ |
#endif |
331 |
+ |
|
332 |
|
#if SAFE_EXEC_68K |
333 |
|
if (ReadMacInt32(XLM_RUN_MODE) != MODE_EMUL_OP) |
334 |
|
printf("FATAL: Execute68k() not called from EMUL_OP mode\n"); |
411 |
|
lr() = saved_lr; |
412 |
|
ctr()= saved_ctr; |
413 |
|
set_cr(saved_cr); |
414 |
+ |
|
415 |
+ |
#if EMUL_TIME_STATS |
416 |
+ |
exec68k_time += (clock() - exec68k_start); |
417 |
+ |
#endif |
418 |
|
} |
419 |
|
|
420 |
|
// Call MacOS PPC code |
421 |
|
uint32 sheepshaver_cpu::execute_macos_code(uint32 tvect, int nargs, uint32 const *args) |
422 |
|
{ |
423 |
+ |
#if EMUL_TIME_STATS |
424 |
+ |
macos_exec_count++; |
425 |
+ |
const clock_t macos_exec_start = clock(); |
426 |
+ |
#endif |
427 |
+ |
|
428 |
|
// Save program counters and branch registers |
429 |
|
uint32 saved_pc = pc(); |
430 |
|
uint32 saved_lr = lr(); |
431 |
|
uint32 saved_ctr= ctr(); |
432 |
|
|
433 |
|
// Build trampoline with EXEC_RETURN |
434 |
< |
uint32 trampoline[] = { htonl(POWERPC_EMUL_OP | 1) }; |
435 |
< |
lr() = (uint32)trampoline; |
434 |
> |
SheepVar32 trampoline = POWERPC_EXEC_RETURN; |
435 |
> |
lr() = trampoline.addr(); |
436 |
|
|
437 |
|
gpr(1) -= 64; // Create stack frame |
438 |
|
uint32 proc = ReadMacInt32(tvect); // Get routine address |
463 |
|
lr() = saved_lr; |
464 |
|
ctr()= saved_ctr; |
465 |
|
|
466 |
+ |
#if EMUL_TIME_STATS |
467 |
+ |
macos_exec_time += (clock() - macos_exec_start); |
468 |
+ |
#endif |
469 |
+ |
|
470 |
|
return retval; |
471 |
|
} |
472 |
|
|
476 |
|
// Save branch registers |
477 |
|
uint32 saved_lr = lr(); |
478 |
|
|
479 |
< |
const uint32 trampoline[] = { htonl(POWERPC_EMUL_OP | 1) }; |
480 |
< |
lr() = (uint32)trampoline; |
479 |
> |
SheepVar32 trampoline = POWERPC_EXEC_RETURN; |
480 |
> |
WriteMacInt32(trampoline.addr(), POWERPC_EXEC_RETURN); |
481 |
> |
lr() = trampoline.addr(); |
482 |
|
|
483 |
|
execute(entry); |
484 |
|
|
572 |
|
if ((addr - ROM_BASE) < ROM_SIZE) |
573 |
|
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
574 |
|
|
575 |
< |
// Ignore all other faults, if requested |
576 |
< |
if (PrefsFindBool("ignoresegv")) |
577 |
< |
return SIGSEGV_RETURN_FAILURE; |
575 |
> |
// Get program counter of target CPU |
576 |
> |
sheepshaver_cpu * const cpu = current_cpu; |
577 |
> |
const uint32 pc = cpu->pc(); |
578 |
> |
|
579 |
> |
// Fault in Mac ROM or RAM? |
580 |
> |
bool mac_fault = (pc >= ROM_BASE) && (pc < (ROM_BASE + ROM_AREA_SIZE)) || (pc >= RAMBase) && (pc < (RAMBase + RAMSize)); |
581 |
> |
if (mac_fault) { |
582 |
> |
|
583 |
> |
// "VM settings" during MacOS 8 installation |
584 |
> |
if (pc == ROM_BASE + 0x488160 && cpu->gpr(20) == 0xf8000000) |
585 |
> |
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
586 |
> |
|
587 |
> |
// MacOS 8.5 installation |
588 |
> |
else if (pc == ROM_BASE + 0x488140 && cpu->gpr(16) == 0xf8000000) |
589 |
> |
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
590 |
> |
|
591 |
> |
// MacOS 8 serial drivers on startup |
592 |
> |
else if (pc == ROM_BASE + 0x48e080 && (cpu->gpr(8) == 0xf3012002 || cpu->gpr(8) == 0xf3012000)) |
593 |
> |
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
594 |
> |
|
595 |
> |
// MacOS 8.1 serial drivers on startup |
596 |
> |
else if (pc == ROM_BASE + 0x48c5e0 && (cpu->gpr(20) == 0xf3012002 || cpu->gpr(20) == 0xf3012000)) |
597 |
> |
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
598 |
> |
else if (pc == ROM_BASE + 0x4a10a0 && (cpu->gpr(20) == 0xf3012002 || cpu->gpr(20) == 0xf3012000)) |
599 |
> |
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
600 |
> |
|
601 |
> |
// Ignore all other faults, if requested |
602 |
> |
if (PrefsFindBool("ignoresegv")) |
603 |
> |
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
604 |
> |
} |
605 |
|
#else |
606 |
|
#error "FIXME: You don't have the capability to skip instruction within signal handlers" |
607 |
|
#endif |
638 |
|
mon_add_command("regs", dump_registers, "regs Dump PowerPC registers\n"); |
639 |
|
mon_add_command("log", dump_log, "log Dump PowerPC emulation log\n"); |
640 |
|
#endif |
641 |
+ |
|
642 |
+ |
#if EMUL_TIME_STATS |
643 |
+ |
emul_start_time = clock(); |
644 |
+ |
#endif |
645 |
+ |
} |
646 |
+ |
|
647 |
+ |
/* |
648 |
+ |
* Deinitialize emulation |
649 |
+ |
*/ |
650 |
+ |
|
651 |
+ |
void exit_emul_ppc(void) |
652 |
+ |
{ |
653 |
+ |
#if EMUL_TIME_STATS |
654 |
+ |
clock_t emul_end_time = clock(); |
655 |
+ |
|
656 |
+ |
printf("### Statistics for SheepShaver emulation parts\n"); |
657 |
+ |
const clock_t emul_time = emul_end_time - emul_start_time; |
658 |
+ |
printf("Total emulation time : %.1f sec\n", double(emul_time) / double(CLOCKS_PER_SEC)); |
659 |
+ |
printf("Total interrupt count: %d (%2.1f Hz)\n", interrupt_count, |
660 |
+ |
(double(interrupt_count) * CLOCKS_PER_SEC) / double(emul_time)); |
661 |
+ |
|
662 |
+ |
#define PRINT_STATS(LABEL, VAR_PREFIX) do { \ |
663 |
+ |
printf("Total " LABEL " count : %d\n", VAR_PREFIX##_count); \ |
664 |
+ |
printf("Total " LABEL " time : %.1f sec (%.1f%%)\n", \ |
665 |
+ |
double(VAR_PREFIX##_time) / double(CLOCKS_PER_SEC), \ |
666 |
+ |
100.0 * double(VAR_PREFIX##_time) / double(emul_time)); \ |
667 |
+ |
} while (0) |
668 |
+ |
|
669 |
+ |
PRINT_STATS("Execute68k[Trap] execution", exec68k); |
670 |
+ |
PRINT_STATS("NativeOp execution", native_exec); |
671 |
+ |
PRINT_STATS("MacOS routine execution", macos_exec); |
672 |
+ |
|
673 |
+ |
#undef PRINT_STATS |
674 |
+ |
printf("\n"); |
675 |
+ |
#endif |
676 |
+ |
|
677 |
+ |
delete main_cpu; |
678 |
+ |
#if MULTICORE_CPU |
679 |
+ |
delete interrupt_cpu; |
680 |
+ |
#endif |
681 |
|
} |
682 |
|
|
683 |
|
/* |
691 |
|
current_cpu->start_log(); |
692 |
|
#endif |
693 |
|
// start emulation loop and enable code translation or caching |
694 |
< |
current_cpu->execute(entry, true); |
694 |
> |
current_cpu->execute(entry); |
695 |
|
} |
696 |
|
|
697 |
|
/* |
698 |
|
* Handle PowerPC interrupt |
699 |
|
*/ |
700 |
|
|
701 |
< |
#if !ASYNC_IRQ |
701 |
> |
#if ASYNC_IRQ |
702 |
> |
void HandleInterrupt(void) |
703 |
> |
{ |
704 |
> |
main_cpu->handle_interrupt(); |
705 |
> |
} |
706 |
> |
#else |
707 |
|
void TriggerInterrupt(void) |
708 |
|
{ |
709 |
|
#if 0 |
719 |
|
void sheepshaver_cpu::handle_interrupt(void) |
720 |
|
{ |
721 |
|
// Do nothing if interrupts are disabled |
722 |
< |
if (int32(ReadMacInt32(XLM_IRQ_NEST)) > 0) |
722 |
> |
if (*(int32 *)XLM_IRQ_NEST > 0) |
723 |
|
return; |
724 |
|
|
725 |
|
// Do nothing if there is no interrupt pending |
786 |
|
if (InterruptFlags & INTFLAG_VIA) { |
787 |
|
ClearInterruptFlag(INTFLAG_VIA); |
788 |
|
ADBInterrupt(); |
789 |
< |
ExecutePPC(VideoVBL); |
789 |
> |
ExecuteNative(NATIVE_VIDEO_VBL); |
790 |
|
} |
791 |
|
} |
792 |
|
#endif |
796 |
|
} |
797 |
|
} |
798 |
|
|
682 |
– |
/* |
683 |
– |
* Execute NATIVE_OP opcode (called by PowerPC emulator) |
684 |
– |
*/ |
685 |
– |
|
686 |
– |
#define POWERPC_NATIVE_OP_INIT(LR, OP) \ |
687 |
– |
tswap32(POWERPC_EMUL_OP | ((LR) << 11) | (((uint32)OP) << 6) | 2) |
688 |
– |
|
689 |
– |
// FIXME: Make sure 32-bit relocations are used |
690 |
– |
const uint32 NativeOpTable[NATIVE_OP_MAX] = { |
691 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_PATCH_NAME_REGISTRY), |
692 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_VIDEO_INSTALL_ACCEL), |
693 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_VIDEO_VBL), |
694 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_VIDEO_DO_DRIVER_IO), |
695 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_ETHER_IRQ), |
696 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_ETHER_INIT), |
697 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_ETHER_TERM), |
698 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_ETHER_OPEN), |
699 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_ETHER_CLOSE), |
700 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_ETHER_WPUT), |
701 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_ETHER_RSRV), |
702 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_SERIAL_NOTHING), |
703 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_SERIAL_OPEN), |
704 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_SERIAL_PRIME_IN), |
705 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_SERIAL_PRIME_OUT), |
706 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_SERIAL_CONTROL), |
707 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_SERIAL_STATUS), |
708 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_SERIAL_CLOSE), |
709 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_GET_RESOURCE), |
710 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_GET_1_RESOURCE), |
711 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_GET_IND_RESOURCE), |
712 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_GET_1_IND_RESOURCE), |
713 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_R_GET_RESOURCE), |
714 |
– |
POWERPC_NATIVE_OP_INIT(0, NATIVE_DISABLE_INTERRUPT), |
715 |
– |
POWERPC_NATIVE_OP_INIT(0, NATIVE_ENABLE_INTERRUPT), |
716 |
– |
POWERPC_NATIVE_OP_INIT(1, NATIVE_MAKE_EXECUTABLE), |
717 |
– |
}; |
718 |
– |
|
799 |
|
static void get_resource(void); |
800 |
|
static void get_1_resource(void); |
801 |
|
static void get_ind_resource(void); |
806 |
|
|
807 |
|
static void NativeOp(int selector) |
808 |
|
{ |
809 |
+ |
#if EMUL_TIME_STATS |
810 |
+ |
native_exec_count++; |
811 |
+ |
const clock_t native_exec_start = clock(); |
812 |
+ |
#endif |
813 |
+ |
|
814 |
|
switch (selector) { |
815 |
|
case NATIVE_PATCH_NAME_REGISTRY: |
816 |
|
DoPatchNameRegistry(); |
825 |
|
GPR(3) = (int32)(int16)VideoDoDriverIO((void *)GPR(3), (void *)GPR(4), |
826 |
|
(void *)GPR(5), GPR(6), GPR(7)); |
827 |
|
break; |
828 |
< |
case NATIVE_GET_RESOURCE: |
829 |
< |
get_resource(); |
828 |
> |
#ifdef WORDS_BIGENDIAN |
829 |
> |
case NATIVE_ETHER_IRQ: |
830 |
> |
EtherIRQ(); |
831 |
|
break; |
832 |
< |
case NATIVE_GET_1_RESOURCE: |
833 |
< |
get_1_resource(); |
832 |
> |
case NATIVE_ETHER_INIT: |
833 |
> |
GPR(3) = InitStreamModule((void *)GPR(3)); |
834 |
|
break; |
835 |
< |
case NATIVE_GET_IND_RESOURCE: |
836 |
< |
get_ind_resource(); |
835 |
> |
case NATIVE_ETHER_TERM: |
836 |
> |
TerminateStreamModule(); |
837 |
|
break; |
838 |
< |
case NATIVE_GET_1_IND_RESOURCE: |
839 |
< |
get_1_ind_resource(); |
838 |
> |
case NATIVE_ETHER_OPEN: |
839 |
> |
GPR(3) = ether_open((queue_t *)GPR(3), (void *)GPR(4), GPR(5), GPR(6), (void*)GPR(7)); |
840 |
|
break; |
841 |
< |
case NATIVE_R_GET_RESOURCE: |
842 |
< |
r_get_resource(); |
841 |
> |
case NATIVE_ETHER_CLOSE: |
842 |
> |
GPR(3) = ether_close((queue_t *)GPR(3), GPR(4), (void *)GPR(5)); |
843 |
|
break; |
844 |
+ |
case NATIVE_ETHER_WPUT: |
845 |
+ |
GPR(3) = ether_wput((queue_t *)GPR(3), (mblk_t *)GPR(4)); |
846 |
+ |
break; |
847 |
+ |
case NATIVE_ETHER_RSRV: |
848 |
+ |
GPR(3) = ether_rsrv((queue_t *)GPR(3)); |
849 |
+ |
break; |
850 |
+ |
#else |
851 |
+ |
case NATIVE_ETHER_INIT: |
852 |
+ |
// FIXME: needs more complicated thunks |
853 |
+ |
GPR(3) = false; |
854 |
+ |
break; |
855 |
+ |
#endif |
856 |
|
case NATIVE_SERIAL_NOTHING: |
857 |
|
case NATIVE_SERIAL_OPEN: |
858 |
|
case NATIVE_SERIAL_PRIME_IN: |
873 |
|
GPR(3) = serial_callbacks[selector - NATIVE_SERIAL_NOTHING](GPR(3), GPR(4)); |
874 |
|
break; |
875 |
|
} |
876 |
+ |
case NATIVE_GET_RESOURCE: |
877 |
+ |
case NATIVE_GET_1_RESOURCE: |
878 |
+ |
case NATIVE_GET_IND_RESOURCE: |
879 |
+ |
case NATIVE_GET_1_IND_RESOURCE: |
880 |
+ |
case NATIVE_R_GET_RESOURCE: { |
881 |
+ |
typedef void (*GetResourceCallback)(void); |
882 |
+ |
static const GetResourceCallback get_resource_callbacks[] = { |
883 |
+ |
get_resource, |
884 |
+ |
get_1_resource, |
885 |
+ |
get_ind_resource, |
886 |
+ |
get_1_ind_resource, |
887 |
+ |
r_get_resource |
888 |
+ |
}; |
889 |
+ |
get_resource_callbacks[selector - NATIVE_GET_RESOURCE](); |
890 |
+ |
break; |
891 |
+ |
} |
892 |
|
case NATIVE_DISABLE_INTERRUPT: |
893 |
|
DisableInterrupt(); |
894 |
|
break; |
903 |
|
QuitEmulator(); |
904 |
|
break; |
905 |
|
} |
792 |
– |
} |
906 |
|
|
907 |
< |
/* |
908 |
< |
* Execute native subroutine (LR must contain return address) |
909 |
< |
*/ |
797 |
< |
|
798 |
< |
void ExecuteNative(int selector) |
799 |
< |
{ |
800 |
< |
uint32 tvect[2]; |
801 |
< |
tvect[0] = tswap32(POWERPC_NATIVE_OP_FUNC(selector)); |
802 |
< |
tvect[1] = 0; // Fake TVECT |
803 |
< |
RoutineDescriptor desc = BUILD_PPC_ROUTINE_DESCRIPTOR(0, tvect); |
804 |
< |
M68kRegisters r; |
805 |
< |
Execute68k((uint32)&desc, &r); |
907 |
> |
#if EMUL_TIME_STATS |
908 |
> |
native_exec_time += (clock() - native_exec_start); |
909 |
> |
#endif |
910 |
|
} |
911 |
|
|
912 |
|
/* |
927 |
|
|
928 |
|
void Execute68kTrap(uint16 trap, M68kRegisters *r) |
929 |
|
{ |
930 |
< |
uint16 proc[2]; |
931 |
< |
proc[0] = htons(trap); |
932 |
< |
proc[1] = htons(M68K_RTS); |
933 |
< |
Execute68k((uint32)proc, r); |
930 |
> |
SheepVar proc_var(4); |
931 |
> |
uint32 proc = proc_var.addr(); |
932 |
> |
WriteMacInt16(proc, trap); |
933 |
> |
WriteMacInt16(proc + 2, M68K_RTS); |
934 |
> |
Execute68k(proc, r); |
935 |
|
} |
936 |
|
|
937 |
|
/* |