rtems_interrupt_catch()

Joel Sherrill joel at rtems.org
Thu Jun 25 12:26:27 UTC 2020


On Thu, Jun 25, 2020, 12:38 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> 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;
> }
>

I would prefer this and honestly thought we already had this. Maybe it was
the other direction. PIC interrupt management on top of simple vectored.

Without this, the only acceptable option IMO is compile time failure. This
is comparable to the SMP cases where we wanted someone to fix code. Either
we make it work for them or we let them know at compile time their driver
needs work.

--joel



>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200625/5d77dc0d/attachment.html>


More information about the devel mailing list