summaryrefslogtreecommitdiff
path: root/nuttx/arch/z16/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-01-13 15:31:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-01-13 15:31:26 +0000
commit421de422e496c48fdb1aa9cd5711729c5d702f32 (patch)
treeb73222a61ec92e40f3e764da1ec0b08df9dd7546 /nuttx/arch/z16/src
parentcbb53cff763928f52d5d4851d9993b0b0fc73d8a (diff)
downloadpx4-nuttx-421de422e496c48fdb1aa9cd5711729c5d702f32.tar.gz
px4-nuttx-421de422e496c48fdb1aa9cd5711729c5d702f32.tar.bz2
px4-nuttx-421de422e496c48fdb1aa9cd5711729c5d702f32.zip
Fix Z16F context structure
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@556 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z16/src')
-rw-r--r--nuttx/arch/z16/src/Makefile2
-rw-r--r--nuttx/arch/z16/src/common/up_initialstate.c10
-rw-r--r--nuttx/arch/z16/src/common/up_registerdump.c21
-rw-r--r--nuttx/arch/z16/src/common/up_schedulesigaction.c24
-rw-r--r--nuttx/arch/z16/src/common/up_sigdeliver.c10
5 files changed, 37 insertions, 30 deletions
diff --git a/nuttx/arch/z16/src/Makefile b/nuttx/arch/z16/src/Makefile
index fc579baf1..4015025e5 100644
--- a/nuttx/arch/z16/src/Makefile
+++ b/nuttx/arch/z16/src/Makefile
@@ -81,7 +81,7 @@ $(AOBJS) $(HEAD_AOBJ): %$(OBJEXT): %$(ASMEXT)
$(call ASSEMBLE, $<, $@)
else
$(OBJS) $(HEAD_AOBJ): %$(OBJEXT): %.S
- $(call ASSEMBLE, $<, $@)endif
+ $(call ASSEMBLE, $<, $@)
endif
$(COBJS): %$(OBJEXT): %.c
diff --git a/nuttx/arch/z16/src/common/up_initialstate.c b/nuttx/arch/z16/src/common/up_initialstate.c
index 4a7c49a2b..d4430f346 100644
--- a/nuttx/arch/z16/src/common/up_initialstate.c
+++ b/nuttx/arch/z16/src/common/up_initialstate.c
@@ -78,14 +78,14 @@
void up_initial_state(_TCB *tcb)
{
- struct xcptcontext *xcp = &tcb->xcp;
+ uint32 *reg32 = (uint32*)tcb->xcp.regs;
/* Initialize the initial exception register context structure */
- memset(xcp, 0, sizeof(struct xcptcontext));
+ memset(&tcb->xcp, 0, sizeof(struct xcptcontext));
#ifndef CONFIG_SUPPRESS_INTERRUPTS
- xcp->regs[XCPT_I] = Z80_C_FLAG; /* Carry flag will enable interrupts */
+ xcp->regs[REG_FLAGS] = Z16F_CNTRL_FLAGS_IRQE << 8; /* IRQE flag will enable interrupts */
#endif
- xcp->regs[XCPT_SP] = (chipreg_t)tcb->adj_stack_ptr;
- xcp->regs[XCPT_PC] = (chipreg_t)tcb->start;
+ reg32[REG_SP/2] = (uint32)tcb->adj_stack_ptr;
+ reg32[REG_PC/2] = (uint32)tcb->start;
}
diff --git a/nuttx/arch/z16/src/common/up_registerdump.c b/nuttx/arch/z16/src/common/up_registerdump.c
index 0b1f33f24..5164dd0a6 100644
--- a/nuttx/arch/z16/src/common/up_registerdump.c
+++ b/nuttx/arch/z16/src/common/up_registerdump.c
@@ -76,16 +76,15 @@
#ifdef CONFIG_ARCH_STACKDUMP
static void up_registerdump(void)
{
- if (current_regs)
- {
- lldbg("AF: %04x I: %04x\n",
- current_regs[XCPT_AF], current_regs[XCPT_I]);
- lldbg("BC: %04x DE: %04x HL: %04x\n",
- current_regs[XCPT_BC], current_regs[XCPT_DE], current_regs[XCPT_HL]);
- lldbg("IX: %04x IY: %04x\n",
- current_regs[XCPT_IX], current_regs[XCPT_IY]);
- lldbg("SP: %04x PC: $04x\n"
- current_regs[XCPT_SP], current_regs[XCPT_PC]);
- }
+ uint32 *regs32 = (uint32*)current_regs;
+ lldbg("R0 :%08x R1 :%08x R2 :%08x R3 :%08x "
+ "R4 :%08x R5 :%08x R6 :%08x R7 :%08x\n"
+ regs32[REG_R0/2], regs32[REG_R1/2], regs32[REG_R2/2], regs32[REG_R3/2],
+ regs32[REG_R4/2], regs32[REG_R5/2], regs32[REG_R6/2], regs32[REG_R7/2]);
+ lldbg("R8 :%08x R9 :%08x R10:%08x R11:%08x R12:%08x R13:%08x\n"
+ regs32[REG_R8/2], regs32[REG_R9/2], regs32[REG_R10/2], regs3[REG_R11/2],
+ regs32[REG_R12/2], regs32[REG_R13/2]);
+ lldbg("FP :%08x SP :%08x FLG:%04x\n"
+ regs32[REG_R14/2], regs32[REG_R15/2], current_regs[REG_FLAGS]);
}
#endif
diff --git a/nuttx/arch/z16/src/common/up_schedulesigaction.c b/nuttx/arch/z16/src/common/up_schedulesigaction.c
index 6d1aa00ed..3284fd1bf 100644
--- a/nuttx/arch/z16/src/common/up_schedulesigaction.c
+++ b/nuttx/arch/z16/src/common/up_schedulesigaction.c
@@ -141,21 +141,23 @@ void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver)
else
{
+ uint32 *current_pc = (uint32*)&current_regs[REG_PC];
+
/* Save the return address and interrupt state.
* These will be restored by the signal trampoline after
* the signals have been delivered.
*/
- tcb->xcp.sigdeliver = sigdeliver;
- tcb->xcp.saved_pc = current_regs[XCPT_PC];
- tcb->xcp.saved_i = current_regs[XCPT_I];
+ tcb->xcp.sigdeliver = sigdeliver;
+ tcb->xcp.saved_pc = *current_pc;
+ tcb->xcp.saved_i = current_regs[REG_FLAGS];
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
- current_regs[XCPT_PC] = (chipreg_t)up_sigdeliver;
- current_regs[XCPT_I] = 0;
+ *current_pc = (uint32)up_sigdeliver;
+ current_regs[REG_FLAGS] = 0;
/* And make sure that the saved context in the TCB
* is the same as the interrupt return context.
@@ -173,21 +175,23 @@ void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver)
else
{
+ uint32 *saved_pc = (uint32*)&tcb->xcp.regs[REG_PC];
+
/* Save the return lr and cpsr and one scratch register
* These will be restored by the signal trampoline after
* the signals have been delivered.
*/
- tcb->xcp.sigdeliver = sigdeliver;
- tcb->xcp.saved_pc = tcb->xcp.regs[XCPT_PC];
- tcb->xcp.saved_i = tcb->xcp.regs[XCPT_I];
+ tcb->xcp.sigdeliver = sigdeliver;
+ tcb->xcp.saved_pc = *saved_pc;
+ tcb->xcp.saved_i = tcb->xcp.regs[REG_FLAGS];
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
- tcb->xcp.regs[XCPT_PC] = (chipreg_t)up_sigdeliver;
- tcb->xcp.regs[XCPT_I] = 0;
+ *saved_pc = (uint32)up_sigdeliver;
+ tcb->xcp.regs[REG_FLAGS] = 0;
}
irqrestore(flags);
diff --git a/nuttx/arch/z16/src/common/up_sigdeliver.c b/nuttx/arch/z16/src/common/up_sigdeliver.c
index 9083c596f..5cd96d202 100644
--- a/nuttx/arch/z16/src/common/up_sigdeliver.c
+++ b/nuttx/arch/z16/src/common/up_sigdeliver.c
@@ -83,6 +83,7 @@ void up_sigdeliver(void)
#ifndef CONFIG_DISABLE_SIGNALS
_TCB *rtcb = (_TCB*)g_readytorun.head;
chipreg_t regs[XCPTCONTEXT_REGS];
+ uint32 *regs32 = (uint32*)regs;
sig_deliver_t sigdeliver;
/* Save the errno. This must be preserved throughout the signal handling
@@ -101,8 +102,8 @@ void up_sigdeliver(void)
/* Save the real return state on the stack. */
up_copystate(regs, rtcb->xcp.regs);
- regs[XCPT_PC] = rtcb->xcp.saved_pc;
- regs[XCPT_I] = rtcb->xcp.saved_i;
+ regs32[REG_PC/2] = rtcb->xcp.saved_pc;
+ regs[REG_FLAGS] = rtcb->xcp.saved_i;
/* Get a local copy of the sigdeliver function pointer.
* we do this so that we can nullify the sigdeliver
@@ -116,7 +117,10 @@ void up_sigdeliver(void)
/* Then restore the task interrupt state. */
- irqrestore(regs[XCPT_I]);
+ if ((reg[REG_FLAGS] & (Z16F_CNTRL_FLAGS_IRQE << 8)) != 0)
+ {
+ EI();
+ }
/* Deliver the signals */