--- SheepShaver/src/Unix/sysdeps.h 2004/05/12 11:38:16 1.27 +++ SheepShaver/src/Unix/sysdeps.h 2004/11/22 22:40:26 1.35 @@ -66,14 +66,33 @@ // Define for external components #define SHEEPSHAVER 1 -// Mac and host address space are the same +// Always use Real Addressing mode on native architectures +// Otherwise, use Direct Addressing mode if NATMEM_OFFSET is set +#if !defined(EMULATED_PPC) #define REAL_ADDRESSING 1 +#elif defined(__CYGWIN__) +#define DIRECT_ADDRESSING 1 +#define DIRECT_ADDRESSING_HACK 1 +/* + The following address translation functions were empirically + determined on a Windows XP system running Cygwin 1.5.12-1 so + that RAM size can be maximized (up to 960 MB) and avoiding + the use of a TLB. This also takes into account reduced address + space available when the Cygwin runtime is used. +*/ +#define DIRECT_ADDRESSING_VIRT2PHYS(ADDR) \ + ((ADDR) + (((ADDR) < 0x41000000) ? 0x39000000 : 0xcf800000)) +#define DIRECT_ADDRESSING_PHYS2VIRT(ADDR) \ + ((ADDR) - (((ADDR) >= 0x39000000) ? 0x39000000 : 0xcf800000)) +#elif defined(NATMEM_OFFSET) +#define DIRECT_ADDRESSING 1 +#else +#define REAL_ADDRESSING 1 +#endif #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 @@ -82,12 +101,21 @@ # define ROM_IS_WRITE_PROTECTED 1 #endif // Configure PowerPC emulator -#define PPC_CHECK_INTERRUPTS (ASYNC_IRQ ? 0 : 1) +#define PPC_REENTRANT_JIT 1 +#define PPC_CHECK_INTERRUPTS 1 #define PPC_DECODE_CACHE 1 #define PPC_FLIGHT_RECORDER 1 #define PPC_PROFILE_COMPILE_TIME 0 #define PPC_PROFILE_GENERIC_CALLS 0 #define KPX_MAX_CPUS 1 +#if ENABLE_DYNGEN +// Don't bother with predecode cache when using JIT +#define PPC_ENABLE_JIT 1 +#undef PPC_DECODE_CACHE +#endif +#if defined(__i386__) +#define DYNGEN_ASM_OPTS 1 +#endif #else // Mac ROM is write protected #define ROM_IS_WRITE_PROTECTED 1 @@ -247,15 +275,15 @@ static inline int testandset(volatile in } #endif -#ifdef __i386__ +/* FIXME: SheepShaver occasionnally hangs with those locks */ +#if 0 && (defined(__i386__) || defined(__x86_64__)) #define HAVE_TEST_AND_SET 1 static inline int testandset(volatile int *p) { - int ret; - long int readval; + long int ret; /* Note: the "xchg" instruction does not need a "lock" prefix */ - __asm__ __volatile__("xchgl %0, %1" - : "=r" (ret), "=m" (*p), "=a" (readval) + __asm__ __volatile__("xchgl %k0, %1" + : "=r" (ret), "=m" (*p) : "0" (1), "m" (*p) : "memory"); return ret; @@ -327,12 +355,12 @@ static inline int testandset(volatile in #endif /* __GNUC__ */ -#if HAVE_TEST_AND_SET -#define HAVE_SPINLOCKS 1 typedef volatile int spinlock_t; static const spinlock_t SPIN_LOCK_UNLOCKED = 0; +#if HAVE_TEST_AND_SET +#define HAVE_SPINLOCKS 1 static inline void spin_lock(spinlock_t *lock) { while (testandset(lock)); @@ -347,6 +375,19 @@ static inline int spin_trylock(spinlock_ { return !testandset(lock); } +#else +static inline void spin_lock(spinlock_t *lock) +{ +} + +static inline void spin_unlock(spinlock_t *lock) +{ +} + +static inline int spin_trylock(spinlock_t *lock) +{ + return 1; +} #endif // Time data type for Time Manager emulation @@ -393,14 +434,14 @@ extern X11_LOCK_TYPE x_display_lock; #endif // Macro for calling MacOS routines -#define CallMacOS(type, tvect) call_macos((uint32)tvect) -#define CallMacOS1(type, tvect, arg1) call_macos1((uint32)tvect, (uint32)arg1) -#define CallMacOS2(type, tvect, arg1, arg2) call_macos2((uint32)tvect, (uint32)arg1, (uint32)arg2) -#define CallMacOS3(type, tvect, arg1, arg2, arg3) call_macos3((uint32)tvect, (uint32)arg1, (uint32)arg2, (uint32)arg3) -#define CallMacOS4(type, tvect, arg1, arg2, arg3, arg4) call_macos4((uint32)tvect, (uint32)arg1, (uint32)arg2, (uint32)arg3, (uint32)arg4) -#define CallMacOS5(type, tvect, arg1, arg2, arg3, arg4, arg5) call_macos5((uint32)tvect, (uint32)arg1, (uint32)arg2, (uint32)arg3, (uint32)arg4, (uint32)arg5) -#define CallMacOS6(type, tvect, arg1, arg2, arg3, arg4, arg5, arg6) call_macos6((uint32)tvect, (uint32)arg1, (uint32)arg2, (uint32)arg3, (uint32)arg4, (uint32)arg5, (uint32)arg6) -#define CallMacOS7(type, tvect, arg1, arg2, arg3, arg4, arg5, arg6, arg7) call_macos7((uint32)tvect, (uint32)arg1, (uint32)arg2, (uint32)arg3, (uint32)arg4, (uint32)arg5, (uint32)arg6, (uint32)arg7) +#define CallMacOS(type, tvect) call_macos((uintptr)tvect) +#define CallMacOS1(type, tvect, arg1) call_macos1((uintptr)tvect, (uintptr)arg1) +#define CallMacOS2(type, tvect, arg1, arg2) call_macos2((uintptr)tvect, (uintptr)arg1, (uintptr)arg2) +#define CallMacOS3(type, tvect, arg1, arg2, arg3) call_macos3((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3) +#define CallMacOS4(type, tvect, arg1, arg2, arg3, arg4) call_macos4((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4) +#define CallMacOS5(type, tvect, arg1, arg2, arg3, arg4, arg5) call_macos5((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4, (uintptr)arg5) +#define CallMacOS6(type, tvect, arg1, arg2, arg3, arg4, arg5, arg6) call_macos6((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4, (uintptr)arg5, (uintptr)arg6) +#define CallMacOS7(type, tvect, arg1, arg2, arg3, arg4, arg5, arg6, arg7) call_macos7((uintptr)tvect, (uintptr)arg1, (uintptr)arg2, (uintptr)arg3, (uintptr)arg4, (uintptr)arg5, (uintptr)arg6, (uintptr)arg7) #ifdef __cplusplus extern "C" {