Low-Level CPU Routines

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

Configures the location of exception and interrupt vectors.
Enables the delivery of interrupts to the configured non-bootloader vectors.
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:

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.
Handles exception conditions, switching to a dedicated stack and jumping to the exception_handler routine defined by an application.
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.