summaryrefslogtreecommitdiff
path: root/nuttx/arch/z80
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/z80
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/z80')
-rw-r--r--nuttx/arch/z80/src/common/up_doirq.c2
-rw-r--r--nuttx/arch/z80/src/ez80/ez80_irq.c2
-rw-r--r--nuttx/arch/z80/src/ez80/switch.h26
-rw-r--r--nuttx/arch/z80/src/z8/switch.h14
-rw-r--r--nuttx/arch/z80/src/z80/switch.h25
-rw-r--r--nuttx/arch/z80/src/z80/z80_irq.c4
6 files changed, 47 insertions, 26 deletions
diff --git a/nuttx/arch/z80/src/common/up_doirq.c b/nuttx/arch/z80/src/common/up_doirq.c
index 2c4c9e113..828806a49 100644
--- a/nuttx/arch/z80/src/common/up_doirq.c
+++ b/nuttx/arch/z80/src/common/up_doirq.c
@@ -84,6 +84,8 @@ FAR chipreg_t *up_doirq(uint8_t irq, FAR chipreg_t *regs)
#else
if (irq < NR_IRQS)
{
+ FAR chipreg_t *savestate;
+
/* Indicate that we have entered IRQ processing logic */
IRQ_ENTER(irq, regs);
diff --git a/nuttx/arch/z80/src/ez80/ez80_irq.c b/nuttx/arch/z80/src/ez80/ez80_irq.c
index 38a51c9c4..d89bff859 100644
--- a/nuttx/arch/z80/src/ez80/ez80_irq.c
+++ b/nuttx/arch/z80/src/ez80/ez80_irq.c
@@ -57,7 +57,7 @@
* structure. If is non-NULL only during interrupt processing.
*/
-chipreg_t *current_regs;
+volatile chipreg_t *current_regs;
/****************************************************************************
* Private Data
diff --git a/nuttx/arch/z80/src/ez80/switch.h b/nuttx/arch/z80/src/ez80/switch.h
index b1d71669b..3b7f1bd95 100644
--- a/nuttx/arch/z80/src/ez80/switch.h
+++ b/nuttx/arch/z80/src/ez80/switch.h
@@ -2,7 +2,7 @@
* arch/z80/src/ez80/switch.h
* arch/z80/src/chip/switch.h
*
- * 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
@@ -61,7 +61,7 @@
#define INIT_IRQCONTEXT() current_regs = NULL
-/* IN_INTERRUPT returns true if the system is current operating in the interrupt
+/* IN_INTERRUPT returns true if the system is currently operating in the interrupt
* context. IN_INTERRUPT is the inline equivalent of up_interrupt_context().
*/
@@ -69,11 +69,15 @@
/* The following macro is used when the system enters interrupt handling logic */
-#define IRQ_ENTER(irq, regs) current_regs = (regs)
+#define IRQ_ENTER(irq, regs) \
+ do { \
+ savestate = (FAR chipreg_t *)current_regs; \
+ current_regs = (regs); \
+ } while (0)
/* The following macro is used when the system exits interrupt handling logic */
-#define IRQ_LEAVE(irq) current_regs = NULL
+#define IRQ_LEAVE(irq) current_regs = savestate
/* The following macro is used to sample the interrupt state (as a opaque handle) */
@@ -81,11 +85,11 @@
/* Save the current IRQ context in the specified TCB */
-#define SAVE_IRQCONTEXT(tcb) ez80_copystate((tcb)->xcp.regs, current_regs)
+#define SAVE_IRQCONTEXT(tcb) ez80_copystate((tcb)->xcp.regs, (FAR chipreg_t*)current_regs)
/* Set the current IRQ context to the state specified in the TCB */
-#define SET_IRQCONTEXT(tcb) ez80_copystate(current_regs, (tcb)->xcp.regs)
+#define SET_IRQCONTEXT(tcb) ez80_copystate((FAR chipreg_t*)current_regs, (tcb)->xcp.regs)
/* Save the user context in the specified TCB. User context saves can be simpler
* because only those registers normally saved in a C called need be stored.
@@ -116,7 +120,7 @@
* If is non-NULL only during interrupt processing.
*/
-extern chipreg_t *current_regs;
+extern volatile chipreg_t *current_regs;
#endif
/************************************************************************************
@@ -133,19 +137,19 @@ extern "C" {
/* Defined in ez80_copystate.c */
-EXTERN void ez80_copystate(chipreg_t *dest, const chipreg_t *src);
+EXTERN void ez80_copystate(FAR chipreg_t *dest, FAR const chipreg_t *src);
/* Defined in ez80_saveusercontext.asm */
-EXTERN int ez80_saveusercontext(chipreg_t *regs);
+EXTERN int ez80_saveusercontext(FAR chipreg_t *regs);
/* Defined in ez80_restorecontext.asm */
-EXTERN void ez80_restorecontext(chipreg_t *regs);
+EXTERN void ez80_restorecontext(FAR chipreg_t *regs);
/* Defined in ez80_sigsetup.c */
-EXTERN void ez80_sigsetup(_TCB *tcb, sig_deliver_t sigdeliver, chipreg_t *regs);
+EXTERN void ez80_sigsetup(FAR _TCB *tcb, sig_deliver_t sigdeliver, chipreg_t *regs);
/* Defined in ez80_registerdump.c */
diff --git a/nuttx/arch/z80/src/z8/switch.h b/nuttx/arch/z80/src/z8/switch.h
index 69e766cf6..c37d7bcd0 100644
--- a/nuttx/arch/z80/src/z8/switch.h
+++ b/nuttx/arch/z80/src/z8/switch.h
@@ -2,7 +2,7 @@
* arch/z80/src/z8/switch.h
* arch/z80/src/chip/switch.h
*
- * 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
@@ -105,7 +105,7 @@
g_z8irqstate.state = Z8_IRQSTATE_NONE; \
} while (0)
-/* IN_INTERRUPT returns true if the system is current operating in the interrupt
+/* IN_INTERRUPT returns true if the system is currently operating in the interrupt
* context. IN_INTERRUPT is the inline equivalent of up_interrupt_context().
*/
@@ -114,8 +114,15 @@
/* The following macro is used when the system enters interrupt handling logic */
+#define IRQ_SAVE(irq, regs) savestate = (FAR chipreg_t *)current_regs;
+#define IRQ_ENTER(irq, regs) current_regs = (regs)
+
+/* The following macro is used when the system exits interrupt handling logic */
+
#define IRQ_ENTER(irq, regs) \
do { \
+ savestate.state = g_z8irqstate.state; \
+ savestate.regs = g_z8irqstate.regs; \
g_z8irqstate.state = Z8_IRQSTATE_ENTRY; \
g_z8irqstate.regs = (regs); \
up_maskack_irq(irq); \
@@ -125,7 +132,8 @@
#define IRQ_LEAVE(irq) \
do { \
- g_z8irqstate.state = Z8_IRQSTATE_NONE; \
+ g_z8irqstate.state = savestate.state; \
+ g_z8irqstate.regs = savestate.regs; \
up_enable_irq(irq); \
} while (0)
diff --git a/nuttx/arch/z80/src/z80/switch.h b/nuttx/arch/z80/src/z80/switch.h
index f30f41b9c..1b54ada5e 100644
--- a/nuttx/arch/z80/src/z80/switch.h
+++ b/nuttx/arch/z80/src/z80/switch.h
@@ -2,7 +2,7 @@
* arch/z80/src/z80/switch.h
* arch/z80/src/chip/switch.h
*
- * 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
@@ -68,11 +68,15 @@
/* The following macro is used when the system enters interrupt handling logic */
-#define IRQ_ENTER(irq, regs) current_regs = (regs)
+#define IRQ_ENTER(irq, regs) \
+ do { \
+ savestate = (FAR chipreg_t *)current_regs; \
+ current_regs = (regs); \
+ } while (0)
/* The following macro is used when the system exits interrupt handling logic */
-#define IRQ_LEAVE(irq) current_regs = NULL
+#define IRQ_LEAVE(irq) current_regs = savestate
/* The following macro is used to sample the interrupt state (as a opaque handle) */
@@ -80,11 +84,11 @@
/* Save the current IRQ context in the specified TCB */
-#define SAVE_IRQCONTEXT(tcb) z80_copystate((tcb)->xcp.regs, current_regs)
+#define SAVE_IRQCONTEXT(tcb) z80_copystate((tcb)->xcp.regs, (FAR chipreg_t*)current_regs)
/* Set the current IRQ context to the state specified in the TCB */
-#define SET_IRQCONTEXT(tcb) z80_copystate(current_regs, (tcb)->xcp.regs)
+#define SET_IRQCONTEXT(tcb) z80_copystate((FAR chipreg_t*)current_regs, (tcb)->xcp.regs)
/* Save the user context in the specified TCB. User context saves can be simpler
* because only those registers normally saved in a C called need be stored.
@@ -103,16 +107,19 @@
#define _REGISTER_DUMP() z80_registerdump()
/************************************************************************************
+ * Public Types
+ ************************************************************************************/
+
+/************************************************************************************
* Public Variables
************************************************************************************/
#ifndef __ASSEMBLY__
-/* This holds a references to the current interrupt level
- * register storage structure. If is non-NULL only during
- * interrupt processing.
+/* This holds a references to the current interrupt level register storage structure.
+ * If is non-NULL only during interrupt processing.
*/
-extern chipreg_t *current_regs;
+extern volatile chipreg_t *current_regs;
#endif
/************************************************************************************
diff --git a/nuttx/arch/z80/src/z80/z80_irq.c b/nuttx/arch/z80/src/z80/z80_irq.c
index 8b46acc40..5efd36b9f 100644
--- a/nuttx/arch/z80/src/z80/z80_irq.c
+++ b/nuttx/arch/z80/src/z80/z80_irq.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/z80/src/z80/z80_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
@@ -56,7 +56,7 @@
* structure. If is non-NULL only during interrupt processing.
*/
-chipreg_t *current_regs;
+volatile chipreg_t *current_regs;
/****************************************************************************
* Private Data