void
arch_init(void)
{
- /* This must be called _after_ os_init, so we know what the page
- * size is. */
- if(mmap((os_vm_address_t) call_into_lisp_LRA_page,os_vm_page_size,
- OS_VM_PROT_ALL,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0)
- == (os_vm_address_t) -1)
+ /* This must be called _after_ os_init(), so that we know what the
+ * page size is. */
+ if (mmap((os_vm_address_t) call_into_lisp_LRA_page,os_vm_page_size,
+ OS_VM_PROT_ALL,MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED,-1,0)
+ == (os_vm_address_t) -1)
perror("mmap");
/* call_into_lisp_LRA is a collection of trampolines written in asm -
sig, code, context); */
pc= (unsigned int *)(*os_context_pc_addr(context));
- if(((unsigned long)pc) & 3) {
+ if (((unsigned long)pc) & 3) {
return NULL; /* In what case would pc be unaligned?? */
}
- if( (pc < READ_ONLY_SPACE_START ||
- pc >= READ_ONLY_SPACE_START+READ_ONLY_SPACE_SIZE) &&
- (pc < current_dynamic_space ||
- pc >= current_dynamic_space + DYNAMIC_SPACE_SIZE))
+ if ( (pc < READ_ONLY_SPACE_START ||
+ pc >= READ_ONLY_SPACE_START+READ_ONLY_SPACE_SIZE) &&
+ (pc < current_dynamic_space ||
+ pc >= current_dynamic_space + DYNAMIC_SPACE_SIZE))
return NULL;
badinst = *pc;
- if(((badinst>>27)!=0x16) /* STL or STQ */
- && ((badinst>>27)!=0x13)) /* STS or STT */
- return NULL; /* Otherwise forget about address. */
+ if (((badinst>>27)!=0x16) /* STL or STQ */
+ && ((badinst>>27)!=0x13)) /* STS or STT */
+ return NULL; /* Otherwise forget about address. */
return (os_vm_address_t)
(*os_context_register_addr(context,((badinst>>16)&0x1f))
unsigned char *
arch_internal_error_arguments(os_context_t *context)
{
- return (unsigned char *)(*os_context_pc_addr(context)+4);
+ return (unsigned char *)(*os_context_pc_addr(context)+4);
}
boolean
* didn't use that */
#ifdef __linux__
- *os_context_register_addr(context,reg_ALLOC) |= (1L<<63);
+ *os_context_register_addr(context,reg_ALLOC) |= (1L<<63);
#else
- *os_context_register_addr(context,reg_ALLOC) |= 2;
+ *os_context_register_addr(context,reg_ALLOC) |= 2;
#endif
}
void arch_remove_breakpoint(void *pc, unsigned long orig_inst)
{
- /* was (unsigned int) but gcc complains. Changed to mirror
- * install_breakpoint() above */
- unsigned long *ptr=(unsigned long *)pc;
- *ptr = orig_inst;
- os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long));
+ /* was (unsigned int) but gcc complains. Changed to mirror
+ * install_breakpoint() above */
+ unsigned long *ptr=(unsigned long *)pc;
+ *ptr = orig_inst;
+ os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long));
}
static unsigned int *skipped_break_addr, displaced_after_inst,
/* This returns a PC value. Lisp code is all in the 32-bit-addressable
- * space,so we should be ok with an unsigned int. */
+ * space, so we should be ok with an unsigned int. */
unsigned int
emulate_branch(os_context_t *context,unsigned long orig_inst)
{
- int op = orig_inst >> 26;
- int reg_a = (orig_inst >> 21) & 0x1f;
- int reg_b = (orig_inst >> 16) & 0x1f;
- int disp = (orig_inst&(1<<20)) ? orig_inst | (-1 << 21) : orig_inst&0x1fffff;
- int next_pc = *os_context_pc_addr(context);
- int branch = 0; /* was NULL; */
-
- switch(op) {
- case 0x1a: /* jmp, jsr, jsr_coroutine, ret */
- *os_context_register_addr(context,reg_a)=*os_context_pc_addr(context);
- *os_context_pc_addr(context)=*os_context_register_addr(context,reg_b)& ~3;
- break;
- case 0x30: /* br */
- *os_context_register_addr(context,reg_a)=*os_context_pc_addr(context);
- branch = 1;
- break;
- case 0x31: /* fbeq */
- if(*(os_context_fpregister_addr(context,reg_a))==0) branch = 1;
- break;
- case 0x32: /* fblt */
- if(*os_context_fpregister_addr(context,reg_a)<0) branch = 1;
- break;
- case 0x33: /* fble */
- if(*os_context_fpregister_addr(context,reg_a)<=0) branch = 1;
- break;
- case 0x34: /* bsr */
- *os_context_register_addr(context,reg_a)=*os_context_pc_addr(context);
- branch = 1;
- break;
- case 0x35: /* fbne */
- if(*os_context_register_addr(context,reg_a)!=0) branch = 1;
- break;
- case 0x36: /* fbge */
- if(*os_context_fpregister_addr(context,reg_a)>=0) branch = 1;
- break;
- case 0x37: /* fbgt */
- if(*os_context_fpregister_addr(context,reg_a)>0) branch = 1;
- break;
- case 0x38: /* blbc */
- if((*os_context_register_addr(context,reg_a)&1) == 0) branch = 1;
- break;
- case 0x39: /* beq */
- if(*os_context_register_addr(context,reg_a)==0) branch = 1;
- break;
- case 0x3a: /* blt */
- if(*os_context_register_addr(context,reg_a)<0) branch = 1;
- break;
- case 0x3b: /* ble */
- if(*os_context_register_addr(context,reg_a)<=0) branch = 1;
- break;
- case 0x3c: /* blbs */
- if((*os_context_register_addr(context,reg_a)&1)!=0) branch = 1;
- break;
- case 0x3d: /* bne */
- if(*os_context_register_addr(context,reg_a)!=0) branch = 1;
- break;
- case 0x3e: /* bge */
- if(*os_context_register_addr(context,reg_a)>=0) branch = 1;
- break;
- case 0x3f: /* bgt */
- if(*os_context_register_addr(context,reg_a)>0) branch = 1;
- break;
- }
- if(branch) next_pc += disp*4;
- return next_pc;
+ int op = orig_inst >> 26;
+ int reg_a = (orig_inst >> 21) & 0x1f;
+ int reg_b = (orig_inst >> 16) & 0x1f;
+ int disp =
+ (orig_inst&(1<<20)) ?
+ orig_inst | (-1 << 21) :
+ orig_inst&0x1fffff;
+ int next_pc = *os_context_pc_addr(context);
+ int branch = 0; /* was NULL; */
+
+ switch(op) {
+ case 0x1a: /* jmp, jsr, jsr_coroutine, ret */
+ *os_context_register_addr(context,reg_a) =
+ *os_context_pc_addr(context);
+ *os_context_pc_addr(context) =
+ *os_context_register_addr(context,reg_b)& ~3;
+ break;
+ case 0x30: /* br */
+ *os_context_register_addr(context,reg_a)=*os_context_pc_addr(context);
+ branch = 1;
+ break;
+ case 0x31: /* fbeq */
+ if (*(os_context_float_register_addr(context,reg_a))==0) branch = 1;
+ break;
+ case 0x32: /* fblt */
+ if (*os_context_float_register_addr(context,reg_a)<0) branch = 1;
+ break;
+ case 0x33: /* fble */
+ if (*os_context_float_register_addr(context,reg_a)<=0) branch = 1;
+ break;
+ case 0x34: /* bsr */
+ *os_context_register_addr(context,reg_a)=*os_context_pc_addr(context);
+ branch = 1;
+ break;
+ case 0x35: /* fbne */
+ if (*os_context_register_addr(context,reg_a)!=0) branch = 1;
+ break;
+ case 0x36: /* fbge */
+ if (*os_context_float_register_addr(context,reg_a)>=0) branch = 1;
+ break;
+ case 0x37: /* fbgt */
+ if (*os_context_float_register_addr(context,reg_a)>0) branch = 1;
+ break;
+ case 0x38: /* blbc */
+ if ((*os_context_register_addr(context,reg_a)&1) == 0) branch = 1;
+ break;
+ case 0x39: /* beq */
+ if (*os_context_register_addr(context,reg_a)==0) branch = 1;
+ break;
+ case 0x3a: /* blt */
+ if (*os_context_register_addr(context,reg_a)<0) branch = 1;
+ break;
+ case 0x3b: /* ble */
+ if (*os_context_register_addr(context,reg_a)<=0) branch = 1;
+ break;
+ case 0x3c: /* blbs */
+ if ((*os_context_register_addr(context,reg_a)&1)!=0) branch = 1;
+ break;
+ case 0x3d: /* bne */
+ if (*os_context_register_addr(context,reg_a)!=0) branch = 1;
+ break;
+ case 0x3e: /* bge */
+ if (*os_context_register_addr(context,reg_a)>=0) branch = 1;
+ break;
+ case 0x3f: /* bgt */
+ if (*os_context_register_addr(context,reg_a)>0) branch = 1;
+ break;
+ }
+ if (branch)
+ next_pc += disp*4;
+ return next_pc;
}
static sigset_t orig_sigmask;
* at the BPT instruction itself. This is good, because this is
* where we want to restart execution when we do that */
- unsigned int *pc=(unsigned int *)(*os_context_pc_addr(context));
- unsigned int *next_pc;
- int op = orig_inst >> 26;;
+ unsigned int *pc=(unsigned int *)(*os_context_pc_addr(context));
+ unsigned int *next_pc;
+ int op = orig_inst >> 26;;
- orig_sigmask = *os_context_sigmask_addr(context);
- sigaddset_blockable(os_context_sigmask_addr(context));
+ orig_sigmask = *os_context_sigmask_addr(context);
+ sigaddset_blockable(os_context_sigmask_addr(context));
- /* Put the original instruction back. */
- *pc = orig_inst;
- os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long));
- skipped_break_addr = pc;
+ /* Put the original instruction back. */
+ *pc = orig_inst;
+ os_flush_icache((os_vm_address_t)pc, sizeof(unsigned long));
+ skipped_break_addr = pc;
/* Figure out where we will end up after running the displaced
* instruction */
- if(op == 0x1a || (op&0xf) == 0x30) /* a branch */
+ if (op == 0x1a || (op&0xf) == 0x30) /* a branch */
/* The cast to long is just to shut gcc up. */
next_pc = (unsigned int *)((long)emulate_branch(context,orig_inst));
else
next_pc = pc+1;
- /* Set the after breakpoint. */
- displaced_after_inst = *next_pc;
- *next_pc = BREAKPOINT_INST;
- after_breakpoint=1;
- os_flush_icache((os_vm_address_t)next_pc, sizeof(unsigned long));
+ /* Set the after breakpoint. */
+ displaced_after_inst = *next_pc;
+ *next_pc = BREAKPOINT_INST;
+ after_breakpoint=1;
+ os_flush_icache((os_vm_address_t)next_pc, sizeof(unsigned long));
}
static void
* different opcode so we can test whether we're dealing with a
* breakpoint or a "system service" */
- if((*(unsigned int*)(*os_context_pc_addr(context)-4))== BREAKPOINT_INST) {
- if(after_breakpoint) {
+ if ((*(unsigned int*)(*os_context_pc_addr(context)-4))==BREAKPOINT_INST) {
+ if (after_breakpoint) {
/* see comments above arch_do_displaced_inst. This is where
* we reinsert the breakpoint that we removed earlier */
}
}
-static void sigfpe_handler(int signal, int code, os_context_t *context)
+unsigned long
+arch_get_fp_control()
{
- /* what should this contain? interesting question. If it really
- * is empty, why don't we just ignore the signal? -dan 2001.08.10
- */
+ return ieee_get_fp_control();
+}
+
+void
+arch_set_fp_control(unsigned long fp)
+{
+ ieee_set_fp_control(fp);
}
+
void arch_install_interrupt_handlers()
{
undoably_install_low_level_interrupt_handler(SIGTRAP, sigtrap_handler);
- undoably_install_low_level_interrupt_handler(SIGFPE, sigfpe_handler);
}
extern lispobj call_into_lisp(lispobj fun, lispobj *args, int nargs);