Fix some interrupt handling issues

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@37 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-03-05 14:38:43 +00:00
parent eaa8134b71
commit d62a01ebfa
3 changed files with 18 additions and 45 deletions

View File

@ -142,8 +142,8 @@ extern "C" {
#define EXTERN extern #define EXTERN extern
#endif #endif
EXTERN irqstate_t irqsave(void) __naked; EXTERN irqstate_t irqsave(void);
EXTERN void irqrestore(irqstate_t flags) __naked; EXTERN void irqrestore(irqstate_t flags);
#undef EXTERN #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -84,37 +84,31 @@
.org PM2_VECTOR_EXTINT0 .org PM2_VECTOR_EXTINT0
push acc push acc
push ie
mov a, #EXT_INT0_IRQ mov a, #EXT_INT0_IRQ
ljmp _up_interrupt ljmp _up_interrupt
.org PM2_VECTOR_TIMER0 .org PM2_VECTOR_TIMER0
push acc push acc
push ie
mov a, #TIMER0_IRQ mov a, #TIMER0_IRQ
ljmp _up_interrupt ljmp _up_interrupt
.org PM2_VECTOR_EXTINT1 .org PM2_VECTOR_EXTINT1
push acc push acc
push ie
mov a, #EXT_INT1_IRQ mov a, #EXT_INT1_IRQ
ljmp _up_interrupt ljmp _up_interrupt
.org PM2_VECTOR_TIMER1 .org PM2_VECTOR_TIMER1
push acc push acc
push ie
mov a, #TIMER1_IRQ mov a, #TIMER1_IRQ
ljmp _up_interrupt ljmp _up_interrupt
.org PM2_VECTOR_UART .org PM2_VECTOR_UART
push acc push acc
push ie
mov a, #UART_IRQ mov a, #UART_IRQ
ljmp _up_interrupt ljmp _up_interrupt
.org PM2_VECTOR_TIMER2 .org PM2_VECTOR_TIMER2
push acc push acc
push ie
mov a, #TIMER2_IRQ mov a, #TIMER2_IRQ
ljmp _up_interrupt ljmp _up_interrupt
@ -136,7 +130,7 @@ start:
* Description: * Description:
* All interrupts vector to this point with: * 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 * (2) the IRQ number in the accumulator
* *
************************************************************/ ************************************************************/
@ -151,9 +145,8 @@ _up_interrupt:
ar0 = 0x00 ar0 = 0x00
ar1 = 0x01 ar1 = 0x01
/* Push ACC and IE. Then disable interrupts */ /* ACC already on the stack; push IE. Then disable interrupts */
push acc
push ie push ie
clr ea clr ea

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <8052.h>
#include "up_internal.h" #include "up_internal.h"
/************************************************************ /************************************************************
@ -68,6 +69,11 @@
void up_irqinitialize(void) 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 irqstate_t ret = IE;
mov ie, dpl EA = 0;
clr ea return ret;
ret
_endasm;
} }
/************************************************************ /************************************************************
@ -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 */ IE = flags;
_asm
mov ie, dpl
ret
_endasm;
} }
/************************************************************ /************************************************************
@ -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) void up_disable_irq(int irq)
{ {
if ((unsigned)irq < NR_IRQS) 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) void up_enable_irq(int irq)
{ {
if ((unsigned)irq < NR_IRQS) if ((unsigned)irq < NR_IRQS)
{ {
_up_enable_irq(~(1 << irq)); IE &= ~(1 << irq);
} }
} }