Low-Level CPU Routines

The lib/cpu.S file contains low-level routines for handling specific conditions related to the operation of the CPU:

init_interrupts
Configures the location of exception and interrupt vectors.
enable_interrupts
Enables the delivery of interrupts to the configured non-bootloader vectors.
handle_error_level
Handles the initial state of the CPU, making exception and interrupt conditions possible.

These routines are called in an appropriate order in the general initialisation code.

To support exceptions and interrupts, the following routines are defined in the .vectors section of the payload:

ebase
Handles TLB exceptions, jumping to the general exception handler. The PIC32 products tested with this software do not provide hardware that should raise such exceptions, however.
exc_handler
Handles exception conditions, switching to a dedicated stack and jumping to the exception_handler routine defined by an application.
int_handler
Handles interrupt conditions, switching to a dedicated stack, saving register values, jumping to the interrupt_handler routine defined by an application, then restoring register values, switching back to the application stack and returning to the interrupted code.