Skip to contentSkip to conversation

Shared interrupts (yet another movie :)

PATCH Applied Dmitry Adamushko 4 participants 7 messages Feb 27, 2006 – Feb 28, 2006 1 message not in the archive Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Shared interrupts (yet another movie :)

Hi there,

I have explicitly cc'ed Gilles as this patch affects the posix skin.

In the light of the recent discussions, the AUTOENA flag has been converted to NOAUTOENA and the IRQ line is re-enabled on return from xnintr_irq_handler() and shirq brothers by default.
Also XN_ISR_CHAINED -> XN_ISR_PROPAGATE.

I'm still not sutisfied with results, namely - return values of ISR. But, well, this is a quite separate question to the shirq support so the later one should not remain in pending status only because of that.

I still would like to see something along scalar values : NONE, HANDLED, PROPAGATE and xnintr_disable() being called in ISR to defer IRQ line enabling (not .ending -> PROPAGATE does it).
(*)

Currently, there is a XN_ISR_NOENABLE bit which asks the real-time layer to defer the IRQ line, Warning!, .ending (and not just enabling) until later. In common case, xnarch_end_irq() must be called by the rt_task that stands for a bottom half (and not just xnintr_enable() - this may not work on ppc). This adds a bit of confusion and we will avoid it with (*) scheme. So this is a subject to change in the future.
As I pointed out in another message, the implementation for PPC is not yet clear at the moment. That's it...

Ok, are there any objections as to the current patch? If no, please apply.

CHANGELOG.patch is here
https://mail.gna.org/public/xenomai-core/2006-02/msg00154.html

--
Best regards,
Dmitry Adamushko

include/asm-generic/hal.h +5 -0
diff -urp xenomai-CVS/include/asm-generic/hal.h xenomai/include/asm-generic/hal.h
@@ -64,6 +64,11 @@
 #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_VIRQ_BASE		IPIPE_VIRQ_BASE
+
+#define rthal_virtual_irq_p(irq)	((irq) >= RTHAL_VIRQ_BASE && \
+					(irq) < RTHAL_NR_IRQS)
 
 #define RTHAL_SERVICE_IPI0	IPIPE_SERVICE_IPI0
 #define RTHAL_SERVICE_VECTOR0	IPIPE_SERVICE_VECTOR0
include/asm-generic/system.h +2 -0
diff -urp xenomai-CVS/include/asm-generic/system.h xenomai/include/asm-generic/system.h
@@ -109,6 +109,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: "
include/asm-i386/hal.h +3 -0
diff -urp xenomai-CVS/include/asm-i386/hal.h xenomai/include/asm-i386/hal.h
@@ -141,6 +141,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 +3 -0
diff -urp xenomai-CVS/include/asm-sim/system.h xenomai/include/asm-sim/system.h
@@ -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. */
 
include/asm-uvm/system.h +2 -0
diff -urp xenomai-CVS/include/asm-uvm/system.h xenomai/include/asm-uvm/system.h
@@ -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 */
include/native/intr.h +17 -9
diff -urp xenomai-CVS/include/native/intr.h xenomai/include/native/intr.h
@@ -27,9 +27,9 @@
 #include <native/types.h>
 
 /* Creation flag. */
-#define I_AUTOENA    XN_ISR_ENABLE /* Auto-enable interrupt channel
-				      after each IRQ. */
-#define I_PROPAGATE  XN_ISR_CHAINED /* Propagate IRQs down the
+#define I_NOAUTOENA  XN_ISR_NOENABLE  /* Do not auto-enable interrupt channel
+				        after each IRQ. */
+#define I_PROPAGATE  XN_ISR_PROPAGATE /* Propagate IRQs down the
 				       pipeline after processing; IOW,
 				       pass them to Linux. */
 typedef struct rt_intr_info {
@@ -50,9 +50,14 @@ typedef struct rt_intr_placeholder {
 
 #define XENO_INTR_MAGIC 0x55550a0a
 
-#define RT_INTR_HANDLED XN_ISR_HANDLED
-#define RT_INTR_CHAINED XN_ISR_CHAINED
-#define RT_INTR_ENABLE  XN_ISR_ENABLE
+/* Creation flags. */
+#define I_SHARED	XN_ISR_SHARED
+#define I_EDGE		XN_ISR_EDGE
+
+#define RT_INTR_HANDLED		XN_ISR_HANDLED
+#define RT_INTR_NONE		XN_ISR_NONE
+#define RT_INTR_PROPAGATE	XN_ISR_PROPAGATE
+#define RT_INTR_NOENABLE	XN_ISR_NOENABLE
 
 #define I_DESC(xintr)  ((RT_INTR *)(xintr)->cookie)
 
@@ -81,7 +86,7 @@ typedef struct rt_intr {
 
     xnsynch_t synch_base; /* !< Base synchronization object. */
 
-    pid_t cpid;			/* !< Creator's pid. */
+    pid_t cpid;		/* !< Creator's pid. */
 
 #endif /* __KERNEL__ && CONFIG_XENO_OPT_PERVASIVE */
 
@@ -101,9 +106,11 @@ 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);
+		   rt_iack_t iack,
+		   int mode);
 
 #ifdef CONFIG_XENO_OPT_PERVASIVE
 int rt_intr_handler(xnintr_t *cookie);
@@ -122,7 +129,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 +140,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 +30 -8
diff -urp xenomai-CVS/include/nucleus/intr.h xenomai/include/nucleus/intr.h
@@ -22,25 +22,42 @@
 
 #include <nucleus/types.h>
 
-#define XN_ISR_HANDLED   0x0
-#define XN_ISR_CHAINED   0x1
-#define XN_ISR_ENABLE    0x2
+/* Possible return values of ISR. */
+#define XN_ISR_NONE   	 0x1
+#define XN_ISR_HANDLED	 0x2
+/* Additional bits. */
+#define XN_ISR_PROPAGATE 0x100
+#define XN_ISR_NOENABLE  0x200
+#define XN_ISR_BITMASK	 ~0xff
+
+/* Creation flags. */
+#define XN_ISR_SHARED	 0x1
+#define XN_ISR_EDGE	 0x2
 
-#if defined(__KERNEL__) || defined(__XENO_UVM__) || defined(__XENO_SIM__)
+/* Operational flags. */
+#define XN_ISR_ATTACHED	 0x10000
 
-struct xnintr;
+#if defined(__KERNEL__) || defined(__XENO_UVM__) || defined(__XENO_SIM__)
 
 typedef struct xnintr {
 
-    unsigned irq;	/* !< IRQ number. */
+#if defined(CONFIG_XENO_OPT_SHIRQ_LEVEL) || defined(CONFIG_XENO_OPT_SHIRQ_EDGE)
+    struct xnintr *next; /* !< Next object in the IRQ-sharing chain. */
+#endif /* CONFIG_XENO_OPT_SHIRQ_LEVEL || CONFIG_XENO_OPT_SHIRQ_EDGE */
 
     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. */
+
+    const char *name;	/* !< Symbolic name. */
 
 } xnintr_t;
 
@@ -50,11 +67,16 @@ extern xnintr_t nkclock;
 extern "C" {
 #endif
 
+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,
+		const char *name,
 		unsigned irq,
 		xnisr_t isr,
 		xniack_t iack,
include/posix/pthread.h +2 -2
diff -urp xenomai-CVS/include/posix/pthread.h xenomai/include/posix/pthread.h
@@ -146,8 +146,8 @@ typedef unsigned long pthread_intr_t;
 #define PTHREAD_WARNSW  XNTRAPSW
 #define PTHREAD_PRIMARY XNTHREAD_SPARE1
 
-#define PTHREAD_IAUTOENA    XN_ISR_ENABLE
-#define PTHREAD_IPROPAGATE  XN_ISR_CHAINED
+#define PTHREAD_INOAUTOENA  XN_ISR_NOENABLE
+#define PTHREAD_IPROPAGATE  XN_ISR_PROPAGATE
 
 #define PTHREAD_IENABLE     0
 #define PTHREAD_IDISABLE    1
include/rtdm/rtdm_driver.h +19 -5
diff -urp xenomai-CVS/include/rtdm/rtdm_driver.h xenomai/include/rtdm/rtdm_driver.h
@@ -693,6 +693,17 @@ typedef unsigned long               rtdm
 
 typedef xnintr_t                    rtdm_irq_t;
 
+/*!
+ * @anchor RTDM_IRQTYPE_xxx   @name RTDM_IRQTYPE_xxx
+ * Interrupt registrations flags
+ * @{
+ */
+/** Enable IRQ-sharing with other real-time drivers */
+#define RTDM_IRQTYPE_SHARED         XN_ISR_SHARED
+/** Additional flag to enable IRQ-sharing of edge-triggered interrupts */
+#define RTDM_IRQTYPE_EDGE	    XN_ISR_EDGE
+/** @} */
+
 /**
  * Interrupt handler
  *
@@ -702,16 +713,19 @@ typedef xnintr_t                    rtdm
  */
 typedef int (*rtdm_irq_handler_t)(rtdm_irq_t *irq_handle);
 
-
 /*!
  * @anchor RTDM_IRQ_xxx   @name RTDM_IRQ_xxx
  * Return flags of interrupt handlers
  * @{
  */
+/** Denote handled interrupt */
+#define RTDM_IRQ_HANDLED	    XN_ISR_HANDLED
+/** Unhandled interrupt */
+#define RTDM_IRQ_NONE		    XN_ISR_NONE
 /** Propagate unhandled interrupt to possible other handlers */
-#define RTDM_IRQ_PROPAGATE          XN_ISR_CHAINED
-/** Re-enable interrupt line on return */
-#define RTDM_IRQ_ENABLE             XN_ISR_ENABLE
+#define RTDM_IRQ_PROPAGATE          XN_ISR_PROPAGATE
+/** Interrupt line is not re-enabled on return */
+#define RTDM_IRQ_NOENABLE           XN_ISR_NOENABLE
 /** @} */
 
 /**
@@ -741,7 +755,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/arch/generic/hal.c +0 -46

64 lines not on this page · raw message

ksrc/drivers/16550A/16550A.c +3 -2
diff -urp xenomai-CVS/ksrc/drivers/16550A/16550A.c xenomai/ksrc/drivers/16550A/16550A.c
@@ -266,7 +266,7 @@ static int rt_16550_interrupt(rtdm_irq_t
                 events |= RTSER_EVENT_MODEMLO;
         }
 
-        ret = RTDM_IRQ_ENABLE;
+        ret = RTDM_IRQ_ENABLE | RTDM_IRQ_HANDLED;
     }
 
     if (ctx->in_nwait > 0) {
@@ -446,7 +446,8 @@ int rt_16550_open(struct rtdm_dev_contex
     ctx = (struct rt_16550_context *)context->dev_private;
 
     ret = rtdm_irq_request(&ctx->irq_handle, irq[dev_id], rt_16550_interrupt,
-                           0, context->device->proc_name, ctx);
+			    RTDM_IRQTYPE_SHARED|RTDM_IRQTYPE_EDGE,
+			    context->device->proc_name, ctx);
     if (ret < 0)
         return ret;
 
ksrc/nucleus/intr.c +398 -20

493 lines not on this page · raw message

ksrc/nucleus/module.c +51 -0

75 lines not on this page · raw message

ksrc/nucleus/pod.c +2 -3
diff -urp xenomai-CVS/ksrc/nucleus/pod.c xenomai/ksrc/nucleus/pod.c
@@ -3125,11 +3125,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,0,tickhandler,NULL,0);
+    xnintr_init(&nkclock,"[timer]",XNARCH_TIMER_IRQ,tickhandler,NULL,0);
 
     __setbits(nkpod->status,XNTIMED);
 
ksrc/skins/native/intr.c +22 -7
diff -urp xenomai-CVS/ksrc/skins/native/intr.c xenomai/ksrc/skins/native/intr.c
@@ -120,7 +120,7 @@ static xnpnode_t __intr_pnode = {
 #endif /* CONFIG_XENO_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,int mode)
  * \brief Create an interrupt object from kernel space.
  *
  * Initializes and associates an interrupt object with an IRQ line. In
@@ -156,6 +156,11 @@ static xnpnode_t __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.
  *
@@ -174,6 +179,14 @@ static xnpnode_t __intr_pnode = {
  * the interrupt has been properly acknowledged. If @a iack is NULL,
  * the default routine will be used instead.
  *
+ * @param mode The interrupt object creation mode. The following flags can be
+ * OR'ed into this bitmask, each of them affecting the new interrupt object:
+ *
+ * - I_SHARED enables IRQ-sharing with other interrupt objects.
+ *
+ * - I_EDGE is an additional flag need to be set together with I_SHARED
+ * to enable IRQ-sharing of edge-triggered interrupts.
+ *
  * @return 0 is returned upon success. Otherwise:
  *
  * - -ENOMEM is returned if the system fails to get enough dynamic
@@ -206,9 +219,11 @@ static xnpnode_t __intr_pnode = {
  */
 
 int rt_intr_create (RT_INTR *intr,
+		    const char *name,
 		    unsigned irq,
 		    rt_isr_t isr,
-		    rt_iack_t iack)
+		    rt_iack_t iack,
+		    int mode)
 {
     int err;
     spl_t s;
@@ -216,7 +231,8 @@ 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,mode);
+    xnobject_copy_name(intr->name,name);
 #if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE)
     xnsynch_init(&intr->synch_base,XNSYNCH_PRIO);
     intr->pending = 0;
@@ -229,7 +245,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);
 
@@ -529,15 +544,15 @@ int rt_intr_inquire (RT_INTR *intr,
  * @param mode The interrupt object creation mode. The following flags
  * can be OR'ed into this bitmask:
  *
- * - I_AUTOENA asks Xenomai to re-enable the IRQ line before awakening
+ * - I_NOAUTOENA asks Xenomai not to re-enable the IRQ line before awakening
  * the interrupt server task. This flag is functionally equivalent as
- * always returning RT_INTR_ENABLE from a kernel space interrupt
+ * always returning RT_INTR_NOENABLE from a kernel space interrupt
  * handler.
  *
  * - I_PROPAGATE asks Xenomai to propagate the IRQ down the pipeline; in
  * other words, the interrupt occurrence is chained to Linux after it
  * has been processed by the Xenomai task. This flag is functionally
- * equivalent as always returning RT_INTR_CHAINED from a kernel space
+ * equivalent as always returning RT_INTR_PROPAGATE from a kernel space
  * interrupt handler.
  *
  * @return 0 is returned upon success. Otherwise:
ksrc/skins/native/snippets/user_irq.c +1 -1
diff -urp xenomai-CVS/ksrc/skins/native/snippets/user_irq.c xenomai/ksrc/skins/native/snippets/user_irq.c
@@ -33,7 +33,7 @@ int main (int argc, char *argv[])
 
     /* ... */
 
-    err = rt_intr_create(&intr_desc,IRQ_NUMBER,I_AUTOENA);
+    err = rt_intr_create(&intr_desc,"MyIrq",IRQ_NUMBER,0);
 
     /* ... */
 
ksrc/skins/native/syscall.c +20 -7
diff -urp xenomai-CVS/ksrc/skins/native/syscall.c xenomai/ksrc/skins/native/syscall.c
@@ -2863,16 +2863,17 @@ int rt_intr_handler (xnintr_t *cookie)
     if (xnsynch_nsleepers(&intr->synch_base) > 0)
 	xnsynch_flush(&intr->synch_base,0);
 
-    if (intr->mode & XN_ISR_CHAINED)
-	return XN_ISR_CHAINED|(intr->mode & XN_ISR_ENABLE);
+    if (intr->mode & XN_ISR_PROPAGATE)
+	return XN_ISR_PROPAGATE|(intr->mode & XN_ISR_NOENABLE);
 
-    return XN_ISR_HANDLED|(intr->mode & XN_ISR_ENABLE);
+    return XN_ISR_HANDLED|(intr->mode & XN_ISR_NOENABLE);
 }
 
 EXPORT_SYMBOL(rt_intr_handler);
 
 /*
  * int __rt_intr_create(RT_INTR_PLACEHOLDER *ph,
+ *			const char *name,
  *                      unsigned irq,
  *                      int mode)
  */
@@ -2880,6 +2881,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;
@@ -2888,13 +2890,24 @@ static int __rt_intr_create (struct task
     if (!__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))
+    if (mode & ~(I_NOAUTOENA|I_PROPAGATE))
 	return -EINVAL;
 
     intr = (RT_INTR *)xnmalloc(sizeof(*intr));
@@ -2902,7 +2915,7 @@ static int __rt_intr_create (struct task
     if (!intr)
 	return -ENOMEM;
 
-    err = rt_intr_create(intr,irq,&rt_intr_handler,NULL);
+    err = rt_intr_create(intr,name,irq,&rt_intr_handler,NULL,0);
 
     if (err == 0)
 	{
ksrc/skins/posix/intr.c +1 -1
diff -urp xenomai-CVS/ksrc/skins/posix/intr.c xenomai/ksrc/skins/posix/intr.c
@@ -27,7 +27,7 @@ int pse51_intr_attach (struct pse51_inte
     int 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);
ksrc/skins/posix/intr.h +2 -2
diff -urp xenomai-CVS/ksrc/skins/posix/intr.h xenomai/ksrc/skins/posix/intr.h
@@ -21,8 +21,8 @@
 #include <nucleus/synch.h>
 #include <nucleus/intr.h>
 
-#define PTHREAD_IAUTOENA    XN_ISR_ENABLE
-#define PTHREAD_IPROPAGATE  XN_ISR_CHAINED
+#define PTHREAD_INOAUTOENA  XN_ISR_NOENABLE
+#define PTHREAD_IPROPAGATE  XN_ISR_PROPAGATE
 
 #define PTHREAD_IENABLE     0
 #define PTHREAD_IDISABLE    1
ksrc/skins/posix/syscall.c +4 -4
diff -urp xenomai-CVS/ksrc/skins/posix/syscall.c xenomai/ksrc/skins/posix/syscall.c
@@ -1487,10 +1487,10 @@ static int __pse51_intr_handler (xnintr_
     if (xnsynch_nsleepers(&intr->synch_base) > 0)
         xnsynch_flush(&intr->synch_base,0);
 
-    if (intr->mode & XN_ISR_CHAINED)
-        return XN_ISR_CHAINED|(intr->mode & XN_ISR_ENABLE);
+    if (intr->mode & XN_ISR_PROPAGATE)
+        return XN_ISR_PROPAGATE|(intr->mode & XN_ISR_NOENABLE);
 
-    return XN_ISR_HANDLED|(intr->mode & XN_ISR_ENABLE);
+    return XN_ISR_HANDLED|(intr->mode & XN_ISR_NOENABLE);
 }
 
 int __intr_attach (struct task_struct *curr, struct pt_regs *regs)
@@ -1509,7 +1509,7 @@ int __intr_attach (struct task_struct *c
     /* Interrupt control mode. */
     mode = (int)__xn_reg_arg3(regs);
 
-    if (mode & ~(XN_ISR_ENABLE|XN_ISR_CHAINED))
+    if (mode & ~(XN_ISR_NOENABLE|XN_ISR_PROPAGATE))
         return -EINVAL;
 
     intr = (struct pse51_interrupt *)xnmalloc(sizeof(*intr));
ksrc/skins/rtdm/drvlib.c +1 -1
diff -urp xenomai-CVS/ksrc/skins/rtdm/drvlib.c xenomai/ksrc/skins/rtdm/drvlib.c
@@ -1202,7 +1202,7 @@ EXPORT_SYMBOL(rtdm_mutex_unlock);
  * @param[in,out] irq_handle IRQ handle
  * @param[in] irq_no Line number of the addressed IRQ
  * @param[in] handler Interrupt handler
- * @param[in] flags Currently unused, pass 0
+ * @param[in] flags Registration flags, see @ref RTDM_IRQTYPE_xxx for details
  * @param[in] device_name Optional device name to show up in real-time IRQ
  * lists (not yet implemented)
  * @param[in] arg Pointer to be passed to the interrupt handler on invocation
src/skins/native/intr.c +4 -6
diff -urp xenomai-CVS/src/skins/native/intr.c xenomai/src/skins/native/intr.c
@@ -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,
Config.in +7 -0
diff -ur nucleus-CVS/Config.in nucleus/Config.in
@@ -27,6 +27,13 @@
 		int 'Number of priority levels' CONFIG_XENO_OPT_SCALABLE_PRIOS 256
 	fi
 	endmenu
+
+	mainmenu_option next_comment
+	comment 'Shared interrupts'
+		bool 'Level-triggered interrupts' CONFIG_XENO_OPT_SHIRQ_LEVEL
+		bool 'Edge-triggered interrupts' CONFIG_XENO_OPT_SHIRQ_EDGE
+	endmenu
+
 	if [ "$CONFIG_LTT" != "n" ]; then
 		mainmenu_option next_comment
 		comment 'LTT tracepoints filtering'
Kconfig +24 -0
diff -ur nucleus-CVS/Kconfig nucleus/Kconfig
@@ -131,6 +131,30 @@
 
 endmenu
 
+menu "Shared interrupts"
+
+config XENO_OPT_SHIRQ_LEVEL
+	bool "Level-triggered interrupts"
+	default n
+	help
+	
+	Enables support for shared level-triggered interrupts, so that
+	multiple real-time interrupt handlers are allowed to control
+	dedicated hardware devices which are configured to share
+	the same interrupt channel.
+
+config XENO_OPT_SHIRQ_EDGE
+	bool "Edge-triggered interrupts"
+	default n
+	help
+
+	Enables support for shared edge-triggered interrupts, so that
+	multiple real-time interrupt handlers are allowed to control
+	dedicated hardware devices which are configured to share
+	the same interrupt channel.
+
+endmenu
+
 menu "LTT tracepoints filtering"
 
 	depends on LTT
#1 lore raw
Quoted 27 lines · Dmitry Adamushko

Hi there,

I have explicitly cc'ed Gilles as this patch affects the posix skin.

In the light of the recent discussions, the AUTOENA flag has been converted to NOAUTOENA and the IRQ line is re-enabled on return from xnintr_irq_handler() and shirq brothers by default.
Also XN_ISR_CHAINED -> XN_ISR_PROPAGATE.

I'm still not sutisfied with results, namely - return values of ISR. But, well, this is a quite separate question to the shirq support so the later one should not remain in pending status only because of that.

I still would like to see something along scalar values : NONE, HANDLED, PROPAGATE and xnintr_disable() being called in ISR to defer IRQ line enabling (not .ending -> PROPAGATE does it).
(*)

Currently, there is a XN_ISR_NOENABLE bit which asks the real-time layer to defer the IRQ line, Warning!, .ending (and not just enabling) until later. In common case, xnarch_end_irq() must be called by the rt_task that stands for a bottom half (and not just xnintr_enable() - this may not work on ppc). This adds a bit of confusion and we will avoid it with (*) scheme. So this is a subject to change in the future.
As I pointed out in another message, the implementation for PPC is not yet clear at the moment. That's it...

Quoted 1 line

Ok, are there any objections as to the current patch? If no, please apply.

No objections from my side (I'm overseeing those 2 or 3 white-space inconsistencies ;) ), should get applied!

I will prepare and commit the remaining tiny updates of RTDM and 16550A (regarding propagate and re-enable) as soon as this one is merged.

Quoted 8 lines

CHANGELOG.patch is here
https://mail.gna.org/public/xenomai-core/2006-02/msg00154.html

--
Best regards,
Dmitry Adamushko

Thanks for all your efforts!

Jan

#2 lore raw

[Xenomai-help] rtdm_mmap and rt_heap

Hi All,

Exist differences between RTDM's Memory mapped API (rtdm_mmap()/rtdm_munmap()) and Native's sharing memory API (rt_heap_*())? Which?

Thank you!

Ciao,
Alessio

#3 lore raw

Re: [Xenomai-help] rtdm_mmap and rt_heap

Quoted 5 lines · Alessio Igor Bogani

Hi All,

Exist differences between RTDM's Memory mapped API (rtdm_mmap()/rtdm_munmap()) and Native's sharing memory API (rt_heap_*())? Which?

The RTDM API is intended to be used by portable drivers for all skins (even for other RT-Linux extensions) while the native heaps are for native skin applications. So, if you are planning to implement a driver for some hardware or some communication protocol and you want to map e.g. DMA buffers from kernel to user space, use the RTDM API. If you want to set up shared memory between native applications (user-user, user-kernel), the heaps are your mechanism of choice.

Jan

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 2 lines · Dmitry Adamushko

...
Ok, are there any objections as to the current patch? If no, please

apply.

Quoted 1 line

Oops, I found a minor problem:

Quoted 8 lines

make[2]: Entering directory `/usr/src/xenomai/build/doc/doxygen' doxygen
/usr/src/xenomai/ksrc/skins/native/intr.c:523: Warning: no matching file member found for
int rt_intr_create(RT_INTR *intr, unsigned irq, int mode) Possible candidates:
int rt_intr_create(RT_INTR *intr, const char *name, unsigned irq, int
mode)

...

int rt_intr_bind(rt_intr_placeholder *intr, unsigned irq, RTIME timeout)

Quoted 5 lines

Possible candidates:
int rt_intr_bind(RT_INTR *intr, const char *name, RTIME timeout) int rt_intr_bind(RT_INTR *intr, const char *name, RTIME timeout)

Seems the doc is not yet up-to-date.

Thanks. I have overlooked some parts. This patch fixes it up (should be applied after the main patch).

Jan

Quoted 2 lines

--
Best regards,
Dmitry Adamushko

ksrc/skins/native/intr.c +32 -14
diff -urp xenomai-prev/ksrc/skins/native/intr.c xenomai/ksrc/skins/native/intr.c
@@ -135,16 +135,30 @@ static xnpnode_t __intr_pnode = {
  * the interrupted stack context, the rescheduling procedure is
  * locked, and the interrupt source is masked at hardware level. The
  * status value returned by the ISR is then checked for the following
- * bits:
+ * values:
  *
- * - RT_INTR_ENABLE asks Xenomai to re-enable the IRQ line upon return of
- * the interrupt service routine.
+ * - RT_INTR_HANDLED indicates that the interrupt request has been fulfilled
+ * by the ISR.
  *
- * - RT_INTR_CHAINED tells Xenomai to propagate the interrupt down the
- * Adeos interrupt pipeline to other Adeos domains, such as
- * Linux. This is the regular way to share interrupts between Xenomai and
- * the Linux kernel. At the opposite, RT_INTR_HANDLED can be used
- * instead to indicate that the interrupt request has been fulfilled.
+ * - RT_INTR_NONE indicates the opposite to RT_INTR_HANDLED. The ISR must always
+ * return this value when it determines that the interrupt request has not been
+ * issued by the dedicated hardware device.
+ *
+ * In addition, one of the following bits may be set by the ISR :
+ *
+ * NOTE: use these bits with care and only when you do understand their effect
+ * on the system.
+ * The ISR is not encouraged to use these bits in case it shares the IRQ line
+ * with other ISRs in the real-time domain.
+ *
+ * - RT_INTR_PROPAGATE tells Xenomai to require the real-time control
+ * layer to forward the IRQ. For instance, this would cause the Adeos
+ * control layer to propagate the interrupt down the interrupt
+ * pipeline to other Adeos domains, such as Linux. This is the regular
+ * way to share interrupts between Xenomai and the Linux kernel.
+ *
+ * - RT_INTR_NOENABLE asks Xenomai not to re-enable the IRQ line upon return
+ * of the interrupt service routine.
  *
  * A count of interrupt receipts is tracked into the interrupt
  * descriptor, and reset to zero each time the interrupt object is
@@ -520,7 +534,7 @@ int rt_intr_inquire (RT_INTR *intr,
 }
 
 /*! 
- * \fn int rt_intr_create (RT_INTR *intr,unsigned irq,int mode)
+ * \fn int rt_intr_create (RT_INTR *intr,const char *name,unsigned irq,int mode)
  * \brief Create an interrupt object from user-space.
  *
  * Initializes and associates an interrupt object with an IRQ line
@@ -538,6 +552,11 @@ int rt_intr_inquire (RT_INTR *intr,
  * 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.
  *
@@ -635,7 +654,7 @@ int rt_intr_inquire (RT_INTR *intr,
  */
 
 /**
- * @fn int rt_intr_bind(RT_INTR *intr,unsigned irq,RTIME timeout)
+ * @fn int rt_intr_bind(RT_INTR *intr,const char *name,RTIME timeout)
  * @brief Bind to an interrupt object.
  *
  * This user-space only service retrieves the uniform descriptor of a
@@ -645,14 +664,13 @@ int rt_intr_inquire (RT_INTR *intr,
  * interrupt is registered whenever a kernel-space task invokes the
  * rt_intr_create() service successfully for the given IRQ line.
  *
- * @param irq The hardware interrupt channel associated with the
- * interrupt object to search for. This value is
- * architecture-dependent.
- *
  * @param intr The address of an interrupt object descriptor retrieved
  * by the operation. Contents of this memory is undefined upon
  * failure.
  *
+ * @param name An ASCII string standing for the symbolic name of the
+ * interrupt object to search for.
+ *
  * @param timeout The number of clock ticks to wait for the
  * registration to occur (see note). Passing TM_INFINITE causes the
  * caller to block indefinitely until the object is
#6 lore raw
Quoted 28 lines · Dmitry Adamushko

On 28/02/06, *Jan Kiszka* <[email protected] <mailto:[email protected]>> wrote:

Dmitry Adamushko wrote:
> ...
> Ok, are there any objections as to the current patch? If no,
please apply.
>

Oops, I found a minor problem:

make[2]: Entering directory `/usr/src/xenomai/build/doc/doxygen' doxygen
/usr/src/xenomai/ksrc/skins/native/intr.c:523: Warning: no matching file member found for
int rt_intr_create(RT_INTR *intr, unsigned irq, int mode) Possible candidates:
int rt_intr_create(RT_INTR *intr, const char *name, unsigned irq, int
mode)

...

int rt_intr_bind(rt_intr_placeholder *intr, unsigned irq, RTIME timeout) Possible candidates:
int rt_intr_bind(RT_INTR *intr, const char *name, RTIME timeout) int rt_intr_bind(RT_INTR *intr, const char *name, RTIME timeout)

Quoted 6 lines

Seems the doc is not yet up-to-date.

Thanks. I have overlooked some parts. This patch fixes it up (should be applied after the main patch).

Applied, thanks.

Quoted 9 lines

Jan

Signature · 2 lines
Best regards,
Dmitry Adamushko
Signature · 1 line
Philippe.
#7 lore raw
In reply to Dmitry Adamushko
Quoted 8 lines · Dmitry Adamushko

Hi there,

I have explicitly cc'ed Gilles as this patch affects the posix skin.

In the light of the recent discussions, the AUTOENA flag has been converted to NOAUTOENA and the IRQ line is re-enabled on return from xnintr_irq_handler() and shirq brothers by default. Also XN_ISR_CHAINED -> XN_ISR_PROPAGATE.

Quoted 9 lines

I'm still not sutisfied with results, namely - return values of ISR. But, well, this is a quite separate question to the shirq support so the later one should not remain in pending status only because of that.

I still would like to see something along scalar values : NONE, HANDLED, PROPAGATE and xnintr_disable() being called in ISR to defer IRQ line enabling (not .ending -> PROPAGATE does it). (*)

Currently, there is a XN_ISR_NOENABLE bit which asks the real-time layer to defer the IRQ line, Warning!, .ending (and not just enabling) until later. In common case, xnarch_end_irq() must be called by the rt_task that stands for a bottom half (and not just xnintr_enable() - this may not work on ppc). This adds a bit of confusion and we will avoid it with (*) scheme. So this is a subject to change in the future.
As I pointed out in another message, the implementation for PPC is not yet clear at the moment. That's it...

That's great.

Quoted 2 lines

Ok, are there any objections as to the current patch? If no, please apply.

Applied, thanks.

Quoted 5 lines

CHANGELOG.patch is here https://mail.gna.org/public/xenomai-core/2006-02/msg00154.html

Signature · 2 lines
Best regards,
Dmitry Adamushko
Signature · 1 line
Philippe.