From bd6eaf680ae25de992fe7fc8ade2eccd8687f02d Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Thu, 20 May 2004 12:33:58 +0000 Subject: [PATCH] Get rid of old (and broken) ASYNC_IRQ / MUTICORE code --- SheepShaver/src/Unix/main_unix.cpp | 13 +-- SheepShaver/src/Unix/sysdeps.h | 4 +- SheepShaver/src/include/main.h | 3 - SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp | 108 ++++++------------- 4 files changed, 34 insertions(+), 94 deletions(-) diff --git a/SheepShaver/src/Unix/main_unix.cpp b/SheepShaver/src/Unix/main_unix.cpp index 14e88a9f..b955a0f9 100644 --- a/SheepShaver/src/Unix/main_unix.cpp +++ b/SheepShaver/src/Unix/main_unix.cpp @@ -319,7 +319,6 @@ static void *emul_func(void *arg); static void *nvram_func(void *arg); static void *tick_func(void *arg); #if EMULATED_PPC -static void sigusr2_handler(int sig); extern void emul_ppc(uint32 start); extern void init_emul_ppc(void); extern void exit_emul_ppc(void); @@ -1421,7 +1420,7 @@ void B2_delete_mutex(B2_mutex *mutex) * Trigger signal USR2 from another thread */ -#if !EMULATED_PPC || ASYNC_IRQ +#if !EMULATED_PPC void TriggerInterrupt(void) { if (ready_for_signals) @@ -1471,15 +1470,7 @@ void EnableInterrupt(void) * USR2 handler */ -#if EMULATED_PPC -static void sigusr2_handler(int sig) -{ -#if ASYNC_IRQ - extern void HandleInterrupt(void); - HandleInterrupt(); -#endif -} -#else +#if !EMULATED_PPC static void sigusr2_handler(int sig, siginfo_t *sip, void *scp) { machine_regs *r = MACHINE_REGISTERS(scp); diff --git a/SheepShaver/src/Unix/sysdeps.h b/SheepShaver/src/Unix/sysdeps.h index 1312a490..d7e34ea9 100644 --- a/SheepShaver/src/Unix/sysdeps.h +++ b/SheepShaver/src/Unix/sysdeps.h @@ -72,8 +72,6 @@ #define POWERPC_ROM 1 #if EMULATED_PPC -// Handle interrupts asynchronously? -#define ASYNC_IRQ 0 // Mac ROM is write protected when banked memory is used #if REAL_ADDRESSING || DIRECT_ADDRESSING # define ROM_IS_WRITE_PROTECTED 0 @@ -83,7 +81,7 @@ #endif // Configure PowerPC emulator #define PPC_REENTRANT_JIT 1 -#define PPC_CHECK_INTERRUPTS (ASYNC_IRQ ? 0 : 1) +#define PPC_CHECK_INTERRUPTS 1 #define PPC_DECODE_CACHE 1 #define PPC_FLIGHT_RECORDER 1 #define PPC_PROFILE_COMPILE_TIME 0 diff --git a/SheepShaver/src/include/main.h b/SheepShaver/src/include/main.h index 1412cd16..b2ae6acf 100644 --- a/SheepShaver/src/include/main.h +++ b/SheepShaver/src/include/main.h @@ -69,9 +69,6 @@ enum { extern volatile uint32 InterruptFlags; // Currently pending interrupts extern void SetInterruptFlag(uint32); extern void ClearInterruptFlag(uint32); -#if EMULATED_PPC -extern void HandleInterrupt(void); // Handle SIGUSR1 interrupt in emulator thread -#endif extern void TriggerInterrupt(void); // Trigger SIGUSR1 interrupt in emulator thread extern void DisableInterrupt(void); // Disable SIGUSR1 interrupt (can be nested) extern void EnableInterrupt(void); // Enable SIGUSR1 interrupt (can be nested) diff --git a/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp b/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp index d6bd58bf..d6d549ee 100644 --- a/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp +++ b/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp @@ -84,9 +84,6 @@ extern "C" void check_load_invoc(uint32 type, int16 id, uint32 h); // PowerPC EmulOp to exit from emulation looop const uint32 POWERPC_EXEC_RETURN = POWERPC_EMUL_OP | 1; -// Enable multicore (main/interrupts) cpu emulation? -#define MULTICORE_CPU (ASYNC_IRQ ? 1 : 0) - // Enable interrupt routine safety checks? #define SAFE_INTERRUPT_PPC 1 @@ -603,13 +600,11 @@ void sheepshaver_cpu::interrupt(uint32 entry) depth++; #endif -#if !MULTICORE_CPU // Save program counters and branch registers uint32 saved_pc = pc(); uint32 saved_lr = lr(); uint32 saved_ctr= ctr(); uint32 saved_sp = gpr(1); -#endif // Initialize stack pointer to SheepShaver alternate stack base gpr(1) = SignalStackBase() - 64; @@ -649,13 +644,11 @@ void sheepshaver_cpu::interrupt(uint32 entry) // Enter nanokernel execute(entry); -#if !MULTICORE_CPU // Restore program counters and branch registers pc() = saved_pc; lr() = saved_lr; ctr()= saved_ctr; gpr(1) = saved_sp; -#endif #if EMUL_TIME_STATS interrupt_time += (clock() - interrupt_start); @@ -857,43 +850,25 @@ inline void sheepshaver_cpu::get_resource(uint32 old_get_resource) * SheepShaver CPU engine interface **/ -static sheepshaver_cpu *main_cpu = NULL; // CPU emulator to handle usual control flow -static sheepshaver_cpu *interrupt_cpu = NULL; // CPU emulator to handle interrupts -static sheepshaver_cpu *current_cpu = NULL; // Current CPU emulator context +// PowerPC CPU emulator +static sheepshaver_cpu *ppc_cpu = NULL; void FlushCodeCache(uintptr start, uintptr end) { D(bug("FlushCodeCache(%08x, %08x)\n", start, end)); - main_cpu->invalidate_cache_range(start, end); -#if MULTICORE_CPU - interrupt_cpu->invalidate_cache_range(start, end); -#endif -} - -static inline void cpu_push(sheepshaver_cpu *new_cpu) -{ -#if MULTICORE_CPU - current_cpu = new_cpu; -#endif -} - -static inline void cpu_pop() -{ -#if MULTICORE_CPU - current_cpu = main_cpu; -#endif + ppc_cpu->invalidate_cache_range(start, end); } // Dump PPC registers static void dump_registers(void) { - current_cpu->dump_registers(); + ppc_cpu->dump_registers(); } // Dump log static void dump_log(void) { - current_cpu->dump_log(); + ppc_cpu->dump_log(); } /* @@ -916,7 +891,7 @@ static sigsegv_return_t sigsegv_handler(sigsegv_address_t fault_address, sigsegv return SIGSEGV_RETURN_SKIP_INSTRUCTION; // Get program counter of target CPU - sheepshaver_cpu * const cpu = current_cpu; + sheepshaver_cpu * const cpu = ppc_cpu; const uint32 pc = cpu->pc(); // Fault in Mac ROM or RAM? @@ -956,9 +931,8 @@ static sigsegv_return_t sigsegv_handler(sigsegv_address_t fault_address, sigsegv printf("SIGSEGV\n"); printf(" pc %p\n", fault_instruction); printf(" ea %p\n", fault_address); - printf(" cpu %s\n", current_cpu == main_cpu ? "main" : "interrupts"); dump_registers(); - current_cpu->dump_log(); + ppc_cpu->dump_log(); enter_mon(); QuitEmulator(); @@ -968,16 +942,11 @@ static sigsegv_return_t sigsegv_handler(sigsegv_address_t fault_address, sigsegv void init_emul_ppc(void) { // Initialize main CPU emulator - main_cpu = new sheepshaver_cpu(); - main_cpu->set_register(powerpc_registers::GPR(3), any_register((uint32)ROM_BASE + 0x30d000)); - main_cpu->set_register(powerpc_registers::GPR(4), any_register(KernelDataAddr + 0x1000)); + ppc_cpu = new sheepshaver_cpu(); + ppc_cpu->set_register(powerpc_registers::GPR(3), any_register((uint32)ROM_BASE + 0x30d000)); + ppc_cpu->set_register(powerpc_registers::GPR(4), any_register(KernelDataAddr + 0x1000)); WriteMacInt32(XLM_RUN_MODE, MODE_68K); -#if MULTICORE_CPU - // Initialize alternate CPU emulator to handle interrupts - interrupt_cpu = new sheepshaver_cpu(); -#endif - // Install the handler for SIGSEGV sigsegv_install_handler(sigsegv_handler); @@ -1022,10 +991,7 @@ void exit_emul_ppc(void) printf("\n"); #endif - delete main_cpu; -#if MULTICORE_CPU - delete interrupt_cpu; -#endif + delete ppc_cpu; } #if PPC_ENABLE_JIT && PPC_REENTRANT_JIT @@ -1060,35 +1026,27 @@ void init_emul_op_trampolines(basic_dyngen & dg) void emul_ppc(uint32 entry) { - current_cpu = main_cpu; #if 0 - current_cpu->start_log(); + ppc_cpu->start_log(); #endif // start emulation loop and enable code translation or caching - current_cpu->execute(entry); + ppc_cpu->execute(entry); } /* * Handle PowerPC interrupt */ -#if ASYNC_IRQ -void HandleInterrupt(void) -{ - main_cpu->handle_interrupt(); -} -#else void TriggerInterrupt(void) { #if 0 WriteMacInt32(0x16a, ReadMacInt32(0x16a) + 1); #else // Trigger interrupt to main cpu only - if (main_cpu) - main_cpu->trigger_interrupt(); + if (ppc_cpu) + ppc_cpu->trigger_interrupt(); #endif } -#endif void sheepshaver_cpu::handle_interrupt(void) { @@ -1111,7 +1069,6 @@ void sheepshaver_cpu::handle_interrupt(void) switch (ReadMacInt32(XLM_RUN_MODE)) { case MODE_68K: // 68k emulator active, trigger 68k interrupt level 1 - assert(current_cpu == main_cpu); WriteMacInt16(tswap32(kernel_data->v[0x67c >> 2]), 1); set_cr(get_cr() | tswap32(kernel_data->v[0x674 >> 2])); break; @@ -1119,7 +1076,6 @@ void sheepshaver_cpu::handle_interrupt(void) #if INTERRUPTS_IN_NATIVE_MODE case MODE_NATIVE: // 68k emulator inactive, in nanokernel? - assert(current_cpu == main_cpu); if (gpr(1) != KernelDataAddr && interrupt_depth == 1) { interrupt_context ctx(this, "PowerPC mode"); @@ -1131,12 +1087,10 @@ void sheepshaver_cpu::handle_interrupt(void) // Execute nanokernel interrupt routine (this will activate the 68k emulator) DisableInterrupt(); - cpu_push(interrupt_cpu); if (ROMType == ROMTYPE_NEWWORLD) - current_cpu->interrupt(ROM_BASE + 0x312b1c); + ppc_cpu->interrupt(ROM_BASE + 0x312b1c); else - current_cpu->interrupt(ROM_BASE + 0x312a3c); - cpu_pop(); + ppc_cpu->interrupt(ROM_BASE + 0x312a3c); } break; #endif @@ -1321,7 +1275,7 @@ void sheepshaver_cpu::execute_native_op(uint32 selector) void Execute68k(uint32 pc, M68kRegisters *r) { - current_cpu->execute_68k(pc, r); + ppc_cpu->execute_68k(pc, r); } /* @@ -1344,49 +1298,49 @@ void Execute68kTrap(uint16 trap, M68kRegisters *r) uint32 call_macos(uint32 tvect) { - return current_cpu->execute_macos_code(tvect, 0, NULL); + return ppc_cpu->execute_macos_code(tvect, 0, NULL); } uint32 call_macos1(uint32 tvect, uint32 arg1) { const uint32 args[] = { arg1 }; - return current_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); + return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); } uint32 call_macos2(uint32 tvect, uint32 arg1, uint32 arg2) { const uint32 args[] = { arg1, arg2 }; - return current_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); + return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); } uint32 call_macos3(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3) { const uint32 args[] = { arg1, arg2, arg3 }; - return current_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); + return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); } uint32 call_macos4(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4) { const uint32 args[] = { arg1, arg2, arg3, arg4 }; - return current_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); + return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); } uint32 call_macos5(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4, uint32 arg5) { const uint32 args[] = { arg1, arg2, arg3, arg4, arg5 }; - return current_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); + return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); } uint32 call_macos6(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4, uint32 arg5, uint32 arg6) { const uint32 args[] = { arg1, arg2, arg3, arg4, arg5, arg6 }; - return current_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); + return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); } uint32 call_macos7(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 arg4, uint32 arg5, uint32 arg6, uint32 arg7) { const uint32 args[] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7 }; - return current_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); + return ppc_cpu->execute_macos_code(tvect, sizeof(args)/sizeof(args[0]), args); } /* @@ -1395,25 +1349,25 @@ uint32 call_macos7(uint32 tvect, uint32 arg1, uint32 arg2, uint32 arg3, uint32 a void get_resource(void) { - current_cpu->get_resource(ReadMacInt32(XLM_GET_RESOURCE)); + ppc_cpu->get_resource(ReadMacInt32(XLM_GET_RESOURCE)); } void get_1_resource(void) { - current_cpu->get_resource(ReadMacInt32(XLM_GET_1_RESOURCE)); + ppc_cpu->get_resource(ReadMacInt32(XLM_GET_1_RESOURCE)); } void get_ind_resource(void) { - current_cpu->get_resource(ReadMacInt32(XLM_GET_IND_RESOURCE)); + ppc_cpu->get_resource(ReadMacInt32(XLM_GET_IND_RESOURCE)); } void get_1_ind_resource(void) { - current_cpu->get_resource(ReadMacInt32(XLM_GET_1_IND_RESOURCE)); + ppc_cpu->get_resource(ReadMacInt32(XLM_GET_1_IND_RESOURCE)); } void r_get_resource(void) { - current_cpu->get_resource(ReadMacInt32(XLM_R_GET_RESOURCE)); + ppc_cpu->get_resource(ReadMacInt32(XLM_R_GET_RESOURCE)); }