Interrupt handling

Interrupt handling is by nature machine-specific. The eCos kernel aims to provide efficiency and flexibility in this area, while maintaining a very low interrupt latency. To allow the programmer direct access to hardware, the semantics and the interface can vary from one architecture to another.

The interrupt vectors for a given architecture are defined in hal/ARCH/arch/v1_2_1/include/hal_intr.h where also special semantics and caveats of the interrupt capabilities would be described.

typedef void cyg_VSR_t();
typedef cyg_uint32 cyg_ISR_t(cyg_vector_t vector,
 cyg_addrword_t data);
typedef void cyg_DSR_t(cyg_vector_t vector,
 cyg_ucount32 count,
 cyg_addrword_t data);

enum cyg_ISR_results
 CYG_ISR_HANDLED = 1, /* Interrupt was handled */
 CYG_ISR_CALL_DSR = 2 /* Schedule DSR */

void cyg_interrupt_create(cyg_vector_t vector, cyg_priority_t priority, cyg_addrword_t data, cyg_ISR_t *isr, cyg_DSR_t *dsr, cyg_handle_t *handle, cyg_interrupt *intr);

Creates an interrupt object and returns a handle to it. The object contains information about which interrupt vector to use and the ISR and DSR that will be called after the interrupt object is attached. The interrupt object will be allocated in the memory passed in the intr parameter. The interrupt object is not immediately attached; it must be attached with the cyg_interrupt_attach() call.

void cyg_interrupt_delete(cyg_handle_t interrupt);

Detaches the interrupt from the vector and frees the corresponding memory.

void cyg_interrupt_attach(cyg_handle_t interrupt);

Attaches interrupt.

void cyg_interrupt_detach(cyg_handle_t interrupt);

Detaches interrupt.

void cyg_interrupt_get_vsr(cyg_vector_t vector, cyg_VSR_t **vsr);

Returns a pointer to the VSR currently installed on vector.

void cyg_interrupt_set_vsr(cyg_vector_t vector, cyg_VSR_t *vsr);

Sets the current VSR on vector. A VSR directly attaches to the hardware interrupt vector and needs to be written in assembler.

void cyg_interrupt_disable(void);

Disables all interrupts.

void cyg_interrupt_enable(void);

Enables all interrupts.

void cyg_interrupt_mask(cyg_vector_t vector);

Programs the interrupt controller to stop delivery of interrupts on vector. On some architectures this will also disable all lower priority interrupts while on others they remain enabled.

void cyg_interrupt_unmask(cyg_vector_t vector);

Programs the interrupt controller to allow delivery of interrupts on the given interrupt vector.

void cyg_interrupt_acknowledge(cyg_vector_t vector);

Should be used from inside an ISR to acknowledge receipt of the interrupt. The interrupt must be acknowledged. If an interrupt is not acknowledged, the interrupt may trigger immediately after the ISR returns, causing the ISR to be called again in a loop.

void cyg_interrupt_configure(cyg_vector_t vector, cyg_bool_t level, cyg_bool_t up);

On some interrupt controllers the way an interrupt is detected may be configured. The level parameter chooses between level- or edge-triggered interrupts. The up parameter chooses between high and low level for level triggered interrupts or rising and falling edges for edge triggered interrupts.