diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-10 18:38:37 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-10 18:38:37 +0000 |
commit | cae858890d5f4df465c13913616549af9c39b0c6 (patch) | |
tree | 8b8aefd4f1640e57bb4862d534ac0d9579ff5b57 | |
parent | 506452c6fa4b7d408da0d332100f43a3102168ab (diff) | |
download | px4-nuttx-cae858890d5f4df465c13913616549af9c39b0c6.tar.gz px4-nuttx-cae858890d5f4df465c13913616549af9c39b0c6.tar.bz2 px4-nuttx-cae858890d5f4df465c13913616549af9c39b0c6.zip |
Fix QEMU context switch bug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3361 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | apps/Makefile | 4 | ||||
-rw-r--r-- | apps/exec_nuttapp_list.h | 2 | ||||
-rw-r--r-- | apps/exec_nuttapp_proto.h | 2 | ||||
-rw-r--r-- | nuttx/arch/x86/src/qemu/qemu_fullcontextrestore.S | 16 | ||||
-rw-r--r-- | nuttx/arch/x86/src/qemu/qemu_saveusercontext.S | 39 |
5 files changed, 43 insertions, 20 deletions
diff --git a/apps/Makefile b/apps/Makefile index 4bc1f90bc..0deb46e9c 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -47,7 +47,6 @@ BUILTIN_APPS_BUILT = ifeq ($(CONFIG_BUILTIN_APPS_NUTTX),y) - # Individual application: HELLO ifeq ($(CONFIG_BUILTIN_APPS_HELLO),y) @@ -58,9 +57,6 @@ BUILTIN_APPS_DIR += hello # always walks into the sub-directories and asks for build BUILTIN_APPS_BUILT += hello/.built_always -hello/libhello$(LIBEXT): - @$(MAKE) -C hello TOPDIR="$(TOPDIR)" libhello$(LIBEXT) - endif # end of application list diff --git a/apps/exec_nuttapp_list.h b/apps/exec_nuttapp_list.h deleted file mode 100644 index e8e4424ad..000000000 --- a/apps/exec_nuttapp_list.h +++ /dev/null @@ -1,2 +0,0 @@ -/* List of application requirements, generated during make depend. */ -{ .name = "hello", .priority = SCHED_PRIORITY_DEFAULT, .stacksize = 768, .main = hello_main }, diff --git a/apps/exec_nuttapp_proto.h b/apps/exec_nuttapp_proto.h deleted file mode 100644 index 2c9c65ec9..000000000 --- a/apps/exec_nuttapp_proto.h +++ /dev/null @@ -1,2 +0,0 @@ -/* List of application entry points, generated during make depend. */ -EXTERN int hello_main(int argc, char *argv[]); diff --git a/nuttx/arch/x86/src/qemu/qemu_fullcontextrestore.S b/nuttx/arch/x86/src/qemu/qemu_fullcontextrestore.S index 7d25e9072..9a1e1e64e 100644 --- a/nuttx/arch/x86/src/qemu/qemu_fullcontextrestore.S +++ b/nuttx/arch/x86/src/qemu/qemu_fullcontextrestore.S @@ -61,14 +61,24 @@ /* Trace macros, use like trace 'i' to print char to serial port. */ - .macro trace, ch + .macro chout, addr, ch #ifdef CONFIG_DEBUG - mov $0x3f8, %dx + mov $\addr, %dx mov $\ch, %al out %al, %dx #endif .endm + .macro trace, ch +#ifdef CONFIG_DEBUG + push %eax + push %edx + chout 0x3f8, \ch + pop %edx + pop %eax +#endif + .endm + /************************************************************************** * Public Functions **************************************************************************/ @@ -151,5 +161,5 @@ up_fullcontextrestore: popl %eax iret .size up_fullcontextrestore, . - up_fullcontextrestore - .end + .end diff --git a/nuttx/arch/x86/src/qemu/qemu_saveusercontext.S b/nuttx/arch/x86/src/qemu/qemu_saveusercontext.S index ffa1cf7f6..e9a98b331 100644 --- a/nuttx/arch/x86/src/qemu/qemu_saveusercontext.S +++ b/nuttx/arch/x86/src/qemu/qemu_saveusercontext.S @@ -57,14 +57,24 @@ /* Trace macros, use like trace 'i' to print char to serial port. */ - .macro trace, ch + .macro chout, addr, ch #ifdef CONFIG_DEBUG - mov $0x3f8, %dx + mov $\addr, %dx mov $\ch, %al out %al, %dx #endif .endm + .macro trace, ch +#ifdef CONFIG_DEBUG + push %eax + push %edx + chout 0x3f8, \ch + pop %edx + pop %eax +#endif + .endm + /************************************************************************** * .text **************************************************************************/ @@ -132,15 +142,26 @@ up_saveusercontext: movl %ebp, (4*REG_EBP)(%eax) - /* Get and save the interrupt state */ + /* Save EAX=1. This will be the "apparent" return value from this + * function when context is switch back to this thread. The non-zero + * return value is the indication that we have been resumed. + */ + + movl $1, (4*REG_EAX)(%eax) + + /* Get and save the interrupt state */ - pushf - pop %ecx + pushf + pop %ecx movl %ecx, (4*REG_EFLAGS)(%eax) - - /* And return 0. 'ret' will remove the EIP from the top of the stack. */ - xorl %eax, %eax + /* And return 0 -- The zero return value is the indication that that + * this is the original, "true" return from the function. + * + * 'ret' will remove the EIP from the top of the stack. + */ + + xorl %eax, %eax ret .size up_saveusercontext, . - up_saveusercontext - .end + .end |