What should be the replacement for set_vector()?
Description: In this blog I will study and analyse potential replacements for set_vector().
Tags: rtems, interrupts, gsoc
Requirements and expectations
As I mentioned in the previous blogs about what set_vector() does under the hood, some of the ideas to be considered during finding replacements are as follows:
- The function should be able to look up the Interrupt Vector Table (IVT).
- The function should be able to modify values in the IVT.
These two are the necessary and important steps which the existing function carries out too. Some of the other useful features can be:
- The function should be able to assign a unique or a shared handler as an ISR based on requirements.
- The function should be uniformly implementable across the code-base.
- The function should be documented and should be compatible across all the architectures.
Based on these "criterias", I can see two potential candidates. One is rtems_interrupt_catch() and the other is rtems_interrupt_handler_install().
Candidate 1: rtems_interrupt_catch()
This function establishes an interrupt service routine (ISR) for a specified interrupt vector, i.e. it is able to lookup and modify the IVT.
Function prototype:
`c
rtems_status_code rtems_interrupt_catch(
rtems_isr_entry new_isr_handler,
rtems_vector_number vector,
rtems_isr_entry *old_isr_handler
);
`
Function definition: Link
This function takes a pointer to the old_isr_handler and replaces it with new_isr_handler associated with the said vector in the IVT. Since this function returns only the status code as it is suggested by the return type of the function as rtems_status_code, on further analysis I saw that the core functionality is carried out by _ISR_Install_vector(). Here is the link to its definition and implementation.
What i learned here is interesting, the hierarchy of nested functions here is brilliant!
rtems_interrupt_catch invokes _ISR_Install_vector which in turn invokes _CPU_ISR_Install_vector which is BSP specific. This hierarchy creates a higher level abstraction for using rtems_interrupt_catch() across different BSPs.
What th