All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Ext. Interrupt with POSIX skin from user - space
@ 2011-01-17 18:10 Joerg Mohre
  2011-01-17 18:28 ` Gilles Chanteperdrix
  2011-01-17 18:35 ` Philippe Gerum
  0 siblings, 2 replies; 3+ messages in thread
From: Joerg Mohre @ 2011-01-17 18:10 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 3255 bytes --]

Hi all,

i am using a MPC52000 and try to handle external interrupts (IRQ1) with 
linux kernel 2.6.32 and Xenomai 2.5.5.2.
I use the POSIX skin functions to setup interrupt and wait for interrupt 
in user-space.

First for testing, i wrote a kernel module to setup and handle the 
interrupts.
This worked well.

Now it tried to do the same from user-space with the posix functions.
But unfortunately this wasn't successful.

I have to load the kernel module before i use my user-space application 
(see code).
Otherwise pthread_intr_control_np will fail with error -1 and errono = -19.


static int mpc5200_intr_setup(void)
{
     int                     iret = 0;
         int                                        err = 0;
     pthread_attr_t          ThreadAttribute;
         struct sched_param        sched_param;
         unsigned char                 byPriority;

         unsigned int                i = 0;

         byPriority = 90;
         sched_param.sched_priority = byPriority;
         memset (&sched_param, 0, sizeof (sched_param));

     if ( (pRegsIntCtrl = (int_ctrl_regs*)ioremap( MBAR_VALUE + 
MBAR_INT_CTRL, REMAP_SIZE )) == NULL) {
                 printf("ioremap failed for MBAR_INT_CTRL\n");
         return -1;
         }

     //pRegsIntCtrl->irqctl =  0x00201401; //bit 10,21 => 1: IRQ1 rising 
edge active; enable IRQ1
     pRegsIntCtrl->irqctl =  0x00201001; //bit 10 => 1: IRQ1 rising edge 
active; disbable IRQ1

         if (pthread_intr_attach_np (&irq_object, 65, 0)) {
         printf("Interrupt source not found!\n");
         return -1;
     }
         else {
                 printf("Interrupt source found!\n");
         }

         printf("pregs->irqctl = %08X\n",pRegsIntCtrl->irqctl);

         sleep(5);

         printf("%i\n", i+=1);
     pthread_attr_init( &ThreadAttribute);
         printf("%i\n", i+=1);
     if (pthread_attr_setstacksize(&ThreadAttribute,0x80000)) {
                 printf("Failed to set stack size\n");
                 return -1;
         }
         printf("%i\n", i+=1);
            if (pthread_create( &Thread, &ThreadAttribute, 
cyclic_interrupt_receiver, NULL)) {
                 printf("Failed to create thread\n");
                 return -1;
         }
         printf("%i\n", i+=1);
         if (pthread_setschedparam (Thread,SCHED_FIFO,&sched_param)) {
                 printf("Failed to set scheduling parameter\n");
                 return -1;
         }
         printf("%i\n", i+=1);
         iret = pthread_intr_control_np (irq_object, PTHREAD_IENABLE);
         if (iret)
         {
                 err = errno;
                 printf("Failed to enable interrupt (%i, errno = %i)\n", 
iret, err);
                 return -1;
         }

         printf("%i\n", i+=1);
     return iret;
}

If i enable IRQ1 with
//pRegsIntCtrl->irqctl =  0x00201401; //bit 10,21 => 1: IRQ1 rising edge 
active; enable IRQ1
the CPU seams to be blocked.

I searched the internet but i couldn't find any help for handling 
external interrupts with posix skin in user-space.

Is it necessary to request an irq with native functions from kernel module?

I would expect that all (request, enable setup type ....) is done by the 
posix functions.

Does any one have some ideas?

Thanks




[-- Attachment #2: Type: text/html, Size: 10771 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-17 18:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-17 18:10 [Xenomai-help] Ext. Interrupt with POSIX skin from user - space Joerg Mohre
2011-01-17 18:28 ` Gilles Chanteperdrix
2011-01-17 18:35 ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.