From d62a01ebfad2e224baf3d6f3d6058bac0e31c8c3 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 5 Mar 2007 14:38:43 +0000 Subject: [PATCH] Fix some interrupt handling issues git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@37 42af7a65-404d-4744-a932-0658087f49c3 --- arch/pjrc-8051/include/irq.h | 4 +-- arch/pjrc-8051/src/up_head.S | 11 ++------- arch/pjrc-8051/src/up_irq.c | 48 +++++++++++------------------------- 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/arch/pjrc-8051/include/irq.h b/arch/pjrc-8051/include/irq.h index c0a782967c..8ca78adc88 100644 --- a/arch/pjrc-8051/include/irq.h +++ b/arch/pjrc-8051/include/irq.h @@ -142,8 +142,8 @@ extern "C" { #define EXTERN extern #endif -EXTERN irqstate_t irqsave(void) __naked; -EXTERN void irqrestore(irqstate_t flags) __naked; +EXTERN irqstate_t irqsave(void); +EXTERN void irqrestore(irqstate_t flags); #undef EXTERN #ifdef __cplusplus diff --git a/arch/pjrc-8051/src/up_head.S b/arch/pjrc-8051/src/up_head.S index 4aecda48a2..662b6b18e1 100644 --- a/arch/pjrc-8051/src/up_head.S +++ b/arch/pjrc-8051/src/up_head.S @@ -84,37 +84,31 @@ .org PM2_VECTOR_EXTINT0 push acc - push ie mov a, #EXT_INT0_IRQ ljmp _up_interrupt .org PM2_VECTOR_TIMER0 push acc - push ie mov a, #TIMER0_IRQ ljmp _up_interrupt .org PM2_VECTOR_EXTINT1 push acc - push ie mov a, #EXT_INT1_IRQ ljmp _up_interrupt .org PM2_VECTOR_TIMER1 push acc - push ie mov a, #TIMER1_IRQ ljmp _up_interrupt .org PM2_VECTOR_UART push acc - push ie mov a, #UART_IRQ ljmp _up_interrupt .org PM2_VECTOR_TIMER2 push acc - push ie mov a, #TIMER2_IRQ ljmp _up_interrupt @@ -136,7 +130,7 @@ start: * Description: * All interrupts vector to this point with: * - * (1) acc and ie on the stack and + * (1) acc on the stack and * (2) the IRQ number in the accumulator * ************************************************************/ @@ -151,9 +145,8 @@ _up_interrupt: ar0 = 0x00 ar1 = 0x01 - /* Push ACC and IE. Then disable interrupts */ + /* ACC already on the stack; push IE. Then disable interrupts */ - push acc push ie clr ea diff --git a/arch/pjrc-8051/src/up_irq.c b/arch/pjrc-8051/src/up_irq.c index c524fe3e7e..7726231670 100644 --- a/arch/pjrc-8051/src/up_irq.c +++ b/arch/pjrc-8051/src/up_irq.c @@ -40,6 +40,7 @@ #include #include #include +#include <8052.h> #include "up_internal.h" /************************************************************ @@ -68,6 +69,11 @@ void up_irqinitialize(void) { + /* Enable interrupts globally, but disable all interrupt + * sources. + */ + + IE = 0x80; } /************************************************************ @@ -78,13 +84,11 @@ void up_irqinitialize(void) * ************************************************************/ -irqstate_t irqsave(void) _naked +irqstate_t irqsave(void) { - _asm - mov ie, dpl - clr ea - ret - _endasm; + irqstate_t ret = IE; + EA = 0; + return ret; } /************************************************************ @@ -95,13 +99,9 @@ irqstate_t irqsave(void) _naked * ************************************************************/ -void irqrestore(irqstate_t flags) __naked +void irqrestore(irqstate_t flags) { - flags; /* Avoid compiler warning about unused argument */ - _asm - mov ie, dpl - ret - _endasm; + IE = flags; } /************************************************************ @@ -112,21 +112,11 @@ void irqrestore(irqstate_t flags) __naked * ************************************************************/ -static void _up_disable_irq(ubyte iebit) __naked -{ - _asm - mov a, ie - orl a, dpl - mov ie, a - ret - _endasm; -} - void up_disable_irq(int irq) { if ((unsigned)irq < NR_IRQS) { - _up_disable_irq(1 << irq); + IE |= (1 << irq); } } @@ -138,20 +128,10 @@ void up_disable_irq(int irq) * ************************************************************/ -static void _up_enable_irq(ubyte iebit) __naked -{ - _asm - mov a, ie - anl a, dpl - mov ie, a - ret - _endasm; -} - void up_enable_irq(int irq) { if ((unsigned)irq < NR_IRQS) { - _up_enable_irq(~(1 << irq)); + IE &= ~(1 << irq); } }