Vsr support, Valid contexts – Comtrol eCos User Manual

Page 91

Advertising
background image

Interrupt Handling

VSR Support

When an interrupt occurs the hardware will transfer control to a piece of code known as the VSR, or Vector Service
Routine. By default this code is provided by eCos. Usually it is written in assembler, but on some architectures it
may be possible to implement VSRs in C by specifying an interrupt attribute. Compiler documentation should be
consulted for more information on this. The default eCos VSR will work out which ISR function should process
the interrupt, and set up a C environment suitable for this ISR.

For some applications it may be desirable to replace the default eCos VSR and handle some interrupts directly. This
minimizes interrupt latency, but it requires application developers to program at a lower level. Usually the best way
to write a custom VSR is to copy the existing one supplied by eCos and then make appropriate modifications.
The function

cyg_interrupt_get_vsr

can be used to get hold of the current VSR for a given interrupt vector,

allowing it to be restored if the custom VSR is no longer required.

cyg_interrupt_set_vsr

can be used to install

a replacement VSR. Usually the

vsr

argument will correspond to an exported label in an assembler source file.

Valid contexts

In a typical configuration interrupt handlers are created and attached during system initialization, and never
detached or deleted. However it is possible to perform these operations at thread level, if desired. Similarly

cyg_interrupt_configure

,

cyg_interrupt_set_vsr

, and

cyg_interrupt_set_cpu

are usually called

only during system initialization, but on typical hardware may be called at any time.

cyg_interrupt_get_vsr

and

cyg_interrupt_get_cpu

may be called at any time.

The functions for enabling, disabling, masking and unmasking interrupts can be called in any context, when appro-
priate. It is the responsibility of application developers to determine when the use of these functions is appropriate.

91

Advertising