libdragon
Files | Data Structures | Enumerations

Handle hardware-generated exceptions. More...

Files

file  exception.c
 Exception Handler.
 
file  exception.h
 Exception Handler.
 

Data Structures

struct  reg_block_t
 Structure representing a register block. More...
 
struct  exception_t
 Structure representing an exception. More...
 

Enumerations

enum  { EXCEPTION_TYPE_UNKNOWN = 0 , EXCEPTION_TYPE_RESET , EXCEPTION_TYPE_CRITICAL , EXCEPTION_TYPE_SYSCALL }
 Exception types. More...
 
enum  exception_code_t {
  EXCEPTION_CODE_INTERRUPT = 0 , EXCEPTION_CODE_TLB_MODIFICATION = 1 , EXCEPTION_CODE_TLB_LOAD_I_MISS = 2 , EXCEPTION_CODE_TLB_STORE_MISS = 3 ,
  EXCEPTION_CODE_LOAD_I_ADDRESS_ERROR = 4 , EXCEPTION_CODE_STORE_ADDRESS_ERROR = 5 , EXCEPTION_CODE_I_BUS_ERROR = 6 , EXCEPTION_CODE_D_BUS_ERROR = 7 ,
  EXCEPTION_CODE_SYS_CALL = 8 , EXCEPTION_CODE_BREAKPOINT = 9 , EXCEPTION_CODE_RESERVED_INSTRUCTION = 10 , EXCEPTION_CODE_COPROCESSOR_UNUSABLE = 11 ,
  EXCEPTION_CODE_ARITHMETIC_OVERFLOW = 12 , EXCEPTION_CODE_TRAP = 13 , EXCEPTION_CODE_FLOATING_POINT = 15 , EXCEPTION_CODE_WATCH = 23
}
 Exception codes.
 

Detailed Description

Handle hardware-generated exceptions.

The exception handler traps exceptions generated by hardware. This could be an invalid instruction or invalid memory access exception or it could be a reset exception. In both cases, a handler registered with register_exception_handler will be passed information regarding the exception type and relevant registers.


Data Structure Documentation

◆ reg_block_t

struct reg_block_t

Structure representing a register block.

DO NOT modify the order unless editing inthandler.S

Data Fields
uint64_t gpr[32] General purpose registers 1-32.
uint64_t hi HI.
uint64_t lo LO.
uint32_t sr SR.
uint32_t cr CR (NOTE: can't modify this from an exception handler)
uint32_t epc represents EPC - COP0 register $14

The coprocessor 0 (system control coprocessor - COP0) register $14 is the return from exception program counter. For asynchronous exceptions it points to the place to continue execution whereas for synchronous (caused by code) exceptions, point to the instruction causing the fault condition, which needs correction in the exception handler. This member is for reading/writing its value.

uint32_t fc31 FC31.
uint64_t fpr[32] Floating point registers 1-32.

◆ exception_t

struct exception_t

Structure representing an exception.

Data Fields
int32_t type Exception type.
See also
EXCEPTION_TYPE_RESET, EXCEPTION_TYPE_CRITICAL
exception_code_t code Underlying exception code.
const char * info String information of exception.
reg_block_t * regs Registers at point of exception.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Exception types.

Enumerator
EXCEPTION_TYPE_UNKNOWN 

Unknown exception.

EXCEPTION_TYPE_RESET 

Reset exception.

EXCEPTION_TYPE_CRITICAL 

Critical exception.

EXCEPTION_TYPE_SYSCALL 

Syscall exception.