summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-03-30 08:15:27 +0800
committerBernard Xiong <[email protected]>2013-03-30 08:15:27 +0800
commit608074deafecc96c26e219548a74e73f1f594b6d (patch)
tree417d736d6ab8b29c3a454402a24c63b503d1ae8e /libcpu
parentaaf018685290517b8334b6f94211a2ff1705cfd1 (diff)
update to interrupt description
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/arm/AT91SAM7X/interrupt.c34
-rw-r--r--libcpu/arm/AT91SAM7X/trap.c9
-rw-r--r--libcpu/arm/lpc24xx/interrupt.c54
-rw-r--r--libcpu/arm/lpc24xx/trap.c13
4 files changed, 78 insertions, 32 deletions
diff --git a/libcpu/arm/AT91SAM7X/interrupt.c b/libcpu/arm/AT91SAM7X/interrupt.c
index d3cbbcda2e..1aced87b29 100644
--- a/libcpu/arm/AT91SAM7X/interrupt.c
+++ b/libcpu/arm/AT91SAM7X/interrupt.c
@@ -12,11 +12,14 @@
* 2006-08-23 Bernard first version
*/
-#include <rtthread.h>
+#include <rthw.h>
#include "AT91SAM7X256.h"
#define MAX_HANDLERS 32
+/* exception and interrupt handler table */
+struct rt_irq_desc irq_desc[MAX_HANDLERS];
+
extern rt_uint32_t rt_interrupt_nest;
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
@@ -39,6 +42,13 @@ void rt_hw_interrupt_init()
{
rt_base_t index;
+ /* init exceptions table */
+ for(index=0; index < MAX_HANDLERS; index++)
+ {
+ irq_desc[index].handler = (rt_isr_handler_t)rt_hw_interrupt_handler;
+ irq_desc[index].param = RT_NULL;
+ }
+
for (index = 0; index < MAX_HANDLERS; index ++)
{
AT91C_BASE_AIC->AIC_SVR[index] = (rt_uint32_t)rt_hw_interrupt_handler;
@@ -76,16 +86,28 @@ 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 parameter for interrupt service routine
+ * @name unused.
+ *
+ * @return the 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)
{
+ rt_isr_handler_t old_handler = RT_NULL;
+
if(vector >= 0 && vector < MAX_HANDLERS)
{
- if (old_handler != RT_NULL) *old_handler = (rt_isr_handler_t)AT91C_BASE_AIC->AIC_SVR[vector];
- if (new_handler != RT_NULL) AT91C_BASE_AIC->AIC_SVR[vector] = (rt_uint32_t)new_handler;
+ old_handler = irq_desc[vector].handler;
+ if (handler != RT_NULL)
+ {
+ irq_desc[vector].handler = (rt_isr_handler_t)handler;
+ irq_desc[vector].param = param;
+ }
}
+
+ return old_handler;
}
/*@}*/
diff --git a/libcpu/arm/AT91SAM7X/trap.c b/libcpu/arm/AT91SAM7X/trap.c
index 2e137fc009..4b21f81c1c 100644
--- a/libcpu/arm/AT91SAM7X/trap.c
+++ b/libcpu/arm/AT91SAM7X/trap.c
@@ -24,9 +24,14 @@
void rt_hw_trap_irq()
{
- rt_isr_handler_t hander = (rt_isr_handler_t)AT91C_BASE_AIC->AIC_IVR;
+ int irqno;
+ extern struct rt_irq_desc irq_desc[];
- hander(AT91C_BASE_AIC->AIC_ISR);
+ /* get interrupt number */
+ irqno = AT91C_BASE_AIC->AIC_ISR;
+
+ /* invoke isr with parameters */
+ irq_desc[irqno].handler(irqno, irq_desc[irqno].param);
/* end of interrupt */
AT91C_BASE_AIC->AIC_EOICR = 0;
diff --git a/libcpu/arm/lpc24xx/interrupt.c b/libcpu/arm/lpc24xx/interrupt.c
index b18c1e10ff..6d64d7a07c 100644
--- a/libcpu/arm/lpc24xx/interrupt.c
+++ b/libcpu/arm/lpc24xx/interrupt.c
@@ -12,24 +12,25 @@
* 2008-12-11 XuXinming first version
*/
-#include <rtthread.h>
+#include <rthw.h>
#include "LPC24xx.h"
#define MAX_HANDLERS 32
+/* exception and interrupt handler table */
+struct rt_irq_desc irq_desc[MAX_HANDLERS];
+
extern rt_uint32_t rt_interrupt_nest;
/* exception and interrupt handler table */
rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
rt_uint32_t rt_thread_switch_interrupt_flag;
-
/**
* @addtogroup LPC2478
*/
/*@{*/
-
-void rt_hw_interrupt_handle(int vector)
+void rt_hw_interrupt_handler(int vector, void *param)
{
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
}
@@ -45,11 +46,15 @@ void rt_hw_interrupt_init()
VICVectAddr = 0;
VICIntSelect = 0;
- for ( i = 0; i < 32; i++ )
+ /* init exceptions table */
+ for(i=0; i < MAX_HANDLERS; i++)
{
- vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + i*4);
- vect_cntl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + i*4);
- *vect_addr = 0x0;
+ irq_desc[i].handler = (rt_isr_handler_t)rt_hw_interrupt_handler;
+ irq_desc[i].param = RT_NULL;
+
+ vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + i*4);
+ vect_cntl = (rt_uint32_t *)(VIC_BASE_ADDR + 0x200 + i*4);
+ *vect_addr = (rt_uint32_t)&irq_desc[i];
*vect_cntl = 0xF;
}
@@ -70,20 +75,31 @@ void rt_hw_interrupt_umask(int vector)
VICIntEnable = (1 << vector);
}
-void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler)
+/**
+ * This function will install a interrupt service routine to a interrupt.
+ * @param vector the interrupt number
+ * @param handler the interrupt service routine to be installed
+ * @param param the parameter for interrupt service routine
+ * @name unused.
+ *
+ * @return the old handler
+ */
+rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
+ void *param, char *name)
{
- rt_uint32_t *vect_addr;
-
- if(vector < MAX_HANDLERS)
- {
- /* find first un-assigned VIC address for the handler */
- vect_addr = (rt_uint32_t *)(VIC_BASE_ADDR + 0x100 + vector*4);
+ rt_isr_handler_t old_handler = RT_NULL;
- /* get old handler */
- if (old_handler != RT_NULL) *old_handler = (rt_isr_handler_t)*vect_addr;
-
- *vect_addr = (rt_uint32_t)new_handler; /* set interrupt vector */
+ if(vector >= 0 && vector < MAX_HANDLERS)
+ {
+ old_handler = irq_desc[vector].handler;
+ if (handler != RT_NULL)
+ {
+ irq_desc[vector].handler = (rt_isr_handler_t)handler;
+ irq_desc[vector].param = param;
+ }
}
+
+ return old_handler;
}
/*@}*/
diff --git a/libcpu/arm/lpc24xx/trap.c b/libcpu/arm/lpc24xx/trap.c
index 1aa58bc0d6..53ff13b4eb 100644
--- a/libcpu/arm/lpc24xx/trap.c
+++ b/libcpu/arm/lpc24xx/trap.c
@@ -128,12 +128,15 @@ void rt_hw_trap_resv(struct rt_hw_register *regs)
extern rt_isr_handler_t isr_table[];
void rt_hw_trap_irq()
{
- rt_isr_handler_t isr_func;
-
- isr_func = (rt_isr_handler_t) VICVectAddr;
+ int irqno;
+ struct rt_irq_desc* irq;
+ extern struct rt_irq_desc irq_desc[];
- /* fixme, how to get interrupt number */
- isr_func(0);
+ irq = (struct rt_irq_desc*) VICVectAddr;
+ irqno = ((rt_uint32_t) irq - (rt_uint32_t) &irq_desc[0])/sizeof(struct rt_irq_desc);
+
+ /* invoke isr */
+ irq->handler(irqno, irq->param);
}
void rt_hw_trap_fiq()