Function pointer within isr

Jennifer Averett Jennifer.Averett at OARcorp.com
Mon Jun 30 18:41:34 UTC 2014


Is h_args on the stack or in global space when passed into  rtems_interrupt_handler_install?

--jennifer

> -----Original Message-----
> From: devel [mailto:devel-bounces at rtems.org] On Behalf Of Andre
> Marques
> Sent: Monday, June 30, 2014 1:09 PM
> To: Gedare Bloom; Wendell Silva
> Cc: devel at rtems.org
> Subject: Re: Function pointer within isr
> 
> On 06/30/14 18:07, Gedare Bloom wrote:
> > On Mon, Jun 30, 2014 at 12:52 PM, Wendell Silva <silvawp at gmail.com>
> wrote:
> >> André,
> >>
> >> Technically, you should be able to call functions (directly or
> >> indirectly) in any point of your program. AFAIK, there are only a
> >> subset of RTEMS directives you shouldn't call from an ISR.
> > If the function does not 'sleep' it should be ok. Some other issues
> > involve whether you try to access the executing task context, which
> > may not work right. The full set of safe RTEMS functions are:
> > http://rtems.org/onlinedocs/doc-current/share/rtems/html/c_user/Interr
> > upt-Manager-Directives-Allowed-from-an-ISR.html#Interrupt-Manager-
> Dire
> > ctives-Allowed-from-an-ISR
> >
> > In general, you should be able to call a function. Make sure the
> > function pointer is valid (points to a function you expect). If the
> > function is calling printf then you may definitely have a problem.
> >
> > -Gedare
> 
> I found the problem to be in the arguments received by the handler (which
> include the function pointer).
> 
> I am installing the handler using rtems_interrupt_handler_install, and I am
> passing two arguments to the handler (which receives void*) through a
> struct:
> 
> struct handler_arguments
> {
>    int pin_number;
> 
>    void (*handler) (void);
> } h_args;
> 
> I call rtems_interrupt_handler_install and send the handler arguments with
> &h_args. In the handler function I dereference the void pointer with:
> 
> void handler (void* arg)
> {
>    struct handler_arguments* h_args;
> 
>    h_args = (struct handler_arguments*) arg;
> 
> What happens is that if I call the handler function myself the function
> receives the arguments as they were sent, but if the handler is called by an
> interrupt then it does not receive what it was supposed to.
> 
>   I have looked at the rtems_interrupt_handler_install and could not
> understand why that happens.
> 
> >> What kind of error have you got? BSP?
> 
> No error, just hanged. I am using the Raspberry Pi BSP.
> 
> >> --Wendell.
> >>
> >>
> >>
> >> 2014-06-30 13:47 GMT-03:00 Andre Marques
> <andre.lousa.marques at gmail.com>:
> >>
> >>> Hello,
> >>>
> >>> I am trying to call a function through a function pointer from an
> >>> interrupt handler, but I am not sure if this is even possible as the
> >>> system hangs at that point. If not, is there any way in RTEMS to
> >>> have that function executed outside the isr?
> >>>
> >>> Thanks,
> >>> André Marques.
> >>>
> >>>
> >>> _______________________________________________
> >>> devel mailing list
> >>> devel at rtems.org
> >>> http://lists.rtems.org/mailman/listinfo/devel
> >>
> >>
> >> _______________________________________________
> >> devel mailing list
> >> devel at rtems.org
> >> http://lists.rtems.org/mailman/listinfo/devel
> 
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list