summaryrefslogtreecommitdiff
path: root/libcpu/ia32
diff options
context:
space:
mode:
authorssslady <[email protected]>2009-10-14 08:52:06 +0000
committerssslady <[email protected]>2009-10-14 08:52:06 +0000
commit4e399f6e90c248b04ca1ca1d30e0c6e1da42d6a9 (patch)
treee76a8926d30e607a7a1302e06f9fa44a99709e14 /libcpu/ia32
parentb07743f604c9c9b4b44e4fc2ab20a97fae93b991 (diff)
fix bug in rt_hw_context_swicth
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@97 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'libcpu/ia32')
-rw-r--r--libcpu/ia32/context.S32
1 files changed, 28 insertions, 4 deletions
diff --git a/libcpu/ia32/context.S b/libcpu/ia32/context.S
index 96ebda41cf..767a104b2b 100644
--- a/libcpu/ia32/context.S
+++ b/libcpu/ia32/context.S
@@ -24,15 +24,39 @@
.globl rt_hw_context_switch
rt_hw_context_switch:
pushfl /*pushed eflags*/
- push %cs /*push cs register*/
- pushl 0x8(%esp) /*pushed eip register*/
+/*
+ * add by [email protected] 2009-10-14
+ * When we return again the esp should no be change.
+ * The old code change the esp to esp-4 :-(.
+ * A protection fault maybe occure for img created by some compiler,eg.gcc in the fedor-11
+ * -------------------------------------------------------------------------
+ * entry old code new code
+ * EIP ->return esp EIP FLAGS ->return esp
+ * ... FLAGS ->retern esp CS
+ * CS EIP
+ * EIP
+ */
+ popl %eax /*get flags*/
+ popl %ebx /*get eip*/
+ pushl %eax /*push flags*/
+ push %cs /*push cs*/
+ pushl %ebx /*push eip*/
+
+/*-------------------------------------------------------------------
+ */
+
+ /*push %cs*/ /*push cs register*/
+ /*pushl 0x8(%esp)*/ /*pushed eip register*/
+
pushl $0 /*fill irqno*/
push %ds /*push ds register*/
push %es /*push es register*/
pushal /*push eax,ecx,edx,ebx,esp,ebp,esp,edi registers*/
- movl 0x40(%esp), %eax /*to thread TCB*/
- movl 0x3c(%esp), %ebx /*from thread TCB*/
+ /*movl 0x40(%esp), %eax*/ /*to thread TCB*/
+ /*movl 0x3c(%esp), %ebx*/ /*from thread TCB*/
+ movl 0x3c(%esp), %eax /*to thread TCB*/
+ movl 0x38(%esp), %ebx /*from thread TCB*/
movl %esp, (%ebx) /*store esp in preempted tasks TCB*/
movl (%eax), %esp /*get new task stack pointer*/