mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-11 10:30:09 +00:00
works again under NetBSD/m68k
This commit is contained in:
parent
3c2e4f8c06
commit
efc60c7f60
@ -38,6 +38,7 @@
|
||||
|
||||
// Mac ROM is not write protected
|
||||
#define ROM_IS_WRITE_PROTECTED 0
|
||||
#define USE_SCRATCHMEM_SUBTERFUGE 1
|
||||
|
||||
// ExtFS is supported
|
||||
#define SUPPORTS_EXTFS 1
|
||||
|
@ -112,7 +112,7 @@ AC_CHECK_FUNCS(pthread_cancel)
|
||||
dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
|
||||
SEMSRC=
|
||||
AC_CHECK_FUNCS(sem_init, , [
|
||||
if [ "x$HAVE_PTHREADS" = "xyes" ]; then
|
||||
if test "x$HAVE_PTHREADS" = "xyes"; then
|
||||
SEMSRC=posix_sem.cpp
|
||||
fi
|
||||
])
|
||||
@ -510,13 +510,13 @@ elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xy
|
||||
AC_MSG_RESULT($SPARC_TYPE)
|
||||
case "$SPARC_TYPE" in
|
||||
SPARC_V8)
|
||||
ASM_OPTIMIZATIONS="SPARC V8 architecture"
|
||||
ASM_OPTIMIZATIONS="SPARC V8 architecture"
|
||||
DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTFLAGS"
|
||||
CFLAGS="$CFLAGS -Wa,-Av8"
|
||||
CXXFLAGS="$CXXFLAGS -Wa,-Av8"
|
||||
;;
|
||||
SPARC_V9)
|
||||
ASM_OPTIMIZATIONS="SPARC V9 architecture"
|
||||
ASM_OPTIMIZATIONS="SPARC V9 architecture"
|
||||
DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTFLAGS"
|
||||
CFLAGS="$CFLAGS -Wa,-Av9"
|
||||
CXXFLAGS="$CXXFLAGS -Wa,-Av9"
|
||||
@ -542,9 +542,9 @@ fi
|
||||
|
||||
dnl Remove the "-g" option if set for GCC.
|
||||
if [[ "x$HAVE_GCC27" = "xyes" ]]; then
|
||||
dnl gb-- Probably not the cleanest way to take
|
||||
CFLAGS=`echo $CFLAGS | sed -e 's/ -g / /;s/^-g / /;s/ -g$/ /;s/^-g$//'`
|
||||
CXXFLAGS=`echo $CXXFLAGS | sed -e 's/ -g / /;s/^-g / /;s/ -g$/ /;s/^-g$//'`
|
||||
dnl gb-- Probably not the cleanest way to take
|
||||
CFLAGS=`echo $CFLAGS | sed -e 's/ -g / /;s/^-g / /;s/ -g$/ /;s/^-g$//'`
|
||||
CXXFLAGS=`echo $CXXFLAGS | sed -e 's/ -g / /;s/^-g / /;s/ -g$/ /;s/^-g$//'`
|
||||
fi
|
||||
|
||||
dnl Generate Makefile.
|
||||
|
@ -133,11 +133,10 @@ 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)
|
||||
uint8 *ScratchMem = NULL; // Scratch memory for Mac ROM writes
|
||||
#endif
|
||||
|
||||
#if USE_SCRATCHMEM_SUBTERFUGE
|
||||
uint8 *ScratchMem = 0; // Scratch memory for Mac ROM writes
|
||||
uint8 *ScratchMem = NULL; // Scratch memory for Mac ROM writes
|
||||
#endif
|
||||
|
||||
static struct sigaction timer_sa; // sigaction used for timer
|
||||
@ -157,6 +156,10 @@ static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped
|
||||
static bool memory_mapped_from_zero = false; // Flag: Could allocate RAM area from 0
|
||||
#endif
|
||||
|
||||
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
||||
static uint32 mapped_ram_rom_size; // Total size of mmap()ed RAM/ROM area
|
||||
#endif
|
||||
|
||||
#ifdef USE_MAPPED_MEMORY
|
||||
extern char *address_space, *good_address_map;
|
||||
#endif
|
||||
@ -269,18 +272,19 @@ int main(int argc, char **argv)
|
||||
const uint32 page_size = getpagesize();
|
||||
const uint32 page_mask = page_size - 1;
|
||||
const uint32 aligned_ram_size = (RAMSize + page_mask) & ~page_mask;
|
||||
const uint32 ram_rom_size = aligned_ram_size + 0x100000;
|
||||
mapped_ram_rom_size = aligned_ram_size + 0x100000;
|
||||
#endif
|
||||
|
||||
#if REAL_ADDRESSING
|
||||
// Try to allocate the complete address space from zero
|
||||
// gb-- the Solaris manpage about mmap(2) states that using MAP_FIXED
|
||||
// implies undefined behaviour for further use of sbrk(), malloc(), etc.
|
||||
#if defined(OS_solaris)
|
||||
// cebix-- on NetBSD/m68k, this causes a segfault
|
||||
#if defined(OS_solaris) || defined(OS_netbsd)
|
||||
// Anyway, it doesn't work...
|
||||
if (0) {
|
||||
#else
|
||||
if (mmap((caddr_t)0x0000, ram_rom_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, zero_fd, 0) != MAP_FAILED) {
|
||||
if (mmap((caddr_t)0x0000, mapped_ram_rom_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, zero_fd, 0) != MAP_FAILED) {
|
||||
#endif
|
||||
D(bug("Could allocate RAM and ROM from 0x0000\n"));
|
||||
memory_mapped_from_zero = true;
|
||||
@ -298,7 +302,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !EMULATED_68K || USE_SCRATCHMEM_SUBTERFUGE
|
||||
#if USE_SCRATCHMEM_SUBTERFUGE
|
||||
// Allocate scratch memory
|
||||
ScratchMem = (uint8 *)malloc(SCRATCH_MEM_SIZE);
|
||||
if (ScratchMem == NULL) {
|
||||
@ -339,7 +343,7 @@ int main(int argc, char **argv)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
RAMBaseHost = (uint8 *)mmap(0, ram_rom_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0);
|
||||
RAMBaseHost = (uint8 *)mmap(0, mapped_ram_rom_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0);
|
||||
if (RAMBaseHost == (uint8 *)MAP_FAILED) {
|
||||
ErrorAlert(GetString(STR_NO_MEM_ERR));
|
||||
QuitEmulator();
|
||||
@ -354,6 +358,7 @@ int main(int argc, char **argv)
|
||||
QuitEmulator();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DIRECT_ADDRESSING
|
||||
// Initialize MEMBaseDiff now so that Host2MacAddr in the Video module
|
||||
// will return correct results
|
||||
@ -617,34 +622,26 @@ void QuitEmulator(void)
|
||||
// Deinitialize everything
|
||||
ExitAll();
|
||||
|
||||
// Free ROM/RAM areas
|
||||
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
||||
// Unmap ROM area
|
||||
if (ROMBaseHost != (uint8 *)MAP_FAILED) {
|
||||
munmap((caddr_t)ROMBaseHost, 0x100000);
|
||||
ROMBaseHost = 0;
|
||||
}
|
||||
|
||||
//Unmap RAM area
|
||||
if (RAMBaseHost != (uint8 *)MAP_FAILED) {
|
||||
const uint32 page_size = getpagesize();
|
||||
const uint32 page_mask = page_size - 1;
|
||||
munmap((caddr_t)RAMBaseHost, ((RAMSize + page_mask) & ~page_mask));
|
||||
if (memory_mapped_from_zero)
|
||||
munmap((caddr_t)0x0000, mapped_ram_rom_size);
|
||||
else if (RAMBaseHost != (uint8 *)MAP_FAILED) {
|
||||
munmap((caddr_t)RAMBaseHost, mapped_ram_rom_size);
|
||||
RAMBaseHost = NULL;
|
||||
}
|
||||
#else
|
||||
// Delete ROM area
|
||||
if (ROMBaseHost) {
|
||||
free(ROMBaseHost);
|
||||
ROMBaseHost = NULL;
|
||||
}
|
||||
|
||||
// Delete RAM area
|
||||
if (RAMBaseHost) {
|
||||
free(RAMBaseHost);
|
||||
RAMBaseHost = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !EMULATED_68K || USE_SCRATMEM_SUBTERFUGE
|
||||
#if USE_SCRATCHMEM_SUBTERFUGE
|
||||
// Delete scratch memory area
|
||||
if (ScratchMem) {
|
||||
free((void *)(ScratchMem - SCRATCH_MEM_SIZE/2));
|
||||
@ -748,6 +745,11 @@ void TriggerInterrupt(void)
|
||||
raise(SIG_IRQ);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TriggerNMI(void)
|
||||
{
|
||||
// not yet supported
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -69,6 +69,7 @@
|
||||
|
||||
/* Mac ROM is not write protected */
|
||||
#define ROM_IS_WRITE_PROTECTED 0
|
||||
#define USE_SCRATCHMEM_SUBTERFUGE 1
|
||||
|
||||
#else
|
||||
|
||||
@ -83,7 +84,7 @@
|
||||
/* The m68k emulator uses a prefetch buffer ? */
|
||||
#define USE_PREFETCH_BUFFER 0
|
||||
|
||||
/* Mac ROM is write protected */
|
||||
/* Mac ROM is write protected when banked memory is used */
|
||||
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
||||
# define ROM_IS_WRITE_PROTECTED 0
|
||||
# define USE_SCRATCHMEM_SUBTERFUGE 1
|
||||
|
@ -583,6 +583,7 @@ static bool init_fbdev_dga(char *in_fb_name)
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_VOSF
|
||||
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
||||
// If the blit function is null, i.e. just a copy of the buffer,
|
||||
// we first try to avoid the allocation of a temporary frame buffer
|
||||
@ -599,8 +600,9 @@ static bool init_fbdev_dga(char *in_fb_name)
|
||||
the_buffer = (uint8 *)allocate_framebuffer(the_buffer_size);
|
||||
memset(the_buffer, 0, the_buffer_size);
|
||||
}
|
||||
#elif ENABLE_VOSF
|
||||
#else
|
||||
use_vosf = false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
set_video_monitor(width, height, bytes_per_row, true);
|
||||
@ -1905,6 +1907,7 @@ static void video_refresh_dga(void)
|
||||
handle_palette_changes(depth, DISPLAY_DGA);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOSF
|
||||
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
||||
static void video_refresh_dga_vosf(void)
|
||||
{
|
||||
@ -1932,7 +1935,6 @@ static void video_refresh_dga_vosf(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VOSF
|
||||
static void video_refresh_window_vosf(void)
|
||||
{
|
||||
// Quit DGA mode if requested
|
||||
@ -1957,7 +1959,7 @@ static void video_refresh_window_vosf(void)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // def ENABLE_VOSF
|
||||
|
||||
static void video_refresh_window_static(void)
|
||||
{
|
||||
@ -1998,7 +2000,7 @@ void VideoRefreshInit(void)
|
||||
{
|
||||
// TODO: set up specialised 8bpp VideoRefresh handlers ?
|
||||
if (display_type == DISPLAY_DGA) {
|
||||
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
||||
#if ENABLE_VOSF && (REAL_ADDRESSING || DIRECT_ADDRESSING)
|
||||
if (use_vosf)
|
||||
video_refresh = video_refresh_dga_vosf;
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user