mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-05-28 12:41:32 +00:00
[Patch from Mike Sliczniak]
This first patch gets B2 and SS to build under Leopard and Tiger. I tested this on a 32-bit intel 10.5.6 mac like so: B2 ./autogen.sh --disable-standalone-gui --enable-vosf --enable-sdl-video --enable-sdl-audio --enable-addressing=real --without-esd --without-gtk --without-mon --without-x SS ./autogen.sh --disable-standalone-gui --enable-vosf -enable-sdl-video --disable-sdl-audio --enable-addressing=real --without-esd --without-gtk --without-mon --without-x --enable-jit There is also a little tweak so that you can use sdl audio in SheepShaver when building for Mac OS X.
This commit is contained in:
parent
d6db773362
commit
ca2b9b5832
|
@ -550,10 +550,10 @@ static sigsegv_address_t get_fault_address(struct sigcontext *scp)
|
|||
#ifndef HAVE_MACH_EXCEPTIONS
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#if (defined(ppc) || defined(__ppc__))
|
||||
#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp
|
||||
#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct __darwin_sigcontext *scp
|
||||
#define SIGSEGV_FAULT_HANDLER_ARGS sig, code, scp
|
||||
#define SIGSEGV_FAULT_ADDRESS get_fault_address(scp)
|
||||
#define SIGSEGV_FAULT_INSTRUCTION scp->sc_ir
|
||||
#define SIGSEGV_FAULT_INSTRUCTION scp->MACH_FIELD_NAME(sc_ir)
|
||||
#define SIGSEGV_ALL_SIGNALS FAULT_HANDLER(SIGBUS)
|
||||
#define SIGSEGV_REGISTER_FILE (unsigned int *)&scp->sc_ir, &((unsigned int *) scp->sc_regs)[2]
|
||||
#define SIGSEGV_SKIP_INSTRUCTION powerpc_skip_instruction
|
||||
|
@ -561,11 +561,11 @@ static sigsegv_address_t get_fault_address(struct sigcontext *scp)
|
|||
// Use decoding scheme from SheepShaver
|
||||
static sigsegv_address_t get_fault_address(struct sigcontext *scp)
|
||||
{
|
||||
unsigned int nip = (unsigned int) scp->sc_ir;
|
||||
unsigned int * gpr = &((unsigned int *) scp->sc_regs)[2];
|
||||
unsigned int nip = (unsigned int) scp->MACH_FIELD_NAME(sc_ir);
|
||||
unsigned int * gpr = &((unsigned int *) scp->MACH_FIELD_NAME(sc_regs))[2];
|
||||
instruction_t instr;
|
||||
|
||||
powerpc_decode_instruction(&instr, nip, gpr);
|
||||
powerpc_decode_instruction(&instr, nip, (long unsigned int*)gpr);
|
||||
return (sigsegv_address_t)instr.addr;
|
||||
}
|
||||
#endif
|
||||
|
@ -618,6 +618,11 @@ extern "C" {
|
|||
#include <mach/mach_error.h>
|
||||
|
||||
#ifndef HAVE_MACH64_VM
|
||||
|
||||
// Undefine this to prevent a preprocessor warning when compiling on a
|
||||
// 32-bit machine with Mac OS X 10.5.
|
||||
#undef MACH_EXCEPTION_CODES
|
||||
|
||||
#define MACH_EXCEPTION_CODES 0
|
||||
#define mach_exception_data_t exception_data_t
|
||||
#define mach_exception_data_type_t exception_data_type_t
|
||||
|
@ -2613,6 +2618,7 @@ static void mach_set_thread_state(sigsegv_info_t *SIP)
|
|||
sigsegv_address_t sigsegv_get_fault_address(sigsegv_info_t *SIP)
|
||||
{
|
||||
#ifdef HAVE_MACH_EXCEPTIONS
|
||||
#ifdef EMULATED_PPC
|
||||
static int use_fast_path = -1;
|
||||
if (use_fast_path != 1 && !SIP->has_exc_state) {
|
||||
mach_get_exception_state(SIP);
|
||||
|
@ -2631,6 +2637,7 @@ sigsegv_address_t sigsegv_get_fault_address(sigsegv_info_t *SIP)
|
|||
}
|
||||
SIP->addr = addr;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return SIP->addr;
|
||||
}
|
||||
|
@ -2640,11 +2647,13 @@ sigsegv_address_t sigsegv_get_fault_address(sigsegv_info_t *SIP)
|
|||
sigsegv_address_t sigsegv_get_fault_instruction_address(sigsegv_info_t *SIP)
|
||||
{
|
||||
#ifdef HAVE_MACH_EXCEPTIONS
|
||||
#ifdef EMULATED_PPC
|
||||
if (!SIP->has_thr_state) {
|
||||
mach_get_thread_state(SIP);
|
||||
|
||||
SIP->pc = (sigsegv_address_t)SIGSEGV_FAULT_INSTRUCTION;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return SIP->pc;
|
||||
}
|
||||
|
|
|
@ -527,6 +527,7 @@ AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>])
|
|||
AC_CHECK_FRAMEWORK(CoreAudio, [#include <CoreAudio/CoreAudio.h>])
|
||||
AC_CHECK_FRAMEWORK(AudioUnit, [#include <AudioUnit/AudioUnit.h>])
|
||||
AC_CHECK_FRAMEWORK(AudioToolbox, [#include <AudioToolbox/AudioToolbox.h>])
|
||||
AC_CHECK_FRAMEWORK(AppKit, [])
|
||||
|
||||
dnl Select system-dependant sources.
|
||||
SERIALSRC=serial_unix.cpp
|
||||
|
@ -564,10 +565,12 @@ darwin*)
|
|||
fi
|
||||
if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
|
||||
EXTFSSRC=../MacOSX/extfs_macosx.cpp
|
||||
PREFSSRC="../MacOSX/prefs_macosx.mm ../MacOSX/PrefsEditor/PrefsEditor.mm"
|
||||
CPPFLAGS="$CPPFLAGS -I../MacOSX/PrefsEditor"
|
||||
fi
|
||||
if [[ "x$ac_cv_framework_CoreAudio" = "xyes" ]]; then
|
||||
if [[ "x$ac_cv_framework_AppKit" = "xyes" ]]; then
|
||||
PREFSSRC="../MacOSX/prefs_macosx.mm ../MacOSX/PrefsEditor/PrefsEditor.mm"
|
||||
CPPFLAGS="$CPPFLAGS -I../MacOSX/PrefsEditor"
|
||||
fi
|
||||
fi
|
||||
if [[ "x$ac_cv_framework_CoreAudio" = "xyes" -a "x$WANT_SDL_AUDIO" = "xno" ]]; then
|
||||
AUDIOSRC="../MacOSX/audio_macosx.cpp ../MacOSX/AudioBackEnd.cpp ../MacOSX/AudioDevice.cpp ../MacOSX/MacOSX_sound_if.cpp"
|
||||
fi
|
||||
;;
|
||||
|
|
|
@ -225,8 +225,8 @@ static uintptr sig_stack = 0; // Stack for PowerPC interrupt routine
|
|||
#else
|
||||
static struct sigaction sigsegv_action; // Data access exception signal (of emulator thread)
|
||||
static struct sigaction sigill_action; // Illegal instruction signal (of emulator thread)
|
||||
static struct sigaltstack sig_stack; // Stack for signal handlers
|
||||
static struct sigaltstack extra_stack; // Stack for SIGSEGV inside interrupt handler
|
||||
static stack_t sig_stack; // Stack for signal handlers
|
||||
static stack_t extra_stack; // Stack for SIGSEGV inside interrupt handler
|
||||
static bool emul_thread_fatal = false; // Flag: MacOS thread crashed, tick thread shall dump debug output
|
||||
static sigregs sigsegv_regs; // Register dump when crashed
|
||||
static const char *crash_reason = NULL; // Reason of the crash (SIGSEGV, SIGBUS, SIGILL)
|
||||
|
@ -1623,6 +1623,15 @@ void sigusr2_handler(int sig, siginfo_t *sip, void *scp)
|
|||
*/
|
||||
|
||||
#if !EMULATED_PPC
|
||||
// XXX: don't redefine locally?
|
||||
// Note: Original declaration is in sigsegv.cpp
|
||||
// FIXME: If HAVE_MACH_EXCEPTIONS is set, sigsegv_info_t has a bunch of other
|
||||
// fields too! Let's hope Screen_fault_handler() doesn't use them...
|
||||
struct sigsegv_info_t {
|
||||
sigsegv_address_t addr;
|
||||
sigsegv_address_t pc;
|
||||
};
|
||||
|
||||
static void sigsegv_handler(int sig, siginfo_t *sip, void *scp)
|
||||
{
|
||||
machine_regs *r = MACHINE_REGISTERS(scp);
|
||||
|
@ -1641,12 +1650,7 @@ static void sigsegv_handler(int sig, siginfo_t *sip, void *scp)
|
|||
|
||||
#if ENABLE_VOSF
|
||||
// Handle screen fault
|
||||
// XXX: don't redefine locally?
|
||||
#if SIGSEGV_CHECK_VERSION(1,0,0)
|
||||
struct sigsegv_info_t {
|
||||
sigsegv_address_t addr;
|
||||
sigsegv_address_t pc;
|
||||
};
|
||||
sigsegv_info_t si;
|
||||
si.addr = (sigsegv_address_t)addr;
|
||||
si.pc = (sigsegv_address_t)r->pc();
|
||||
|
|
|
@ -85,8 +85,8 @@ void paranoia_check(void)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
struct sigaltstack old_stack;
|
||||
struct sigaltstack new_stack;
|
||||
stack_t old_stack;
|
||||
stack_t new_stack;
|
||||
new_stack.ss_sp = (char *)sig_stack;
|
||||
new_stack.ss_flags = 0;
|
||||
new_stack.ss_size = SIG_STACK_SIZE;
|
||||
|
|
|
@ -79,24 +79,34 @@ struct machine_regs : public mcontext_t
|
|||
// Extract machine registers from Darwin signal frame
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#include <sys/signal.h>
|
||||
extern "C" int sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss);
|
||||
|
||||
#include <sys/ucontext.h>
|
||||
#define MACHINE_REGISTERS(scp) ((machine_regs *)(((ucontext_t *)scp)->uc_mcontext))
|
||||
|
||||
#if __DARWIN_UNIX03
|
||||
#define __(x) __CONCAT(__,x)
|
||||
#else
|
||||
#define __(x) x
|
||||
#endif
|
||||
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
#if __DARWIN_UNIX03
|
||||
struct machine_regs : public __darwin_mcontext
|
||||
#else
|
||||
struct machine_regs : public mcontext
|
||||
#endif
|
||||
{
|
||||
uint32 & cr() { return ss.cr; }
|
||||
uint32 cr() const { return ss.cr; }
|
||||
uint32 lr() const { return ss.lr; }
|
||||
uint32 ctr() const { return ss.ctr; }
|
||||
uint32 xer() const { return ss.xer; }
|
||||
uint32 msr() const { return ss.srr1; }
|
||||
uint32 dar() const { return es.dar; }
|
||||
uint32 & pc() { return ss.srr0; }
|
||||
uint32 pc() const { return ss.srr0; }
|
||||
uint32 & gpr(int i) { return (&ss.r0)[i]; }
|
||||
uint32 gpr(int i) const { return (&ss.r0)[i]; }
|
||||
uint32 & cr() { return __(ss).__(cr); }
|
||||
uint32 cr() const { return __(ss).__(cr); }
|
||||
uint32 lr() const { return __(ss).__(lr); }
|
||||
uint32 ctr() const { return __(ss).__(ctr); }
|
||||
uint32 xer() const { return __(ss).__(xer); }
|
||||
uint32 msr() const { return __(ss).__(srr1); }
|
||||
uint32 dar() const { return __(es).__(dar); }
|
||||
uint32 & pc() { return __(ss).__(srr0); }
|
||||
uint32 pc() const { return __(ss).__(srr0); }
|
||||
uint32 & gpr(int i) { return (&__(ss).__(r0))[i]; }
|
||||
uint32 gpr(int i) const { return (&__(ss).__(r0))[i]; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user