From 850038164847699f1720cc077c97f27e3e510f20 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sun, 20 Feb 2005 18:08:50 +0000 Subject: [PATCH] Initial support for NetBSD/ppc in native mode (some crashes occur but I could boot MacOS 9.0.4) --- SheepShaver/src/Unix/main_unix.cpp | 20 ++++++++++++++++++++ SheepShaver/src/Unix/ppc_asm.tmpl | 4 ++-- SheepShaver/src/Unix/sysdeps.h | 2 +- SheepShaver/src/thunks.cpp | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/SheepShaver/src/Unix/main_unix.cpp b/SheepShaver/src/Unix/main_unix.cpp index 67428942..b0660e69 100644 --- a/SheepShaver/src/Unix/main_unix.cpp +++ b/SheepShaver/src/Unix/main_unix.cpp @@ -204,6 +204,26 @@ struct machine_regs : public pt_regs }; #endif +#if defined(__NetBSD__) +#include +#define MACHINE_REGISTERS(scp) ((machine_regs *)&(((ucontext_t *)scp)->uc_mcontext)) + +struct machine_regs : public mcontext_t +{ + long & cr() { return __gregs[_REG_CR]; } + uint32 cr() const { return __gregs[_REG_CR]; } + uint32 lr() const { return __gregs[_REG_LR]; } + uint32 ctr() const { return __gregs[_REG_CTR]; } + uint32 xer() const { return __gregs[_REG_XER]; } + uint32 msr() const { return __gregs[_REG_MSR]; } + uint32 dar() const { return (uint32)(((siginfo_t *)(((unsigned long)this) - offsetof(ucontext_t, uc_mcontext))) - 1)->si_addr; } /* HACK */ + long & pc() { return __gregs[_REG_PC]; } + uint32 pc() const { return __gregs[_REG_PC]; } + long & gpr(int i) { return __gregs[_REG_R0 + i]; } + uint32 gpr(int i) const { return __gregs[_REG_R0 + i]; } +}; +#endif + #if defined(__APPLE__) && defined(__MACH__) #include extern "C" int sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss); diff --git a/SheepShaver/src/Unix/ppc_asm.tmpl b/SheepShaver/src/Unix/ppc_asm.tmpl index 08473ccb..20de7e5f 100644 --- a/SheepShaver/src/Unix/ppc_asm.tmpl +++ b/SheepShaver/src/Unix/ppc_asm.tmpl @@ -18,7 +18,7 @@ #endif /* Register names */ -#if defined(__linux__) +#if defined(__linux__) || defined(__NetBSD__) #define r0 0 #define r1 1 #define r2 2 @@ -53,7 +53,7 @@ #define r31 31 #endif -#if defined(__linux__) +#if defined(__linux__) || defined(__NetBSD__) #define f0 0 #define f1 1 #define f2 2 diff --git a/SheepShaver/src/Unix/sysdeps.h b/SheepShaver/src/Unix/sysdeps.h index 0760c236..2f3e81fd 100644 --- a/SheepShaver/src/Unix/sysdeps.h +++ b/SheepShaver/src/Unix/sysdeps.h @@ -413,7 +413,7 @@ typedef struct timeval tm_time_t; extern uint64 GetTicks_usec(void); extern void Delay_usec(uint32 usec); -#if defined(HAVE_PTHREADS) || (defined(__linux__) && defined(__powerpc__)) +#if defined(HAVE_PTHREADS) || ((defined(__linux__) || defined(__NetBSD__)) && defined(__powerpc__)) // Setup pthread attributes extern void Set_pthread_attr(pthread_attr_t *attr, int priority); #endif diff --git a/SheepShaver/src/thunks.cpp b/SheepShaver/src/thunks.cpp index 49024f87..83b7e17a 100644 --- a/SheepShaver/src/thunks.cpp +++ b/SheepShaver/src/thunks.cpp @@ -215,7 +215,7 @@ bool ThunksInit(void) native_op[NATIVE_R_GET_RESOURCE].func = r_get_resource_func; #endif #else -#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(__linux__) || defined(__NetBSD__) || (defined(__APPLE__) && defined(__MACH__)) #define DEFINE_NATIVE_OP(ID, FUNC) do { \ uintptr base = SheepMem::Reserve(8); \ WriteMacInt32(base + 0, (uint32)FUNC); \