diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-01-25 22:28:46 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-01-25 22:28:46 +0000 |
commit | 28898b80bc259a37f940e1727ad4bd8495a03982 (patch) | |
tree | e7f4ff0efc04d2daa0541100beead13fe6643373 /nuttx/arch/z16/src/z16f | |
parent | 347fa8f13710529e0306c2d894e3ea4f05534918 (diff) | |
download | px4-nuttx-28898b80bc259a37f940e1727ad4bd8495a03982.tar.gz px4-nuttx-28898b80bc259a37f940e1727ad4bd8495a03982.tar.bz2 px4-nuttx-28898b80bc259a37f940e1727ad4bd8495a03982.zip |
Initial Z61F debug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@565 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z16/src/z16f')
-rwxr-xr-x | nuttx/arch/z16/src/z16f/z16f_head.S | 38 | ||||
-rwxr-xr-x | nuttx/arch/z16/src/z16f/z16f_restoreusercontext.S | 210 | ||||
-rw-r--r-- | nuttx/arch/z16/src/z16f/z16f_sysexec.c | 6 |
3 files changed, 139 insertions, 115 deletions
diff --git a/nuttx/arch/z16/src/z16f/z16f_head.S b/nuttx/arch/z16/src/z16f/z16f_head.S index 85bfc04ef..2a1871aae 100755 --- a/nuttx/arch/z16/src/z16f/z16f_head.S +++ b/nuttx/arch/z16/src/z16f/z16f_head.S @@ -270,12 +270,12 @@ _halt2: /* _z16f_sysexec() should not return */ _timer2_isr: pushmlo <r0-r7> /* Save r0-r7 on the stack */ - ld r1, #Z16F_IRQ_TIMER0 /* r1 = Timer 2 IRQ number */ + ld r1, #Z16F_IRQ_TIMER2 /* r1 = Timer 2 IRQ number */ jp _common_isr /* Join common interrupt handling logic */ _timer1_isr: pushmlo <r0-r7> /* Save r0-r7 on the stack */ - ld r1, #Z16F_IRQ_TIMER0 /* r1 = Timer 1 IRQ number */ + ld r1, #Z16F_IRQ_TIMER1 /* r1 = Timer 1 IRQ number */ jp _common_isr /* Join common interrupt handling logic */ _timer0_isr: @@ -397,7 +397,7 @@ _c0_isr: * * On entry: * - * r0 = IRQ number + * r1 = IRQ number * * And the stack contains the following: * @@ -409,8 +409,8 @@ _c0_isr: * TOS[20-23] = r5 * TOS[24-27] = r6 * TOS[28-31] = r7 - * TOS[32-33] = return PC - * TOS[34-35] = flags (with padding) + * TOS[32-35] = return PC + * TOS[36-37] = flags (with padding) * **************************************************************************/ @@ -419,9 +419,9 @@ _common_isr: * push that as the saved value of r15=sp */ - ld r1, #-36 /* See stack accounting above */ - add r1, sp /* r1 = Value of the SP before the interrupt */ - push r1 /* Push r1 in the spot for the saved SP */ + ld r2, #(9*4+2) /* See stack accounting above */ + add r2, sp /* r1 = Value of the SP before the interrupt */ + push r2 /* Push r1 in the spot for the saved SP */ /* Save all of the remaining registers */ @@ -439,16 +439,34 @@ _common_isr: * to use to return from the interrupt in r0. This may or may not be the * same value as sp. */ + + cp r0, sp /* Check if we are performing a context switch */ + jp nz, _common_switch /* Jump if yes, else use faster return */ + popmhi <r8-r14> /* Restore r8-r14 */ + add sp, #4 /* Skip over restore of r15=sp */ + popmlo <r0-r7> /* Restore r0-r7 */ + iret + /* We are not returning to the same thread that was interrupted. In this case, + * r0 is not in the stack but, instead, refers to a storage structure in the TCB + */ + +_common_switch: ld sp, 2*REG_SP(r0) /* sp=Value of SP on return from interrupt */ ld.w r1, 2*REG_FLAGS(r0) /* r1=padded flags value */ push.w r1 /* Push padded flags value onto the stack */ ld r1, 2*REG_PC(r0) /* r1=return address */ push r1 /* Push the return address onto the stack */ + ld r7, 2*REG_R7(r0) /* Recover saved r7 */ + push r7 /* And save on the stack so that we can use r7 */ + ld r7, sp /* r7=saved sp */ - ld sp, r0 /* sp=Value of SP at call to _up_doirq */ + ld sp, r0 /* sp=Pointer to register save structure */ popmhi <r8-r14> /* Restore r8-r14 */ - popmlo <r0-r7> /* Restore r0-r7 */ + add sp, #4 /* Skip over restore of r15=sp */ + popmlo <r0-r6> /* Restore r0-r6 */ + ld sp, r7 /* Switch back to the correct stack */ + pop r7 /* Recover r7 from the stack */ iret /* Return from interrupt */ end diff --git a/nuttx/arch/z16/src/z16f/z16f_restoreusercontext.S b/nuttx/arch/z16/src/z16f/z16f_restoreusercontext.S index 447ba1124..f983499ba 100755 --- a/nuttx/arch/z16/src/z16f/z16f_restoreusercontext.S +++ b/nuttx/arch/z16/src/z16f/z16f_restoreusercontext.S @@ -1,105 +1,105 @@ -/*************************************************************************
- * arch/z16/src/z16f/z16f_restoreusercontext.asm
- *
- * Copyright (C) 2008 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSeqUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- *************************************************************************/
-
-/*************************************************************************
- * Included Files
- *************************************************************************/
-
-#include <nuttx/config.h>
-#include <arch/irq.h>
-#include "chip/chip.h"
-
-/*************************************************************************
- * External References / External Definitions
- *************************************************************************/
-
- xdef _up_restoreusercontext
-
-/*************************************************************************
- * Data Allocation
- *************************************************************************/
-
- define CODESEG, SPACE=EROM
- segment CODESEG
-
-/*************************************************************************
- * Code
- *************************************************************************/
-
-/*************************************************************************
- * Name: up_restoreusercontext
- *
- * Description:
- * Restore the current user context.
- *
- * Parameters:
- * r1: pointer to the register save array in the XCPT structure
- *
- *************************************************************************/
-
-_up_restoreusercontext:
- /* Disable interrupts throughout the following */
-
- di
-
- /* Set up the stack for return */
-
- ld sp, 2*REG_SP(r1) /* sp=Value of SP on return */
- ld r2, 2*REG_PC(r1) /* r2=return address */
- push r1 /* Push the return address onto the stack */
-
- /* Retore r8-r18 */
-
- ld sp, r1 /* sp=Value of SP at call to _up_doirq */
- popmhi <r8-r14> /* Restore r8-r14 */
-
- /* Test if interrupts should be enabled upon return */
-
- ld.w r2, 2*REG_FLAGS(r1) /* r2=padded flags value */
- tm r2, #(Z16F_CNTRL_FLAGS_IRQE << 8) /* Test (shifted) IRQE bit */
- jp z, _up_returndisabled /* Jump if interrupts should remain disabled */
-
- /* Return with interrupts enabled */
-
- popmlo <r0-r7> /* Restore r0-r7 */
- ei /* Enable interrupts and return */
- ret
-
- /* Return with interrupts disabled */
-
-_up_returndisabled:
- popmlo <r0-r7> /* Restore r0-r7 */
- ret
- end
+/************************************************************************* + * arch/z16/src/z16f/z16f_restoreusercontext.asm + * + * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSeqUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + *************************************************************************/ + +/************************************************************************* + * Included Files + *************************************************************************/ + +#include <nuttx/config.h> +#include <arch/irq.h> +#include "chip/chip.h" + +/************************************************************************* + * External References / External Definitions + *************************************************************************/ + + xdef _up_restoreusercontext + +/************************************************************************* + * Data Allocation + *************************************************************************/ + + define CODESEG, SPACE=EROM + segment CODESEG + +/************************************************************************* + * Code + *************************************************************************/ + +/************************************************************************* + * Name: up_restoreusercontext + * + * Description: + * Restore the current user context. + * + * Parameters: + * r1: pointer to the register save array in the XCPT structure + * + *************************************************************************/ + +_up_restoreusercontext: + /* Disable interrupts throughout the following */ + + di + + /* Set up the stack for return */ + + ld sp, 2*REG_SP(r1) /* sp=Value of SP on return */ + ld r2, 2*REG_PC(r1) /* r2=return address */ + push r1 /* Push the return address onto the stack */ + + /* Retore r8-r18 */ + + ld sp, r1 /* sp=Value of SP at call to _up_doirq */ + popmhi <r8-r14> /* Restore r8-r14 */ + + /* Test if interrupts should be enabled upon return */ + + ld.w r2, 2*REG_FLAGS(r1) /* r2=padded flags value */ + tm r2, #Z16F_CNTRL_FLAGS_IRQE /* Test IRQE bit */ + jp z, _up_returndisabled /* Jump if interrupts should remain disabled */ + + /* Return with interrupts enabled */ + + popmlo <r0-r7> /* Restore r0-r7 */ + ei /* Enable interrupts and return */ + ret + + /* Return with interrupts disabled */ + +_up_returndisabled: + popmlo <r0-r7> /* Restore r0-r7 */ + ret + end diff --git a/nuttx/arch/z16/src/z16f/z16f_sysexec.c b/nuttx/arch/z16/src/z16f/z16f_sysexec.c index 8ee91764c..e492bab6e 100644 --- a/nuttx/arch/z16/src/z16f/z16f_sysexec.c +++ b/nuttx/arch/z16/src/z16f/z16f_sysexec.c @@ -82,6 +82,12 @@ void z16f_sysexec(FAR chipreg_t *regs) { int errcode = OSERR_ERREXCEPTION; uint16 excp; + + /* Save that register reference so that it can be used for built-in + * diagnostics. + */ + + current_regs = regs; /* The cause of the the system exception is indicated in the SYSEXCPH&L * registers |