mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-11 10:30:09 +00:00
Add linker scripts from Basilisk II and make it possible to allocate up to
1 GB of Mac memory. Only tested on Linux/x86_64 so far but with a somewhat interesting (MacOS, ROM, RAM size) matrix. XXX: It should be possible to allocate up to 1.5 GB by relocating the ROM base to something like 0x60800000.
This commit is contained in:
parent
6da4032ab7
commit
bc13355b57
@ -67,7 +67,7 @@ links:
|
||||
Unix/video_blit.cpp Unix/config.sub Unix/config.guess Unix/m4 \
|
||||
Unix/keycodes Unix/tunconfig Unix/clip_unix.cpp Unix/Irix/audio_irix.cpp \
|
||||
Unix/Linux/scsi_linux.cpp Unix/Linux/NetDriver Unix/ether_unix.cpp \
|
||||
Unix/rpc.h Unix/rpc_unix.cpp Unix/Darwin/mkstandalone \
|
||||
Unix/rpc.h Unix/rpc_unix.cpp Unix/ldscripts Unix/Darwin/mkstandalone \
|
||||
Unix/Darwin/lowmem.c Unix/Darwin/pagezero.c Unix/Darwin/testlmem.sh \
|
||||
dummy/audio_dummy.cpp dummy/clip_dummy.cpp dummy/serial_dummy.cpp \
|
||||
dummy/prefs_editor_dummy.cpp dummy/scsi_dummy.cpp SDL slirp \
|
||||
|
@ -1485,6 +1485,39 @@ if [[ "x$HAVE_IPA" = "xyes" ]]; then
|
||||
LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
|
||||
fi
|
||||
|
||||
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";;
|
||||
linux*:powerpc) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-ppc.ld";;
|
||||
netbsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
|
||||
freebsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/freebsd-i386.ld";;
|
||||
darwin*:*) LINKER_SCRIPT_FLAGS="-Wl,-seg1addr,0x78048000";;
|
||||
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 Generate Makefile.
|
||||
AC_SUBST(PERL)
|
||||
AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen])
|
||||
|
@ -369,6 +369,7 @@ int main(int argc, char **argv)
|
||||
uint32 rom_size, actual;
|
||||
uint8 *rom_tmp;
|
||||
time_t now, expire;
|
||||
bool memory_mapped_from_zero;
|
||||
|
||||
// Initialize variables
|
||||
RAMBase = 0;
|
||||
@ -743,16 +744,6 @@ int main(int argc, char **argv)
|
||||
goto quit;
|
||||
}
|
||||
|
||||
#ifndef PAGEZERO_HACK
|
||||
// Create Low Memory area (0x0000..0x3000)
|
||||
if (vm_mac_acquire(0, 0x3000) < 0) {
|
||||
sprintf(str, GetString(STR_LOW_MEM_MMAP_ERR), strerror(errno));
|
||||
ErrorAlert(str);
|
||||
goto quit;
|
||||
}
|
||||
lm_area_mapped = true;
|
||||
#endif
|
||||
|
||||
// Create areas for Kernel Data
|
||||
if (!kernel_data_init())
|
||||
goto quit;
|
||||
@ -815,13 +806,32 @@ int main(int argc, char **argv)
|
||||
WarningAlert(GetString(STR_SMALL_RAM_WARN));
|
||||
RAMSize = 8*1024*1024;
|
||||
}
|
||||
|
||||
if (vm_mac_acquire(RAM_BASE, RAMSize) < 0) {
|
||||
sprintf(str, GetString(STR_RAM_MMAP_ERR), strerror(errno));
|
||||
ErrorAlert(str);
|
||||
goto quit;
|
||||
memory_mapped_from_zero = false;
|
||||
#if REAL_ADDRESSING && HAVE_LINKER_SCRIPT
|
||||
if (vm_mac_acquire(0, RAMSize) == 0) {
|
||||
D(bug("Could allocate RAM from 0x0000\n"));
|
||||
RAMBase = 0;
|
||||
memory_mapped_from_zero = true;
|
||||
}
|
||||
RAMBaseHost = Mac2HostAddr(RAM_BASE);
|
||||
#endif
|
||||
if (!memory_mapped_from_zero) {
|
||||
#ifndef PAGEZERO_HACK
|
||||
// Create Low Memory area (0x0000..0x3000)
|
||||
if (vm_mac_acquire(0, 0x3000) < 0) {
|
||||
sprintf(str, GetString(STR_LOW_MEM_MMAP_ERR), strerror(errno));
|
||||
ErrorAlert(str);
|
||||
goto quit;
|
||||
}
|
||||
lm_area_mapped = true;
|
||||
#endif
|
||||
if (vm_mac_acquire(RAM_BASE, RAMSize) < 0) {
|
||||
sprintf(str, GetString(STR_RAM_MMAP_ERR), strerror(errno));
|
||||
ErrorAlert(str);
|
||||
goto quit;
|
||||
}
|
||||
RAMBase = RAM_BASE;
|
||||
}
|
||||
RAMBaseHost = Mac2HostAddr(RAMBase);
|
||||
#if !EMULATED_PPC
|
||||
if (vm_protect(RAMBaseHost, RAMSize, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE) < 0) {
|
||||
sprintf(str, GetString(STR_RAM_MMAP_ERR), strerror(errno));
|
||||
@ -829,7 +839,6 @@ int main(int argc, char **argv)
|
||||
goto quit;
|
||||
}
|
||||
#endif
|
||||
RAMBase = RAM_BASE;
|
||||
ram_area_mapped = true;
|
||||
D(bug("RAM area at %p (%08x)\n", RAMBaseHost, RAMBase));
|
||||
|
||||
@ -985,7 +994,7 @@ static void Quit(void)
|
||||
|
||||
// Delete RAM area
|
||||
if (ram_area_mapped)
|
||||
vm_mac_release(RAM_BASE, RAMSize);
|
||||
vm_mac_release(RAMBase, RAMSize);
|
||||
|
||||
// Delete ROM area
|
||||
if (rom_area_mapped)
|
||||
|
Loading…
x
Reference in New Issue
Block a user