summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/arm/AT91SAM7X/interrupt.c7
-rw-r--r--libcpu/arm/AT91SAM7X/trap.c6
-rw-r--r--libcpu/arm/lpc214x/cpuport.c70
-rw-r--r--libcpu/arm/lpc24xx/interrupt.c10
-rw-r--r--libcpu/arm/lpc24xx/trap.c4
-rw-r--r--libcpu/arm/s3c24x0/interrupt.c79
-rw-r--r--libcpu/arm/s3c24x0/trap.c35
-rw-r--r--libcpu/arm/sep4020/interrupt.c86
-rw-r--r--libcpu/arm/sep4020/trap.c44
-rw-r--r--libcpu/mips/jz47xx/interrupt.c6
-rw-r--r--libcpu/mips/loongson/interrupt.c106
-rw-r--r--libcpu/mips/loongson_1b/interrupt.c57
12 files changed, 314 insertions, 196 deletions
diff --git a/libcpu/arm/AT91SAM7X/interrupt.c b/libcpu/arm/AT91SAM7X/interrupt.c
index 1aced87b29..71884f9f3f 100644
--- a/libcpu/arm/AT91SAM7X/interrupt.c
+++ b/libcpu/arm/AT91SAM7X/interrupt.c
@@ -10,8 +10,10 @@
* Change Logs:
* Date Author Notes
* 2006-08-23 Bernard first version
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
+#include <rtthread.h>
#include <rthw.h>
#include "AT91SAM7X256.h"
@@ -30,7 +32,7 @@ rt_uint32_t rt_thread_switch_interrupt_flag;
*/
/*@{*/
-void rt_hw_interrupt_handler(int vector)
+static void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -38,7 +40,7 @@ void rt_hw_interrupt_handler(int vector)
/**
* This function will initialize hardware interrupt
*/
-void rt_hw_interrupt_init()
+void rt_hw_interrupt_init(void)
{
rt_base_t index;
@@ -96,7 +98,6 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
void *param, char *name)
{
rt_isr_handler_t old_handler = RT_NULL;
-
if(vector >= 0 && vector < MAX_HANDLERS)
{
old_handler = irq_desc[vector].handler;
diff --git a/libcpu/arm/AT91SAM7X/trap.c b/libcpu/arm/AT91SAM7X/trap.c
index 4b21f81c1c..74d1cba445 100644
--- a/libcpu/arm/AT91SAM7X/trap.c
+++ b/libcpu/arm/AT91SAM7X/trap.c
@@ -22,7 +22,7 @@
*/
/*@{*/
-void rt_hw_trap_irq()
+void rt_hw_trap_irq(void)
{
int irqno;
extern struct rt_irq_desc irq_desc[];
@@ -37,13 +37,13 @@ void rt_hw_trap_irq()
AT91C_BASE_AIC->AIC_EOICR = 0;
}
-void rt_hw_trap_fiq()
+void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
extern struct rt_thread* rt_current_thread;
-void rt_hw_trap_abort()
+void rt_hw_trap_abort(void)
{
rt_kprintf("Abort occured!!! Thread [%s] suspended.\n",rt_current_thread->name);
rt_thread_suspend(rt_current_thread);
diff --git a/libcpu/arm/lpc214x/cpuport.c b/libcpu/arm/lpc214x/cpuport.c
index 512ff89f08..1cd33b897b 100644
--- a/libcpu/arm/lpc214x/cpuport.c
+++ b/libcpu/arm/lpc214x/cpuport.c
@@ -10,9 +10,11 @@
* Change Logs:
* Date Author Notes
* 2011-06-15 aozima the first version for lpc214x
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
+#include <rthw.h>
#include "lpc214x.h"
#define MAX_HANDLERS 32
@@ -20,6 +22,9 @@
extern rt_uint32_t rt_interrupt_nest;
+/* exception and interrupt handler table */
+struct rt_irq_desc irq_desc[MAX_HANDLERS];
+
/**
* @addtogroup LPC214x
*/
@@ -71,7 +76,7 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
-void rt_hw_interrupt_handler(int vector)
+void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -79,7 +84,7 @@ void rt_hw_interrupt_handler(int vector)
/**
* This function will initialize hardware interrupt
*/
-void rt_hw_interrupt_init()
+void rt_hw_interrupt_init(void)
{
rt_base_t index;
rt_uint32_t *vect_addr, *vect_ctl;
@@ -90,12 +95,15 @@ void rt_hw_interrupt_init()
/* set all to IRQ */
VICIntSelect = 0;
+ rt_memset(irq_desc, 0x00, sizeof(irq_desc));
for (index = 0; index < MAX_HANDLERS; index ++)
{
+ irq_desc[index].handler = rt_hw_interrupt_handler;
+
vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + (index << 2));
vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (index << 2));
- *vect_addr = (rt_uint32_t)rt_hw_interrupt_handler;
+ *vect_addr = (rt_uint32_t)&irq_desc[index];
*vect_ctl = 0xF;
}
@@ -127,30 +135,39 @@ void rt_hw_interrupt_umask(int vector)
/**
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
- * @param new_handler the interrupt service routine to be installed
- * @param old_handler the old interrupt service routine
+ * @param handler the interrupt service routine to be installed
+ * @param param the interrupt service function parameter
+ * @param name the interrupt name
+ * @return old handler
*/
-void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
+rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
+ void *param, char *name)
{
- if(vector >= 0 && vector < MAX_HANDLERS)
- {
- /* get VIC address */
- rt_uint32_t* vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + (vector << 2));
- rt_uint32_t* vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (vector << 2));
+ rt_isr_handler_t old_handler = RT_NULL;
- /* assign IRQ slot and enable this slot */
- *vect_ctl = 0x20 | (vector & 0x1F);
+ if(vector >= 0 && vector < MAX_HANDLERS)
+ {
+ rt_uint32_t* vect_ctl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + (vector << 2));
- if (old_handler != RT_NULL) *old_handler = (rt_isr_handler_t) *vect_addr;
- if (new_handler != RT_NULL) *vect_addr = (rt_uint32_t) new_handler;
- }
+ /* assign IRQ slot and enable this slot */
+ *vect_ctl = 0x20 | (vector & 0x1F);
+
+ old_handler = irq_desc[vector].handler;
+ if (handler != RT_NULL)
+ {
+ irq_desc[vector].handler = handler;
+ irq_desc[vector].param = param;
+ }
+ }
+
+ return old_handler;
}
/**
* this function will reset CPU
*
*/
-void rt_hw_cpu_reset()
+void rt_hw_cpu_reset(void)
{
}
@@ -165,18 +182,23 @@ void rt_hw_cpu_shutdown()
while (1);
}
-void rt_hw_trap_irq()
+void rt_hw_trap_irq(void)
{
- rt_isr_handler_t isr_func;
+ int irqno;
+ struct rt_irq_desc* irq;
+ extern struct rt_irq_desc irq_desc[];
+
+ irq = (struct rt_irq_desc*) VICVectAddr;
+ irqno = ((rt_uint32_t) irq - (rt_uint32_t) &irq_desc[0])/sizeof(struct rt_irq_desc);
- isr_func = (rt_isr_handler_t) VICVectAddr;
- isr_func(0);
+ /* invoke isr */
+ irq->handler(irqno, irq->param);
- /* acknowledge Interrupt */
- // VICVectAddr = 0;
+ /* acknowledge Interrupt */
+ // VICVectAddr = 0;
}
-void rt_hw_trap_fiq()
+void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
diff --git a/libcpu/arm/lpc24xx/interrupt.c b/libcpu/arm/lpc24xx/interrupt.c
index 6d64d7a07c..16d1dd7e99 100644
--- a/libcpu/arm/lpc24xx/interrupt.c
+++ b/libcpu/arm/lpc24xx/interrupt.c
@@ -10,8 +10,10 @@
* Change Logs:
* Date Author Notes
* 2008-12-11 XuXinming first version
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
+#include <rtthread.h>
#include <rthw.h>
#include "LPC24xx.h"
@@ -35,7 +37,7 @@ void rt_hw_interrupt_handler(int vector, void *param)
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
-void rt_hw_interrupt_init()
+void rt_hw_interrupt_init(void)
{
register int i;
@@ -47,10 +49,10 @@ void rt_hw_interrupt_init()
VICIntSelect = 0;
/* init exceptions table */
+ rt_memset(irq_desc, 0x00, sizeof(irq_desc));
for(i=0; i < MAX_HANDLERS; i++)
{
- irq_desc[i].handler = (rt_isr_handler_t)rt_hw_interrupt_handler;
- irq_desc[i].param = RT_NULL;
+ irq_desc[i].handler = rt_hw_interrupt_handler;
vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + i*4);
vect_cntl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + i*4);
@@ -94,7 +96,7 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
old_handler = irq_desc[vector].handler;
if (handler != RT_NULL)
{
- irq_desc[vector].handler = (rt_isr_handler_t)handler;
+ irq_desc[vector].handler = handler;
irq_desc[vector].param = param;
}
}
diff --git a/libcpu/arm/lpc24xx/trap.c b/libcpu/arm/lpc24xx/trap.c
index 53ff13b4eb..71d88101fc 100644
--- a/libcpu/arm/lpc24xx/trap.c
+++ b/libcpu/arm/lpc24xx/trap.c
@@ -126,7 +126,7 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
}
extern rt_isr_handler_t isr_table[];
-void rt_hw_trap_irq()
+void rt_hw_trap_irq(void)
{
int irqno;
struct rt_irq_desc* irq;
@@ -139,7 +139,7 @@ void rt_hw_trap_irq()
irq->handler(irqno, irq->param);
}
-void rt_hw_trap_fiq()
+void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
diff --git a/libcpu/arm/s3c24x0/interrupt.c b/libcpu/arm/s3c24x0/interrupt.c
index 18cdbaa09f..df0c1406d3 100644
--- a/libcpu/arm/s3c24x0/interrupt.c
+++ b/libcpu/arm/s3c24x0/interrupt.c
@@ -10,9 +10,11 @@
* Change Logs:
* Date Author Notes
* 2006-03-13 Bernard first version
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
+#include <rthw.h>
#include "s3c24x0.h"
#define MAX_HANDLERS 32
@@ -20,7 +22,7 @@
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
-rt_isr_handler_t isr_table[MAX_HANDLERS];
+struct rt_irq_desc isr_table[MAX_HANDLERS];
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
@@ -29,10 +31,9 @@ rt_uint32_t rt_thread_switch_interrupt_flag;
*/
/*@{*/
-rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
+static void rt_hw_interrupt_handle(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
- return RT_NULL;
}
/**
@@ -40,37 +41,38 @@ rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
*/
void rt_hw_interrupt_init(void)
{
- register rt_uint32_t idx;
+ register rt_uint32_t idx;
- /* all clear source pending */
- SRCPND = 0x0;
+ /* all clear source pending */
+ SRCPND = 0x0;
- /* all clear sub source pending */
- SUBSRCPND = 0x0;
+ /* all clear sub source pending */
+ SUBSRCPND = 0x0;
- /* all=IRQ mode */
- INTMOD = 0x0;
+ /* all=IRQ mode */
+ INTMOD = 0x0;
- /* all interrupt disabled include global bit */
- INTMSK = BIT_ALLMSK;
+ /* all interrupt disabled include global bit */
+ INTMSK = BIT_ALLMSK;
- /* all sub interrupt disable */
- INTSUBMSK = BIT_SUB_ALLMSK;
+ /* all sub interrupt disable */
+ INTSUBMSK = BIT_SUB_ALLMSK;
- /* all clear interrupt pending */
- INTPND = BIT_ALLMSK;
+ /* all clear interrupt pending */
+ INTPND = BIT_ALLMSK;
- /* init exceptions table */
- for(idx=0; idx < MAX_HANDLERS; idx++)
- {
- isr_table[idx] = (rt_isr_handler_t)rt_hw_interrupt_handle;
- }
+ /* init exceptions table */
+ rt_memset(isr_table, 0x00, sizeof(isr_table));
+ for(idx=0; idx < MAX_HANDLERS; idx++)
+ {
+ isr_table[idx].handler = rt_hw_interrupt_handle;
+ }
- /* init interrupt nest, and context in thread sp */
- rt_interrupt_nest = 0;
- rt_interrupt_from_thread = 0;
- rt_interrupt_to_thread = 0;
- rt_thread_switch_interrupt_flag = 0;
+ /* init interrupt nest, and context in thread sp */
+ rt_interrupt_nest = 0;
+ rt_interrupt_from_thread = 0;
+ rt_interrupt_to_thread = 0;
+ rt_thread_switch_interrupt_flag = 0;
}
/**
@@ -105,13 +107,26 @@ void rt_hw_interrupt_umask(int vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
-void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
+rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
+ void *param, char *name)
{
- if(vector < MAX_HANDLERS)
- {
- if (old_handler != RT_NULL) *old_handler = isr_table[vector];
- if (new_handler != RT_NULL) isr_table[vector] = new_handler;
- }
+ rt_isr_handler_t old_handler = RT_NULL;
+
+ if(vector < MAX_HANDLERS)
+ {
+ old_handler = isr_table[vector].handler;
+
+ if (handler != RT_NULL)
+ {
+#ifdef RT_USING_INTERRUPT_INFO
+ rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
+#endif /* RT_USING_INTERRUPT_INFO */
+ isr_table[vector].handler = handler;
+ isr_table[vector].param = param;
+ }
+ }
+
+ return old_handler;
}
/*@}*/
diff --git a/libcpu/arm/s3c24x0/trap.c b/libcpu/arm/s3c24x0/trap.c
index bdeae9aab0..f1c81768c9 100644
--- a/libcpu/arm/s3c24x0/trap.c
+++ b/libcpu/arm/s3c24x0/trap.c
@@ -12,6 +12,7 @@
* 2006-03-13 Bernard first version
* 2006-05-27 Bernard add skyeye support
* 2007-11-19 Yi.Qiu fix rt_hw_trap_irq function
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
@@ -140,29 +141,35 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
rt_hw_cpu_shutdown();
}
-extern rt_isr_handler_t isr_table[];
+extern struct rt_irq_desc isr_table[];
-void rt_hw_trap_irq()
+void rt_hw_trap_irq(void)
{
- unsigned long intstat;
- rt_isr_handler_t isr_func;
+ unsigned long irq;
+ rt_isr_handler_t isr_func;
+ void *param;
- intstat = INTOFFSET;
+ irq = INTOFFSET;
- if (intstat == INTGLOBAL) return;
+ if (irq == INTGLOBAL) return;
- /* get interrupt service routine */
- isr_func = isr_table[intstat];
+ /* get interrupt service routine */
+ isr_func = isr_table[irq].handler;
+ param = isr_table[irq].param;
- /* turn to interrupt service routine */
- isr_func(intstat);
+ /* turn to interrupt service routine */
+ isr_func(irq, param);
- /* clear pending register */
- /* note: must be the last, if not, may repeat*/
- ClearPending(1 << intstat);
+ /* clear pending register */
+ /* note: must be the last, if not, may repeat*/
+ ClearPending(1 << irq);
+
+#ifdef RT_USING_INTERRUPT_INFO
+ isr_table[irq].counter++;
+#endif /* RT_USING_INTERRUPT_INFO */
}
-void rt_hw_trap_fiq()
+void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
diff --git a/libcpu/arm/sep4020/interrupt.c b/libcpu/arm/sep4020/interrupt.c
index 8ed22dc816..88130c1a33 100644
--- a/libcpu/arm/sep4020/interrupt.c
+++ b/libcpu/arm/sep4020/interrupt.c
@@ -10,9 +10,11 @@
* Change Logs:
* Date Author Notes
* 2006-03-13 Bernard first version
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
+#include <rthw.h>
#include <sep4020.h>
#define MAX_HANDLERS 32
@@ -20,7 +22,7 @@
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
-rt_isr_handler_t isr_table[MAX_HANDLERS];
+struct rt_irq_desc isr_table[MAX_HANDLERS];
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
@@ -38,44 +40,45 @@ rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
/**
* This function will initialize hardware interrupt
*/
-void rt_hw_interrupt_init()
+void rt_hw_interrupt_init(void)
{
- register rt_uint32_t idx;
+ register rt_uint32_t idx;
- /*Make sure all intc registers in proper state*/
+ /*Make sure all intc registers in proper state*/
- /*mask all the irq*/
- *(RP)(INTC_IMR) = 0xFFFFFFFF;
+ /*mask all the irq*/
+ *(RP)(INTC_IMR) = 0xFFFFFFFF;
- /*enable all the irq*/
- *(RP)(INTC_IER) = 0XFFFFFFFF;
+ /*enable all the irq*/
+ *(RP)(INTC_IER) = 0XFFFFFFFF;
- /*Dont use any forced irq*/
- *(RP)(INTC_IFR) = 0x0;
+ /*Dont use any forced irq*/
+ *(RP)(INTC_IFR) = 0x0;
- /*Disable all the fiq*/
- *(RP)(INTC_FIER) = 0x0;
+ /*Disable all the fiq*/
+ *(RP)(INTC_FIER) = 0x0;
- /*Mask all the fiq*/
- *(RP)(INTC_FIMR) = 0x0F;
+ /*Mask all the fiq*/
+ *(RP)(INTC_FIMR) = 0x0F;
- /*Dont use forced fiq*/
- *(RP)(INTC_FIFR) = 0x0;
+ /*Dont use forced fiq*/
+ *(RP)(INTC_FIFR) = 0x0;
- /*Intrrupt priority register*/
- *(RP)(INTC_IPLR) = 0x0;
+ /*Intrrupt priority register*/
+ *(RP)(INTC_IPLR) = 0x0;
- /* init exceptions table */
- for(idx=0; idx < MAX_HANDLERS; idx++)
- {
- isr_table[idx] = (rt_isr_handler_t)rt_hw_interrupt_handle;
- }
+ /* init exceptions table */
+ rt_memset(isr_table, 0x00, sizeof(isr_table));
+ for(idx=0; idx < MAX_HANDLERS; idx++)
+ {
+ isr_table[idx].handler = rt_hw_interrupt_handle;
+ }
- /* init interrupt nest, and context in thread sp */
- rt_interrupt_nest = 0;
- rt_interrupt_from_thread = 0;
- rt_interrupt_to_thread = 0;
- rt_thread_switch_interrupt_flag = 0;
+ /* init interrupt nest, and context in thread sp */
+ rt_interrupt_nest = 0;
+ rt_interrupt_from_thread = 0;
+ rt_interrupt_to_thread = 0;
+ rt_thread_switch_interrupt_flag = 0;
}
/**
@@ -108,15 +111,26 @@ void rt_hw_interrupt_umask(rt_uint32_t vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
-void rt_hw_interrupt_install(rt_uint32_t vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
+rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
+ void *param, char *name)
{
- if(vector < MAX_HANDLERS)
- {
- if (*old_handler != RT_NULL)
- *old_handler = isr_table[vector];
- if (new_handler != RT_NULL)
- isr_table[vector] = new_handler;
- }
+ rt_isr_handler_t old_handler = RT_NULL;
+
+ if(vector < MAX_HANDLERS)
+ {
+ old_handler = isr_table[vector].handler;
+
+ if (handler != RT_NULL)
+ {
+#ifdef RT_USING_INTERRUPT_INFO
+ rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
+#endif /* RT_USING_INTERRUPT_INFO */
+ isr_table[vector].handler = handler;
+ isr_table[vector].param = param;
+ }
+ }
+
+ return old_handler;
}
/*@}*/
diff --git a/libcpu/arm/sep4020/trap.c b/libcpu/arm/sep4020/trap.c
index e7a6e369f9..33da0d9e98 100644
--- a/libcpu/arm/sep4020/trap.c
+++ b/libcpu/arm/sep4020/trap.c
@@ -12,6 +12,7 @@
* 2006-03-13 Bernard first version
* 2006-05-27 Bernard add skyeye support
* 2007-11-19 Yi.Qiu fix rt_hw_trap_irq function
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
@@ -131,31 +132,38 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
rt_hw_cpu_shutdown();
}
-extern rt_isr_handler_t isr_table[];
+extern struct rt_irq_desc isr_table[];
-void rt_hw_trap_irq()
+void rt_hw_trap_irq(void)
{
- unsigned long intstat;
- rt_uint32_t i = 0;
- rt_isr_handler_t isr_func;
+ unsigned long intstat;
+ rt_uint32_t irq = 0;
+ rt_isr_handler_t isr_func;
+ void *param;
- /*Get the final intrrupt source*/
- intstat = *(RP)(INTC_IFSR);;
+ /*Get the final intrrupt source*/
+ intstat = *(RP)(INTC_IFSR);;
- /*Shift to get the intrrupt number*/
- while(intstat != 1)
- {
- intstat = intstat >> 1;
- i++;
- }
- /* get interrupt service routine */
- isr_func = isr_table[i];
+ /*Shift to get the intrrupt number*/
+ while(intstat != 1)
+ {
+ intstat = intstat >> 1;
+ irq++;
+ }
- /* turn to interrupt service routine */
- isr_func(i);
+ /* get interrupt service routine */
+ isr_func = isr_table[irq].isr_handle;
+ param = isr_table[irq].param;
+
+ /* turn to interrupt service routine */
+ isr_func(irq, param);
+
+#ifdef RT_USING_INTERRUPT_INFO
+ isr_table[irq].counter++;
+#endif /* RT_USING_INTERRUPT_INFO */
}
-void rt_hw_trap_fiq()
+void rt_hw_trap_fiq(void)
{
rt_kprintf("fast interrupt request\n");
}
diff --git a/libcpu/mips/jz47xx/interrupt.c b/libcpu/mips/jz47xx/interrupt.c
index f9ada3254a..0ea4827ee2 100644
--- a/libcpu/mips/jz47xx/interrupt.c
+++ b/libcpu/mips/jz47xx/interrupt.c
@@ -90,7 +90,9 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector,
{
old_handler = irq_handle_table[vector].handler;
+#ifdef RT_USING_INTERRUPT_INFO
rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX);
+#endif /* RT_USING_INTERRUPT_INFO */
irq_handle_table[vector].handler = handler;
irq_handle_table[vector].param = param;
}
@@ -118,6 +120,10 @@ void rt_interrupt_dispatch(void *ptreg)
/* do interrupt */
(*irq_func)(i, irq_handle_table[i].param);
+#ifdef RT_USING_INTERRUPT_INFO
+ irq_handle_table[i].counter++;
+#endif /* RT_USING_INTERRUPT_INFO */
+
/* ack interrupt */
INTC_IPR = (1 << i);
}
diff --git a/libcpu/mips/loongson/interrupt.c b/libcpu/mips/loongson/interrupt.c
index 4b97068a70..7e59ec950d 100644
--- a/libcpu/mips/loongson/interrupt.c
+++ b/libcpu/mips/loongson/interrupt.c
@@ -10,8 +10,11 @@
* Change Logs:
* Date Author Notes
* 2010-10-15 Bernard first version
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
+
#include <rtthread.h>
+#include <rthw.h>
#include "soc3210.h"
#define MAX_INTR 32
@@ -20,17 +23,17 @@ extern rt_uint32_t rt_interrupt_nest;
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
-static rt_isr_handler_t irq_handle_table[MAX_INTR];
+static struct rt_irq_desc irq_handle_table[MAX_INTR];
void rt_interrupt_dispatch(void *ptreg);
void rt_hw_timer_handler();
/**
* @addtogroup Loongson SoC3210
*/
-
+
/*@{*/
-void rt_hw_interrupt_handler(int vector)
+static void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -40,11 +43,12 @@ void rt_hw_interrupt_handler(int vector)
*/
void rt_hw_interrupt_init(void)
{
- rt_int32_t index;
+ rt_int32_t idx;
- for (index = 0; index < MAX_INTR; index ++)
+ rt_memset(irq_handle_table, 0x00, sizeof(irq_handle_table));
+ for (idx = 0; idx < MAX_INTR; idx ++)
{
- irq_handle_table[index] = (rt_isr_handler_t)rt_hw_interrupt_handler;
+ irq_handle_table[idx].handler = rt_hw_interrupt_handler;
}
/* init interrupt nest, and context in thread sp */
@@ -79,52 +83,70 @@ void rt_hw_interrupt_umask(int vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
-void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
+rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
+ void *param, char *name)
{
- if (vector >= 0 && vector < MAX_INTR)
- {
- if (old_handler != RT_NULL)
- *old_handler = irq_handle_table[vector];
- if (new_handler != RT_NULL)
- irq_handle_table[vector] = (rt_isr_handler_t)new_handler;
- }
+ rt_isr_handler_t old_handler = RT_NULL;
+
+ if(vector < MAX_INTR)
+ {
+ old_handler = irq_handle_table[vector].handler;
+
+ if (handler != RT_NULL)
+ {
+#ifdef RT_USING_INTERRUPT_INFO
+ rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX);
+#endif /* RT_USING_INTERRUPT_INFO */
+ irq_handle_table[vector].handler = handler;
+ irq_handle_table[vector].param = param;
+ }
+ }
+
+ return old_handler;
}
void rt_interrupt_dispatch(void *ptreg)
{
- int i;
- rt_isr_handler_t irq_func;
- static rt_uint32_t status = 0;
- rt_uint32_t c0_status;
+ int irq;
+ void *param;
+ rt_isr_handler_t irq_func;
+ static rt_uint32_t status = 0;
+ rt_uint32_t c0_status;
- /* check os timer */
- c0_status = read_c0_status();
- if (c0_status & 0x8000)
- {
- rt_hw_timer_handler();
- }
+ /* check os timer */
+ c0_status = read_c0_status();
+ if (c0_status & 0x8000)
+ {
+ rt_hw_timer_handler();
+ }
- if (c0_status & 0x0400)
- {
- /* the hardware interrupt */
- status |= INT_ISR;
- if (!status) return;
+ if (c0_status & 0x0400)
+ {
+ /* the hardware interrupt */
+ status |= INT_ISR;
+ if (!status) return;
- for (i = MAX_INTR; i > 0; --i)
- {
- if ((status & (1<<i)))
- {
- status &= ~(1<<i);
- irq_func = irq_handle_table[i];
+ for (irq = MAX_INTR; irq > 0; --irq)
+ {
+ if ((status & (1 << irq)))
+ {
+ status &= ~(1 << irq);
- /* do interrupt */
- (*irq_func)(i);
+ irq_func = irq_handle_table[irq].handler;
+ param = irq_handle_table[irq].param;
- /* ack interrupt */
- INT_CLR = (1 << i);
- }
- }
- }
+ /* do interrupt */
+ (*irq_func)(irq, param);
+
+#ifdef RT_USING_INTERRUPT_INFO
+ irq_handle_table[irq].counter++;
+#endif /* RT_USING_INTERRUPT_INFO */
+
+ /* ack interrupt */
+ INT_CLR = (1 << irq);
+ }
+ }
+ }
}
/*@}*/
diff --git a/libcpu/mips/loongson_1b/interrupt.c b/libcpu/mips/loongson_1b/interrupt.c
index 63240053a8..c5b4bad038 100644
--- a/libcpu/mips/loongson_1b/interrupt.c
+++ b/libcpu/mips/loongson_1b/interrupt.c
@@ -11,9 +11,11 @@
* Date Author Notes
* 2010-10-15 Bernard first version
* 2010-10-15 lgnq modified for LS1B
+ * 2013-03-29 aozima Modify the interrupt interface implementations.
*/
#include <rtthread.h>
+#include <rthw.h>
#include "ls1b.h"
#define MAX_INTR 32
@@ -23,7 +25,7 @@ rt_uint32_t rt_interrupt_from_thread;
rt_uint32_t rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
-static rt_isr_handler_t irq_handle_table[MAX_INTR];
+static struct rt_irq_desc irq_handle_table[MAX_INTR];
void rt_interrupt_dispatch(void *ptreg);
void rt_hw_timer_handler();
@@ -36,7 +38,7 @@ static struct ls1b_intc_regs volatile *ls1b_hw0_icregs
/*@{*/
-void rt_hw_interrupt_handler(int vector)
+static void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -46,7 +48,7 @@ void rt_hw_interrupt_handler(int vector)
*/
void rt_hw_interrupt_init(void)
{
- rt_int32_t index;
+ rt_int32_t idx;
/* pci active low */
ls1b_hw0_icregs->int_pol = -1; //must be done here 20110802 lgnq
@@ -55,9 +57,10 @@ void rt_hw_interrupt_init(void)
/* mask all interrupts */
(ls1b_hw0_icregs+0)->int_clr = 0xffffffff;
- for (index = 0; index < MAX_INTR; index ++)
+ rt_memset(irq_handle_table, 0x00, sizeof(irq_handle_table));
+ for (idx = 0; idx < MAX_INTR; idx ++)
{
- irq_handle_table[index] = (rt_isr_handler_t)rt_hw_interrupt_handler;
+ irq_handle_table[idx].handler = rt_hw_interrupt_handler;
}
/* init interrupt nest, and context in thread sp */
@@ -92,20 +95,32 @@ void rt_hw_interrupt_umask(int vector)
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
-void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
+rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
+ void *param, char *name)
{
+ rt_isr_handler_t old_handler = RT_NULL;
+
if (vector >= 0 && vector < MAX_INTR)
{
- if (old_handler != RT_NULL)
- *old_handler = irq_handle_table[vector];
- if (new_handler != RT_NULL)
- irq_handle_table[vector] = (rt_isr_handler_t)new_handler;
- }
+ old_handler = irq_handle_table[vector].handler;
+
+ if (handler != RT_NULL)
+ {
+#ifdef RT_USING_INTERRUPT_INFO
+ rt_strncpy(irq_handle_table[vector].name, name, RT_NAME_MAX);
+#endif /* RT_USING_INTERRUPT_INFO */
+ irq_handle_table[vector].handler = handler;
+ irq_handle_table[vector].param = param;
+ }
+ }
+
+ return old_handler;
}
void rt_interrupt_dispatch(void *ptreg)
{
- int i;
+ int irq;
+ void *param;
rt_isr_handler_t irq_func;
static rt_uint32_t status = 0;
rt_uint32_t c0_status;
@@ -134,18 +149,24 @@ void rt_interrupt_dispatch(void *ptreg)
if (!status)
return;
- for (i = MAX_INTR; i > 0; --i)
+ for (irq = MAX_INTR; irq > 0; --irq)
{
- if ((status & (1<<i)))
+ if ((status & (1 << irq)))
{
- status &= ~(1<<i);
- irq_func = irq_handle_table[i];
+ status &= ~(1 << irq);
+
+ irq_func = irq_handle_table[irq].handler;
+ param = irq_handle_table[irq].param;
/* do interrupt */
- (*irq_func)(i);
+ (*irq_func)(irq, param);
+
+#ifdef RT_USING_INTERRUPT_INFO
+ irq_handle_table[irq].counter++;
+#endif /* RT_USING_INTERRUPT_INFO */
/* ack interrupt */
- ls1b_hw0_icregs->int_clr |= (1 << i);
+ ls1b_hw0_icregs->int_clr |= (1 << irq);
}
}
}