瀏覽代碼

fix interrupt compiling issue in PPC

Bernard Xiong 12 年之前
父節點
當前提交
edef109d76
共有 2 個文件被更改,包括 18 次插入14 次删除
  1. 15 11
      libcpu/ppc/ppc405/interrupt.c
  2. 3 3
      libcpu/ppc/ppc405/serial.c

+ 15 - 11
libcpu/ppc/ppc405/interrupt.c

@@ -12,7 +12,7 @@
  * 2009-01-05     Bernard      first version
  */
 
-#include <rtthread.h>
+#include <rthw.h>
 #include <asm/ppc4xx.h>
 #include <asm/processor.h>
 
@@ -21,12 +21,12 @@ extern volatile rt_uint8_t rt_interrupt_nest;
 
 /* exception and interrupt handler table */
 #define MAX_HANDLERS 32
-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_interrput_flag;
 
-rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector)
+rt_isr_handler_t rt_hw_interrupt_handler(rt_uint32_t vector, void* param)
 {
 	rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
 	return RT_NULL;
@@ -42,9 +42,9 @@ void  uic_int_handler (unsigned int vec)
 	rt_interrupt_enter();
 
     /* Allow external interrupts to the CPU. */
-    if (isr_table [vec] != 0)
+    if (isr_table [vec].handler != 0)
     {
-       (*isr_table[vec])(vec);
+       (*isr_table[vec].handler)(vec, isr_table[vec].param);
     }
     uic_irq_ack(vec);
 	
@@ -78,21 +78,24 @@ void uic_interrupt(rt_uint32_t uic_base, int vec_base)
 	}
 }
 
-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 new_handler, 
+    void* param, char* name)
 {
     int	intVal;
+    rt_isr_handler_t old_handler;
 
     if (((int)vector < 0)  || ((int) vector >= MAX_HANDLERS)) 
 	{
-        return;   /*  out of range  */
+        return RT_NULL;   /*  out of range  */
 	}
    
     /* install the handler in the system interrupt table  */
     intVal = rt_hw_interrupt_disable (); /* lock interrupts to prevent races */
 
-	if (*old_handler != RT_NULL) *old_handler = isr_table[vector];
-	if (new_handler != RT_NULL) isr_table[vector] = new_handler;
-
+    old_handler = isr_table[vector].handler;
+    isr_table[vector].handler = new_handler;
+    isr_table[vector].param = param;
+    
     rt_hw_interrupt_enable (intVal);
 }
 
@@ -120,7 +123,8 @@ void rt_hw_interrupt_init()
 	/* set default interrupt handler */
     for (vector = 0; vector < MAX_HANDLERS; vector++)
     {
-	    isr_table [vector] = (rt_isr_handler_t)rt_hw_interrupt_handle;
+	    isr_table [vector].handler = (rt_isr_handler_t)rt_hw_interrupt_handler;
+        isr_table [vector].param = RT_NULL;
     }
 
 	/* initialize interrupt nest, and context in thread sp */

+ 3 - 3
libcpu/ppc/ppc405/serial.c

@@ -220,12 +220,12 @@ void rt_serial_set_baudrate(struct rt_ppc405_serial* device)
 	out_8((rt_uint8_t *)device->hw_base + UART_DLM, bdiv >> 8); /* set baudrate divisor */
 }
 
-void rt_serial_isr(int irqno)
+void rt_serial_isr(int irqno, void* param)
 {
 	unsigned char status;
 	struct rt_ppc405_serial *device;
 
-	device = (struct rt_ppc405_serial*) &ppc405_serial;
+	device = (struct rt_ppc405_serial*) param;
 	status = in_8((rt_uint8_t *)device->hw_base + UART_LSR);
 
 	if (status & 0x01)
@@ -289,7 +289,7 @@ void rt_hw_serial_init(void)
 	device->hw_base = UART0_BASE;
 	device->baudrate = 115200;
 	device->irqno = VECNUM_U0;
-	rt_hw_interrupt_install(device->irqno, rt_serial_isr, RT_NULL); /* install isr */
+	rt_hw_interrupt_install(device->irqno, rt_serial_isr, device, "serial"); /* install isr */
 
 	rt_memset(device->rx_buffer, 0, sizeof(device->rx_buffer));
 	device->read_index = device->save_index = 0;