From 4ac4e0fe30fc1d5fb19be4ea25c68649bd8fa1a6 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 7 Sep 2014 12:32:49 +0300 Subject: [PATCH] spinlock updates. --- custom.cpp | 2 +- events.cpp | 10 +++++++--- include/uae/ppc.h | 2 +- newcpu.cpp | 6 ++++++ ppc/ppc.cpp | 34 +++++++++++++++++----------------- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/custom.cpp b/custom.cpp index 383a92c1..3362c4ef 100644 --- a/custom.cpp +++ b/custom.cpp @@ -7701,7 +7701,7 @@ static void hsync_handler_post (bool onvsync) } else { vsyncmintime = vsyncmaxtime; /* emulate if still time left */ is_syncline_end = read_processor_time () + vsynctimebase; /* far enough in future, we never wait that long */ - is_syncline = 1; + is_syncline = 2; } } else { static int linecounter; diff --git a/events.cpp b/events.cpp index e847b341..e12a97bb 100644 --- a/events.cpp +++ b/events.cpp @@ -70,7 +70,12 @@ void do_cycles_slow (unsigned long cycles_to_add) #ifdef WITH_PPC if (regs.halted < 0) { - uae_ppc_execute_quick(); + if (is_syncline == 1) { + uae_ppc_execute_quick(0); + } else { + uae_ppc_execute_quick(1); + pissoff = pissoff_value; + } } else { #endif @@ -90,8 +95,7 @@ void do_cycles_slow (unsigned long cycles_to_add) #ifdef WITH_PPC if (regs.halted < 0) { - if (v < -vsynctimebase / 20) - uae_ppc_execute_quick(); + uae_ppc_execute_quick(0); } else { #endif diff --git a/include/uae/ppc.h b/include/uae/ppc.h index cbdd8ccf..58346f5b 100644 --- a/include/uae/ppc.h +++ b/include/uae/ppc.h @@ -41,7 +41,7 @@ void uae_ppc_reset(bool hardreset); void uae_ppc_hsync_handler(void); void uae_ppc_wakeup(void); -void uae_ppc_execute_quick(void); +void uae_ppc_execute_quick(int linetype); void uae_ppc_spinlock_reset(void); void uae_ppc_spinlock_get(void); void uae_ppc_spinlock_release(void); diff --git a/newcpu.cpp b/newcpu.cpp index 3cf5763f..a64044e2 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -3223,6 +3223,12 @@ STATIC_INLINE bool time_for_interrupt (void) void doint (void) { +#ifdef WITH_PPC + if (ppc_state) { + if (!ppc_interrupt(intlev())) + return; + } +#endif if (m68k_interrupt_delay) { regs.ipl_pin = intlev (); unset_special (SPCFLAG_INT); diff --git a/ppc/ppc.cpp b/ppc/ppc.cpp index 0f3efd84..165af886 100644 --- a/ppc/ppc.cpp +++ b/ppc/ppc.cpp @@ -13,8 +13,11 @@ #include "uae/ppc.h" -#define PPC_DEBUG_ADDR_FROM 0xf00000 -#define PPC_DEBUG_ADDR_TO 0xf40000 +#define PPC_SYNC_WRITE 0 +#define PPC_ACCESS_LOG 0 + +#define PPC_DEBUG_ADDR_FROM 0x000000 +#define PPC_DEBUG_ADDR_TO 0xffffff #ifdef WITH_PEARPC_CPU #include "pearpc/cpu/cpu.h" @@ -22,9 +25,6 @@ #include "pearpc/cpu/cpu_generic/ppc_cpu.h" #endif -#define PPC_SYNC_WRITE 0 -#define PPC_ACCESS_LOG 0 - #define TRACE(format, ...) write_log(_T("PPC: ---------------- ") format, ## __VA_ARGS__) @@ -343,11 +343,18 @@ bool uae_ppc_to_main_thread(void) return true; } -void uae_ppc_execute_quick(void) +void uae_ppc_execute_quick(int linetype) { - uae_ppc_spinlock_release(); - sleep_millis(1); - uae_ppc_spinlock_get(); + if (linetype == 0) { + for (int i = 0; i < 2; i++) { + uae_ppc_spinlock_release(); + uae_ppc_spinlock_get(); + } + } else { + uae_ppc_spinlock_release(); + sleep_millis(1); + uae_ppc_spinlock_get(); + } } void uae_ppc_emulate(void) @@ -362,13 +369,6 @@ void uae_ppc_emulate(void) g_ppc_cpu_run_single(10); } -static bool ppc_safe_addr(uaecptr addr) -{ - if (addr >= 0x08000000 && addr < 0x10000000) - return true; - return false; -} - bool uae_ppc_poll_queue(void) { if (!ppc_io_pipe) @@ -546,7 +546,7 @@ bool UAECALL uae_ppc_io_mem_read(uint32_t addr, uint32_t *data, int size) #if PPC_ACCESS_LOG > 0 if (!ppc_io_pipe && !valid_address(addr, size)) { - if (addr >= PPC_DEBUG_ADDR_FROM && addr < PPC_DEBUG_ADDR_TO) + if (addr >= PPC_DEBUG_ADDR_FROM && addr < PPC_DEBUG_ADDR_TO && addr != 0xdff006) write_log(_T("PPC io read %08x=%08x %d\n"), addr, v, size); } #endif -- 2.47.3