Skip to contentSkip to conversation

Handling a interrupt from user space on PPC405

Xenomai-help Niklaus Giger 3 participants 7 messages Dec 13, 2006 – Dec 14, 2006

lore
Share & tools
lore
#0 lore raw

Hi

I tried to use the FIT (Fixed Interrupt Timer) on my PPC405GPr board, which uses 0x1010 as its interrupt vector in a user space (vxworks-skin) application.
<..>
RT_INTR FITnterrupt;
res = rt_intr_create(&FITnterrupt, 0, 0x1010, I_NOAUTOENA);
<..>
But I got -22 EINVAL as error.
Could somebody please tell me, what is wrong with my example.
I would like to have as little as possible code in the kernel and handling the whole interrupt in a RT (vxworks-skin) user space task.

And how do I have to handle the case, where my interrupt handler is only interested in one of external interrupts of the PPC405?

A good answer would enable me to publish afterwards a working example code.

Best regards.

Signature · 1 line
Niklaus Giger
#1 lore raw

Niklaus Giger kirjoitti:

Quoted 9 lines

Hi

I tried to use the FIT (Fixed Interrupt Timer) on my PPC405GPr board, which uses 0x1010 as its interrupt vector in a user space (vxworks-skin) application. <..>
RT_INTR FITnterrupt;
res = rt_intr_create(&FITnterrupt, 0, 0x1010, I_NOAUTOENA);
<..>
But I got -22 EINVAL as error.
Could somebody please tell me, what is wrong with my example.

The 0x1010 is the HW interrupt vector, but the argument should be the interrupt _line_. Besides, last time I checked, the ppc405 FIT isn't even 'wired' in the kernel; actually, there's no space for the interrupt prologue code, which basically results that no handler is called when the FIT interrupt occurs.

-- Heikki Lindholm

#2 lore raw
Quoted 11 lines · Heikki Lindholm

Niklaus Giger kirjoitti:

Quoted 9 lines

Hi

I tried to use the FIT (Fixed Interrupt Timer) on my PPC405GPr board, which uses 0x1010 as its interrupt vector in a user space (vxworks-skin) application. <..>
RT_INTR FITnterrupt;
res = rt_intr_create(&FITnterrupt, 0, 0x1010, I_NOAUTOENA);
<..>
But I got -22 EINVAL as error.
Could somebody please tell me, what is wrong with my example.

Quoted 1 line

The 0x1010 is the HW interrupt vector, but the argument should be the interrupt _line_. Besides, last time I checked, the ppc405 FIT isn't even 'wired' in the kernel; actually, there's no space for the interrupt prologue code, which basically results that no handler is called when the FIT interrupt occurs.

Yes, in head_4xx.c there is the following note:

/* NOTE:
* FIT and WDT handlers are not implemented yet. */

But the relevant code could be copied from the PIT interrupt.

  /* 0x1000 - Programmable Interval Timer (PIT) Exception */
        START_EXCEPTION(0x1000, Decrementer)
        NORMAL_EXCEPTION_PROLOG
        lis     r0,TSR_PIS@h
        mtspr   SPRN_TSR,r0             /* Clear the PIT exception */
        addi    r3,r1,STACK_FRAME_OVERHEAD
  #ifdef CONFIG_IPIPE
        EXC_XFER_IPIPE(0x1000, __ipipe_grab_timer)
  #else /* !CONFIG_IPIPE */
        EXC_XFER_LITE(0x1000, timer_interrupt)
  #endif /* CONFIG_IPIPE */

and modified accordingly.

Wolfgang.

Wolfgang.

#3 lore raw

Wolfgang Grandegger kirjoitti:

Quoted 38 lines
Quoted 13 lines · Heikki Lindholm

Niklaus Giger kirjoitti:

Quoted 9 lines

Hi

I tried to use the FIT (Fixed Interrupt Timer) on my PPC405GPr board, which uses 0x1010 as its interrupt vector in a user space (vxworks-skin) application. <..>
RT_INTR FITnterrupt;
res = rt_intr_create(&FITnterrupt, 0, 0x1010, I_NOAUTOENA);
<..>
But I got -22 EINVAL as error.
Could somebody please tell me, what is wrong with my example.

Quoted 1 line

The 0x1010 is the HW interrupt vector, but the argument should be the interrupt _line_. Besides, last time I checked, the ppc405 FIT isn't even 'wired' in the kernel; actually, there's no space for the interrupt prologue code, which basically results that no handler is called when the FIT interrupt occurs.

Yes, in head_4xx.c there is the following note:

/* NOTE:
* FIT and WDT handlers are not implemented yet. */

But the relevant code could be copied from the PIT interrupt.

  /* 0x1000 - Programmable Interval Timer (PIT) Exception */
        START_EXCEPTION(0x1000, Decrementer)
        NORMAL_EXCEPTION_PROLOG
        lis     r0,TSR_PIS@h
        mtspr   SPRN_TSR,r0             /* Clear the PIT exception */
        addi    r3,r1,STACK_FRAME_OVERHEAD
  #ifdef CONFIG_IPIPE
        EXC_XFER_IPIPE(0x1000, __ipipe_grab_timer)
  #else /* !CONFIG_IPIPE */
        EXC_XFER_LITE(0x1000, timer_interrupt)
  #endif /* CONFIG_IPIPE */
Quoted 1 line

and modified accordingly.

But one should note that the decrementer vector is at 0x1000 and the FIT vector at 0x1010. The decrementer exception prologue is obviously bigger than 0x10 (16) bytes and thus needs to be moved elsewhere (and branched to from the decr vector.) It might be feasible to unite the handlers, though, by passing some variable to the C-language handler, telling which happened.

-- Heikki Lindholm

#4 lore raw
Quoted 39 lines · Heikki Lindholm

Wolfgang Grandegger kirjoitti:

Quoted 38 lines
Quoted 13 lines · Heikki Lindholm

Niklaus Giger kirjoitti:

Quoted 9 lines

Hi

I tried to use the FIT (Fixed Interrupt Timer) on my PPC405GPr board, which uses 0x1010 as its interrupt vector in a user space (vxworks-skin) application. <..>
RT_INTR FITnterrupt;
res = rt_intr_create(&FITnterrupt, 0, 0x1010, I_NOAUTOENA);
<..>
But I got -22 EINVAL as error.
Could somebody please tell me, what is wrong with my example.

Quoted 1 line

The 0x1010 is the HW interrupt vector, but the argument should be the interrupt _line_. Besides, last time I checked, the ppc405 FIT isn't even 'wired' in the kernel; actually, there's no space for the interrupt prologue code, which basically results that no handler is called when the FIT interrupt occurs.

Yes, in head_4xx.c there is the following note:

/* NOTE:
* FIT and WDT handlers are not implemented yet. */

But the relevant code could be copied from the PIT interrupt.

  /* 0x1000 - Programmable Interval Timer (PIT) Exception */
        START_EXCEPTION(0x1000, Decrementer)
        NORMAL_EXCEPTION_PROLOG
        lis     r0,TSR_PIS@h
        mtspr   SPRN_TSR,r0             /* Clear the PIT exception */
        addi    r3,r1,STACK_FRAME_OVERHEAD
  #ifdef CONFIG_IPIPE
        EXC_XFER_IPIPE(0x1000, __ipipe_grab_timer)
  #else /* !CONFIG_IPIPE */
        EXC_XFER_LITE(0x1000, timer_interrupt)
  #endif /* CONFIG_IPIPE */
Quoted 3 lines
Quoted 1 line

and modified accordingly.

But one should note that the decrementer vector is at 0x1000 and the FIT vector at 0x1010. The decrementer exception prologue is obviously bigger than 0x10 (16) bytes and thus needs to be moved elsewhere (and branched to from the decr vector.) It might be feasible to unite the handlers, though, by passing some variable to the C-language handler, telling which happened.

The above code snippet has to be modified for the FIT exception, of course, which calls _ipipe_grap_fit(). Here is what is basically needed:

  __ipipe_init_platform()
    calls fit_virq = ipipe_alloc_virq();

  __ipipe_grap_fit(regs)
    calls __ipipe_handle_irq(IPIPE_FIT_VIRQ, regs);

And the FIT timer has to be programed properly elsewhere.

Wolfgang.

#5 lore raw
In reply to Heikki Lindholm

Am Donnerstag, 14. Dezember 2006 08:05 schrieb Heikki Lindholm:

Quoted 13 lines

Niklaus Giger kirjoitti:

Quoted 11 lines

Hi

I tried to use the FIT (Fixed Interrupt Timer) on my PPC405GPr board, which uses 0x1010 as its interrupt vector in a user space (vxworks-skin) application.
<..>
RT_INTR FITnterrupt;
res = rt_intr_create(&FITnterrupt, 0, 0x1010, I_NOAUTOENA);
<..>
But I got -22 EINVAL as error.
Could somebody please tell me, what is wrong with my example.

Quoted 6 lines

The 0x1010 is the HW interrupt vector, but the argument should be the interrupt _line_. Besides, last time I checked, the ppc405 FIT isn't even 'wired' in the kernel; actually, there's no space for the interrupt prologue code, which basically results that no handler is called when the FIT interrupt occurs.

Thanks a lot for your tip.
I did now test using IPIPE_TRAP_UNKNOWN, where my main test routine looks like this.

Quoted 19 lines

int res, j;
RT_INTR FITnterrupt;
printf("\n%s:", __FUNCTION__);
// res = rt_intr_create(&FITnterrupt, "sysAuxClk", 0x1010, I_NOAUTOENA); // returns -22 EINVAL
res = rt_intr_create(&FITnterrupt, 0, IPIPE_TRAP_UNKNOWN, I_NOAUTOENA); perror("rt_intr_create returned " );
printf("%s: rt_intr_create return %d errno %s\n", __FUNCTION__, res,
strerror(res)); if (res != 0) exit(1);

res = rt_intr_enable(&FITnterrupt);
printf("%s: rt_intr_enable return %d errno %s\n", __FUNCTION__, res,
strerror(res));

for (j=0; j < 3; j++)

  {
    /* Timeout is one second in timer jiffies, as with vxworks we have the
periodic time */ res = rt_intr_wait(&FITnterrupt, sysClkRateGet());
    printf("%s: rt_intr_wait return %d errno %s\n", __FUNCTION__, res,
Quoted 8 lines

strerror(res)); }
res = rt_intr_disable(&FITnterrupt);
printf("%s: rt_intr_disable return %d errno %s\n", __FUNCTION__, res,
strerror(res));

res = rt_intr_delete(&FITnterrupt);
printf("%s: rt_intr_delete return %d errno %s\n", __FUNCTION__, res,
strerror(res)); exit(0);

My output at the target now looks like.

Quoted 6 lines

__xeno_user_init: rt_intr_enable return 0 errno Success __xeno_user_init: rt_intr_wait return -110 errno Unknown error 4294967186 __xeno_user_init: rt_intr_wait return -110 errno Unknown error 4294967186 __xeno_user_init: rt_intr_wait return -110 errno Unknown error 4294967186 __xeno_user_init: rt_intr_disable return 0 errno Success __xeno_user_init: rt_intr_delete return 0 errno Success

This is what I expect, as this interrupt should not occur. IPIPE_TRAP_UNKNOWN however cannot be found in any *.h exported
to /usr/xenomai/include. I found it in include/asm-ppc/ipipe.h in the patched Linux kernel.
So I suppose, that some how Xenomai should export this definition to user space, too.

Dealing with FIT and other interrupts will take some more time. But I would like to thank you and Wolfgang for your help, as your answers helped me a lot to see the problem.

Best regards

Signature · 1 line
Niklaus Giger
#6 lore raw
In reply to Niklaus Giger
Quoted 9 lines · Niklaus Giger

Hi

I tried to use the FIT (Fixed Interrupt Timer) on my PPC405GPr board, which uses 0x1010 as its interrupt vector in a user space (vxworks-skin) application. <..>
RT_INTR FITnterrupt;
res = rt_intr_create(&FITnterrupt, 0, 0x1010, I_NOAUTOENA);
<..>
But I got -22 EINVAL as error.
Could somebody please tell me, what is wrong with my example.

The FIT exception is not an external interrupt and cannot be used with the the above function. And 0x1010 is not a valid IRQ number anyhow (it's actually the jump address of the FIT exception).

Quoted 5 lines

I would like to have as little as possible code in the kernel and handling the whole interrupt in a RT (vxworks-skin) user space task.

And how do I have to handle the case, where my interrupt handler is only interested in one of external interrupts of the PPC405?

A good answer would enable me to publish afterwards a working example code.

The right thing to do is to handle the expection as VIRQ like the decrementer (or the PIT on the AMCC 405). Unfortunately, this requires various modifications to the ADEOS-IPIPE patch, but it's feasible, of course. Search for CONFIG_IPIPE in head_4xx.c,

Wolfgang.