diff --git a/BasiliskII/src/CrossPlatform/sigsegv.cpp b/BasiliskII/src/CrossPlatform/sigsegv.cpp index e3e6fea0..dab0d5a9 100755 --- a/BasiliskII/src/CrossPlatform/sigsegv.cpp +++ b/BasiliskII/src/CrossPlatform/sigsegv.cpp @@ -2916,10 +2916,6 @@ static bool sigsegv_do_install_handler(int sig) sigemptyset(&sigsegv_sa.sa_mask); sigsegv_sa.sa_handler = (signal_handler)sigsegv_handler; sigsegv_sa.sa_flags = 0; -#if !EMULATED_68K && defined(__NetBSD__) - sigaddset(&sigsegv_sa.sa_mask, SIGALRM); - sigsegv_sa.sa_flags |= SA_ONSTACK; -#endif return (sigaction(sig, &sigsegv_sa, 0) == 0); #else return (signal(sig, (signal_handler)sigsegv_handler) != SIG_ERR); diff --git a/BasiliskII/src/CrossPlatform/video_blit.cpp b/BasiliskII/src/CrossPlatform/video_blit.cpp index 5f1a0ae3..40c1c41f 100755 --- a/BasiliskII/src/CrossPlatform/video_blit.cpp +++ b/BasiliskII/src/CrossPlatform/video_blit.cpp @@ -523,7 +523,7 @@ bool Screen_blitter_init(VisualFormat const & visual_format, bool native_byte_or #else const bool use_sdl_video = false; #endif -#if REAL_ADDRESSING || DIRECT_ADDRESSING || USE_SDL_VIDEO +#if DIRECT_ADDRESSING || USE_SDL_VIDEO if (mac_depth == 1 && !use_sdl_video && !visual_format.fullscreen) { // Windowed 1-bit mode uses a 1-bit X image, so there's no need for special blitting routines diff --git a/BasiliskII/src/CrossPlatform/video_vosf.h b/BasiliskII/src/CrossPlatform/video_vosf.h index f99b44bf..a5eba67a 100644 --- a/BasiliskII/src/CrossPlatform/video_vosf.h +++ b/BasiliskII/src/CrossPlatform/video_vosf.h @@ -535,11 +535,11 @@ static void update_display_window_vosf(VIDEO_DRV_WIN_INIT) /* * Update display for DGA mode and VOSF - * (only in Real or Direct Addressing mode) + * (only in Direct Addressing mode) */ #ifndef TEST_VOSF_PERFORMANCE -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING static void update_display_dga_vosf(VIDEO_DRV_DGA_INIT) { VIDEO_MODE_INIT; diff --git a/BasiliskII/src/CrossPlatform/vm_alloc.cpp b/BasiliskII/src/CrossPlatform/vm_alloc.cpp old mode 100755 new mode 100644 index 005cb727..50636029 --- a/BasiliskII/src/CrossPlatform/vm_alloc.cpp +++ b/BasiliskII/src/CrossPlatform/vm_alloc.cpp @@ -83,6 +83,10 @@ typedef unsigned long vm_uintptr_t; #define MAP_ANONYMOUS 0 #endif +/* NOTE: on linux MAP_32BIT is only implemented on AMD64 + it is a null op on all other architectures + thus the MAP_BASE setting below is the only thing + ensuring low addresses on aarch64 for example */ #define MAP_EXTRA_FLAGS (MAP_32BIT) #ifdef HAVE_MMAP_VM @@ -91,6 +95,16 @@ typedef unsigned long vm_uintptr_t; don't get addresses above when the program is run on AMD64. NOTE: this is empirically determined on Linux/x86. */ #define MAP_BASE 0x10000000 +#elif DIRECT_ADDRESSING +/* linux does not implement any useful fallback behavior + such as allocating the next available address + and the first 4k-64k of address space is marked unavailable + for security reasons (see https://wiki.debian.org/mmap_min_addr) + so we must start requesting after the first page + or we get a high 64bit address that will crash direct addressing + + leaving NULL unmapped is a good idea anyway for debugging reasons */ +#define MAP_BASE 0x00010000 #else #define MAP_BASE 0x00000000 #endif @@ -255,9 +269,12 @@ void * vm_acquire(size_t size, int options) if ((addr = mmap((caddr_t)next_address, size, VM_PAGE_DEFAULT, the_map_flags, fd, 0)) == (void *)MAP_FAILED) return VM_MAP_FAILED; - // Sanity checks for 64-bit platforms +#if DIRECT_ADDRESSING + // Sanity check to prevent crash on 64-bit when direct addressing + // FIXME: this results in a misleading "out of memory" error to the user when it fails if (sizeof(void *) == 8 && (options & VM_MAP_32BIT) && !((char *)addr <= (char *)0xffffffff)) return VM_MAP_FAILED; +#endif next_address = (char *)addr + size; #elif defined(HAVE_WIN32_VM) diff --git a/BasiliskII/src/MacOSX/PrefsEditor.mm b/BasiliskII/src/MacOSX/PrefsEditor.mm index 1b9cd13a..06af5382 100644 --- a/BasiliskII/src/MacOSX/PrefsEditor.mm +++ b/BasiliskII/src/MacOSX/PrefsEditor.mm @@ -763,7 +763,7 @@ - (IBAction) ShowPrefs: (id)sender cpu = PrefsFindInt32("cpu"); val = PrefsFindInt32("modelid"); -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING puts("Current memory model does not support 24bit addressing"); if ( val == [classic tag] ) { diff --git a/BasiliskII/src/MacOSX/config.h b/BasiliskII/src/MacOSX/config.h index ab1f6ee5..fd270f88 100644 --- a/BasiliskII/src/MacOSX/config.h +++ b/BasiliskII/src/MacOSX/config.h @@ -31,9 +31,6 @@ /* Define if using "mon". */ /* #undef ENABLE_MON */ -/* Define if using native 68k mode. */ -/* #undef ENABLE_NATIVE_M68K */ - /* Define to 1 if translation of program messages to the user's native language is requested. */ /* #undef ENABLE_NLS */ diff --git a/BasiliskII/src/MacOSX/main_macosx.mm b/BasiliskII/src/MacOSX/main_macosx.mm index b14a2ede..b226e93b 100644 --- a/BasiliskII/src/MacOSX/main_macosx.mm +++ b/BasiliskII/src/MacOSX/main_macosx.mm @@ -32,7 +32,7 @@ # include #endif -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING # include #endif @@ -107,11 +107,6 @@ static void sigint_handler(...); #endif -#if REAL_ADDRESSING -static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped -#endif - - /* * Helpers to map memory that can be accessed from the Mac side */ @@ -334,58 +329,14 @@ bool InitEmulator (void) if (RAMSize > 1023*1024*1024) // Cap to 1023MB (APD crashes at 1GB) RAMSize = 1023*1024*1024; -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING RAMSize = RAMSize & -getpagesize(); // Round down to page boundary #endif // Initialize VM system vm_init(); -#if REAL_ADDRESSING - // Flag: RAM and ROM are contigously allocated from address 0 - bool memory_mapped_from_zero = false; - - // Make sure to map RAM & ROM at address 0 only on platforms that - // supports linker scripts to relocate the Basilisk II executable - // above 0x70000000 -#if HAVE_LINKER_SCRIPT - const bool can_map_all_memory = true; -#else - const bool can_map_all_memory = false; -#endif - - // Try to allocate all memory from 0x0000, if it is not known to crash - if (can_map_all_memory && (vm_acquire_mac_fixed(0, RAMSize + 0x100000) == 0)) { - D(bug("Could allocate RAM and ROM from 0x0000\n")); - memory_mapped_from_zero = true; - } - -#ifndef PAGEZERO_HACK - // Otherwise, just create the Low Memory area (0x0000..0x2000) - else if (vm_acquire_mac_fixed(0, 0x2000) == 0) { - D(bug("Could allocate the Low Memory globals\n")); - lm_area_mapped = true; - } - - // Exit on failure - else { - sprintf(str, GetString(STR_LOW_MEM_MMAP_ERR), strerror(errno)); - ErrorAlert(str); - QuitEmulator(); - } -#endif -#else - *str = 0; // Eliminate unused variable warning -#endif /* REAL_ADDRESSING */ - // Create areas for Mac RAM and ROM -#if REAL_ADDRESSING - if (memory_mapped_from_zero) { - RAMBaseHost = (uint8 *)0; - ROMBaseHost = RAMBaseHost + RAMSize; - } - else -#endif { uint8 *ram_rom_area = (uint8 *)vm_acquire_mac(RAMSize + 0x100000); if (ram_rom_area == VM_MAP_FAILED) { @@ -411,10 +362,6 @@ bool InitEmulator (void) MEMBaseDiff = (uintptr)RAMBaseHost; RAMBaseMac = 0; ROMBaseMac = Host2MacAddr(ROMBaseHost); -#endif -#if REAL_ADDRESSING - RAMBaseMac = Host2MacAddr(RAMBaseHost); - ROMBaseMac = Host2MacAddr(ROMBaseHost); #endif D(bug("Mac RAM starts at %p (%08x)\n", RAMBaseHost, RAMBaseMac)); D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac)); @@ -498,12 +445,6 @@ void QuitEmuNoExit() } #endif -#if REAL_ADDRESSING - // Delete Low Memory area - if (lm_area_mapped) - vm_release(0, 0x2000); -#endif - // Exit VM wrappers vm_exit(); diff --git a/BasiliskII/src/MacOSX/video_macosx.mm b/BasiliskII/src/MacOSX/video_macosx.mm index 026ae2c8..99148336 100644 --- a/BasiliskII/src/MacOSX/video_macosx.mm +++ b/BasiliskII/src/MacOSX/video_macosx.mm @@ -409,7 +409,7 @@ static void mask_buffer (void *buffer, size_t width, size_t size) void OSX_monitor::set_mac_frame_buffer(const video_mode mode) { -#if !REAL_ADDRESSING && !DIRECT_ADDRESSING +#if !DIRECT_ADDRESSING set_mac_frame_base(MacFrameBaseMac); // Set variables used by UAE memory banking diff --git a/BasiliskII/src/Unix/configure.ac b/BasiliskII/src/Unix/configure.ac index 4903a1a9..eed14c87 100755 --- a/BasiliskII/src/Unix/configure.ac +++ b/BasiliskII/src/Unix/configure.ac @@ -61,11 +61,10 @@ dnl Addressing modes. AC_ARG_ENABLE(addressing, [ --enable-addressing=AM specify the addressing mode to use [default=fastest]], [ case "$enableval" in - real) ADDRESSING_TEST_ORDER="real";; direct) ADDRESSING_TEST_ORDER="direct";; banks) ADDRESSING_TEST_ORDER="banks";; fastest)ADDRESSING_TEST_ORDER="direct banks";; - *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);; + *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, direct, banks]);; esac ], [ ADDRESSING_TEST_ORDER="direct banks" @@ -127,11 +126,6 @@ if [[ "x$BII_CROSS_MPROTECT_WORKS" = "x" ]]; then BII_CROSS_MPROTECT_WORKS="guessing no" fi -AC_ARG_VAR(BII_CROSS_MAP_LOW_AREA, [ Whether the target system can map 0x2000 bytes from 0x0000 [default=guessing no]]) -if [[ "x$BII_CROSS_MAP_LOW_AREA" = "x" ]]; then - BII_CROSS_MAP_LOW_AREA="guessing no" -fi - AC_ARG_VAR(BII_CROSS_SIGNAL_NEED_REINSTALL, [ Whether the target system needs signal handlers to be reinstalled [default=guessing yes]]) if [[ "x$BII_CROSS_SIGNAL_NEED_REINSTALL" = "x" ]]; then BII_CROSS_SIGNAL_NEED_REINSTALL="guessing yes" @@ -189,13 +183,11 @@ DEFINES="$DEFINES -DOS_$OS_TYPE" dnl Target CPU type. HAVE_I386=no -HAVE_M68K=no HAVE_SPARC=no HAVE_POWERPC=no HAVE_X86_64=no case "$target_cpu" in i386* | i486* | i586* | i686* | i786* ) HAVE_I386=yes;; - m68k* ) HAVE_M68K=yes;; sparc* ) HAVE_SPARC=yes;; powerpc* ) HAVE_POWERPC=yes;; x86_64* | amd64* ) HAVE_X86_64=yes;; @@ -738,7 +730,6 @@ SCSISRC=../dummy/scsi_dummy.cpp AUDIOSRC=../dummy/audio_dummy.cpp EXTFSSRC=extfs_unix.cpp EXTRASYSSRCS= -CAN_NATIVE_M68K=no case "$target_os" in linux*) ETHERSRC=ether_unix.cpp @@ -769,7 +760,6 @@ freebsd*) fi ;; netbsd*) - CAN_NATIVE_M68K=yes ETHERSRC=ether_unix.cpp ;; solaris*) @@ -916,14 +906,6 @@ if [[ "x$have_libvhd" = "xyes" ]]; then EXTRASYSSRCS="$EXTRASYSSRCS vhd_unix.cpp" fi - -dnl Use 68k CPU natively? -WANT_NATIVE_M68K=no -if [[ "x$HAVE_M68K" = "xyes" -a "x$CAN_NATIVE_M68K" = "xyes" ]]; then - AC_DEFINE(ENABLE_NATIVE_M68K, 1, [Define if using native 68k mode.]) - WANT_NATIVE_M68K=yes -fi - if [[ "x$HAVE_PTHREADS" = "xno" ]]; then dnl Serial, ethernet and audio support needs pthreads AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.]) @@ -1116,42 +1098,6 @@ AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm", fi dnl HAVE_MMAP_VM -dnl Check if we can modify the __PAGEZERO segment for use as Low Memory -AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000], - ac_cv_pagezero_hack, [ - ac_cv_pagezero_hack=no - if AC_TRY_COMMAND([Darwin/testlmem.sh 0x2000]); then - ac_cv_pagezero_hack=yes - dnl might as well skip the test for mmap-able low memory - ac_cv_can_map_lm=no - fi -]) -AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack", - [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.]) - -dnl Check if we can mmap 0x2000 bytes from 0x0000 -AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000], - ac_cv_can_map_lm, [ - AC_LANG_SAVE - AC_LANG_CPLUSPLUS - AC_TRY_RUN([ - #include "../CrossPlatform/vm_alloc.cpp" - int main(void) { /* returns 0 if we could map the lowmem globals */ - volatile char * lm = 0; - if (vm_init() < 0) exit(1); - if (vm_acquire_fixed(0, 0x2000) < 0) exit(1); - lm[0] = 'z'; - if (vm_release((char *)lm, 0x2000) < 0) exit(1); - vm_exit(); exit(0); - } - ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no, - dnl When cross-compiling, do not assume anything. - ac_cv_can_map_lm="$BII_CROSS_MAP_LOW_AREA" - ) - AC_LANG_RESTORE - ] -) - dnl Check signal handlers need to be reinstalled AC_CACHE_CHECK([whether signal handlers need to be reinstalled], ac_cv_signal_need_reinstall, [ @@ -1418,32 +1364,10 @@ AC_TRANSLATE_DEFINE(HAVE_LINKER_SCRIPT, "$ac_cv_linker_script_works", [Define if there is a linker script to relocate the executable above 0x70000000.]) dnl Determine the addressing mode to use -if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then - ADDRESSING_MODE="real" -else ADDRESSING_MODE="" AC_MSG_CHECKING([for the addressing mode to use]) for am in $ADDRESSING_TEST_ORDER; do case $am in - real) - dnl Requires ability to mmap() Low Memory globals - if [[ "x$ac_cv_can_map_lm$ac_cv_pagezero_hack" = "xnono" ]]; then - continue - fi - dnl Requires VOSF screen updates - if [[ "x$CAN_VOSF" = "xno" ]]; then - continue - fi - dnl Real addressing will probably work. - ADDRESSING_MODE="real" - WANT_VOSF=yes dnl we can use VOSF and we need it actually - DEFINES="$DEFINES -DREAL_ADDRESSING" - if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then - BLESS=Darwin/lowmem - LDFLAGS="$LDFLAGS -pagezero_size 0x2000" - fi - break - ;; direct) dnl Requires VOSF screen updates if [[ "x$CAN_VOSF" = "xyes" ]]; then @@ -1467,7 +1391,6 @@ else AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER]) ADDRESSING_MODE="memory banks" fi -fi dnl Banked Memory Addressing mode is not supported by the JIT compiler if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then @@ -1641,10 +1564,6 @@ elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xy esac ;; esac -elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then - dnl Native m68k, no emulation - CPUINCLUDES="-I../native_cpu" - CPUSRCS="asm_support.s" fi dnl Enable JIT compiler, if possible. @@ -1862,11 +1781,9 @@ dnl Check for certain math functions AC_CHECK_FUNCS(atanh) AC_CHECK_FUNCS(isnan isinf finite isnormal signbit) -dnl UAE CPU sources for all non-m68k-native architectures. -if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then - CPUINCLUDES="-I../uae_cpu" - CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp $FPUSRCS cpustbl.cpp cpudefs.cpp $CPUSRCS $JITSRCS" -fi +dnl UAE CPU sources for all architectures. +CPUINCLUDES="-I../uae_cpu" +CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cpp ../uae_cpu/readcpu.cpp $FPUSRCS cpustbl.cpp cpudefs.cpp $CPUSRCS $JITSRCS" dnl Or if we have -IPA (MIPSPro compilers) if [[ "x$HAVE_IPA" = "xyes" ]]; then @@ -1904,7 +1821,6 @@ echo Enable video on SEGV signals ........... : $WANT_VOSF echo ESD sound support ...................... : $WANT_ESD echo GTK user interface ..................... : $WANT_GTK echo mon debugger support ................... : $WANT_MON -echo Running m68k code natively ............. : $WANT_NATIVE_M68K echo Use JIT compiler ....................... : $WANT_JIT echo JIT debug mode ......................... : $WANT_JIT_DEBUG echo Floating-Point emulation core .......... : $FPE_CORE diff --git a/BasiliskII/src/Unix/main_unix.cpp b/BasiliskII/src/Unix/main_unix.cpp index ee4ce917..948875a7 100644 --- a/BasiliskII/src/Unix/main_unix.cpp +++ b/BasiliskII/src/Unix/main_unix.cpp @@ -39,24 +39,10 @@ # include #endif -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING # include #endif -#if !EMULATED_68K && defined(__NetBSD__) -# include -# include -# include -# include -struct sigstate { - int ss_flags; - struct frame ss_frame; - struct fpframe ss_fpstate; -}; -# define SS_FPSTATE 0x02 -# define SS_USERREGS 0x04 -#endif - #ifdef ENABLE_GTK # include # include @@ -101,26 +87,10 @@ extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_suppo #define DEBUG 0 #include "debug.h" - // Constants const char ROM_FILE_NAME[] = "ROM"; -#if !EMULATED_68K -const int SIG_STACK_SIZE = SIGSTKSZ; // Size of signal stack -#endif const int SCRATCH_MEM_SIZE = 0x10000; // Size of scratch memory area - -#if !EMULATED_68K -// RAM and ROM pointers -uint32 RAMBaseMac; // RAM base (Mac address space) -uint8 *RAMBaseHost; // RAM base (host address space) -uint32 RAMSize; // Size of RAM -uint32 ROMBaseMac; // ROM base (Mac address space) -uint8 *ROMBaseHost; // ROM base (host address space) -uint32 ROMSize; // Size of ROM -#endif - - // CPU and FPU type, addressing mode int CPUType; bool CPUIs68060; @@ -140,10 +110,6 @@ X11_LOCK_TYPE x_display_lock = X11_LOCK_INIT; // X11 display lock static uint8 last_xpram[XPRAM_SIZE]; // Buffer for monitoring XPRAM changes #ifdef HAVE_PTHREADS -#if !EMULATED_68K -static pthread_t emul_thread; // Handle of MacOS emulation thread (main thread) -#endif - static bool xpram_thread_active = false; // Flag: XPRAM watchdog installed static volatile bool xpram_thread_cancel = false; // Flag: Cancel XPRAM thread static pthread_t xpram_thread; // XPRAM watchdog @@ -164,14 +130,6 @@ static pthread_mutex_t intflag_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to pro #endif -#if !EMULATED_68K -#define SIG_IRQ SIGUSR1 -static struct sigaction sigirq_sa; // Virtual 68k interrupt signal -static struct sigaction sigill_sa; // Illegal instruction -static void *sig_stack = NULL; // Stack for signal handlers -uint16 EmulatedSR; // Emulated bits of SR (supervisor bit and interrupt mask) -#endif - #if USE_SCRATCHMEM_SUBTERFUGE uint8 *ScratchMem = NULL; // Scratch memory for Mac ROM writes #endif @@ -190,10 +148,6 @@ static struct sigaction sigint_sa; // sigaction for SIGINT handler static void sigint_handler(...); #endif -#if REAL_ADDRESSING -static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped -#endif - static rpc_connection_t *gui_connection = NULL; // RPC connection to the GUI static const char *gui_connection_path = NULL; // GUI connection identifier @@ -202,11 +156,6 @@ static const char *gui_connection_path = NULL; // GUI connection identifier static void *xpram_func(void *arg); static void *tick_func(void *arg); static void one_tick(...); -#if !EMULATED_68K -static void sigirq_handler(int sig, int code, struct sigcontext *scp); -static void sigill_handler(int sig, int code, struct sigcontext *scp); -extern "C" void EmulOpTrampoline(void); -#endif // vde switch variable char* vde_sock; @@ -284,11 +233,9 @@ static void sigsegv_dump_state(sigsegv_info_t *sip) if (fault_instruction != SIGSEGV_INVALID_ADDRESS) fprintf(stderr, " [IP=%p]", fault_instruction); fprintf(stderr, "\n"); -#if EMULATED_68K uaecptr nextpc; extern void m68k_dumpstate(uaecptr *nextpc); m68k_dumpstate(&nextpc); -#endif #if USE_JIT && JIT_DEBUG extern void compiler_dumpstate(void); compiler_dumpstate(); @@ -590,56 +537,14 @@ int main(int argc, char **argv) if (RAMSize > 1023*1024*1024) // Cap to 1023MB (APD crashes at 1GB) RAMSize = 1023*1024*1024; -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING RAMSize = RAMSize & -getpagesize(); // Round down to page boundary #endif // Initialize VM system vm_init(); -#if REAL_ADDRESSING - // Flag: RAM and ROM are contigously allocated from address 0 - bool memory_mapped_from_zero = false; - - // Make sure to map RAM & ROM at address 0 only on platforms that - // supports linker scripts to relocate the Basilisk II executable - // above 0x70000000 -#if HAVE_LINKER_SCRIPT - const bool can_map_all_memory = true; -#else - const bool can_map_all_memory = false; -#endif - - // Try to allocate all memory from 0x0000, if it is not known to crash - if (can_map_all_memory && (vm_acquire_mac_fixed(0, RAMSize + 0x100000) == 0)) { - D(bug("Could allocate RAM and ROM from 0x0000\n")); - memory_mapped_from_zero = true; - } - -#ifndef PAGEZERO_HACK - // Otherwise, just create the Low Memory area (0x0000..0x2000) - else if (vm_acquire_mac_fixed(0, 0x2000) == 0) { - D(bug("Could allocate the Low Memory globals\n")); - lm_area_mapped = true; - } - - // Exit on failure - else { - sprintf(str, GetString(STR_LOW_MEM_MMAP_ERR), strerror(errno)); - ErrorAlert(str); - QuitEmulator(); - } -#endif -#endif /* REAL_ADDRESSING */ - // Create areas for Mac RAM and ROM -#if REAL_ADDRESSING - if (memory_mapped_from_zero) { - RAMBaseHost = (uint8 *)0; - ROMBaseHost = RAMBaseHost + RAMSize; - } - else -#endif { uint8 *ram_rom_area = (uint8 *)vm_acquire_mac(RAMSize + 0x100000); if (ram_rom_area == VM_MAP_FAILED) { @@ -665,10 +570,6 @@ int main(int argc, char **argv) MEMBaseDiff = (uintptr)RAMBaseHost; RAMBaseMac = 0; ROMBaseMac = Host2MacAddr(ROMBaseHost); -#endif -#if REAL_ADDRESSING - RAMBaseMac = Host2MacAddr(RAMBaseHost); - ROMBaseMac = Host2MacAddr(ROMBaseHost); #endif D(bug("Mac RAM starts at %p (%08x)\n", RAMBaseHost, RAMBaseMac)); D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac)); @@ -701,91 +602,11 @@ int main(int argc, char **argv) QuitEmulator(); } -#if !EMULATED_68K - // Get CPU model - int mib[2] = {CTL_HW, HW_MODEL}; - char *model; - size_t model_len; - sysctl(mib, 2, NULL, &model_len, NULL, 0); - model = (char *)malloc(model_len); - sysctl(mib, 2, model, &model_len, NULL, 0); - D(bug("Model: %s\n", model)); - - // Set CPU and FPU type - CPUIs68060 = false; - if (strstr(model, "020")) - CPUType = 2; - else if (strstr(model, "030")) - CPUType = 3; - else if (strstr(model, "040")) - CPUType = 4; - else if (strstr(model, "060")) { - CPUType = 4; - CPUIs68060 = true; - } else { - printf("WARNING: Cannot detect CPU type, assuming 68020\n"); - CPUType = 2; - } - FPUType = 1; // NetBSD has an FPU emulation, so the FPU ought to be available at all times - TwentyFourBitAddressing = false; -#endif - // Initialize everything if (!InitAll(vmdir)) QuitEmulator(); D(bug("Initialization complete\n")); -#if !EMULATED_68K - // (Virtual) supervisor mode, disable interrupts - EmulatedSR = 0x2700; - -#ifdef HAVE_PTHREADS - // Get handle of main thread - emul_thread = pthread_self(); -#endif - - // Create and install stack for signal handlers - sig_stack = malloc(SIG_STACK_SIZE); - D(bug("Signal stack at %p\n", sig_stack)); - if (sig_stack == NULL) { - ErrorAlert(STR_NOT_ENOUGH_MEMORY_ERR); - QuitEmulator(); - } - stack_t new_stack; - new_stack.ss_sp = sig_stack; - new_stack.ss_flags = 0; - new_stack.ss_size = SIG_STACK_SIZE; - if (sigaltstack(&new_stack, NULL) < 0) { - sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno)); - ErrorAlert(str); - QuitEmulator(); - } - - // Install SIGILL handler for emulating privileged instructions and - // executing A-Trap and EMUL_OP opcodes - sigemptyset(&sigill_sa.sa_mask); // Block virtual 68k interrupts during SIGILL handling - sigaddset(&sigill_sa.sa_mask, SIG_IRQ); - sigaddset(&sigill_sa.sa_mask, SIGALRM); - sigill_sa.sa_handler = (void (*)(int))sigill_handler; - sigill_sa.sa_flags = SA_ONSTACK; - if (sigaction(SIGILL, &sigill_sa, NULL) < 0) { - sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIGILL", strerror(errno)); - ErrorAlert(str); - QuitEmulator(); - } - - // Install virtual 68k interrupt signal handler - sigemptyset(&sigirq_sa.sa_mask); - sigaddset(&sigirq_sa.sa_mask, SIGALRM); - sigirq_sa.sa_handler = (void (*)(int))sigirq_handler; - sigirq_sa.sa_flags = SA_ONSTACK | SA_RESTART; - if (sigaction(SIG_IRQ, &sigirq_sa, NULL) < 0) { - sprintf(str, GetString(STR_SIG_INSTALL_ERR), "SIG_IRQ", strerror(errno)); - ErrorAlert(str); - QuitEmulator(); - } -#endif - #ifdef ENABLE_MON // Setup SIGINT handler to enter mon sigemptyset(&sigint_sa.sa_mask); @@ -842,9 +663,6 @@ int main(int argc, char **argv) // Start 60Hz timer sigemptyset(&timer_sa.sa_mask); // Block virtual 68k interrupts during SIGARLM handling -#if !EMULATED_68K - sigaddset(&timer_sa.sa_mask, SIG_IRQ); -#endif timer_sa.sa_handler = one_tick; timer_sa.sa_flags = SA_ONSTACK | SA_RESTART; if (sigaction(SIGALRM, &timer_sa, NULL) < 0) { @@ -884,10 +702,8 @@ void QuitEmulator(void) { D(bug("QuitEmulator\n")); -#if EMULATED_68K // Exit 680x0 emulation Exit680x0(); -#endif #if defined(USE_CPU_EMUL_SERVICES) // Show statistics @@ -943,12 +759,6 @@ void QuitEmulator(void) } #endif -#if REAL_ADDRESSING - // Delete Low Memory area - if (lm_area_mapped) - vm_release(0, 0x2000); -#endif - // Exit VM wrappers vm_exit(); @@ -985,9 +795,6 @@ void FlushCodeCache(void *start, uint32 size) if (UseJIT) flush_icache_range((uint8 *)start, size); #endif -#if !EMULATED_68K && defined(__NetBSD__) - m68k_sync_icache(start, size); -#endif } @@ -996,13 +803,10 @@ void FlushCodeCache(void *start, uint32 size) */ #ifdef ENABLE_MON -static void sigint_handler(...) -{ -#if EMULATED_68K +static void sigint_handler(...){ uaecptr nextpc; extern void m68k_dumpstate(uaecptr *nextpc); m68k_dumpstate(&nextpc); -#endif VideoQuitFullScreen(); const char *arg[4] = {"mon", "-m", "-r", NULL}; mon(3, arg); @@ -1129,7 +933,6 @@ void B2_delete_mutex(B2_mutex *mutex) uint32 InterruptFlags = 0; -#if EMULATED_68K void SetInterruptFlag(uint32 flag) { LOCK_INTFLAGS; @@ -1143,24 +946,6 @@ void ClearInterruptFlag(uint32 flag) InterruptFlags &= ~flag; UNLOCK_INTFLAGS; } -#endif - -#if !EMULATED_68K -void TriggerInterrupt(void) -{ -#if defined(HAVE_PTHREADS) - pthread_kill(emul_thread, SIG_IRQ); -#else - raise(SIG_IRQ); -#endif -} - -void TriggerNMI(void) -{ - // not yet supported -} -#endif - /* * XPRAM watchdog thread (saves XPRAM every minute) @@ -1255,312 +1040,6 @@ static void *tick_func(void *arg) } #endif - -#if !EMULATED_68K -/* - * Virtual 68k interrupt handler - */ - -static void sigirq_handler(int sig, int code, struct sigcontext *scp) -{ - // Interrupts disabled? Then do nothing - if (EmulatedSR & 0x0700) - return; - - struct sigstate *state = (struct sigstate *)scp->sc_ap; - M68kRegisters *regs = (M68kRegisters *)&state->ss_frame; - - // Set up interrupt frame on stack - uint32 a7 = regs->a[7]; - a7 -= 2; - WriteMacInt16(a7, 0x64); - a7 -= 4; - WriteMacInt32(a7, scp->sc_pc); - a7 -= 2; - WriteMacInt16(a7, scp->sc_ps | EmulatedSR); - scp->sc_sp = regs->a[7] = a7; - - // Set interrupt level - EmulatedSR |= 0x2100; - - // Jump to MacOS interrupt handler on return - scp->sc_pc = ReadMacInt32(0x64); -} - - -/* - * SIGILL handler, for emulation of privileged instructions and executing - * A-Trap and EMUL_OP opcodes - */ - -static void sigill_handler(int sig, int code, struct sigcontext *scp) -{ - struct sigstate *state = (struct sigstate *)scp->sc_ap; - uint16 *pc = (uint16 *)scp->sc_pc; - uint16 opcode = *pc; - M68kRegisters *regs = (M68kRegisters *)&state->ss_frame; - -#define INC_PC(n) scp->sc_pc += (n) - -#define GET_SR (scp->sc_ps | EmulatedSR) - -#define STORE_SR(v) \ - scp->sc_ps = (v) & 0xff; \ - EmulatedSR = (v) & 0xe700; \ - if (((v) & 0x0700) == 0 && InterruptFlags) \ - TriggerInterrupt(); - -//printf("opcode %04x at %p, sr %04x, emul_sr %04x\n", opcode, pc, scp->sc_ps, EmulatedSR); - - if ((opcode & 0xf000) == 0xa000) { - - // A-Line instruction, set up A-Line trap frame on stack - uint32 a7 = regs->a[7]; - a7 -= 2; - WriteMacInt16(a7, 0x28); - a7 -= 4; - WriteMacInt32(a7, (uint32)pc); - a7 -= 2; - WriteMacInt16(a7, GET_SR); - scp->sc_sp = regs->a[7] = a7; - - // Jump to MacOS A-Line handler on return - scp->sc_pc = ReadMacInt32(0x28); - - } else if ((opcode & 0xff00) == 0x7100) { - - // Extended opcode, push registers on user stack - uint32 a7 = regs->a[7]; - a7 -= 4; - WriteMacInt32(a7, (uint32)pc); - a7 -= 2; - WriteMacInt16(a7, scp->sc_ps); - for (int i=7; i>=0; i--) { - a7 -= 4; - WriteMacInt32(a7, regs->a[i]); - } - for (int i=7; i>=0; i--) { - a7 -= 4; - WriteMacInt32(a7, regs->d[i]); - } - scp->sc_sp = regs->a[7] = a7; - - // Jump to EmulOp trampoline code on return - scp->sc_pc = (uint32)EmulOpTrampoline; - - } else switch (opcode) { // Emulate privileged instructions - - case 0x40e7: // move sr,-(sp) - regs->a[7] -= 2; - WriteMacInt16(regs->a[7], GET_SR); - scp->sc_sp = regs->a[7]; - INC_PC(2); - break; - - case 0x46df: { // move (sp)+,sr - uint16 sr = ReadMacInt16(regs->a[7]); - STORE_SR(sr); - regs->a[7] += 2; - scp->sc_sp = regs->a[7]; - INC_PC(2); - break; - } - - case 0x007c: { // ori #xxxx,sr - uint16 sr = GET_SR | pc[1]; - scp->sc_ps = sr & 0xff; // oring bits into the sr can't enable interrupts, so we don't need to call STORE_SR - EmulatedSR = sr & 0xe700; - INC_PC(4); - break; - } - - case 0x027c: { // andi #xxxx,sr - uint16 sr = GET_SR & pc[1]; - STORE_SR(sr); - INC_PC(4); - break; - } - - case 0x46fc: // move #xxxx,sr - STORE_SR(pc[1]); - INC_PC(4); - break; - - case 0x46ef: { // move (xxxx,sp),sr - uint16 sr = ReadMacInt16(regs->a[7] + (int32)(int16)pc[1]); - STORE_SR(sr); - INC_PC(4); - break; - } - - case 0x46d8: // move (a0)+,sr - case 0x46d9: { // move (a1)+,sr - uint16 sr = ReadMacInt16(regs->a[opcode & 7]); - STORE_SR(sr); - regs->a[opcode & 7] += 2; - INC_PC(2); - break; - } - - case 0x40f8: // move sr,xxxx.w - WriteMacInt16(pc[1], GET_SR); - INC_PC(4); - break; - - case 0x40d0: // move sr,(a0) - case 0x40d1: // move sr,(a1) - case 0x40d2: // move sr,(a2) - case 0x40d3: // move sr,(a3) - case 0x40d4: // move sr,(a4) - case 0x40d5: // move sr,(a5) - case 0x40d6: // move sr,(a6) - case 0x40d7: // move sr,(sp) - WriteMacInt16(regs->a[opcode & 7], GET_SR); - INC_PC(2); - break; - - case 0x40c0: // move sr,d0 - case 0x40c1: // move sr,d1 - case 0x40c2: // move sr,d2 - case 0x40c3: // move sr,d3 - case 0x40c4: // move sr,d4 - case 0x40c5: // move sr,d5 - case 0x40c6: // move sr,d6 - case 0x40c7: // move sr,d7 - regs->d[opcode & 7] = GET_SR; - INC_PC(2); - break; - - case 0x46c0: // move d0,sr - case 0x46c1: // move d1,sr - case 0x46c2: // move d2,sr - case 0x46c3: // move d3,sr - case 0x46c4: // move d4,sr - case 0x46c5: // move d5,sr - case 0x46c6: // move d6,sr - case 0x46c7: { // move d7,sr - uint16 sr = regs->d[opcode & 7]; - STORE_SR(sr); - INC_PC(2); - break; - } - - case 0xf327: // fsave -(sp) - regs->a[7] -= 4; - WriteMacInt32(regs->a[7], 0x41000000); // Idle frame - scp->sc_sp = regs->a[7]; - INC_PC(2); - break; - - case 0xf35f: // frestore (sp)+ - regs->a[7] += 4; - scp->sc_sp = regs->a[7]; - INC_PC(2); - break; - - case 0x4e73: { // rte - uint32 a7 = regs->a[7]; - uint16 sr = ReadMacInt16(a7); - a7 += 2; - scp->sc_ps = sr & 0xff; - EmulatedSR = sr & 0xe700; - scp->sc_pc = ReadMacInt32(a7); - a7 += 4; - uint16 format = ReadMacInt16(a7) >> 12; - a7 += 2; - static const int frame_adj[16] = { - 0, 0, 4, 4, 8, 0, 0, 52, 50, 12, 24, 84, 16, 0, 0, 0 - }; - scp->sc_sp = regs->a[7] = a7 + frame_adj[format]; - break; - } - - case 0x4e7a: // movec cr,x - switch (pc[1]) { - case 0x0002: // movec cacr,d0 - regs->d[0] = 0x3111; - break; - case 0x1002: // movec cacr,d1 - regs->d[1] = 0x3111; - break; - case 0x0003: // movec tc,d0 - case 0x0004: // movec itt0,d0 - case 0x0005: // movec itt1,d0 - case 0x0006: // movec dtt0,d0 - case 0x0007: // movec dtt1,d0 - case 0x0806: // movec urp,d0 - case 0x0807: // movec srp,d0 - regs->d[0] = 0; - break; - case 0x1000: // movec sfc,d1 - case 0x1001: // movec dfc,d1 - case 0x1003: // movec tc,d1 - case 0x1801: // movec vbr,d1 - regs->d[1] = 0; - break; - case 0x8801: // movec vbr,a0 - regs->a[0] = 0; - break; - case 0x9801: // movec vbr,a1 - regs->a[1] = 0; - break; - default: - goto ill; - } - INC_PC(4); - break; - - case 0x4e7b: // movec x,cr - switch (pc[1]) { - case 0x1000: // movec d1,sfc - case 0x1001: // movec d1,dfc - case 0x0801: // movec d0,vbr - case 0x1801: // movec d1,vbr - break; - case 0x0002: // movec d0,cacr - case 0x1002: // movec d1,cacr - FlushCodeCache(NULL, 0); - break; - default: - goto ill; - } - INC_PC(4); - break; - - case 0xf478: // cpusha dc - case 0xf4f8: // cpusha dc/ic - FlushCodeCache(NULL, 0); - INC_PC(2); - break; - - default: -ill: printf("SIGILL num %d, code %d\n", sig, code); - printf(" context %p:\n", scp); - printf(" onstack %08x\n", scp->sc_onstack); - printf(" sp %08x\n", scp->sc_sp); - printf(" fp %08x\n", scp->sc_fp); - printf(" pc %08x\n", scp->sc_pc); - printf(" opcode %04x\n", opcode); - printf(" sr %08x\n", scp->sc_ps); - printf(" state %p:\n", state); - printf(" flags %d\n", state->ss_flags); - for (int i=0; i<8; i++) - printf(" d%d %08x\n", i, state->ss_frame.f_regs[i]); - for (int i=0; i<8; i++) - printf(" a%d %08x\n", i, state->ss_frame.f_regs[i+8]); - - VideoQuitFullScreen(); -#ifdef ENABLE_MON - const char *arg[4] = {"mon", "-m", "-r", NULL}; - mon(3, arg); -#endif - QuitEmulator(); - break; - } -} -#endif - - /* * Display alert */ diff --git a/BasiliskII/src/Unix/prefs_editor_gtk.cpp b/BasiliskII/src/Unix/prefs_editor_gtk.cpp index 637e1e67..5f994ad8 100644 --- a/BasiliskII/src/Unix/prefs_editor_gtk.cpp +++ b/BasiliskII/src/Unix/prefs_editor_gtk.cpp @@ -1506,7 +1506,6 @@ static void create_memory_pane(GtkWidget *top) } table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active); -#if EMULATED_68K static const opt_desc cpu_options[] = { {STR_CPU_68020_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020)}, {STR_CPU_68020_FPU_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020_fpu)}, @@ -1524,7 +1523,6 @@ static void create_memory_pane(GtkWidget *top) case 4: active = 4; } table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active); -#endif w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom"); diff --git a/BasiliskII/src/Unix/sysdeps.h b/BasiliskII/src/Unix/sysdeps.h index 51a53c78..ff86e3cf 100644 --- a/BasiliskII/src/Unix/sysdeps.h +++ b/BasiliskII/src/Unix/sysdeps.h @@ -66,41 +66,17 @@ #include #endif -#ifdef ENABLE_NATIVE_M68K - -/* Mac and host address space are the same */ -#define REAL_ADDRESSING 1 - -/* Using 68k natively */ -#define EMULATED_68K 0 - -/* Mac ROM is not write protected */ -#define ROM_IS_WRITE_PROTECTED 0 -#define USE_SCRATCHMEM_SUBTERFUGE 1 - -#else - -/* Mac and host address space are distinct */ -#ifndef REAL_ADDRESSING -#define REAL_ADDRESSING 0 -#endif - -/* Using 68k emulator */ -#define EMULATED_68K 1 - /* The m68k emulator uses a prefetch buffer ? */ #define USE_PREFETCH_BUFFER 0 /* Mac ROM is write protected when banked memory is used */ -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING # define ROM_IS_WRITE_PROTECTED 0 # define USE_SCRATCHMEM_SUBTERFUGE 1 #else # define ROM_IS_WRITE_PROTECTED 1 #endif -#endif - /* Direct Addressing requires Video on SEGV signals in plain X11 mode */ #if DIRECT_ADDRESSING && (!ENABLE_VOSF && !USE_SDL_VIDEO) # undef ENABLE_VOSF @@ -117,11 +93,9 @@ #ifdef HAVE_PTHREADS #define USE_PTHREADS_SERVICES #endif -#if EMULATED_68K #if defined(__NetBSD__) #define USE_CPU_EMUL_SERVICES #endif -#endif #ifdef USE_CPU_EMUL_SERVICES #undef USE_PTHREADS_SERVICES #endif diff --git a/BasiliskII/src/Unix/video_x.cpp b/BasiliskII/src/Unix/video_x.cpp index e373719c..374e9a91 100644 --- a/BasiliskII/src/Unix/video_x.cpp +++ b/BasiliskII/src/Unix/video_x.cpp @@ -406,7 +406,7 @@ static void add_window_modes(video_depth depth) // Set Mac frame layout and base address (uses the_buffer/MacFrameBaseMac) static void set_mac_frame_buffer(X11_monitor_desc &monitor, video_depth depth, bool native_byte_order) { -#if !REAL_ADDRESSING && !DIRECT_ADDRESSING +#if !DIRECT_ADDRESSING int layout = FLAYOUT_DIRECT; if (depth == VDEPTH_16BIT) layout = (xdepth == 15) ? FLAYOUT_HOST_555 : FLAYOUT_HOST_565; @@ -1265,7 +1265,7 @@ driver_fbdev::driver_fbdev(X11_monitor_desc &m) : driver_dga(m) } #if ENABLE_VOSF -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING // Screen_blitter_init() returns TRUE if VOSF is mandatory // i.e. the framebuffer update function is not Blit_Copy_Raw use_vosf = Screen_blitter_init(visualFormat, true, mode.depth); @@ -1402,7 +1402,7 @@ driver_xf86dga::driver_xf86dga(X11_monitor_desc &m) // Init blitting routines int bytes_per_row = TrivialBytesPerRow((v_width + 7) & ~7, mode.depth); #if ENABLE_VOSF -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING // Screen_blitter_init() returns TRUE if VOSF is mandatory // i.e. the framebuffer update function is not Blit_Copy_Raw use_vosf = Screen_blitter_init(visualFormat, x_native_byte_order, depth_of_video_mode(mode)); @@ -2608,7 +2608,7 @@ static void video_refresh_dga(void) } #ifdef ENABLE_VOSF -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING static void video_refresh_dga_vosf(void) { // Quit DGA mode if requested @@ -2681,7 +2681,7 @@ static void VideoRefreshInit(void) { // TODO: set up specialised 8bpp VideoRefresh handlers ? if (display_type == DISPLAY_DGA) { -#if ENABLE_VOSF && (REAL_ADDRESSING || DIRECT_ADDRESSING) +#if ENABLE_VOSF && DIRECT_ADDRESSING if (use_vosf) video_refresh = video_refresh_dga_vosf; else diff --git a/BasiliskII/src/Windows/main_windows.cpp b/BasiliskII/src/Windows/main_windows.cpp index 07a1f157..74aa879e 100755 --- a/BasiliskII/src/Windows/main_windows.cpp +++ b/BasiliskII/src/Windows/main_windows.cpp @@ -94,11 +94,6 @@ static SDL_mutex *intflag_lock = NULL; // Mutex to protect InterruptFlags uint8 *ScratchMem = NULL; // Scratch memory for Mac ROM writes #endif -#if REAL_ADDRESSING -static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped -#endif - - // Prototypes static int xpram_func(void *arg); static int tick_func(void *arg); diff --git a/BasiliskII/src/Windows/prefs_editor_gtk.cpp b/BasiliskII/src/Windows/prefs_editor_gtk.cpp index 7e04ba80..a52714f3 100644 --- a/BasiliskII/src/Windows/prefs_editor_gtk.cpp +++ b/BasiliskII/src/Windows/prefs_editor_gtk.cpp @@ -1685,9 +1685,7 @@ static void create_memory_pane(GtkWidget *top) case 14: active = 1; break; } table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active); -#endif -#if EMULATED_68K static const opt_desc cpu_options[] = { {STR_CPU_68020_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020)}, {STR_CPU_68020_FPU_LAB, GTK_SIGNAL_FUNC(mn_cpu_68020_fpu)}, diff --git a/BasiliskII/src/Windows/sysdeps.h b/BasiliskII/src/Windows/sysdeps.h index ac040a43..cf73f924 100755 --- a/BasiliskII/src/Windows/sysdeps.h +++ b/BasiliskII/src/Windows/sysdeps.h @@ -47,23 +47,11 @@ #include #include - -/* Mac and host address space are distinct */ -#ifndef REAL_ADDRESSING -#define REAL_ADDRESSING 0 -#endif -#if REAL_ADDRESSING -#error "Real Addressing mode can't work without proper kernel support" -#endif - -/* Using 68k emulator */ -#define EMULATED_68K 1 - /* The m68k emulator uses a prefetch buffer ? */ #define USE_PREFETCH_BUFFER 0 /* Mac ROM is write protected when banked memory is used */ -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING # define ROM_IS_WRITE_PROTECTED 0 # define USE_SCRATCHMEM_SUBTERFUGE 1 #else diff --git a/BasiliskII/src/ether.cpp b/BasiliskII/src/ether.cpp index 8df8c86b..13221789 100644 --- a/BasiliskII/src/ether.cpp +++ b/BasiliskII/src/ether.cpp @@ -444,7 +444,6 @@ void ether_udp_read(uint32 packet, int length, struct sockaddr_in *from) * Ethernet packet allocator */ -#if SIZEOF_VOID_P != 4 || REAL_ADDRESSING == 0 static uint32 ether_packet = 0; // Ethernet packet (cached allocation) static uint32 n_ether_packets = 0; // Number of ethernet packets allocated so far (should be at most 1) @@ -476,4 +475,3 @@ EthernetPacket::~EthernetPacket() bug("WARNING: Nested allocation of ethernet packets!\n"); } } -#endif diff --git a/BasiliskII/src/include/ether.h b/BasiliskII/src/include/ether.h index e1e988d0..a497cb97 100644 --- a/BasiliskII/src/include/ether.h +++ b/BasiliskII/src/include/ether.h @@ -61,19 +61,13 @@ enum { extern uint32 ether_data; // Mac address of driver data in MacOS RAM -// Ethernet packet allocator (optimized for 32-bit platforms in real addressing mode) +// Ethernet packet allocator class EthernetPacket { -#if SIZEOF_VOID_P == 4 && REAL_ADDRESSING - uint8 packet[1516]; - public: - uint32 addr(void) const { return (uint32)packet; } -#else uint32 packet; public: EthernetPacket(); ~EthernetPacket(); uint32 addr(void) const { return packet; } -#endif }; // Copy packet data from WDS to linear buffer (must hold at least 1514 bytes), diff --git a/BasiliskII/src/main.cpp b/BasiliskII/src/main.cpp index dcb86e9c..d7da2f98 100644 --- a/BasiliskII/src/main.cpp +++ b/BasiliskII/src/main.cpp @@ -69,7 +69,6 @@ bool InitAll(const char *vmdir) return false; } -#if EMULATED_68K // Set CPU and FPU type (UAE emulation) switch (ROMVersion) { case ROM_VERSION_64K: @@ -97,7 +96,6 @@ bool InitAll(const char *vmdir) break; } CPUIs68060 = false; -#endif // Load XPRAM XPRAMInit(vmdir); @@ -180,11 +178,9 @@ bool InitAll(const char *vmdir) XPRAM[0x58] = uint8(main_monitor.depth_to_apple_mode(main_monitor.get_current_mode().depth)); XPRAM[0x59] = 0; -#if EMULATED_68K // Init 680x0 emulation (this also activates the memory system which is needed for PatchROM()) if (!Init680x0()) return false; -#endif // Install ROM patches if (!PatchROM()) { diff --git a/BasiliskII/src/native_cpu/cpu_emulation.h b/BasiliskII/src/native_cpu/cpu_emulation.h deleted file mode 100644 index 822ee047..00000000 --- a/BasiliskII/src/native_cpu/cpu_emulation.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * cpu_emulation.h - Definitions for Basilisk II CPU emulation module (native 68k version) - * - * Basilisk II (C) 1997-2008 Christian Bauer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef CPU_EMULATION_H -#define CPU_EMULATION_H - - -/* - * Memory system - */ - -// RAM and ROM pointers (allocated and set by main_*.cpp) -extern uint32 RAMBaseMac; // RAM base (Mac address space), does not include Low Mem when != 0 -extern uint8 *RAMBaseHost; // RAM base (host address space) -extern uint32 RAMSize; // Size of RAM - -extern uint32 ROMBaseMac; // ROM base (Mac address space) -extern uint8 *ROMBaseHost; // ROM base (host address space) -extern uint32 ROMSize; // Size of ROM - -// Mac memory access functions -static inline uint32 ReadMacInt32(uint32 addr) {return *(uint32 *)addr;} -static inline uint32 ReadMacInt16(uint32 addr) {return *(uint16 *)addr;} -static inline uint32 ReadMacInt8(uint32 addr) {return *(uint8 *)addr;} -static inline void WriteMacInt32(uint32 addr, uint32 l) {*(uint32 *)addr = l;} -static inline void WriteMacInt16(uint32 addr, uint32 w) {*(uint16 *)addr = w;} -static inline void WriteMacInt8(uint32 addr, uint32 b) {*(uint8 *)addr = b;} -static inline uint8 *Mac2HostAddr(uint32 addr) {return (uint8 *)addr;} -static inline uint32 Host2MacAddr(uint8 *addr) {return (uint32)addr;} -static inline void *Mac_memset(uint32 addr, int c, size_t n) {return memset(Mac2HostAddr(addr), c, n);} -static inline void *Mac2Host_memcpy(void *dest, uint32 src, size_t n) {return memcpy(dest, Mac2HostAddr(src), n);} -static inline void *Host2Mac_memcpy(uint32 dest, const void *src, size_t n) {return memcpy(Mac2HostAddr(dest), src, n);} -static inline void *Mac2Mac_memcpy(uint32 dest, uint32 src, size_t n) {return memcpy(Mac2HostAddr(dest), Mac2HostAddr(src), n);} - - -/* - * 680x0 emulation - */ - -// 680x0 emulation functions -struct M68kRegisters; -extern void Start680x0(void); // Reset and start 680x0 -extern "C" void Execute68k(uint32 addr, M68kRegisters *r); // Execute 68k code from EMUL_OP routine -extern "C" void Execute68kTrap(uint16 trap, M68kRegisters *r); // Execute MacOS 68k trap from EMUL_OP routine - -// Interrupt functions -extern void TriggerInterrupt(void); // Trigger interrupt (InterruptFlag must be set first) -extern void TriggerNMI(void); // Trigger interrupt level 7 - -#endif diff --git a/BasiliskII/src/rom_patches.cpp b/BasiliskII/src/rom_patches.cpp index 5cfb13e2..1fb85e59 100644 --- a/BasiliskII/src/rom_patches.cpp +++ b/BasiliskII/src/rom_patches.cpp @@ -832,7 +832,7 @@ bool CheckROM(void) // Read version ROMVersion = ntohs(*(uint16 *)(ROMBaseHost + 8)); -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING // Real and direct addressing modes require a 32-bit clean ROM return ROMVersion == ROM_VERSION_32; #else @@ -1257,15 +1257,6 @@ static bool patch_rom_32(void) *wp++ = htons(0x0cea); *wp = htons(M68K_RTS); -#if REAL_ADDRESSING - // Move system zone to start of Mac RAM - wp = (uint16 *)(ROMBaseHost + 0x50a); - *wp++ = htons(HiWord(RAMBaseMac + 0x2000)); - *wp++ = htons(LoWord(RAMBaseMac + 0x2000)); - *wp++ = htons(HiWord(RAMBaseMac + 0x3800)); - *wp = htons(LoWord(RAMBaseMac + 0x3800)); -#endif - #if !ROM_IS_WRITE_PROTECTED #if defined(USE_SCRATCHMEM_SUBTERFUGE) // Set fake handle at 0x0000 to scratch memory area (so broken Mac programs won't write into Mac ROM) @@ -1280,13 +1271,6 @@ static bool patch_rom_32(void) #endif #endif -#if REAL_ADDRESSING - // gb-- Temporary hack to get rid of crashes in Speedometer - wp = (uint16 *)(ROMBaseHost + 0xdba2); - if (ntohs(*wp) == 0x662c) // bne.b #$2c - *wp = htons(0x602c); // bra.b #$2c -#endif - // Don't write to VIA in InitTimeMgr wp = (uint16 *)(ROMBaseHost + 0xb0e2); *wp++ = htons(0x4cdf); // movem.l (sp)+,d0-d5/a0-a4 diff --git a/BasiliskII/src/uae_cpu/basilisk_glue.cpp b/BasiliskII/src/uae_cpu/basilisk_glue.cpp index b29c7702..d6c6d3b1 100644 --- a/BasiliskII/src/uae_cpu/basilisk_glue.cpp +++ b/BasiliskII/src/uae_cpu/basilisk_glue.cpp @@ -41,12 +41,10 @@ uint32 ROMBaseMac; // ROM base (Mac address space) uint8 *ROMBaseHost; // ROM base (host address space) uint32 ROMSize; // Size of ROM -#if !REAL_ADDRESSING // Mac frame buffer uint8 *MacFrameBaseHost; // Frame buffer base (host address space) uint32 MacFrameSize; // Size of frame buffer int MacFrameLayout; // Frame buffer layout -#endif #if DIRECT_ADDRESSING uintptr MEMBaseDiff; // Global offset between a Mac address and its Host equivalent @@ -64,13 +62,8 @@ extern bool quit_program; * Initialize 680x0 emulation, CheckROM() must have been called first */ -bool Init680x0(void) -{ -#if REAL_ADDRESSING - // Mac address space = host address space - RAMBaseMac = (uintptr)RAMBaseHost; - ROMBaseMac = (uintptr)ROMBaseHost; -#elif DIRECT_ADDRESSING +bool Init680x0(void){ +#if DIRECT_ADDRESSING // Mac address space = host address space minus constant offset (MEMBaseDiff) // NOTE: MEMBaseDiff is set up in main_unix.cpp/main() RAMBaseMac = 0; @@ -119,14 +112,12 @@ void Exit680x0(void) exit_m68k(); } - /* * Initialize memory mapping of frame buffer (called upon video mode change) */ -void InitFrameBufferMapping(void) -{ -#if !REAL_ADDRESSING && !DIRECT_ADDRESSING +void InitFrameBufferMapping(void){ +#if !DIRECT_ADDRESSING memory_init(); #endif } diff --git a/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp b/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp index 1713b734..1abc20ad 100644 --- a/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp +++ b/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp @@ -25,8 +25,8 @@ #include "sysdeps.h" -#if !REAL_ADDRESSING && !DIRECT_ADDRESSING -#error "Only Real or Direct Addressing is supported with the JIT Compiler" +#if !DIRECT_ADDRESSING +#error "Only Direct Addressing is supported with the JIT Compiler" #endif #if X86_ASSEMBLY && !SAHF_SETO_PROFITABLE @@ -5563,9 +5563,7 @@ void get_n_addr(int address, int dest, int tmp) f=dest; } -#if REAL_ADDRESSING - mov_l_rr(dest, address); -#elif DIRECT_ADDRESSING +#if DIRECT_ADDRESSING lea_l_brr(dest,address,MEMBaseDiff); #endif forget_about(tmp); @@ -7078,7 +7076,7 @@ void execute_normal(void) if (!check_for_cache_miss()) { cpu_history pc_hist[MAXRUN]; int blocklen = 0; -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING start_pc_p = regs.pc_p; start_pc = get_virtual_address(regs.pc_p); #else diff --git a/BasiliskII/src/uae_cpu/cpu_emulation.h b/BasiliskII/src/uae_cpu/cpu_emulation.h index cd588ec1..6acf0ab9 100644 --- a/BasiliskII/src/uae_cpu/cpu_emulation.h +++ b/BasiliskII/src/uae_cpu/cpu_emulation.h @@ -37,8 +37,8 @@ extern uint32 ROMBaseMac; // ROM base (Mac address space) extern uint8 *ROMBaseHost; // ROM base (host address space) extern uint32 ROMSize; // Size of ROM -#if !REAL_ADDRESSING && !DIRECT_ADDRESSING -// If we are not using real or direct addressing, the Mac frame buffer gets +#if !DIRECT_ADDRESSING +// If we are not using direct addressing, the Mac frame buffer gets // mapped to this location. The memory must be allocated by VideoInit(). // If multiple monitors are used, they must share the frame buffer const uint32 MacFrameBaseMac = 0xa0000000; diff --git a/BasiliskII/src/uae_cpu/memory.cpp b/BasiliskII/src/uae_cpu/memory.cpp index 7483f506..aa0b22b4 100644 --- a/BasiliskII/src/uae_cpu/memory.cpp +++ b/BasiliskII/src/uae_cpu/memory.cpp @@ -34,7 +34,7 @@ #include "readcpu.h" #include "newcpu.h" -#if !REAL_ADDRESSING && !DIRECT_ADDRESSING +#if !DIRECT_ADDRESSING static bool illegal_mem = false; @@ -638,5 +638,5 @@ void map_banks(addrbank *bank, int start, int size) put_mem_bank((bnr + hioffs) << 16, bank); } -#endif /* !REAL_ADDRESSING && !DIRECT_ADDRESSING */ +#endif /* !DIRECT_ADDRESSING */ diff --git a/BasiliskII/src/uae_cpu/memory.h b/BasiliskII/src/uae_cpu/memory.h index 75a6303b..d7898166 100644 --- a/BasiliskII/src/uae_cpu/memory.h +++ b/BasiliskII/src/uae_cpu/memory.h @@ -23,7 +23,7 @@ #ifndef UAE_MEMORY_H #define UAE_MEMORY_H -#if !DIRECT_ADDRESSING && !REAL_ADDRESSING +#if !DIRECT_ADDRESSING /* Enabling this adds one additional native memory reference per 68k memory * access, but saves one shift (on the x86). Enabling this is probably @@ -115,15 +115,11 @@ extern void byteput(uaecptr addr, uae_u32 b); #endif -#endif /* !DIRECT_ADDRESSING && !REAL_ADDRESSING */ +#endif /* !DIRECT_ADDRESSING */ -#if REAL_ADDRESSING -const uintptr MEMBaseDiff = 0; -#elif DIRECT_ADDRESSING +#if DIRECT_ADDRESSING extern uintptr MEMBaseDiff; -#endif -#if REAL_ADDRESSING || DIRECT_ADDRESSING static __inline__ uae_u8 *do_get_real_address(uaecptr addr) { return (uae_u8 *)MEMBaseDiff + addr; @@ -201,7 +197,7 @@ static __inline__ uae_u8 *get_real_address(uaecptr addr) } /* gb-- deliberately not implemented since it shall not be used... */ extern uae_u32 get_virtual_address(uae_u8 *addr); -#endif /* DIRECT_ADDRESSING || REAL_ADDRESSING */ +#endif /* DIRECT_ADDRESSING */ #endif /* MEMORY_H */ diff --git a/BasiliskII/src/uae_cpu/newcpu.cpp b/BasiliskII/src/uae_cpu/newcpu.cpp index d13a6078..1bdfa155 100644 --- a/BasiliskII/src/uae_cpu/newcpu.cpp +++ b/BasiliskII/src/uae_cpu/newcpu.cpp @@ -303,7 +303,7 @@ static int backup_pointer = 0; static long int m68kpc_offset; int lastint_no; -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING #define get_ibyte_1(o) get_byte(get_virtual_address(regs.pc_p) + (o) + 1) #define get_iword_1(o) get_word(get_virtual_address(regs.pc_p) + (o)) #define get_ilong_1(o) get_long(get_virtual_address(regs.pc_p) + (o)) diff --git a/BasiliskII/src/uae_cpu/newcpu.h b/BasiliskII/src/uae_cpu/newcpu.h index e2d5b5ed..ccb36dc5 100644 --- a/BasiliskII/src/uae_cpu/newcpu.h +++ b/BasiliskII/src/uae_cpu/newcpu.h @@ -182,7 +182,7 @@ static __inline__ void fill_prefetch_2 (void) static __inline__ uaecptr m68k_getpc (void) { -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING return get_virtual_address(regs.pc_p); #else return regs.pc + ((char *)regs.pc_p - (char *)regs.pc_oldp); @@ -195,7 +195,7 @@ static __inline__ void m68k_setpc (uaecptr newpc) uae_u32 previous_pc = m68k_getpc(); #endif -#if REAL_ADDRESSING || DIRECT_ADDRESSING +#if DIRECT_ADDRESSING regs.pc_p = get_real_address(newpc); #else regs.pc_p = regs.pc_oldp = get_real_address(newpc); diff --git a/SheepShaver/src/Unix/configure.ac b/SheepShaver/src/Unix/configure.ac index 749ebdff..02b7fb30 100755 --- a/SheepShaver/src/Unix/configure.ac +++ b/SheepShaver/src/Unix/configure.ac @@ -29,7 +29,7 @@ case $target_os in esac dnl Options. -AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes]) +AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no]) AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC emulator [default=auto]], [WANT_EMULATED_PPC=$enableval], [WANT_EMULATED_PPC=auto]) AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb0 [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes]) AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes]) @@ -57,13 +57,13 @@ AC_ARG_WITH(libvhd, dnl Addressing mode AC_ARG_ENABLE(addressing, - [ --enable-addressing=AM set the addressing mode to use [default=real]], + [ --enable-addressing=AM set the addressing mode to use [default=direct]], [case "$enableval" in real) WANT_ADDRESSING_MODE="real";; direct) WANT_ADDRESSING_MODE="direct";; direct,0x*) WANT_ADDRESSING_MODE="direct"; NATMEM_OFFSET=`echo "$enableval" | sed -n '/direct,\(0[[xX]][[0-9A-Fa-f]]*\([[UuLl]]\{1,2\}\)\?\)$/s//\1/p'`;; esac], - [WANT_ADDRESSING_MODE="real"] + [WANT_ADDRESSING_MODE="direct"] ) dnl SDL options.