libctr9
Nintendo 3DS ARM9 library
|
#include <stdint.h>
Go to the source code of this file.
Enumerations | |
enum | ctr_interrupt_enum { CTR_INTERRUPT_RESET, CTR_INTERRUPT_UNDEF, CTR_INTERRUPT_SWI, CTR_INTERRUPT_PREABRT, CTR_INTERRUPT_DATABRT, CTR_INTERRUPT_IRQ, CTR_INTERRUPT_FIQ } |
Enumerations for the different ARM9 CPU exceptions. More... | |
Functions | |
void | ctr_interrupt_global_disable (void) |
Disables FIQ and IRQ interrupts. | |
void | ctr_interrupt_global_enable (void) |
Enables FIQ and IRQ interrupts. | |
void | ctr_interrupt_prepare (void) |
Sets up the exception vectors in ITCM. More... | |
void | ctr_interrupt_set (ctr_interrupt_enum interrupt_type, void(*interrupt)(uint32_t *)) |
Sets up a handler for the given exception. More... | |
enum ctr_interrupt_enum |
Enumerations for the different ARM9 CPU exceptions.
These enumerations can be used as indices to set handlers for the exceptions with ctr_interrupt_set.
void ctr_interrupt_prepare | ( | void | ) |
Sets up the exception vectors in ITCM.
For this function to work, ITCM must be enabled and MPU must allow for writing and reading from 0x0000 to 0x8000. In addition, the stacks for the exception modes must be set up, else when trying to jump to the exception handling code, the stacks will be setup randomly and will most likely lead to a crash.
void ctr_interrupt_set | ( | ctr_interrupt_enum | interrupt_type, |
void(*)(uint32_t *) | interrupt | ||
) |
Sets up a handler for the given exception.
When the user-provided handler is called when an exception is generated, the parameter given to the function is an array with the following data from before the exception: [ cpsr, sp, lr, r0-r12 ]
Note that lr is the lr as saved by the current exception mode, refer to the ARM documentation to see how much lr was modified relative to the PC of when the exceptiin was triggered. Any changes to any of the values in the input array WILL be written back to the corresponding registers when the exception returns, if the handler returns. This can be used to skip the instruction that caused a data abort, for example, by editing lr to skip it. Note that for lr adjustments, the mode of execution when the exception was triggered is important. Check the T bit of cpsr in the input array to determine the mode of execution when the exception was thrown.
[in] | interrupt_type | Enumeration determining which exception to set up. |
[in] | interrupt | Handler to call when the exception is fired. The handler can be either Thumb or ARM code. |