eCosTM Reference Manual
Prev | Chapter 5. Native kernel C language API | Next

# Exception handling

Exception handlers can be installed to deal with various system-level exceptions, such as alignment errors, resets, timers and so forth. Exception handling is a configurable feature of eCos and is enabled by default.

The range of values for the `exception_number` parameter in the functions below is hardware-dependent, as are the individual exceptions. See `hal/ARCH/arch/v1_2_1/include/hal_intr` for the exception vector definitions specific to a given architecture.

The exception handler is a function of the following type:

    typedef void cyg_exception_handler_t(
     cyg_addrword_t data,
     cyg_code_t exception_number,
     cyg_addrword_t info
    );

cyg_exception_handler_t is the type used for functions which are called as a result of an exception. It is used in the function `cyg_exception_set_handler()`.

`void cyg_exception_set_handler`(cyg_code_t exception_number, cyg_exception_handler_t *new_handler, cyg_addrword_t new_data, cyg_exception_handler_t **old_handler, void **old_data);

Replace current exception handler. This may apply to either the thread, or to a global exception handler, according to how exception handling was configured (global or per-thread). The exception may be ignored, or used to specify a particular handler.

`void cyg_exception_call_handler`(cyg_handle_t thread, cyg_code_t exception_number, cyg_addrword_t exception_info);

Invoke exception handler for the given exception number. The exception handler will be invoked with `exception_info` as its third argument.

Prev | Home | Next
Priority manipulation | Up | Interrupt handling