libparanut
A Hardware Abstraction Layer for ParaNut Architectures.
|
Functions for controlling the handling of interrupts/exceptions. More...
void | pn_exception_init (void) |
Initializes libparanut internal exception handling. Interrupts (not exceptions in general!) are disabled after. Should be called before using pn_exception_set_handler(). | |
int | pn_exception_set_handler (void(*handler)(unsigned int cause, unsigned int program_counter, unsigned int mtval), unsigned int exception_code) |
Set your own exception handler. More... | |
void | pn_ecall (void) |
Raises an environment call exception. More... | |
void | pn_interrupt_enable (void) |
Enables interrupts only. More... | |
void | pn_interrupt_disable (void) |
Disables interrupts only. More... | |
void | pn_progress_mepc (void) |
Sets program counter of the register which keeps the exception return adress to next instruction. More... | |
Functions for controlling the handling of interrupts/exceptions.
Why are we calling this exceptions, even though most people would call this an interrupt? Historic reasons. The libparanut was first written for the RISCV implementation of the ParaNut, and the RISCV specification refers to both interrupts and exceptions as exceptions.
void pn_ecall | ( | void | ) |
Raises an environment call exception.
Can be called without using pn_exception_init() first.
int pn_exception_set_handler | ( | void(*)(unsigned int cause, unsigned int program_counter, unsigned int mtval) | handler, |
unsigned int | exception_code | ||
) |
Set your own exception handler.
Can be called without using pn_exception_init() first, will not work though.
Already does the work of saving away registers, setting program counter etc. for you. You can just hang in what you want to do.
[in] | handler | is a function pointer to your exception handler. Will return an error (PN_ERR_PARAM) if NULL is given. |
[in] | exception_code | is the number that your exception has. You can look up the exception codes in the ParaNut Manual. For interrupts, the value of the most significant bit of the exception code has to be 1. For synchronous exceptions, it has to be 0. This function will return an error (PN_ERR_EXC) if a non implemented value for cause is given. |
void pn_interrupt_disable | ( | void | ) |
Disables interrupts only.
Can be called without using pn_exception_init() first.
void pn_interrupt_enable | ( | void | ) |
Enables interrupts only.
Can be called without using pn_exception_init() first.
void pn_progress_mepc | ( | void | ) |
Sets program counter of the register which keeps the exception return adress to next instruction.
Can be called without using pn_exception_init() first.