Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - MsgSendPulse to wake up an Interrupt Handler: (5 Items)
   
MsgSendPulse to wake up an Interrupt Handler  
Hi,

I've written two device drivers which have currently interrupt service routines which return an event upon determining 
that an interrupt of interest has occured.

I've used InterruptAttach to define my interrupt service routine and have associated a pulse with an event handler, to 
allow the calling of the event handler when the interrupt service routine returns an event, i.e.

const struct sigevent *mailboxISR(void *pArea, int id)
{
    mailboxDev_t   *mbxDev = pArea;

    if(SomeInterrupt)
        return &mbxDev->event;
    else
        return NULL;
}

int mailboxEventHandler(message_context_t *pMsgCtp, int code, unsigned flags, void *pHandle)
{
    /* Do the work for the interrupt */
}

const struct sigevent *frameISR(void *pArea, int id)
{
    frameDev_t   *frameDev = pArea;

    if(SomeInterrupt)
        return &frameDev->event;
    else
        return NULL;
}

int frameEventHandler(message_context_t *pMsgCtp, int code, unsigned flags, void *pHandle)
{
    /* Do the work for the interrupt */
}


Both drivers have their own ISR and EventHandlers, but now I have to write a single ISR for both drivers, as there is 
only one interrupt source for both drivers.
For this I have written a new driver which simply contains the ISR and an EventHandler.

My idea was that the new EventHandler would wake up the frameEventHandler or mailboxEventHandler upon detecting an 
interrupt for those two devices.

But my question is, how can I send an pulse to wake-up the frameEventHandler or mailboxEventHandler from my new 
interrupt driver EventHandler?

I thought I may be able to use MsgSendPulse with the appropriate coid and code for frameEventHandler/mailboxEventHandler
, but I can't get this to work.

I'm trying to minimise the amount of changes I need to do to my two existing drivers.

Any help would be greatly appriciated.

Cheers, Mark.
RE: MsgSendPulse to wake up an Interrupt Handler  

> -----Original Message-----
> From: Mark Pearson [mailto:community-noreply@qnx.com]
> Sent: Monday, August 10, 2009 9:44 AM
> To: ostech-core_os
> Subject: MsgSendPulse to wake up an Interrupt Handler
> 
> Hi,
> 
> I've written two device drivers which have currently interrupt service
> routines which return an event upon determining that an interrupt of
> interest has occured.
> 
> I've used InterruptAttach to define my interrupt service routine and
> have associated a pulse with an event handler, to allow the calling of
> the event handler when the interrupt service routine returns an event,
> i.e.
> 
> const struct sigevent *mailboxISR(void *pArea, int id)
> {
>     mailboxDev_t   *mbxDev = pArea;
> 
>     if(SomeInterrupt)
>         return &mbxDev->event;
>     else
>         return NULL;
> }
> 
> int mailboxEventHandler(message_context_t *pMsgCtp, int code, unsigned
> flags, void *pHandle)
> {
>     /* Do the work for the interrupt */
> }
> 
> const struct sigevent *frameISR(void *pArea, int id)
> {
>     frameDev_t   *frameDev = pArea;
> 
>     if(SomeInterrupt)
>         return &frameDev->event;
>     else
>         return NULL;
> }
> 
> int frameEventHandler(message_context_t *pMsgCtp, int code, unsigned
> flags, void *pHandle)
> {
>     /* Do the work for the interrupt */
> }
> 
> 
> Both drivers have their own ISR and EventHandlers, but now I have to
> write a single ISR for both drivers, as there is only one interrupt
> source for both drivers.

I assume you mean each driver handle two different hardware that shares the same interrupt?  That's not an issue as long
 as each ISR check if the interrupt comes from the corresponding hardware.

If that is not the case.  You can use the _NTO_INTR_FLAGS_END to control the order into which the ISR is called.  Hence 
making sure which ISR gets called first if that is important to your design. 

 > For this I have written a new driver which simply contains the ISR and
> an EventHandler.
> 
> My idea was that the new EventHandler would wake up the
> frameEventHandler or mailboxEventHandler upon detecting an interrupt
> for those two devices.
> 
> But my question is, how can I send an pulse to wake-up the
> frameEventHandler or mailboxEventHandler from my new interrupt driver
> EventHandler?
> 
> I thought I may be able to use MsgSendPulse with the appropriate coid
> and code for frameEventHandler/mailboxEventHandler, but I can't get
> this to work.
> 
> I'm trying to minimise the amount of changes I need to do to my two
> existing drivers.
> 
> Any help would be greatly appriciated.
> 
> Cheers, Mark.
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post35552
> 
Re: RE: MsgSendPulse to wake up an Interrupt Handler  
> 
> I assume you mean each driver handle two different hardware that shares the 
> same interrupt?  That's not an issue as long as each ISR check if the 
> interrupt comes from the corresponding hardware.
> 
> If that is not the case.  You can use the _NTO_INTR_FLAGS_END to control the 
> order into which the ISR is called.  Hence making sure which ISR gets called 
> first if that is important to your design. 
> 
Thanks for the quick reply.

Yes, the drivers handle two different hardware devices sharing a single interrupt.

So I can still use InterruptAttach and both ISRs will be called sequentially, with _NTO_INTR_FLAGS_END controlling the 
order of the ISR calls? That would be perfect :-)

Many thanks, Mark.
RE: RE: MsgSendPulse to wake up an Interrupt Handler  

> -----Original Message-----
> From: Mark Pearson [mailto:community-noreply@qnx.com]
> Sent: Monday, August 10, 2009 9:59 AM
> To: ostech-core_os
> Subject: Re: RE: MsgSendPulse to wake up an Interrupt Handler
> 
> 
> >
> > I assume you mean each driver handle two different hardware that
> shares the
> > same interrupt?  That's not an issue as long as each ISR check if the
> > interrupt comes from the corresponding hardware.
> >
> > If that is not the case.  You can use the _NTO_INTR_FLAGS_END to
> control the
> > order into which the ISR is called.  Hence making sure which ISR gets
> called
> > first if that is important to your design.
> >
> Thanks for the quick reply.
> 
> Yes, the drivers handle two different hardware devices sharing a single
> interrupt.
> 
> So I can still use InterruptAttach and both ISRs will be called
> sequentially, with _NTO_INTR_FLAGS_END controlling the order of the ISR
> calls? 

Yes.  Check the documentation on InterruptAttach, it's all explained there.

> 
> Many thanks, Mark.
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post35562
> 
Re: RE: RE: MsgSendPulse to wake up an Interrupt Handler  
I think another way to do this is to write a cascaded interrupt callout to return 2 new vectors, and you driver will 
attach to each vectors. This should have less overhead.