X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fhppa-arch.c;h=bf9a4645461ecab6f21186a996255cb238047866;hb=5759fa78f2289c7e891aaded2a54e069b8bdac01;hp=04af27b2451919f9df86dad7ceba96428a0a3a6c;hpb=79cc569a97e444389350ea3f5b1017374fe16bec;p=sbcl.git diff --git a/src/runtime/hppa-arch.c b/src/runtime/hppa-arch.c index 04af27b..bf9a464 100644 --- a/src/runtime/hppa-arch.c +++ b/src/runtime/hppa-arch.c @@ -23,7 +23,6 @@ #include "interrupt.h" #include "interr.h" #include "breakpoint.h" -#include "monitor.h" void arch_init(void) { @@ -77,7 +76,18 @@ unsigned char *arch_internal_error_arguments(os_context_t *context) boolean arch_pseudo_atomic_atomic(os_context_t *context) { - return ((*os_context_register_addr(context,reg_ALLOC)) & 4); + /* FIXME: this foreign_function_call_active test is dubious at + * best. If a foreign call is made in a pseudo atomic section + * (?) or more likely a pseudo atomic section is in a foreign + * call then an interrupt is executed immediately. Maybe it + * has to do with C code not maintaining pseudo atomic + * properly. MG - 2005-08-10 + * + * The foreign_function_call_active used to live at each call-site + * to arch_pseudo_atomic_atomic, but this seems clearer. + * --NS 2007-05-15 */ + return (!foreign_function_call_active) + && ((*os_context_register_addr(context,reg_ALLOC)) & 4); } void arch_set_pseudo_atomic_interrupted(os_context_t *context) @@ -85,25 +95,31 @@ void arch_set_pseudo_atomic_interrupted(os_context_t *context) *os_context_register_addr(context,reg_ALLOC) |= 1; } +/* FIXME: untested */ +void arch_clear_pseudo_atomic_interrupted(os_context_t *context) +{ + *os_context_register_addr(context,reg_ALLOC) &= ~1; +} + void arch_skip_instruction(os_context_t *context) { ((char *) *os_context_pc_addr(context)) = ((char *) *os_context_npc_addr(context)); ((char *) *os_context_npc_addr(context)) += 4; } -unsigned long arch_install_breakpoint(void *pc) +unsigned int arch_install_breakpoint(void *pc) { - unsigned long *ulpc = (unsigned long *)pc; - unsigned long orig_inst = *ulpc; + unsigned int *ulpc = (unsigned int *)pc; + unsigned int orig_inst = *ulpc; *ulpc = trap_Breakpoint; os_flush_icache((os_vm_address_t)pc, sizeof(*ulpc)); return orig_inst; } -void arch_remove_breakpoint(void *pc, unsigned long orig_inst) +void arch_remove_breakpoint(void *pc, unsigned int orig_inst) { - unsigned long *ulpc = (unsigned long *)pc; + unsigned int *ulpc = (unsigned int *)pc; *ulpc = orig_inst; os_flush_icache((os_vm_address_t)pc, sizeof(*ulpc)); @@ -117,14 +133,14 @@ void arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst) /* We change the next-pc to point to a breakpoint instruction, restore */ /* the original instruction, and exit. We would like to be able to */ /* sigreturn, but we can't, because this is hpux. */ - unsigned long *pc = (unsigned long *)(SC_PC(scp) & ~3); + unsigned int *pc = (unsigned int *)(SC_PC(scp) & ~3); NextPc = SC_NPC(scp); - SC_NPC(scp) = (unsigned)SingleStepTraps | (SC_NPC(scp)&3); + SC_NPC(scp) = (unsigned int)SingleStepTraps | (SC_NPC(scp)&3); BreakpointAddr = pc; *pc = orig_inst; - os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long)); + os_flush_icache((os_vm_address_t)pc, sizeof(unsigned int)); #else /* We set the recovery counter to cover one instruction, put the */ /* original instruction back in, and then resume. We will then trap */ @@ -133,7 +149,7 @@ void arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst) ((struct hp800_thread_state *)scp->sc_ap)->cr0 = 1; scp->sc_ps |= 0x10; - *(unsigned long *)SC_PC(scp) = orig_inst; + *(unsigned int *)SC_PC(scp) = orig_inst; sigreturn(scp); #endif @@ -148,12 +164,12 @@ static void restore_breakpoint(struct sigcontext *scp) /* state so that we will continue as if nothing happened. */ if (NextPc == NULL) - lose("SingleStepBreakpoint trap at strange time."); + lose("SingleStepBreakpoint trap at strange time.\n"); - if ((SC_PC(scp)&~3) == (unsigned long)SingleStepTraps) { + if ((SC_PC(scp)&~3) == (unsigned int)SingleStepTraps) { /* The next instruction was not nullified. */ SC_PC(scp) = NextPc; - if ((SC_NPC(scp)&~3) == (unsigned long)SingleStepTraps + 4) { + if ((SC_NPC(scp)&~3) == (unsigned int)SingleStepTraps + 4) { /* The instruction we just stepped over was not a branch, so */ /* we need to fix it up. If it was a branch, it will point to */ /* the correct place. */ @@ -170,77 +186,54 @@ static void restore_breakpoint(struct sigcontext *scp) if (BreakpointAddr) { *BreakpointAddr = trap_Breakpoint; os_flush_icache((os_vm_address_t)BreakpointAddr, - sizeof(unsigned long)); + sizeof(unsigned int)); BreakpointAddr = NULL; } } #endif -static void sigtrap_handler(int signal, siginfo_t *siginfo, void *void_context) +void +arch_handle_breakpoint(os_context_t *context) +{ + /*sigsetmask(scp->sc_mask); */ + handle_breakpoint(context); +} + +void +arch_handle_fun_end_breakpoint(os_context_t *context) +{ + /*sigsetmask(scp->sc_mask); */ + unsigned long pc; + pc = (unsigned long) + handle_fun_end_breakpoint(context); + *os_context_pc_addr(context) = pc; + *os_context_npc_addr(context) = pc + 4; +} + +static void +sigtrap_handler(int signal, siginfo_t *siginfo, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); - unsigned long bad_inst; + unsigned int bad_inst; #if 0 printf("sigtrap_handler, pc=0x%08x, alloc=0x%08x\n", scp->sc_pcoqh, SC_REG(scp,reg_ALLOC)); #endif - bad_inst = *(unsigned long *)(*os_context_pc_addr(context) & ~3); + bad_inst = *(unsigned int *)(*os_context_pc_addr(context) & ~3); if (bad_inst & 0xfc001fe0) interrupt_handle_now(signal, siginfo, context); else { int im5 = bad_inst & 0x1f; - - switch (im5) { - case trap_Halt: - fake_foreign_function_call(context); - lose("%%primitive halt called; the party is over.\n"); - - case trap_PendingInterrupt: - arch_skip_instruction(context); - interrupt_handle_pending(context); - break; - - case trap_Error: - case trap_Cerror: - interrupt_internal_error(signal, siginfo, context, im5==trap_Cerror); - break; - - case trap_Breakpoint: - /*sigsetmask(scp->sc_mask); */ - handle_breakpoint(signal, siginfo, context); - break; - - case trap_FunEndBreakpoint: - /*sigsetmask(scp->sc_mask); */ - { - unsigned long pc; - pc = (unsigned long) - handle_fun_end_breakpoint(signal, siginfo, context); - *os_context_pc_addr(context) = pc; - *os_context_npc_addr(context) = pc + 4; - } - break; - - case trap_SingleStepBreakpoint: - /* Uh, FIXME */ -#ifdef hpux - restore_breakpoint(context); -#endif - break; - - default: - interrupt_handle_now(signal, siginfo, context); - break; - } + handle_trap(context, trap); } } static void sigfpe_handler(int signal, siginfo_t *siginfo, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); - unsigned long badinst; + unsigned int badinst; int opcode, r1, r2, t; long op1, op2, res; @@ -251,7 +244,7 @@ static void sigfpe_handler(int signal, siginfo_t *siginfo, void *void_context) switch (siginfo->si_code) { case FPE_INTOVF: /*I_OVFLO: */ - badinst = *(unsigned long *)(*os_context_pc_addr(context) & ~3); + badinst = *(unsigned int *)(*os_context_pc_addr(context) & ~3); opcode = badinst >> 26; if (opcode == 2) { @@ -301,7 +294,7 @@ static void sigfpe_handler(int signal, siginfo_t *siginfo, void *void_context) break; case 0: /* I_COND: ?? Maybe tagged add?? FIXME */ - badinst = *(unsigned long *)(*os_context_pc_addr(context) & ~3); + badinst = *(unsigned int *)(*os_context_pc_addr(context) & ~3); if ((badinst&0xfffff800) == (0xb000e000|reg_ALLOC<<21|reg_ALLOC<<16)) { /* It is an ADDIT,OD i,ALLOC,ALLOC instruction that trapped. */ /* That means that it is the end of a pseudo-atomic. So do the */ @@ -333,11 +326,11 @@ static void sigfpe_handler(int signal, siginfo_t *siginfo, void *void_context) static void sigbus_handler(int signal, siginfo_t *siginfo, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); - unsigned long badinst; + unsigned int badinst; int opcode, r1, r2, t; long op1, op2, res; - badinst = *(unsigned long *)(*os_context_pc_addr(context) & ~3); + badinst = *(unsigned int *)(*os_context_pc_addr(context) & ~3); /* First, test for the pseudo-atomic instruction */ if ((badinst & 0xfffff800) == (0xb000e000 | reg_ALLOC<<21 | @@ -414,44 +407,3 @@ void arch_install_interrupt_handlers(void) /* FIXME: beyond 2.4.19-pa4 this shouldn't be necessary. */ undoably_install_low_level_interrupt_handler(SIGBUS,sigbus_handler); } - - -lispobj funcall0(lispobj function) -{ - lispobj *args = current_control_stack_pointer; - - return call_into_lisp(function, args, 0); -} - -lispobj funcall1(lispobj function, lispobj arg0) -{ - lispobj *args = current_control_stack_pointer; - - current_control_stack_pointer += 1; - args[0] = arg0; - - return call_into_lisp(function, args, 1); -} - -lispobj funcall2(lispobj function, lispobj arg0, lispobj arg1) -{ - lispobj *args = current_control_stack_pointer; - - current_control_stack_pointer += 2; - args[0] = arg0; - args[1] = arg1; - - return call_into_lisp(function, args, 2); -} - -lispobj funcall3(lispobj function, lispobj arg0, lispobj arg1, lispobj arg2) -{ - lispobj *args = current_control_stack_pointer; - - current_control_stack_pointer += 3; - args[0] = arg0; - args[1] = arg1; - args[2] = arg2; - - return call_into_lisp(function, args, 3); -}