The trap_init() Function

Trap_init() is usually located in arch/<host>/kernel/traps.c.

Trap_init() initializes some of the processor's interrupt handling capability. In particular, it aims the processors interrupt vector table pointer to the address of the actual vector table, if necessary. Interrupts are not enabled until later on, just before the calibrate_delay() function is run.

The code in Figure 6 shows trap_init() for the Hitachi SH.

void __init trap_init(void)
{
   extern void *vbr_base;
   extern void *exception_handling_table[14];

   exception_handling_table[12] = (void *)do_reserved_inst;
   exception_handling_table[13] = (void *)do_illegal_slot_inst;

   asm volatile("ldc  %0, vbr"
                  : /* no output */
                  : "r" (&vbr_base)
                  : "memory");
}

Figure 6. The trap_init() function.