Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove real 68k #147

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions BasiliskII/src/CrossPlatform/sigsegv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion BasiliskII/src/CrossPlatform/video_blit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions BasiliskII/src/CrossPlatform/video_vosf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 18 additions & 1 deletion BasiliskII/src/CrossPlatform/vm_alloc.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion BasiliskII/src/MacOSX/PrefsEditor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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] )
{
Expand Down
3 changes: 0 additions & 3 deletions BasiliskII/src/MacOSX/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
63 changes: 2 additions & 61 deletions BasiliskII/src/MacOSX/main_macosx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# include <pthread.h>
#endif

#if REAL_ADDRESSING || DIRECT_ADDRESSING
#if DIRECT_ADDRESSING
# include <sys/mman.h>
#endif

Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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) {
Expand All @@ -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));
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion BasiliskII/src/MacOSX/video_macosx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
92 changes: 4 additions & 88 deletions BasiliskII/src/Unix/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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;;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -769,7 +760,6 @@ freebsd*)
fi
;;
netbsd*)
CAN_NATIVE_M68K=yes
ETHERSRC=ether_unix.cpp
;;
solaris*)
Expand Down Expand Up @@ -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.])
Expand Down Expand Up @@ -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, [
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading