Fix fullcontextrestore bug

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3353 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-03-09 02:04:45 +00:00
parent 494faf2fbc
commit 022fafacee
5 changed files with 98 additions and 63 deletions

View File

@ -1,5 +1,5 @@
/****************************************************************************
* arch/x86/src/i486/up_assert.c
* arch/x86/src/common/up_assert.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@ -108,36 +108,6 @@ static void up_stackdump(uint32_t sp, uint32_t stack_base)
# define up_stackdump()
#endif
/****************************************************************************
* Name: up_registerdump
****************************************************************************/
#ifdef CONFIG_ARCH_STACKDUMP
static inline void up_registerdump(void)
{
/* Are user registers available from interrupt processing? */
if (current_regs)
{
lldbg(" ds:%08x irq:%08x err:%08x\n",
current_regs[REG_DS], current_regs[REG_IRQNO],
current_regs[REG_ERRCODE]);
lldbg("edi:%08x esi:%08x ebp:%08x esp:%08x\n",
current_regs[REG_EDI], current_regs[REG_ESI],
current_regs[REG_EBP], current_regs[REG_ESP]);
lldbg("ebx:%08x edx:%08x ecx:%08x eax:%08x\n",
current_regs[REG_EBX], current_regs[REG_EDX],
current_regs[REG_ECX], current_regs[REG_EAX]);
lldbg("eip:%08x cs:%08x flg:%08x sp:%08x ss:%08x\n",
current_regs[REG_EIP], current_regs[REG_CS],
current_regs[REG_EFLAGS], current_regs[REG_SP],
current_regs[REG_SS]);
}
}
#else
# define up_registerdump()
#endif
/****************************************************************************
* Name: up_dumpstate
****************************************************************************/
@ -226,7 +196,10 @@ static void up_dumpstate(void)
/* Then dump the registers (if available) */
up_registerdump();
if (current_regs != NULL)
{
up_registerdump(current_regs);
}
}
#else
# define up_dumpstate()

View File

@ -163,28 +163,8 @@ extern void up_lowputc(char ch);
extern void up_puts(const char *str);
extern void up_lowputs(const char *str);
extern void up_doirq(int irq, uint32_t *regs);
#ifdef CONFIG_PAGING
extern void up_pginitialize(void);
extern uint32_t *up_va2pte(uintptr_t vaddr);
extern void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr);
#else /* CONFIG_PAGING */
# define up_pginitialize()
extern void up_dataabort(uint32_t *regs);
#endif /* CONFIG_PAGING */
extern void up_prefetchabort(uint32_t *regs);
extern void up_syscall(uint32_t *regs);
extern void up_undefinedinsn(uint32_t *regs);
/* Defined in up_vectors.S */
extern void up_vectorundefinsn(void);
extern void up_vectorswi(void);
extern void up_vectorprefetch(void);
extern void up_vectordata(void);
extern void up_vectoraddrexcptn(void);
extern void up_vectorirq(void);
extern void up_vectorfiq(void);
extern void up_registerdump(uint32_t *regs);
/* Defined in up_allocateheap.c */

View File

@ -0,0 +1,82 @@
/****************************************************************************
* arch/x86/src/i486/up_regdump.c
*
* Copyright (C) 2011 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 <debug.h>
#include <nuttx/irq.h>
#include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Output debug info -- even if debug is not selected. */
#undef lldbg
#define lldbg lib_lowprintf
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_registerdump
****************************************************************************/
void up_registerdump(uint32_t *regs)
{
lldbg(" ds:%08x irq:%08x err:%08x\n",
regs[REG_DS], regs[REG_IRQNO], regs[REG_ERRCODE]);
lldbg("edi:%08x esi:%08x ebp:%08x esp:%08x\n",
regs[REG_EDI], regs[REG_ESI], regs[REG_EBP], regs[REG_ESP]);
lldbg("ebx:%08x edx:%08x ecx:%08x eax:%08x\n",
regs[REG_EBX], regs[REG_EDX], regs[REG_ECX], regs[REG_EAX]);
lldbg("eip:%08x cs:%08x flg:%08x sp:%08x ss:%08x\n",
regs[REG_EIP], regs[REG_CS], regs[REG_EFLAGS], regs[REG_SP],
regs[REG_SS]);
}

View File

@ -41,9 +41,9 @@ HEAD_ASRC = qemu_head.S
CMN_ASRCS = i486_utils.S
CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c \
up_createstack.c up_mdelay.c up_udelay.c up_exit.c \
up_createstack.c up_mdelay.c up_udelay.c up_exit.c\
up_initialize.c up_initialstate.c up_interruptcontext.c \
up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c \
up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c up_regdump.c \
up_releasepending.c up_releasestack.c up_reprioritizertr.c \
up_sigdeliver.c up_schedulesigaction.c up_unblocktask.c \
up_usestack.c

View File

@ -120,17 +120,17 @@ up_fullcontextrestore:
/* Now restore the remaining registers */
movl (4*REG_EDI)(%ebx), %edi
movl (4*REG_ESI)(%ebx), %esi
movl (4*REG_EBP)(%ebx), %ebp
movl (4*REG_EDX)(%ebx), %edx
movl (4*REG_ECX)(%ebx), %ecx
movl (4*REG_EDI)(%eax), %edi
movl (4*REG_ESI)(%eax), %esi
movl (4*REG_EBP)(%eax), %ebp
movl (4*REG_EDX)(%eax), %edx
movl (4*REG_ECX)(%eax), %ecx
/* Restore the segment registers */
mov (4*REG_DS)(%ebx), %ds
mov (4*REG_CS)(%ebx), %cs
mov (4*REG_SS)(%ebx), %ss
mov (4*REG_DS)(%eax), %ds
mov (4*REG_CS)(%eax), %cs
mov (4*REG_SS)(%eax), %ss
/* Restore the correct value of EAX, EBX, and the EFLAGS then return */