rtems_interrupt_catch()

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Jun 25 05:37:57 UTC 2020


On 25/06/2020 01:36, Chris Johns wrote:

> On 24/6/20 2:40 am, Sebastian Huber wrote:
>> Hello,
>>
>> I noticed that the rtems_interrupt_catch() directive is only declared 
>> and implemented if CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE:
>>
>> #if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE)
>>
>> typedef ISR_Handler_entry rtems_isr_entry;
>>
>> #else
>> /**
>>   *  @brief Interrupt handler type.
>>   *
>>   *  @see rtems_interrupt_catch()
>>   */
>> typedef rtems_isr ( *rtems_isr_entry )(
>>                   rtems_vector_number
>>               );
>>
>> /**
>>   * @brief RTEMS Interrupt Catch
>>   *
>>   * This directive installs @a new_isr_handler as the RTEMS interrupt 
>> service
>>   * routine for the interrupt vector with number @a vector. The 
>> previous RTEMS
>>   * interrupt service routine is returned in @a old_isr_handler.
>>   *
>>   * @param[in] new_isr_handler is the address of interrupt service 
>> routine
>>   * @param[in] vector is the interrupt vector number
>>   * @param[in] old_isr_handler address at which to store previous ISR 
>> address
>>   *
>>   * @retval RTEMS_SUCCESSFUL and *old_isr_handler filled with 
>> previous ISR
>>   *         address
>>   */
>> rtems_status_code rtems_interrupt_catch(
>>    rtems_isr_entry      new_isr_handler,
>>    rtems_vector_number  vector,
>>    rtems_isr_entry     *old_isr_handler
>> );
>> #endif
>>
>> This is not mentioned in the documentation:
>>
>> https://docs.rtems.org/branches/master/c-user/interrupt_manager.html#interrupt-catch-establish-an-isr 
>>
>>
>> Should we provide this function also if 
>> CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE and for example just return 
>> RTEMS_NOT_IMPLEMENTED?
>
> Which archs define CPU_SIMPLE_VECTORED_INTERRUPTS as false?
cpukit/score/cpu/arm/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS FALSE
cpukit/score/cpu/v850/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS FALSE
cpukit/score/cpu/x86_64/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS FALSE
cpukit/score/cpu/i386/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS FALSE
cpukit/score/cpu/powerpc/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS FALSE
cpukit/score/cpu/mips/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS FALSE

cpukit/score/cpu/m68k/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/bfin/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/sparc64/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/sh/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/lm32/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/nios2/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/sparc/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE
cpukit/score/cpu/moxie/include/rtems/score/cpu.h:#define 
CPU_SIMPLE_VECTORED_INTERRUPTS TRUE

It seem riscv is missing, so an implicit FALSE.

Instead of returning RTEMS_NOT_IMPLEMENTED we could also implement it 
like this for CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE:

#if CPU_SIMPLE_VECTORED_INTERRUPTS == TRUE
   typedef ISR_Handler_entry rtems_isr_entry;
#else
   typedef void ( *rtems_isr_entry )( void * );
   /* Now: typedef void rtems_isr_entry; */
#endif

rtems_status_code rtems_interrupt_catch(
   rtems_isr_entry      new_isr_handler,
   rtems_vector_number  vector,
   rtems_isr_entry     *old_isr_handler
)
{
   rtems_status_code sc;

   if ( old_isr_handler == NULL ) {
     return RTEMS_INVALID_ADDRESS;
   }

   sc = rtems_interrupt_handler_install(
     vector,
     "Catch",
     RTEMS_INTERRUPT_UNIQUE,
     new_isr_handler,
     NULL
   );

   if ( sc == RTEMS_SUCCESSFUL ) {
     *old_isr_handler = NULL;
   }

   return RTEMS_SUCCESSFUL;
}




More information about the devel mailing list