Shared interrupts (base, /proc support, edge-triggered stuff)
Hi there,
as I promised, here go the following patches (ordered as they have to be applied one by one) :
1) shirq-base.patch
Adds the "name" field to the interrupt object of the nucleus layer. Reworks the related bits of the native skin (+ a few minor changes for posix and rtdm) to support the named interrupt objects.
2) shirq-v7.patch
Generic support for shared interrupts.
3) shirq-proc.patch
/proc support.
Now /proc/xenomai/irq shows the names of handlers.
The related code have been removed from the hal layer to nucleus.
-----
4) shirq-isa.patch
Trying to handle the edge-triggered stuff.
This is a very preliminary version so the only thing I promise so far is that it compiles successfully.
The functionality added by first 3 patches seem to be working.
--
Best regards,
Dmitry Adamushko
include/native/intr.h +3 -3
@@ -71,8 +71,6 @@ typedef struct rt_intr {rt_handle_t handle;/* !< Handle in registry -- zero if unregistered. */ -char name[XNOBJECT_NAME_LEN ];/* !< Symbolic name. */ -#if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE )int mode;/* !< Interrupt control mode. */
@@ -101,6 +99,7 @@ int __native_intr_pkg_init(void);void __native_intr_pkg_cleanup (void );int rt_intr_create (RT_INTR *intr, +const char *name,unsigned irq,rt_isr_t isr,rt_iack_t iack);
@@ -122,7 +121,7 @@ extern "C" {#endif int rt_intr_bind (RT_INTR *intr, -unsigned irq, +const char *name,RTIME timeout);static inline int rt_intr_unbind (RT_INTR *intr)
@@ -133,6 +132,7 @@ static inline int rt_intr_unbind (RT_INT }int rt_intr_create (RT_INTR *intr, +const char *name,unsigned irq,int mode);
include/nucleus/intr.h +3 -0
@@ -42,6 +42,8 @@ typedef struct xnintr {void *cookie;/* !< User-defined cookie value. */ +char name[XNOBJECT_NAME_LEN ];/* !< Symbolic name. */ + } xnintr_t;extern xnintr_t nkclock;
@@ -55,6 +57,7 @@ void xnintr_clock_handler(void);/* Public interface. */ int xnintr_init(xnintr_t *intr, + const char *name, unsigned irq, xnisr_t isr, xniack_t iack,
include/rtdm/rtdm_driver.h +1 -1
@@ -743,7 +743,7 @@ static inline int rtdm_irq_request(rtdm_const char *device_name, void *arg) { -xnintr_init (irq_handle ,irq_no ,handler ,NULL ,flags ); +xnintr_init (irq_handle ,device_name ,irq_no ,handler ,NULL ,flags );return xnintr_attach (irq_handle, arg); }
ksrc/nucleus/intr.c +6 -1
@@ -42,7 +42,7 @@ static void xnintr_irq_handler(unsigned void *cookie);/*! -* \fn int xnintr_init (xnintr_t *intr,unsigned irq,xnisr_t isr,xniack_t iack,xnflags_t flags) +* \fn int xnintr_init (xnintr_t *intr,const char *name,unsigned irq,xnisr_t isr,xniack_t iack,xnflags_t flags) * \brief Initialize an interrupt object. * * Associates an interrupt object with an IRQ line.
@@ -82,6 +82,9 @@ static void xnintr_irq_handler(unsigned* descriptor must always be valid while the object is active * therefore it must be allocated in permanent memory. * +* @param name An ASCII string standing for the symbolic name of the +* interrupt object. +* * @param irq The hardware interrupt channel associated with the * interrupt object. This value is architecture-dependent. An * interrupt object must then be attached to the hardware interrupt
@@ -120,6 +123,7 @@ static void xnintr_irq_handler(unsigned*/ int xnintr_init (xnintr_t *intr, + const char *name, unsigned irq, xnisr_t isr, xniack_t iack,
@@ -130,6 +134,7 @@ int xnintr_init (xnintr_t *intr, intr->iack = iack; intr->cookie =NULL ; intr->hits =0 ; +xnobject_copy_name (intr->name,name);return 0 ; }
ksrc/nucleus/pod.c +1 -1
@@ -3042,7 +3042,7 @@ unlock_and_exit:attached directly by the arch-dependent layer (xnarch_start_timer). */ -xnintr_init (&nkclock,0 ,tickhandler,NULL ,0 ); +xnintr_init (&nkclock,NULL ,0 ,tickhandler,NULL ,0 );__setbits (nkpod->status,XNTIMED );
ksrc/skins/native/intr.c +10 -5
@@ -119,7 +119,7 @@ static RT_OBJECT_PROCNODE __intr_pnode =#endif /* CONFIG_XENO_NATIVE_EXPORT_REGISTRY */ /*! -* \fn int rt_intr_create (RT_INTR *intr,unsigned irq,rt_isr_t isr,rt_iack_t iack) +* \fn int rt_intr_create (RT_INTR *intr,const char *name,unsigned irq,rt_isr_t isr,rt_iack_t iack) * \brief Create an interrupt object from kernel space. * * Initializes and associates an interrupt object with an IRQ line. In
@@ -155,6 +155,11 @@ static RT_OBJECT_PROCNODE __intr_pnode =* be valid while the object is active therefore it must be allocated * in permanent memory. * +* @param name An ASCII string standing for the symbolic name of the +* interrupt object. When non-NULL and non-empty, this string is copied +* to a safe place into the descriptor, and passed to the registry package +* if enabled for indexing the created interrupt objects. +* * @param irq The hardware interrupt channel associated with the * interrupt object. This value is architecture-dependent. *
@@ -205,6 +210,7 @@ static RT_OBJECT_PROCNODE __intr_pnode =*/ int rt_intr_create (RT_INTR *intr, +const char *name,unsigned irq,rt_isr_t isr,rt_iack_t iack)
@@ -215,7 +221,7 @@ int rt_intr_create (RT_INTR *intr,if (xnpod_asynch_p ())return -EPERM ; -xnintr_init (&intr->intr_base,irq,isr,iack,0 ); +xnintr_init (&intr->intr_base,name,irq,isr,iack,0 );#if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE )xnsynch_init (&intr->synch_base,XNSYNCH_PRIO ); intr->pending =0 ;
@@ -228,7 +234,6 @@ int rt_intr_create (RT_INTR *intr,xnlock_get_irqsave (&nklock,s);appendq (&__xeno_intr_q,&intr->link);xnlock_put_irqrestore (&nklock,s); -snprintf (intr->name,sizeof (intr->name),"irq%u" ,irq); err =xnintr_attach (&intr->intr_base,intr);
@@ -238,7 +243,7 @@ int rt_intr_create (RT_INTR *intr,half-baked objects... */ if (!err) - err =rt_registry_enter (intr->name,intr,&intr->handle,&__intr_pnode); + err =rt_registry_enter (intr->intr_base.name,intr,&intr->handle,&__intr_pnode);#endif /* CONFIG_XENO_OPT_NATIVE_REGISTRY */ if (err)
@@ -492,7 +497,7 @@ int rt_intr_inquire (RT_INTR *intr, goto unlock_and_exit; } -strcpy (info->name,intr->name); +strcpy (info->name,intr->intr_base.name); info->hits = intr->intr_base.hits; info->irq = intr->intr_base.irq;
ksrc/skins/native/syscall.c +16 -3
@@ -2894,6 +2894,7 @@ EXPORT_SYMBOL(rt_intr_handler);/* * int __rt_intr_create(RT_INTR_PLACEHOLDER *ph, +* const char *name, * unsigned irq, * int mode) */
@@ -2901,6 +2902,7 @@ EXPORT_SYMBOL(rt_intr_handler);static int __rt_intr_create (struct task_struct *curr,struct pt_regs *regs) { +char name[XNOBJECT_NAME_LEN ];RT_INTR_PLACEHOLDER ph;int err, mode;RT_INTR *intr;
@@ -2909,11 +2911,22 @@ static int __rt_intr_create (struct taskif (!__xn_access_ok (curr,VERIFY_WRITE ,__xn_reg_arg1 (regs),sizeof (ph)))return -EFAULT ; +if (__xn_reg_arg2 (regs)) + { +if (!__xn_access_ok (curr,VERIFY_READ ,__xn_reg_arg2 (regs),sizeof (name))) +return -EFAULT ; + +__xn_strncpy_from_user (curr,name,(const char __user *)__xn_reg_arg2 (regs),sizeof (name) -1 ); + name[sizeof (name) -1 ] ='\0' ; + } +else + *name ='\0' ; +/* Interrupt line number. */ - irq = (unsigned )__xn_reg_arg2 (regs); + irq = (unsigned )__xn_reg_arg3 (regs);/* Interrupt control mode. */ - mode = (int )__xn_reg_arg3 (regs); + mode = (int )__xn_reg_arg4 (regs);if (mode & ~(I_AUTOENA |I_PROPAGATE ))return -EINVAL ;
@@ -2923,7 +2936,7 @@ static int __rt_intr_create (struct taskif (!intr)return -ENOMEM ; - err =rt_intr_create (intr,irq,&rt_intr_handler,NULL ); + err =rt_intr_create (intr,name,irq,&rt_intr_handler,NULL );if (err ==0 ) {
ksrc/skins/posix/intr.c +1 -1
@@ -27,7 +27,7 @@ int pse51_intr_attach (struct pse51_inteint err;spl_t s; -xnintr_init (&intr->intr_base,irq,isr,iack,0 ); +xnintr_init (&intr->intr_base,NULL ,irq,isr,iack,0 );#if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE )xnsynch_init (&intr->synch_base,XNSYNCH_PRIO );
src/skins/native/intr.c +4 -6
@@ -24,24 +24,22 @@extern int __native_muxid;int rt_intr_create (RT_INTR *intr, +const char *name,unsigned irq,int mode) { -return XENOMAI_SKINCALL3 (__native_muxid, +return XENOMAI_SKINCALL4 (__native_muxid, __native_intr_create, intr, + name, irq, mode); }int rt_intr_bind (RT_INTR *intr, -unsigned irq, +const char *name,RTIME timeout) { -char name[XNOBJECT_NAME_LEN ]; - -snprintf (name,sizeof (name),"irq%u" ,irq); - return XENOMAI_SKINCALL3(__native_muxid, __native_intr_bind, intr,
include/asm-generic/hal.h +1 -0
@@ -62,6 +62,7 @@#define RTHAL_NR_CPUS IPIPE_NR_CPUS#define RTHAL_ROOT_PRIO IPIPE_ROOT_PRIO#define RTHAL_NR_FAULTS IPIPE_NR_FAULTS +#define RTHAL_NR_IRQS IPIPE_NR_IRQS#define RTHAL_SERVICE_IPI0 IPIPE_SERVICE_IPI0#define RTHAL_SERVICE_VECTOR0 IPIPE_SERVICE_VECTOR0
include/asm-generic/system.h +12 -0
@@ -101,6 +101,8 @@ typedef struct { volatile unsigned long#define XNARCH_NR_CPUS RTHAL_NR_CPUS +#define XNARCH_TIMER_IRQ RTHAL_TIMER_IRQ +#define XNARCH_ROOT_STACKSZ 0/* Only a placeholder -- no stack */ #define XNARCH_PROMPT "Xenomai: "
@@ -470,6 +472,16 @@ static inline unsigned long long xnarch_#ifdef XENO_INTR_MODULE +#define XNARCH_NR_IRQS RTHAL_NR_IRQS + +static inline unsigned long xnarch_critical_enter (void (*synch)(void )) { +return rthal_critical_enter (synch); +} + +static inline void xnarch_critical_exit (unsigned long flags) { +return rthal_critical_exit (flags); +} + static inline int xnarch_hook_irq (unsigned irq, rthal_irq_handler_t handler, rthal_irq_ackfn_t ackfn,
include/asm-i386/hal.h +3 -0
@@ -191,6 +191,9 @@ static inline __attribute_const__ unsign#define RTHAL_APIC_TIMER_VECTOR RTHAL_SERVICE_VECTOR3#define RTHAL_APIC_TIMER_IPI RTHAL_SERVICE_IPI3#define RTHAL_APIC_ICOUNT ((RTHAL_TIMER_FREQ + HZ/2)/HZ) +#define RTHAL_TIMER_IRQ RTHAL_APIC_TIMER_IPI +#else /* !CONFIG_X86_LOCAL_APIC */ +#define RTHAL_TIMER_IRQ RTHAL_8254_IRQ#endif /* CONFIG_X86_LOCAL_APIC */ #define RTHAL_NMICLK_FREQ RTHAL_CPU_FREQ
include/asm-sim/system.h +13 -0
@@ -75,6 +75,9 @@ typedef unsigned long xnlock_t;#define XNARCH_NR_CPUS 1 +/* Should be equal to the value used for creating the mvmtimer object (mvm_start_timer). */ +#define XNARCH_TIMER_IRQ 1 +#define XNARCH_DEFAULT_TICK 10000000/* ns, i.e. 10ms */ #define XNARCH_HOST_TICK 0/* No host ticking service. */
@@ -365,6 +368,16 @@ void mvm_tcl_build_pendq(mvm_tcl_listobjtypedef void (*rthal_irq_handler_t )(unsigned ,void *);typedef int (*rthal_irq_ackfn_t )(unsigned ); +#define XNARCH_NR_IRQS MVM_IRQ_LEVELS + +static inline unsigned long xnarch_critical_enter (void (*synch)(void )) { +return 0 ; +} + +static inline void xnarch_critical_exit (unsigned long flags) { +return ; +} + static inline int xnarch_hook_irq (unsigned irq, rthal_irq_handler_t handler, rthal_irq_ackfn_t ackfn, /* Ignored. */
include/asm-uvm/system.h +12 -0
@@ -74,6 +74,8 @@ typedef unsigned long xnlock_t;#define XNARCH_NR_CPUS 1 +#define XNARCH_TIMER_IRQ 0 +#define XNARCH_DEFAULT_TICK 1000000/* ns, i.e. 1ms */ #define XNARCH_SIG_RESTART SIGUSR1#define XNARCH_HOST_TICK 0/* No host ticking service */
@@ -270,6 +272,16 @@ void xnarch_sync_irq (void) /* Synchronitypedef void (*rthal_irq_handler_t )(unsigned ,void *);typedef int (*rthal_irq_ackfn_t )(unsigned ); +#define XNARCH_NR_IRQS 0 + +static inline unsigned long xnarch_critical_enter (void (*synch)(void )) { +return 0 ; +} + +static inline void xnarch_critical_exit (unsigned long flags) { +return ; +} + static inline int xnarch_hook_irq (unsigned irq, rthal_irq_handler_t handler, rthal_irq_ackfn_t ackfn,
include/nucleus/intr.h +15 -3
@@ -26,21 +26,31 @@#define XN_ISR_CHAINED 0x1#define XN_ISR_ENABLE 0x2 +/* Creation flags. */ +#define XN_ISR_SHARED 0x1 + +/* Operational flags. */ +#define XN_ISR_ATTACHED 0x100 + #if defined(__KERNEL__) || defined(__XENO_UVM__) || defined(__XENO_SIM__) struct xnintr; typedef struct xnintr { - unsigned irq; /* !< IRQ number. */ + struct xnintr *next; xnisr_t isr; /* !< Interrupt service routine. */ - xniack_t iack; /* !< Interrupt acknowledge routine. */ + void *cookie; /* !< User-defined cookie value. */ unsigned long hits; /* !< Number of receipts (since attachment). */ - void *cookie; /* !< User-defined cookie value. */ + xnflags_t flags; /* !< Creation flags. */ + + unsigned irq; /* !< IRQ number. */ + + xniack_t iack; /* !< Interrupt acknowledge routine. */ char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
@@ -52,6 +62,8 @@ extern xnintr_t nkclock;extern "C" {#endif +int xnintr_mount (void ); +void xnintr_clock_handler (void );/* Public interface. */
ksrc/nucleus/intr.c +185 -9
251 lines not on this page · raw message
ksrc/nucleus/module.c +2 -0
@@ -713,6 +713,8 @@ int __init __xeno_sys_init (void)xnpod_init_proc ();#endif /* CONFIG_PROC_FS */ +xnintr_mount (); +#ifdef CONFIG_LTT xnltt_mount ();#endif /* CONFIG_LTT */
ksrc/nucleus/pod.c +2 -3
@@ -3038,11 +3038,10 @@ unlock_and_exit:/* The clock interrupt does not need to be attached since the timer service will handle the arch-dependent setup. The IRQ -number (arg #2) is not used since the IRQ source will be -attached directly by the arch-dependent layer +source will be attached directly by the arch-dependent layer (xnarch_start_timer). */ -xnintr_init (&nkclock,NULL ,0 ,tickhandler,NULL ,0 ); +xnintr_init (&nkclock,NULL ,XNARCH_TIMER_IRQ ,tickhandler,NULL ,0 );__setbits (nkpod->status,XNTIMED );
include/nucleus/intr.h +2 -0
@@ -66,6 +66,8 @@ int xnintr_mount(void);void xnintr_clock_handler (void ); +int xnintr_irq_proc (unsigned int irq,char *str); +/* Public interface. */ int xnintr_init(xnintr_t *intr,
ksrc/arch/generic/hal.c +0 -46
64 lines not on this page · raw message
ksrc/nucleus/intr.c +29 -1
@@ -536,7 +536,6 @@ static void xnintr_irq_handler (unsigned intr = intr->next; } -xnintr_shirq_unlock (shirq); }
@@ -564,6 +563,35 @@ static void xnintr_irq_handler (unsignedxnltt_log_event (xeno_ev_iexit,irq); } +int xnintr_irq_proc (unsigned int irq,char *str) +{ +xnintr_shirq_t *shirq; +xnintr_t *intr; +char *p = str; + + shirq = &xnshirqs[irq]; + +xnintr_shirq_lock (shirq); + intr = shirq->handlers; + +if (intr) + p +=sprintf (p," " ); + +while (intr) + { +if (*(intr->name)) + p +=sprintf (p," %s," , intr->name); + + intr = intr->next; + } + +xnintr_shirq_unlock (shirq); + +if (p != str) + --p; + +return p - str; +}/*@}*/
ksrc/nucleus/module.c +49 -0
67 lines not on this page · raw message
include/nucleus/intr.h +2 -0
@@ -25,9 +25,11 @@#define XN_ISR_HANDLED 0x0#define XN_ISR_CHAINED 0x1#define XN_ISR_ENABLE 0x2 +#define XN_ISR_NOINT 0x4/* Creation flags. */ #define XN_ISR_SHARED 0x1 +#define XN_ISR_ISA 0x2/* Operational flags. */ #define XN_ISR_ATTACHED 0x100
ksrc/nucleus/intr.c +75 -2
101 lines not on this page · raw message
Quoted 27 lines · Dmitry Adamushko
Hi there,
as I promised, here go the following patches (ordered as they have to be applied one by one) :
1) shirq-base.patch
Adds the "name" field to the interrupt object of the nucleus layer. Reworks the related bits of the native skin (+ a few minor changes for posix and rtdm) to support the named interrupt objects.
2) shirq-v7.patch
Generic support for shared interrupts.
3) shirq-proc.patch
/proc support.
Now
/proc/xenomai/irqshows the names of handlers.The related code have been removed from the hal layer to nucleus.
Quoted 8 lines
-----
4) shirq-isa.patch
Trying to handle the edge-triggered stuff.
This is a very preliminary version so the only thing I promise so far is that it compiles successfully.
Why not name it XN_ISR_EDGE or so (also the related functions etc.)? Although it mostly targets ISA hardware, it's about the edge-triggered characteristic of that devices after all.
Quoted 8 lines
The functionality added by first 3 patches seem to be working.
--
Best regards,
Dmitry Adamushko
I'm now trying to organise a full test scenario with shared UART ISA-IRQs at our institute. May take till beginning of next week, some regressions in our own software need to be fixed first.
Jan
Quoted 33 lines · Jan Kiszka
Quoted 31 lines · Dmitry Adamushko
Hi there,
as I promised, here go the following patches (ordered as they have to be applied one by one) :
1) shirq-base.patch
Adds the "name" field to the interrupt object of the nucleus layer. Reworks the related bits of the native skin (+ a few minor changes for posix and rtdm) to support the named interrupt objects.
2) shirq-v7.patch
Generic support for shared interrupts.
3) shirq-proc.patch
/proc support.
Now
/proc/xenomai/irqshows the names of handlers.The related code have been removed from the hal layer to nucleus.
-----
4) shirq-isa.patch
Quoted 8 lines
Quoted 4 lines
Trying to handle the edge-triggered stuff.
This is a very preliminary version so the only thing I promise so far is that it compiles successfully.
Why not name it
XN_ISR_EDGEor so (also the related functions etc.)? Although it mostly targets ISA hardware, it's about the edge-triggered characteristic of that devices after all.
Ack.
I forgot to apply your earlier fixes so it will be done too.
Quoted 4 lines
Quoted 4 lines
The functionality added by first 3 patches seem to be working.
Quoted 8 lines
Quoted 4 lines
--
Best regards,
Dmitry AdamushkoI'm now trying to organise a full test scenario with shared UART ISA-IRQs at our institute. May take till beginning of next week, some regressions in our own software need to be fixed first.
That's good. Thanks. Keep me informed on progress.
Jan
Quoted 4 lines
--
Best regards,
Dmitry Adamushko