mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-12-25 17:29:19 +00:00
Incorporate recent changes from Unix equivalent files
This commit is contained in:
parent
0fc35d5a91
commit
cce2d58228
@ -256,6 +256,60 @@ AC_CHECK_FILE([/dev/ptc],
|
|||||||
dnl (end of code from openssh-3.2.2p1 configure.ac)
|
dnl (end of code from openssh-3.2.2p1 configure.ac)
|
||||||
|
|
||||||
|
|
||||||
|
dnl Check for systems where POSIX-style non-blocking I/O (O_NONBLOCK)
|
||||||
|
dnl doesn't work or is unimplemented. On these systems (mostly older
|
||||||
|
dnl ones), use the old BSD-style FIONBIO approach instead. [tcl.m4]
|
||||||
|
AC_CACHE_CHECK([FIONBIO vs. O_NONBLOCK for non-blocking I/O],
|
||||||
|
ac_cv_nonblocking_io, [
|
||||||
|
case "$host" in
|
||||||
|
*-*-osf*)
|
||||||
|
ac_cv_nonblocking_io=FIONBIO
|
||||||
|
;;
|
||||||
|
*-*-sunos4*)
|
||||||
|
ac_cv_nonblocking_io=FIONBIO
|
||||||
|
;;
|
||||||
|
*-*-ultrix*)
|
||||||
|
ac_cv_nonblocking_io=FIONBIO
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ac_cv_nonblocking_io=O_NONBLOCK
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
])
|
||||||
|
if [[ "$ac_cv_nonblocking_io" = "FIONBIO" ]]; then
|
||||||
|
AC_DEFINE(USE_FIONBIO, 1, [Define if BSD-style non-blocking I/O is to be used])
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Check whether compiler supports byte bit-fields
|
||||||
|
AC_CACHE_CHECK([whether compiler supports byte bit-fields],
|
||||||
|
ac_cv_have_byte_bitfields, [
|
||||||
|
AC_LANG_SAVE
|
||||||
|
AC_LANG_CPLUSPLUS
|
||||||
|
AC_TRY_RUN([
|
||||||
|
struct A {
|
||||||
|
unsigned char b1:4;
|
||||||
|
unsigned char b2:4;
|
||||||
|
unsigned char c;
|
||||||
|
unsigned short s;
|
||||||
|
unsigned char a[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
A a;
|
||||||
|
return ! (sizeof(A) == 8 && &a.c == ((unsigned char *)&a + 1));
|
||||||
|
}],
|
||||||
|
[ac_cv_have_byte_bitfields=yes],
|
||||||
|
[ac_cv_have_byte_bitfields=no],
|
||||||
|
dnl When cross-compiling, assume only GCC supports this
|
||||||
|
[if [[ "$GCC" = "yes" ]]; then
|
||||||
|
ac_cv_have_byte_bitfields="guessing yes"
|
||||||
|
else
|
||||||
|
ac_cv_have_byte_bitfields="guessing no"
|
||||||
|
fi]
|
||||||
|
)
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
])
|
||||||
|
|
||||||
dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
|
dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
|
||||||
AC_DEFUN([AC_CHECK_FRAMEWORK], [
|
AC_DEFUN([AC_CHECK_FRAMEWORK], [
|
||||||
AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
|
AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
|
||||||
@ -302,7 +356,13 @@ dnl Select system-dependant source files.
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
dnl Is the slirp library supported?
|
dnl Is the slirp library supported?
|
||||||
if [[ "x$ETHERSRC" = "xether_unix.cpp" ]]; then
|
case "$ac_cv_have_byte_bitfields" in
|
||||||
|
yes|"guessing yes")
|
||||||
|
CAN_SLIRP=yes
|
||||||
|
ETHERSRC=ether_unix.cpp
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [[ -n "$CAN_SLIRP" ]]; then
|
||||||
AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
|
AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
|
||||||
SLIRP_SRCS="\
|
SLIRP_SRCS="\
|
||||||
../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
|
../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
|
||||||
@ -749,6 +809,35 @@ fi
|
|||||||
dnl A dummy program that returns always true
|
dnl A dummy program that returns always true
|
||||||
AC_PATH_PROG([BLESS], "true")
|
AC_PATH_PROG([BLESS], "true")
|
||||||
|
|
||||||
|
dnl Check for linker script support
|
||||||
|
case $target_os:$target_cpu in
|
||||||
|
linux*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
|
||||||
|
linux*:x86_64) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-x86_64.ld";;
|
||||||
|
esac
|
||||||
|
if [[ -n "$LINKER_SCRIPT_FLAGS" ]]; then
|
||||||
|
AC_CACHE_CHECK([whether linker script is usable],
|
||||||
|
ac_cv_linker_script_works, [
|
||||||
|
AC_LANG_SAVE
|
||||||
|
AC_LANG_CPLUSPLUS
|
||||||
|
saved_LDFLAGS="$LDFLAGS"
|
||||||
|
LDFLAGS="$LDFLAGS $LINKER_SCRIPT_FLAGS"
|
||||||
|
AC_TRY_RUN(
|
||||||
|
[int main() {if ((char *)&main < (char *)0x70000000) return 1;}],
|
||||||
|
[ac_cv_linker_script_works=yes],
|
||||||
|
[ac_cv_linker_script_works=no],
|
||||||
|
dnl When cross-compiling, assume it works
|
||||||
|
[ac_cv_linker_script_works="guessing yes"]
|
||||||
|
)
|
||||||
|
AC_LANG_RESTORE
|
||||||
|
if [[ "$ac_cv_linker_script_works" = "no" ]]; then
|
||||||
|
LDFLAGS="$saved_LDFLAGS"
|
||||||
|
LINKER_SCRIPT_FLAGS=""
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
fi
|
||||||
|
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
|
dnl Determine the addressing mode to use
|
||||||
if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
|
if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
|
||||||
ADDRESSING_MODE="real"
|
ADDRESSING_MODE="real"
|
||||||
@ -950,7 +1039,7 @@ elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then
|
|||||||
DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
|
DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
|
||||||
JITSRCS="cpuemu1_nf.cpp cpuemu2_nf.cpp cpuemu3_nf.cpp cpuemu4_nf.cpp cpuemu5_nf.cpp cpuemu6_nf.cpp cpuemu7_nf.cpp cpuemu8_nf.cpp $JITSRCS"
|
JITSRCS="cpuemu1_nf.cpp cpuemu2_nf.cpp cpuemu3_nf.cpp cpuemu4_nf.cpp cpuemu5_nf.cpp cpuemu6_nf.cpp cpuemu7_nf.cpp cpuemu8_nf.cpp $JITSRCS"
|
||||||
CAN_JIT=yes
|
CAN_JIT=yes
|
||||||
WANT_32BIT_ADDRESSING=yes
|
WANT_33BIT_ADDRESSING=yes
|
||||||
fi
|
fi
|
||||||
elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
|
elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
|
||||||
dnl SPARC CPU
|
dnl SPARC CPU
|
||||||
|
@ -111,19 +111,36 @@ static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map memory that can be accessed from the Mac side
|
* Helpers to map memory that can be accessed from the Mac side
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// NOTE: VM_MAP_33BIT is only used when compiling a 64-bit JIT on specific platforms
|
||||||
void *vm_acquire_mac(size_t size)
|
void *vm_acquire_mac(size_t size)
|
||||||
{
|
{
|
||||||
void *m = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_33BIT);
|
void *m = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_33BIT);
|
||||||
if (m == NULL) {
|
#ifdef USE_33BIT_ADDRESSING
|
||||||
|
if (m == VM_MAP_FAILED) {
|
||||||
|
printf("WARNING: Cannot acquire memory in 33-bit address space (%s)\n", strerror(errno));
|
||||||
ThirtyThreeBitAddressing = false;
|
ThirtyThreeBitAddressing = false;
|
||||||
m = vm_acquire(size);
|
m = vm_acquire(size);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vm_acquire_mac_fixed(void *addr, size_t size)
|
||||||
|
{
|
||||||
|
int ret = vm_acquire_fixed(addr, size, VM_MAP_DEFAULT | VM_MAP_33BIT);
|
||||||
|
#ifdef USE_33BIT_ADDRESSING
|
||||||
|
if (ret < 0) {
|
||||||
|
printf("WARNING: Cannot acquire fixed memory in 33-bit address space (%s)\n", strerror(errno));
|
||||||
|
ThirtyThreeBitAddressing = false;
|
||||||
|
ret = vm_acquire_fixed(addr, size);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIGSEGV handler
|
* SIGSEGV handler
|
||||||
@ -174,8 +191,8 @@ static void sigsegv_dump_state(sigsegv_address_t fault_address, sigsegv_address_
|
|||||||
#ifdef ENABLE_MON
|
#ifdef ENABLE_MON
|
||||||
char *arg[4] = {"mon", "-m", "-r", NULL};
|
char *arg[4] = {"mon", "-m", "-r", NULL};
|
||||||
mon(3, arg);
|
mon(3, arg);
|
||||||
QuitEmulator();
|
|
||||||
#endif
|
#endif
|
||||||
|
QuitEmulator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -276,6 +293,8 @@ bool InitEmulator (void)
|
|||||||
WarningAlert(GetString(STR_SMALL_RAM_WARN));
|
WarningAlert(GetString(STR_SMALL_RAM_WARN));
|
||||||
RAMSize = 1024*1024;
|
RAMSize = 1024*1024;
|
||||||
}
|
}
|
||||||
|
if (RAMSize > 1023*1024*1024) // Cap to 1023MB (APD crashes at 1GB)
|
||||||
|
RAMSize = 1023*1024*1024;
|
||||||
|
|
||||||
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
||||||
RAMSize = RAMSize & -getpagesize(); // Round down to page boundary
|
RAMSize = RAMSize & -getpagesize(); // Round down to page boundary
|
||||||
@ -284,27 +303,33 @@ bool InitEmulator (void)
|
|||||||
// Initialize VM system
|
// Initialize VM system
|
||||||
vm_init();
|
vm_init();
|
||||||
|
|
||||||
|
#ifdef USE_33BIT_ADDRESSING
|
||||||
|
// Speculatively enables 33-bit addressing
|
||||||
|
ThirtyThreeBitAddressing = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if REAL_ADDRESSING
|
#if REAL_ADDRESSING
|
||||||
// Flag: RAM and ROM are contigously allocated from address 0
|
// Flag: RAM and ROM are contigously allocated from address 0
|
||||||
bool memory_mapped_from_zero = false;
|
bool memory_mapped_from_zero = false;
|
||||||
|
|
||||||
// Under Solaris/SPARC and NetBSD/m68k, Basilisk II is known to crash
|
// Make sure to map RAM & ROM at address 0 only on platforms that
|
||||||
// when trying to map a too big chunk of memory starting at address 0
|
// supports linker scripts to relocate the Basilisk II executable
|
||||||
#if defined(OS_solaris) || defined(OS_netbsd) || defined(PAGEZERO_HACK)
|
// above 0x70000000
|
||||||
const bool can_map_all_memory = false;
|
#if HAVE_LINKER_SCRIPT
|
||||||
#else
|
|
||||||
const bool can_map_all_memory = true;
|
const bool can_map_all_memory = true;
|
||||||
|
#else
|
||||||
|
const bool can_map_all_memory = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Try to allocate all memory from 0x0000, if it is not known to crash
|
// Try to allocate all memory from 0x0000, if it is not known to crash
|
||||||
if (can_map_all_memory && (vm_acquire_fixed(0, RAMSize + 0x100000) == 0)) {
|
if (can_map_all_memory && (vm_acquire_mac_fixed(0, RAMSize + 0x100000) == 0)) {
|
||||||
D(bug("Could allocate RAM and ROM from 0x0000\n"));
|
D(bug("Could allocate RAM and ROM from 0x0000\n"));
|
||||||
memory_mapped_from_zero = true;
|
memory_mapped_from_zero = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PAGEZERO_HACK
|
#ifndef PAGEZERO_HACK
|
||||||
// Otherwise, just create the Low Memory area (0x0000..0x2000)
|
// Otherwise, just create the Low Memory area (0x0000..0x2000)
|
||||||
else if (vm_acquire_fixed(0, 0x2000) == 0) {
|
else if (vm_acquire_mac_fixed(0, 0x2000) == 0) {
|
||||||
D(bug("Could allocate the Low Memory globals\n"));
|
D(bug("Could allocate the Low Memory globals\n"));
|
||||||
lm_area_mapped = true;
|
lm_area_mapped = true;
|
||||||
}
|
}
|
||||||
@ -329,10 +354,6 @@ bool InitEmulator (void)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef USE_33BIT_ADDRESSING
|
|
||||||
// Speculatively enables 33-bit addressing
|
|
||||||
ThirtyThreeBitAddressing = true;
|
|
||||||
#endif
|
|
||||||
uint8 *ram_rom_area = (uint8 *)vm_acquire_mac(RAMSize + 0x100000);
|
uint8 *ram_rom_area = (uint8 *)vm_acquire_mac(RAMSize + 0x100000);
|
||||||
if (ram_rom_area == VM_MAP_FAILED) {
|
if (ram_rom_area == VM_MAP_FAILED) {
|
||||||
ErrorAlert(STR_NO_MEM_ERR);
|
ErrorAlert(STR_NO_MEM_ERR);
|
||||||
@ -344,7 +365,7 @@ bool InitEmulator (void)
|
|||||||
|
|
||||||
#if USE_SCRATCHMEM_SUBTERFUGE
|
#if USE_SCRATCHMEM_SUBTERFUGE
|
||||||
// Allocate scratch memory
|
// Allocate scratch memory
|
||||||
ScratchMem = (uint8 *)vm_acquire(SCRATCH_MEM_SIZE);
|
ScratchMem = (uint8 *)vm_acquire_mac(SCRATCH_MEM_SIZE);
|
||||||
if (ScratchMem == VM_MAP_FAILED) {
|
if (ScratchMem == VM_MAP_FAILED) {
|
||||||
ErrorAlert(STR_NO_MEM_ERR);
|
ErrorAlert(STR_NO_MEM_ERR);
|
||||||
QuitEmulator();
|
QuitEmulator();
|
||||||
@ -359,8 +380,8 @@ bool InitEmulator (void)
|
|||||||
ROMBaseMac = Host2MacAddr(ROMBaseHost);
|
ROMBaseMac = Host2MacAddr(ROMBaseHost);
|
||||||
#endif
|
#endif
|
||||||
#if REAL_ADDRESSING
|
#if REAL_ADDRESSING
|
||||||
RAMBaseMac = (uint32)RAMBaseHost;
|
RAMBaseMac = Host2MacAddr(RAMBaseHost);
|
||||||
ROMBaseMac = (uint32)ROMBaseHost;
|
ROMBaseMac = Host2MacAddr(ROMBaseHost);
|
||||||
#endif
|
#endif
|
||||||
D(bug("Mac RAM starts at %p (%08x)\n", RAMBaseHost, RAMBaseMac));
|
D(bug("Mac RAM starts at %p (%08x)\n", RAMBaseHost, RAMBaseMac));
|
||||||
D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac));
|
D(bug("Mac ROM starts at %p (%08x)\n", ROMBaseHost, ROMBaseMac));
|
||||||
@ -430,6 +451,7 @@ void QuitEmuNoExit()
|
|||||||
if (RAMBaseHost != VM_MAP_FAILED) {
|
if (RAMBaseHost != VM_MAP_FAILED) {
|
||||||
vm_release(RAMBaseHost, RAMSize + 0x100000);
|
vm_release(RAMBaseHost, RAMSize + 0x100000);
|
||||||
RAMBaseHost = NULL;
|
RAMBaseHost = NULL;
|
||||||
|
ROMBaseHost = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_SCRATCHMEM_SUBTERFUGE
|
#if USE_SCRATCHMEM_SUBTERFUGE
|
||||||
|
Loading…
Reference in New Issue
Block a user