ez80 is code complete
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@691 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
c558d34600
commit
0823879b84
@ -300,7 +300,7 @@ struct xcptcontext
|
|||||||
/* The following retains that state during signal execution */
|
/* The following retains that state during signal execution */
|
||||||
|
|
||||||
uint16 saved_pc; /* Saved return address */
|
uint16 saved_pc; /* Saved return address */
|
||||||
uint16 saved_i; /* Saved interrupt state */
|
uint16 saved_irqctl; /* Saved interrupt state */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,19 +52,4 @@
|
|||||||
* Definitions
|
* 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 */
|
#endif /* __UP_ARCH_H */
|
||||||
|
@ -45,6 +45,14 @@
|
|||||||
* Definitions
|
* Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
|
/* Hexadecimal Representation *******************************************************/
|
||||||
|
|
||||||
|
#ifdef __ASSEMBLY__
|
||||||
|
# define _HX(h) %##h
|
||||||
|
#else
|
||||||
|
# define _HX(w) 0x##h
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Memory Map
|
/* Memory Map
|
||||||
*
|
*
|
||||||
* 64Kb Program Memory (64K series)
|
* 64Kb Program Memory (64K series)
|
||||||
@ -60,6 +68,28 @@
|
|||||||
* f00 - fff : 256 byte control register area
|
* 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
|
* Public Function Prototypes
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
|
#include <ez8.h>
|
||||||
|
|
||||||
#include "chip/switch.h"
|
#include "chip/switch.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
@ -81,6 +83,19 @@ struct z8_irqstate_s g_z8irqstate;
|
|||||||
|
|
||||||
irqstate_t irqsave(void)
|
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)
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,12 +76,12 @@ static void z8_sigsetup(FAR _TCB *tcb, sig_deliver_t sigdeliver, FAR chipreg_t *
|
|||||||
|
|
||||||
tcb->xcp.sigdeliver = sigdeliver;
|
tcb->xcp.sigdeliver = sigdeliver;
|
||||||
tcb->xcp.saved_pc = regs[XCPT_PC];
|
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 */
|
/* Then set up to vector to the trampoline with interrupts disabled */
|
||||||
|
|
||||||
regs[XCPT_PC] = (chipreg_t)up_sigdeliver;
|
regs[XCPT_PC] = (chipreg_t)up_sigdeliver;
|
||||||
regs[XCPT_I] = 0;
|
regs[XCPT_IRQCTL] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -64,6 +64,21 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* 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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -83,7 +98,7 @@ void up_sigdeliver(void)
|
|||||||
{
|
{
|
||||||
#ifndef CONFIG_DISABLE_SIGNALS
|
#ifndef CONFIG_DISABLE_SIGNALS
|
||||||
FAR _TCB *rtcb = (_TCB*)g_readytorun.head;
|
FAR _TCB *rtcb = (_TCB*)g_readytorun.head;
|
||||||
chipret_t regs[XCPTCONTEXT_REGS];
|
chipreg_t regs[XCPTCONTEXT_REGS];
|
||||||
sig_deliver_t sigdeliver;
|
sig_deliver_t sigdeliver;
|
||||||
|
|
||||||
/* Save the errno. This must be preserved throughout the signal handling
|
/* 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. */
|
/* Save the real return state on the stack. */
|
||||||
|
|
||||||
z8_copystate(regs, rtcb->xcp.regs);
|
z8_copystate(regs, rtcb->xcp.regs);
|
||||||
regs[XCPT_PC] = rtcb->xcp.saved_pc;
|
regs[XCPT_PC] = rtcb->xcp.saved_pc;
|
||||||
regs[XCPT_I] = rtcb->xcp.saved_i;
|
regs[XCPT_IRQCTL] = rtcb->xcp.saved_irqctl;
|
||||||
|
|
||||||
/* Get a local copy of the sigdeliver function pointer. We do this so
|
/* 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
|
* 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. */
|
/* Then restore the task interrupt state. */
|
||||||
|
|
||||||
irqrestore(regs[XCPT_I]);
|
irqrestore(regs[XCPT_IRQCTL]);
|
||||||
|
|
||||||
/* Deliver the signals */
|
/* Deliver the signals */
|
||||||
|
|
||||||
@ -134,7 +149,7 @@ void up_sigdeliver(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
up_ledoff(LED_SIGNAL);
|
up_ledoff(LED_SIGNAL);
|
||||||
z8_restoreusercontext(regs);
|
z8_restorecontext(regs);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
* Definitions
|
* Definitions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/* Bits in the Z80 FLAGS register */
|
/* Bits in the Z80 FLAGS register ***************************************************/
|
||||||
|
|
||||||
#define Z80_C_FLAG 0x01 /* Bit 0: Carry flag */
|
#define Z80_C_FLAG 0x01 /* Bit 0: Carry flag */
|
||||||
#define Z80_N_FLAG 0x02 /* Bit 1: Add/Subtract 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_Z_FLAG 0x40 /* Bit 5: Zero flag */
|
||||||
#define Z80_S_FLAG 0x80 /* Bit 7: Sign 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
|
* Public Function Prototypes
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user