summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-06 23:01:06 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-06 23:01:06 +0000
commit8285ffad2245a53de14c65913b00dab5568f0afc (patch)
treea4707d8f1e51d31b1fc2866c63260bfbf99b1f34 /nuttx/arch/arm
parentdcea5f0360725d2c25b61eefe9db7b2474b26dd6 (diff)
downloadpx4-nuttx-8285ffad2245a53de14c65913b00dab5568f0afc.tar.gz
px4-nuttx-8285ffad2245a53de14c65913b00dab5568f0afc.tar.bz2
px4-nuttx-8285ffad2245a53de14c65913b00dab5568f0afc.zip
current_regs should be volatile; add support for nested interrupts; enable interrupts during syscall processing
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3475 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm')
-rw-r--r--nuttx/arch/arm/include/cortexm3/irq.h14
-rw-r--r--nuttx/arch/arm/src/arm/up_dataabort.c16
-rw-r--r--nuttx/arch/arm/src/arm/up_doirq.c13
-rw-r--r--nuttx/arch/arm/src/arm/up_prefetchabort.c14
-rw-r--r--nuttx/arch/arm/src/c5471/c5471_irq.c4
-rw-r--r--nuttx/arch/arm/src/common/up_internal.h8
-rw-r--r--nuttx/arch/arm/src/cortexm3/up_doirq.c15
-rw-r--r--nuttx/arch/arm/src/cortexm3/up_svcall.c23
-rw-r--r--nuttx/arch/arm/src/dm320/dm320_decodeirq.c12
-rw-r--r--nuttx/arch/arm/src/dm320/dm320_irq.c2
-rw-r--r--nuttx/arch/arm/src/imx/imx_decodeirq.c11
-rw-r--r--nuttx/arch/arm/src/imx/imx_irq.c4
-rw-r--r--nuttx/arch/arm/src/lm3s/lm3s_irq.c2
-rwxr-xr-xnuttx/arch/arm/src/lpc17xx/lpc17_irq.c2
-rw-r--r--nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c12
-rw-r--r--nuttx/arch/arm/src/lpc214x/lpc214x_irq.c4
-rwxr-xr-xnuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c13
-rwxr-xr-xnuttx/arch/arm/src/lpc2378/lpc23xx_irq.c2
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_decodeirq.c10
-rwxr-xr-xnuttx/arch/arm/src/lpc313x/lpc313x_irq.c4
-rwxr-xr-xnuttx/arch/arm/src/sam3u/sam3u_irq.c2
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_irq.c2
-rw-r--r--nuttx/arch/arm/src/str71x/str71x_decodeirq.c13
-rw-r--r--nuttx/arch/arm/src/str71x/str71x_irq.c4
24 files changed, 152 insertions, 54 deletions
diff --git a/nuttx/arch/arm/include/cortexm3/irq.h b/nuttx/arch/arm/include/cortexm3/irq.h
index 5c9ef04c0..063568655 100644
--- a/nuttx/arch/arm/include/cortexm3/irq.h
+++ b/nuttx/arch/arm/include/cortexm3/irq.h
@@ -156,6 +156,13 @@ struct xcptcontext
#ifndef __ASSEMBLY__
+/* Disable IRQs */
+
+static inline void irqdisable(void)
+{
+ __asm__ __volatile__ ("\tcpsid i\n");
+}
+
/* Save the current primask state & disable IRQs */
static inline irqstate_t irqsave(void)
@@ -176,6 +183,13 @@ static inline irqstate_t irqsave(void)
return primask;
}
+/* Enable IRQs */
+
+static inline void irqenable(void)
+{
+ __asm__ __volatile__ ("\tcpsie i\n");
+}
+
/* Restore saved primask state */
static inline void irqrestore(irqstate_t primask)
diff --git a/nuttx/arch/arm/src/arm/up_dataabort.c b/nuttx/arch/arm/src/arm/up_dataabort.c
index 05886e384..c36970c1b 100644
--- a/nuttx/arch/arm/src/arm/up_dataabort.c
+++ b/nuttx/arch/arm/src/arm/up_dataabort.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/arm/up_dataabort.c
*
- * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -103,13 +103,19 @@
void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
{
FAR _TCB *tcb = (FAR _TCB *)g_readytorun.head;
+#ifdef CONFIG_PAGING
+ uint32_t *savestate;
/* Save the saved processor context in current_regs where it can be accessed
* for register dumps and possibly context switching.
*/
+
+ savestate = (uint32_t*)current_regs;
+#endif
current_regs = regs;
+#ifdef CONFIG_PAGING
/* In the NuttX on-demand paging implementation, only the read-only, .text
* section is paged. However, the ARM compiler generated PC-relative data
* fetches from within the .text sections. Also, it is customary to locate
@@ -162,12 +168,16 @@ void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
pg_miss();
- /* Indicate that we are no longer in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
return;
segfault:
+#endif
lldbg("Data abort. PC: %08x FAR: %08x FSR: %08x\n", regs[REG_PC], far, fsr);
PANIC(OSERR_ERREXCEPTION);
}
diff --git a/nuttx/arch/arm/src/arm/up_doirq.c b/nuttx/arch/arm/src/arm/up_doirq.c
index 5c127b75c..1f1c77473 100644
--- a/nuttx/arch/arm/src/arm/up_doirq.c
+++ b/nuttx/arch/arm/src/arm/up_doirq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/arm/up_doirq.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -76,6 +76,8 @@ void up_doirq(int irq, uint32_t *regs)
#ifdef CONFIG_SUPPRESS_INTERRUPTS
PANIC(OSERR_ERREXCEPTION);
#else
+ uint32_t *savestate;
+
/* Nested interrupts are not supported in this implementation. If you want
* implemented nested interrupts, you would have to (1) change the way that
* current regs is handled and (2) the design associated with
@@ -86,7 +88,7 @@ void up_doirq(int irq, uint32_t *regs)
* current_regs is also used to manage interrupt level context switches.
*/
- DEBUGASSERT(current_regs == NULL);
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Mask and acknowledge the interrupt */
@@ -97,9 +99,12 @@ void up_doirq(int irq, uint32_t *regs)
irq_dispatch(irq, regs);
- /* Indicate that we are no long in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
/* Unmask the last interrupt (global interrupts are still disabled) */
diff --git a/nuttx/arch/arm/src/arm/up_prefetchabort.c b/nuttx/arch/arm/src/arm/up_prefetchabort.c
index 2d184bad6..ed3dd91d3 100644
--- a/nuttx/arch/arm/src/arm/up_prefetchabort.c
+++ b/nuttx/arch/arm/src/arm/up_prefetchabort.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/src/up_prefetchabort.c
*
- * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -89,10 +89,15 @@
void up_prefetchabort(uint32_t *regs)
{
+#ifdef CONFIG_PAGING
+ uint32_t *savestate;
+
/* Save the saved processor context in current_regs where it can be accessed
* for register dumps and possibly context switching.
*/
+ savestate = (uint32_t*)current_regs;
+#endif
current_regs = regs;
#ifdef CONFIG_PAGING
@@ -133,9 +138,12 @@ void up_prefetchabort(uint32_t *regs)
pg_miss();
- /* Indicate that we are no longer in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
}
else
#endif
diff --git a/nuttx/arch/arm/src/c5471/c5471_irq.c b/nuttx/arch/arm/src/c5471/c5471_irq.c
index 6906e8f8d..fbeb2e720 100644
--- a/nuttx/arch/arm/src/c5471/c5471_irq.c
+++ b/nuttx/arch/arm/src/c5471/c5471_irq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/c5471/c5471_irq.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/common/up_internal.h b/nuttx/arch/arm/src/common/up_internal.h
index 9fe4464c7..803a6563d 100644
--- a/nuttx/arch/arm/src/common/up_internal.h
+++ b/nuttx/arch/arm/src/common/up_internal.h
@@ -82,11 +82,11 @@
*/
#ifdef CONFIG_ARCH_CORTEXM3
-# define up_savestate(regs) up_copystate(regs, current_regs)
+# define up_savestate(regs) up_copystate(regs, (uint32_t*)current_regs)
# define up_restorestate(regs) (current_regs = regs)
#else
-# define up_savestate(regs) up_copystate(regs, current_regs)
-# define up_restorestate(regs) up_copystate(current_regs, regs)
+# define up_savestate(regs) up_copystate(regs, (uint32_t*)current_regs)
+# define up_restorestate(regs) up_copystate((uint32_t*)current_regs, regs)
#endif
/****************************************************************************
@@ -107,7 +107,7 @@ typedef void (*up_vector_t)(void);
* interrupt processing.
*/
-extern uint32_t *current_regs;
+extern volatile uint32_t *current_regs;
/* This is the beginning of heap as provided from up_head.S.
* This is the first address in DRAM after the loaded
diff --git a/nuttx/arch/arm/src/cortexm3/up_doirq.c b/nuttx/arch/arm/src/cortexm3/up_doirq.c
index d5f3a6185..fc2f75c97 100644
--- a/nuttx/arch/arm/src/cortexm3/up_doirq.c
+++ b/nuttx/arch/arm/src/cortexm3/up_doirq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/cortexm3/up_doirq.c
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -76,6 +76,8 @@ uint32_t *up_doirq(int irq, uint32_t *regs)
#ifdef CONFIG_SUPPRESS_INTERRUPTS
PANIC(OSERR_ERREXCEPTION);
#else
+ uint32_t *savestate;
+
/* Nested interrupts are not supported in this implementation. If you want
* implemented nested interrupts, you would have to (1) change the way that
* current regs is handled and (2) the design associated with
@@ -86,7 +88,7 @@ uint32_t *up_doirq(int irq, uint32_t *regs)
* current_regs is also used to manage interrupt level context switches.
*/
- DEBUGASSERT(current_regs == NULL);
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Mask and acknowledge the interrupt */
@@ -103,11 +105,14 @@ uint32_t *up_doirq(int irq, uint32_t *regs)
* switch occurred during interrupt processing.
*/
- regs = current_regs;
+ regs = (uint32_t*)current_regs;
- /* Indicate that we are no long in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
/* Unmask the last interrupt (global interrupts are still disabled) */
diff --git a/nuttx/arch/arm/src/cortexm3/up_svcall.c b/nuttx/arch/arm/src/cortexm3/up_svcall.c
index ec67617a7..f7e55a98b 100644
--- a/nuttx/arch/arm/src/cortexm3/up_svcall.c
+++ b/nuttx/arch/arm/src/cortexm3/up_svcall.c
@@ -57,7 +57,20 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/* Configuration ************************************************************/
+
+#undef SYSCALL_INTERRUPTIBLE
+#if defined(CONFIG_NUTTX_KERNEL)
+# if CONFIG_ARCH_INTERRUPTSTACK > 3
+# warning "CONFIG_ARCH_INTERRUPTSTACK and CONFIG_NUTTX_KERNEL are incompatible"
+# warning "options as currently implemented. Interrupts will have to be disabled"
+# warning "during SYScall processing to avoid un-handled nested interrupts"
+# else
+# define SYSCALL_INTERRUPTIBLE 1
+# endif
+#endif
+/* Debug ********************************************************************/
/* Debug output from this file may interfere with context switching! To get
* debug output you must enabled the following in your NuttX configuration:
*
@@ -116,6 +129,12 @@ static inline void dispatch_syscall(uint32_t *regs)
int index = cmd - CONFIG_SYS_RESERVED;
+ /* Enable interrupts while the SYSCALL executes */
+
+#ifdef SYSCALL_INTERRUPTIBLE
+ irqenable();
+#endif
+
/* Call the correct stub for each SYS call, based on the number of parameters */
svcdbg("Calling stub%d at %p\n", index, g_stubloopkup[index].stub0);
@@ -177,6 +196,10 @@ static inline void dispatch_syscall(uint32_t *regs)
cmd, g_stubnparms[index]);
break;
}
+
+#ifdef SYSCALL_INTERRUPTIBLE
+ irqdisable();
+#endif
}
/* Set up the return vaue. First, check if a context switch occurred.
diff --git a/nuttx/arch/arm/src/dm320/dm320_decodeirq.c b/nuttx/arch/arm/src/dm320/dm320_decodeirq.c
index a844fcae9..cb3efa5b9 100644
--- a/nuttx/arch/arm/src/dm320/dm320_decodeirq.c
+++ b/nuttx/arch/arm/src/dm320/dm320_decodeirq.c
@@ -2,7 +2,7 @@
* arch/arm/src/dm320/dm320_decodeirq.c
* arch/arm/src/chip/dm320_decodeirq.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -94,6 +94,8 @@ void up_decodeirq(uint32_t* regs)
if ((unsigned)irq < NR_IRQS)
{
+ uint32_t *savestate;
+
/* Mask and acknowledge the interrupt */
up_maskack_irq(irq);
@@ -102,15 +104,19 @@ void up_decodeirq(uint32_t* regs)
* current_regs is also used to manage interrupt level context switches.
*/
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Deliver the IRQ */
irq_dispatch(irq, regs);
- /* Indicate that we are no longer in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
/* Unmask the last interrupt (global interrupts are still
* disabled).
diff --git a/nuttx/arch/arm/src/dm320/dm320_irq.c b/nuttx/arch/arm/src/dm320/dm320_irq.c
index f094bab1c..eb8201bb4 100644
--- a/nuttx/arch/arm/src/dm320/dm320_irq.c
+++ b/nuttx/arch/arm/src/dm320/dm320_irq.c
@@ -57,7 +57,7 @@
* Public Data
************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/imx/imx_decodeirq.c b/nuttx/arch/arm/src/imx/imx_decodeirq.c
index 96a40fd4a..55c72ed76 100644
--- a/nuttx/arch/arm/src/imx/imx_decodeirq.c
+++ b/nuttx/arch/arm/src/imx/imx_decodeirq.c
@@ -2,7 +2,7 @@
* arch/arm/src/imx/imx_decodeirq.c
* arch/arm/src/chip/imx_decodeirq.c
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -78,6 +78,7 @@ void up_decodeirq(uint32_t* regs)
current_regs = regs;
PANIC(OSERR_ERREXCEPTION);
#else
+ uint32_t* savestate;
uint32_t regval;
int irq;
@@ -85,6 +86,7 @@ void up_decodeirq(uint32_t* regs)
* current_regs is also used to manage interrupt level context switches.
*/
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Loop while there are pending interrupts to be processed */
@@ -124,8 +126,11 @@ void up_decodeirq(uint32_t* regs)
}
while (irq < NR_IRQS);
- /* Indicate that we are no longer in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
#endif
}
diff --git a/nuttx/arch/arm/src/imx/imx_irq.c b/nuttx/arch/arm/src/imx/imx_irq.c
index b346064c5..934a60f0b 100644
--- a/nuttx/arch/arm/src/imx/imx_irq.c
+++ b/nuttx/arch/arm/src/imx/imx_irq.c
@@ -2,7 +2,7 @@
* arch/arm/src/imc/imx_irq.c
* arch/arm/src/chip/imx_irq.c
*
- * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -56,7 +56,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/lm3s/lm3s_irq.c b/nuttx/arch/arm/src/lm3s/lm3s_irq.c
index da7f3d9c3..915ce3d13 100644
--- a/nuttx/arch/arm/src/lm3s/lm3s_irq.c
+++ b/nuttx/arch/arm/src/lm3s/lm3s_irq.c
@@ -75,7 +75,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c b/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c
index 967de45d7..cf3467833 100755
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c
@@ -75,7 +75,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c b/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c
index dc76509a9..6317066c3 100644
--- a/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c
+++ b/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c
@@ -1,7 +1,7 @@
/********************************************************************************
* arch/arm/src/lpc214x/lpc214x_decodeirq.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -145,19 +145,25 @@ static void lpc214x_decodeirq( uint32_t *regs)
if (irq < NR_IRQS)
{
+ uint32_t *savestate;
+
/* Current regs non-zero indicates that we are processing an interrupt;
* current_regs is also used to manage interrupt level context switches.
*/
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Deliver the IRQ */
irq_dispatch(irq, regs);
- /* Indicate that we are no long in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
}
#endif
}
diff --git a/nuttx/arch/arm/src/lpc214x/lpc214x_irq.c b/nuttx/arch/arm/src/lpc214x/lpc214x_irq.c
index 9d8ed817b..a8b91037c 100644
--- a/nuttx/arch/arm/src/lpc214x/lpc214x_irq.c
+++ b/nuttx/arch/arm/src/lpc214x/lpc214x_irq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/lpc214x/lpc214x_irq.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c
index 42b678432..100502a22 100755
--- a/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c
+++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c
@@ -6,7 +6,7 @@
*
* This file is part of the NuttX RTOS and based on the lpc2148 port:
*
- * Copyright (C) 2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2010, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -131,11 +131,13 @@ static void lpc23xx_decodeirq(uint32_t *regs)
if (irq < NR_IRQS) /* redundant check ?? */
{
+ uint32_t *savestate;
+
/* Current regs non-zero indicates that we are processing an interrupt;
* current_regs is also used to manage interrupt level context switches.
*/
- DEBUGASSERT(current_regs == NULL);
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Mask and acknowledge the interrupt */
@@ -146,9 +148,12 @@ static void lpc23xx_decodeirq(uint32_t *regs)
irq_dispatch(irq, regs);
- /* Indicate that we are no longer in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
}
#endif
diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c
index 9a6268a2f..10f188cba 100755
--- a/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c
+++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c
@@ -65,7 +65,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_decodeirq.c b/nuttx/arch/arm/src/lpc313x/lpc313x_decodeirq.c
index 9abaff3c1..119e65c50 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_decodeirq.c
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_decodeirq.c
@@ -102,6 +102,8 @@ void up_decodeirq(uint32_t *regs)
if ((unsigned)irq < NR_IRQS)
{
+ uint32_t* savestate;
+
/* Mask and acknowledge the interrupt */
up_maskack_irq(irq);
@@ -110,15 +112,19 @@ void up_decodeirq(uint32_t *regs)
* current_regs is also used to manage interrupt level context switches.
*/
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Deliver the IRQ */
irq_dispatch(irq, regs);
- /* Indicate that we are no longer in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
/* Unmask the last interrupt (global interrupts are still
* disabled).
diff --git a/nuttx/arch/arm/src/lpc313x/lpc313x_irq.c b/nuttx/arch/arm/src/lpc313x/lpc313x_irq.c
index 35ef3e89e..9b7f10e12 100755
--- a/nuttx/arch/arm/src/lpc313x/lpc313x_irq.c
+++ b/nuttx/arch/arm/src/lpc313x/lpc313x_irq.c
@@ -2,7 +2,7 @@
* arch/arm/src/lpc313x/lpc313x_irq.c
* arch/arm/src/chip/lpc313x_irq.c
*
- * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/sam3u/sam3u_irq.c b/nuttx/arch/arm/src/sam3u/sam3u_irq.c
index 1d19c126e..228be0f1f 100755
--- a/nuttx/arch/arm/src/sam3u/sam3u_irq.c
+++ b/nuttx/arch/arm/src/sam3u/sam3u_irq.c
@@ -75,7 +75,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/stm32/stm32_irq.c b/nuttx/arch/arm/src/stm32/stm32_irq.c
index 7f963a117..b27f5448e 100644
--- a/nuttx/arch/arm/src/stm32/stm32_irq.c
+++ b/nuttx/arch/arm/src/stm32/stm32_irq.c
@@ -75,7 +75,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/arm/src/str71x/str71x_decodeirq.c b/nuttx/arch/arm/src/str71x/str71x_decodeirq.c
index 4182ab417..8a24ea44d 100644
--- a/nuttx/arch/arm/src/str71x/str71x_decodeirq.c
+++ b/nuttx/arch/arm/src/str71x/str71x_decodeirq.c
@@ -1,7 +1,7 @@
/********************************************************************************
* arch/arm/src/str71x/str71x_decodeirq.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -108,11 +108,13 @@ void up_decodeirq(uint32_t *regs)
if (irq < NR_IRQS)
{
+ uint32_t* savestate;
+
/* Current regs non-zero indicates that we are processing an interrupt;
* current_regs is also used to manage interrupt level context switches.
*/
- DEBUGASSERT(current_regs == NULL);
+ savestate = (uint32_t*)current_regs;
current_regs = regs;
/* Mask and acknowledge the interrupt */
@@ -123,9 +125,12 @@ void up_decodeirq(uint32_t *regs)
irq_dispatch(irq, regs);
- /* Indicate that we are no long in an interrupt handler */
+ /* Restore the previous value of current_regs. NULL would indicate that
+ * we are no longer in an interrupt handler. It will be non-NULL if we
+ * are returning from a nested interrupt.
+ */
- current_regs = NULL;
+ current_regs = savestate;
/* Unmask the last interrupt (global interrupts are still disabled) */
diff --git a/nuttx/arch/arm/src/str71x/str71x_irq.c b/nuttx/arch/arm/src/str71x/str71x_irq.c
index d27412e17..c5c359cdf 100644
--- a/nuttx/arch/arm/src/str71x/str71x_irq.c
+++ b/nuttx/arch/arm/src/str71x/str71x_irq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/st71x/st71x_irq.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@
* Public Data
****************************************************************************/
-uint32_t *current_regs;
+volatile uint32_t *current_regs;
/****************************************************************************
* Private Data