summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2008-02-15 23:11:51 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2008-02-15 23:11:51 +0000
commita5b66e47108b60545a17d50ecead5ab3dddc1355 (patch)
treee07685cf4a0184ef00746b9829f79cfb6823a67c
parent5dc5d14d667fe2926a7c418e6b28c84c72ef9ea2 (diff)
ez80 is code complete
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@691 7fd9a85b-ad96-42d3-883c-3090e2eb8679
-rw-r--r--nuttx/arch/z80/include/z8/irq.h2
-rw-r--r--nuttx/arch/z80/src/common/up_arch.h15
-rw-r--r--nuttx/arch/z80/src/z8/chip.h30
-rw-r--r--nuttx/arch/z80/src/z8/z8_irq.c25
-rw-r--r--nuttx/arch/z80/src/z8/z8_schedulesigaction.c6
-rw-r--r--nuttx/arch/z80/src/z8/z8_sigdeliver.c25
-rw-r--r--nuttx/arch/z80/src/z80/chip.h14
7 files changed, 92 insertions, 25 deletions
diff --git a/nuttx/arch/z80/include/z8/irq.h b/nuttx/arch/z80/include/z8/irq.h
index 7e8dbf699e..049c8b84cd 100644
--- a/nuttx/arch/z80/include/z8/irq.h
+++ b/nuttx/arch/z80/include/z8/irq.h
@@ -300,7 +300,7 @@ struct xcptcontext
/* The following retains that state during signal execution */
uint16 saved_pc; /* Saved return address */
- uint16 saved_i; /* Saved interrupt state */
+ uint16 saved_irqctl; /* Saved interrupt state */
#endif
};
#endif
diff --git a/nuttx/arch/z80/src/common/up_arch.h b/nuttx/arch/z80/src/common/up_arch.h
index 5ef0b932c7..ff53010dbd 100644
--- a/nuttx/arch/z80/src/common/up_arch.h
+++ b/nuttx/arch/z80/src/common/up_arch.h
@@ -52,19 +52,4 @@
* Definitions
************************************************************************************/
-/************************************************************************************
- * Inline Functions
- ************************************************************************************/
-
-#ifndef __ASSEMBLY__
-
-# define getreg8(a) (*(volatile ubyte *)(a))
-# define putreg8(v,a) (*(volatile ubyte *)(a) = (v))
-# define getreg32(a) (*(volatile uint32 *)(a))
-# define putreg32(v,a) (*(volatile uint32 *)(a) = (v))
-# define getreg(a) getreg16(1)
-# define putreg(v,a) putreg16(v,a)
-
-#endif
-
#endif /* __UP_ARCH_H */
diff --git a/nuttx/arch/z80/src/z8/chip.h b/nuttx/arch/z80/src/z8/chip.h
index 99b058404c..be216f1e04 100644
--- a/nuttx/arch/z80/src/z8/chip.h
+++ b/nuttx/arch/z80/src/z8/chip.h
@@ -45,6 +45,14 @@
* Definitions
************************************************************************************/
+/* Hexadecimal Representation *******************************************************/
+
+#ifdef __ASSEMBLY__
+# define _HX(h) %##h
+#else
+# define _HX(w) 0x##h
+#endif
+
/* Memory Map
*
* 64Kb Program Memory (64K series)
@@ -60,6 +68,28 @@
* f00 - fff : 256 byte control register area
*/
+/* Special Function Registers *******************************************************
+ *
+ * Because of the many different ez80 configurations, we will rely on the
+ * ZDS-II header file, ez8.h, to provide the correct addresses for each register.
+ */
+
+/* Register access macros ***********************************************************
+ *
+ * The register access mechanism provided in ez8.h differs from the useful in other
+ * NuttX architectures. The following NuttX common macros will at least make the
+ * access compatible at the source level (however, strict type check is lost).
+ */
+
+#ifndef __ASSEMBLY__
+# define getreg8(a) (a)
+# define putreg8(v,a) ((a) = (v))
+# define getreg16(a) (a)
+# define putreg16(v,a) ((a) = (v))
+# define getreg32(a) (a)
+# define putreg32(v,a) ((a) = (v))
+#endif /* __ASSEMBLY__ */
+
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
diff --git a/nuttx/arch/z80/src/z8/z8_irq.c b/nuttx/arch/z80/src/z8/z8_irq.c
index d3a46bf178..38f24a9686 100644
--- a/nuttx/arch/z80/src/z8/z8_irq.c
+++ b/nuttx/arch/z80/src/z8/z8_irq.c
@@ -44,6 +44,8 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
+#include <ez8.h>
+
#include "chip/switch.h"
#include "up_internal.h"
@@ -81,6 +83,19 @@ struct z8_irqstate_s g_z8irqstate;
irqstate_t irqsave(void)
{
+ /* Bit 7 (IRQE) of the IRQCTL register determines if interrupts were
+ * enabled when this function was called.
+ */
+
+ register irqstate_t retval = getreg8(IRQCTL);
+
+ /* Disable interrupts */
+
+ DI();
+
+ /* Return the previous interrupt state */
+
+ return retval;
}
/****************************************************************************
@@ -93,4 +108,14 @@ irqstate_t irqsave(void)
void irqrestore(irqstate_t flags)
{
+ /* Bit 7 (IRQE) of the IRQCTL register determines if interrupts were
+ * enabled when irqsave() was called.
+ */
+
+ if ((flags & 0x80) != 0)
+ {
+ /* The IRQE bit was set, re-enable interrupts */
+
+ EI();
+ }
}
diff --git a/nuttx/arch/z80/src/z8/z8_schedulesigaction.c b/nuttx/arch/z80/src/z8/z8_schedulesigaction.c
index ad02f0137c..fd9e715202 100644
--- a/nuttx/arch/z80/src/z8/z8_schedulesigaction.c
+++ b/nuttx/arch/z80/src/z8/z8_schedulesigaction.c
@@ -76,12 +76,12 @@ static void z8_sigsetup(FAR _TCB *tcb, sig_deliver_t sigdeliver, FAR chipreg_t *
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = regs[XCPT_PC];
- tcb->xcp.saved_i = regs[XCPT_I];
+ tcb->xcp.saved_irqctl = regs[XCPT_IRQCTL];
/* Then set up to vector to the trampoline with interrupts disabled */
- regs[XCPT_PC] = (chipreg_t)up_sigdeliver;
- regs[XCPT_I] = 0;
+ regs[XCPT_PC] = (chipreg_t)up_sigdeliver;
+ regs[XCPT_IRQCTL] = 0;
}
/****************************************************************************
diff --git a/nuttx/arch/z80/src/z8/z8_sigdeliver.c b/nuttx/arch/z80/src/z8/z8_sigdeliver.c
index 857db51e5b..8ba3c552eb 100644
--- a/nuttx/arch/z80/src/z8/z8_sigdeliver.c
+++ b/nuttx/arch/z80/src/z8/z8_sigdeliver.c
@@ -65,6 +65,21 @@
****************************************************************************/
/****************************************************************************
+ * Name: z8_copystate
+ ****************************************************************************/
+
+/* Maybe a little faster than most memcpy's */
+
+static void z8_copystate(FAR chipreg_t *dest, FAR const chipreg_t *src)
+{
+ int i;
+ for (i = 0; i < XCPTCONTEXT_REGS; i++)
+ {
+ *dest++ = *src++;
+ }
+}
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -83,7 +98,7 @@ void up_sigdeliver(void)
{
#ifndef CONFIG_DISABLE_SIGNALS
FAR _TCB *rtcb = (_TCB*)g_readytorun.head;
- chipret_t regs[XCPTCONTEXT_REGS];
+ chipreg_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;
/* Save the errno. This must be preserved throughout the signal handling
@@ -102,8 +117,8 @@ void up_sigdeliver(void)
/* Save the real return state on the stack. */
z8_copystate(regs, rtcb->xcp.regs);
- regs[XCPT_PC] = rtcb->xcp.saved_pc;
- regs[XCPT_I] = rtcb->xcp.saved_i;
+ regs[XCPT_PC] = rtcb->xcp.saved_pc;
+ regs[XCPT_IRQCTL] = rtcb->xcp.saved_irqctl;
/* Get a local copy of the sigdeliver function pointer. We do this so
* that we can nullify the sigdeliver function point in the TCB and accept
@@ -115,7 +130,7 @@ void up_sigdeliver(void)
/* Then restore the task interrupt state. */
- irqrestore(regs[XCPT_I]);
+ irqrestore(regs[XCPT_IRQCTL]);
/* Deliver the signals */
@@ -134,7 +149,7 @@ void up_sigdeliver(void)
*/
up_ledoff(LED_SIGNAL);
- z8_restoreusercontext(regs);
+ z8_restorecontext(regs);
#endif
}
diff --git a/nuttx/arch/z80/src/z80/chip.h b/nuttx/arch/z80/src/z80/chip.h
index d5c36bd19f..b960e481fb 100644
--- a/nuttx/arch/z80/src/z80/chip.h
+++ b/nuttx/arch/z80/src/z80/chip.h
@@ -45,7 +45,7 @@
* Definitions
************************************************************************************/
-/* Bits in the Z80 FLAGS register */
+/* Bits in the Z80 FLAGS register ***************************************************/
#define Z80_C_FLAG 0x01 /* Bit 0: Carry flag */
#define Z80_N_FLAG 0x02 /* Bit 1: Add/Subtract flag */
@@ -54,6 +54,18 @@
#define Z80_Z_FLAG 0x40 /* Bit 5: Zero flag */
#define Z80_S_FLAG 0x80 /* Bit 7: Sign flag */
+/* Register access macros ***********************************************************/
+
+#ifndef __ASSEMBLY__
+
+# define getreg8(a) (*(volatile ubyte *)(a))
+# define putreg8(v,a) (*(volatile ubyte *)(a) = (v))
+# define getreg32(a) (*(volatile uint32 *)(a))
+# define putreg32(v,a) (*(volatile uint32 *)(a) = (v))
+# define getreg(a) getreg16(1)
+# define putreg(v,a) putreg16(v,a)
+
+#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/