4 static int undef_initialized = 0;
6 static unsigned long cpu_undef_stack[256];
8 struct undef_hook *undef_hook_chain = NULL;
10 static void undef_exception_handler(int excptnum, struct pt_regs *regs)
12 /*unsigned int correction = thumb_mode(regs) ? 2 : 4;*/
13 unsigned int correction = 0;
14 struct undef_hook *hook;
18 regs->ARM_pc -= correction;
20 pc = (void *)regs->ARM_pc;
22 instr = *(unsigned long *)pc;
24 for(hook = undef_hook_chain; hook; hook = hook->next) {
25 if (((instr & hook->instr_mask) == hook->instr_val) &&
26 ((regs->ARM_cpsr & hook->cpsr_mask) == hook->cpsr_val)) {
27 if (hook->fn(regs, instr) == 0) {
38 int register_undef_hook(struct undef_hook *hook)
44 if(!undef_initialized) {
45 set_cpu_exception_handler(ARM_EXCEPTION_UNDEF, (long)undef_exception_handler);
46 set_cpu_exception_stack(ARM_EXCEPTION_UNDEF, (long)((char*)cpu_undef_stack+sizeof(cpu_undef_stack)-8));
47 undef_initialized = 1;
50 hook->next = undef_hook_chain;
51 undef_hook_chain = hook;