libdragon
Data Structures | Files | Enumerations | Functions | Variables
Exception Handler
Low Level Hardware Interfaces

Handle hardware-generated exceptions. More...

Data Structures

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

Files

file  exception.c
 

Exception Handler.


file  exception.h
 

Exception Handler.


Enumerations

enum  { EXCEPTION_TYPE_UNKNOWN = 0, EXCEPTION_TYPE_RESET, EXCEPTION_TYPE_CRITICAL }
 Exception types. More...

Functions

void register_exception_handler (void(*cb)(exception_t *))
 Register an exception handler to handle exceptions.
static const char * __get_exception_name (uint32_t etype)
 Fetch the string name of the exception.
static void __fetch_regs (exception_t *e, int32_t type)
 Fetch relevant registers.
void __onCriticalException ()
 Respond to a critical exception.
void __onResetException ()
 Respond to a reset exception.

Variables

static void(* __exception_handler )(exception_t *) = NULL
 Exception handler currently registered with exception system.
const unsigned char * __baseRegAddr
 Base register offset as defined by the interrupt controller.

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.


Enumeration Type Documentation

anonymous enum

Exception types.

Enumerator:
EXCEPTION_TYPE_UNKNOWN 

Unknown exception.

EXCEPTION_TYPE_RESET 

Reset exception.

EXCEPTION_TYPE_CRITICAL 

Critical exception.


Function Documentation

static void __fetch_regs ( exception_t e,
int32_t  type 
) [static]

Fetch relevant registers.

Parameters:
[out]ePointer to structure describing the exception
[in]typeException type. Either EXCEPTION_TYPE_CRITICAL or EXCEPTION_TYPE_RESET
static const char* __get_exception_name ( uint32_t  etype) [static]

Fetch the string name of the exception.

Todo:
Implement exceptionMap, then calculate the offset
Parameters:
[in]etypeException type
Returns:
String representation of the exception
void register_exception_handler ( void(*)(exception_t *)  cb)

Register an exception handler to handle exceptions.

Parameters:
[in]cbCallback function to call when exceptions happen
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines