diff --git a/src/lisp/Config.ppc_darwin b/src/lisp/Config.ppc_darwin index 8609a4d885efc3d3d4a2fb376b175d9ede50a7ab..da9737a115ee78d59924b3d870fa02e83041fcf5 100644 --- a/src/lisp/Config.ppc_darwin +++ b/src/lisp/Config.ppc_darwin @@ -12,7 +12,7 @@ CPPFLAGS = -I. -I$(PATH1) # concatenate tokens which reguires the -traditional flag. # Build for OSX 10.2.8 or later. (Is this what we want?) -#OSX_VERSION=-mmacosx-version-min=10.2 +OSX_VERSION=-mmacosx-version-min=10.4 CC = gcc LD = ld NM = $(PATH1)/darwin-nm diff --git a/src/lisp/Darwin-os.c b/src/lisp/Darwin-os.c index 728324a3587832f5ea6e1402ff6408de53c75a3a..2da3d83bcf66ec7e3b84535a9f1eb095a8edbba0 100644 --- a/src/lisp/Darwin-os.c +++ b/src/lisp/Darwin-os.c @@ -113,7 +113,52 @@ os_init(const char *argv[], const char *envp[]) #endif } + #if defined(__ppc__) +#if __DARWIN_UNIX03 + /* Nothing needed for 10.5 */ +#else +/* For 10.4 */ +#define __ss ss +#define __r0 r0 +#define __r1 r1 +#define __r2 r2 +#define __r3 r3 +#define __r4 r4 +#define __r5 r5 +#define __r6 r6 +#define __r7 r7 +#define __r8 r8 +#define __r9 r9 +#define __r10 r10 +#define __r11 r11 +#define __r12 r12 +#define __r13 r13 +#define __r14 r14 +#define __r15 r15 +#define __r16 r16 +#define __r17 r17 +#define __r18 r18 +#define __r19 r19 +#define __r20 r20 +#define __r21 r21 +#define __r22 r22 +#define __r23 r23 +#define __r24 r24 +#define __r25 r25 +#define __r26 r26 +#define __r27 r27 +#define __r28 r28 +#define __r29 r29 +#define __r30 r30 +#define __r31 r31 +#define __lr lr +#define __ctr ctr +#define __es es +#define __dar dar +#define __dsisr dsisr +#endif + unsigned long * sc_reg(os_context_t * context, int offset) { @@ -466,23 +511,24 @@ sigbus_handle_now(HANDLER_ARGS) static void sigbus_handler(HANDLER_ARGS) { + os_context_t *os_context = (os_context_t *) context; #if defined(GENCGC) caddr_t fault_addr = code->si_addr; #endif #ifdef RED_ZONE_HIT - if (os_control_stack_overflow((void *) fault_addr, context)) + if (os_control_stack_overflow((void *) fault_addr, os_context)) return; #endif #ifdef __ppc__ DPRINTF(0, (stderr, "sigbus:\n")); - DPRINTF(0, (stderr, " PC = %p\n", SC_PC(context))); - DPRINTF(0, (stderr, " ALLOC-TN = %p\n", SC_REG(context, reg_ALLOC))); - DPRINTF(0, (stderr, " CODE-TN = %p\n", SC_REG(context, reg_CODE))); - DPRINTF(0, (stderr, " LRA-TN = %p\n", SC_REG(context, reg_LRA))); - DPRINTF(0, (stderr, " CFP-TN = %p\n", SC_REG(context, reg_CFP))); - DPRINTF(0, (stderr, " FDEFN-TN = %p\n", SC_REG(context, reg_FDEFN))); + DPRINTF(0, (stderr, " PC = %p\n", SC_PC(os_context))); + DPRINTF(0, (stderr, " ALLOC-TN = %p\n", SC_REG(os_context, reg_ALLOC))); + DPRINTF(0, (stderr, " CODE-TN = %p\n", SC_REG(os_context, reg_CODE))); + DPRINTF(0, (stderr, " LRA-TN = %p\n", SC_REG(os_context, reg_LRA))); + DPRINTF(0, (stderr, " CFP-TN = %p\n", SC_REG(os_context, reg_CFP))); + DPRINTF(0, (stderr, " FDEFN-TN = %p\n", SC_REG(os_context, reg_FDEFN))); DPRINTF(0, (stderr, " foreign_function_call = %d\n", foreign_function_call_active)); #endif @@ -494,16 +540,16 @@ sigbus_handler(HANDLER_ARGS) if (gc_write_barrier(code->si_addr)) return; #else - if (interrupt_maybe_gc(signal, code, context)) + if (interrupt_maybe_gc(signal, code, os_context)) return; #endif /* a *real* protection fault */ fprintf(stderr, "sigbus_handler: Real protection violation at %p, PC = %p\n", - fault_addr, (void *) SC_PC(context)); - sigbus_handle_now(signal, code, context); + fault_addr, (void *) SC_PC(os_context)); + sigbus_handle_now(signal, code, os_context); #ifdef __ppc__ /* Work around G5 bug; fix courtesy gbyers via chandler */ - sigreturn(context); + sigreturn(os_context); #endif } diff --git a/src/lisp/ppc-arch.c b/src/lisp/ppc-arch.c index 9b3963d79adcb639309366d0a4bea9d59c3f27e3..a7267fcef0036aaeae6adf198e193a38b4dd591e 100644 --- a/src/lisp/ppc-arch.c +++ b/src/lisp/ppc-arch.c @@ -59,9 +59,10 @@ arch_init(fpu_mode_t mode) os_vm_address_t arch_get_bad_addr(HANDLER_ARGS) { + os_context_t *os_context = (os_context_t *) context; os_vm_address_t addr; - addr = (os_vm_address_t) SC_REG(context, PT_DAR); + addr = (os_vm_address_t) SC_REG(os_context, PT_DAR); return addr; } @@ -372,11 +373,12 @@ handle_allocation_trap(os_context_t * context) static void sigill_handler(HANDLER_ARGS) { + os_context_t *os_context = (os_context_t *) context; int badinst; int opcode; - sigprocmask(SIG_SETMASK, &context->uc_sigmask, 0); - opcode = *((int *) SC_PC(context)); + sigprocmask(SIG_SETMASK, &os_context->uc_sigmask, 0); + opcode = *((int *) SC_PC(os_context)); #if 0 printf("SIGILL entry: opcode = 0x%08x\n", opcode); @@ -387,26 +389,26 @@ sigill_handler(HANDLER_ARGS) /* Got a twnei reg_NL3,0 - check for deferred interrupt */ #if 1 /* Clear the pseudo-atomic-interrupted bit */ - SC_REG(context, reg_ALLOC) &= ~1; + SC_REG(os_context, reg_ALLOC) &= ~1; #else - (SC_REG(context, reg_ALLOC) -= PSEUDO_ATOMIC_INTERRUPTED_BIAS); + (SC_REG(os_context, reg_ALLOC) -= PSEUDO_ATOMIC_INTERRUPTED_BIAS); #endif - arch_skip_instruction(context); - interrupt_handle_pending(context); + arch_skip_instruction(os_context); + interrupt_handle_pending(os_context); #ifdef DARWIN /* Work around G5 bug; fix courtesy gbyers via chandler */ - sigreturn(context); + sigreturn(os_context); #endif return; } /* Is this an allocation trap? */ #ifdef GENCGC - if (allocation_trap_p(context)) { - handle_allocation_trap(context); - arch_skip_instruction(context); + if (allocation_trap_p(os_context)) { + handle_allocation_trap(os_context); + arch_skip_instruction(os_context); #ifdef DARWIN - sigreturn(context); + sigreturn(os_context); #endif return; } @@ -423,18 +425,18 @@ sigill_handler(HANDLER_ARGS) switch (trap) { case trap_Halt: - fake_foreign_function_call(context); + fake_foreign_function_call(os_context); lose("%%primitive halt called; the party is over.\n"); case trap_Error: case trap_Cerror: - interrupt_internal_error(signal, code, context, + interrupt_internal_error(signal, code, os_context, trap == trap_Cerror); break; case trap_PendingInterrupt: - arch_skip_instruction(context); - interrupt_handle_pending(context); + arch_skip_instruction(os_context); + interrupt_handle_pending(os_context); break; case trap_Breakpoint: @@ -442,7 +444,7 @@ sigill_handler(HANDLER_ARGS) printf("trap_Breakpoint\n"); fflush(stdout); #endif - handle_breakpoint(signal, code, context); + handle_breakpoint(signal, code, os_context); break; case trap_FunctionEndBreakpoint: @@ -450,8 +452,8 @@ sigill_handler(HANDLER_ARGS) printf("trap_FunctionEndBreakpoint\n"); fflush(stdout); #endif - SC_PC(context) = - (int) handle_function_end_breakpoint(signal, code, context); + SC_PC(os_context) = + (int) handle_function_end_breakpoint(signal, code, os_context); break; case trap_AfterBreakpoint: @@ -459,45 +461,45 @@ sigill_handler(HANDLER_ARGS) fprintf(stderr, "trap_AfterBreakpoint: break_addr = %p\n", skipped_break_addr); fprintf(stderr, " CSP = %p\n", - (void *) SC_REG(context, reg_CSP)); + (void *) SC_REG(os_context, reg_CSP)); fprintf(stderr, " CFP = %p\n", - (void *) SC_REG(context, reg_CFP)); + (void *) SC_REG(os_context, reg_CFP)); fprintf(stderr, " OCFP = %p\n", - (void *) SC_REG(context, reg_OCFP)); + (void *) SC_REG(os_context, reg_OCFP)); #endif /* Put our breakpoint instruction back in */ *skipped_break_addr = TWLLEI_R0(trap_Breakpoint); skipped_break_addr = NULL; - *(unsigned long *) SC_PC(context) = displaced_after_inst; - context->uc_sigmask = orig_sigmask; + *(unsigned long *) SC_PC(os_context) = displaced_after_inst; + os_context->uc_sigmask = orig_sigmask; - os_flush_icache((os_vm_address_t) SC_PC(context), + os_flush_icache((os_vm_address_t) SC_PC(os_context), sizeof(unsigned long)); break; default: - interrupt_handle_now(signal, code, context); + interrupt_handle_now(signal, code, os_context); break; } #ifdef DARWIN /* Work around G5 bug; fix courtesy gbyers via chandler */ - sigreturn(context); + sigreturn(os_context); #endif return; } if (((opcode >> 26) == 3) && (((opcode >> 21) & 31) == 24)) { - interrupt_internal_error(signal, code, context, 0); + interrupt_internal_error(signal, code, os_context, 0); #ifdef DARWIN /* Work around G5 bug; fix courtesy gbyers via chandler */ - sigreturn(context); + sigreturn(os_context); #endif return; } - interrupt_handle_now(signal, code, context); + interrupt_handle_now(signal, code, os_context); #ifdef DARWIN /* Work around G5 bug; fix courtesy gbyers via chandler */ - sigreturn(context); + sigreturn(os_context); #endif } diff --git a/src/lisp/ppc-lispregs.h b/src/lisp/ppc-lispregs.h index b593c1fa1efdc047ea0aea6eb51b9f6ec7cf9c7b..09aec88d12d03903a4a7c0d64d4d4d8896c45982 100644 --- a/src/lisp/ppc-lispregs.h +++ b/src/lisp/ppc-lispregs.h @@ -107,8 +107,13 @@ #ifndef LANGUAGE_ASSEMBLY #if defined DARWIN #define SC_REG(sc,reg) (*sc_reg(sc,reg)) +#if __DARWIN_UNIX03 +/* For 10.5 */ #define SC_PC(sc) (sc->uc_mcontext->__ss.__srr0) #else +#define SC_PC(sc) (sc->uc_mcontext->ss.srr0) +#endif +#else #define SC_REG(sc,reg) (((unsigned long *)(sc->regs))[(reg)]) #define SC_PC(sc) (((unsigned long *)(sc->regs))[PT_NIP]) #endif