projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix kernel bug: process on arm never exit.
[bertos.git]
/
bertos
/
cpu
/
arm
/
hw
/
switch_ctx_arm.S
diff --git
a/bertos/cpu/arm/hw/switch_ctx_arm.S
b/bertos/cpu/arm/hw/switch_ctx_arm.S
index bde843cda734cd14ed7066fcb69dfa096dc2c4b2..39e9f46a2dabb58b88475203acf095dacd9a1155 100644
(file)
--- a/
bertos/cpu/arm/hw/switch_ctx_arm.S
+++ b/
bertos/cpu/arm/hw/switch_ctx_arm.S
@@
-42,6
+42,13
@@
.globl asm_switch_context
asm_switch_context:
mrs r2, cpsr /* Save status. */
.globl asm_switch_context
asm_switch_context:
mrs r2, cpsr /* Save status. */
+
+ /*
+ * To work correctly the lr should point to proc_exit, so when process finish
+ * could be return
+ */
+ push {lr} /* Add one element on stack, for next switching */
+
stmfd sp!, {r2, r4-r11, lr} /* Save registers. */
str sp, [r1] /* Save old stack pointer. */
stmfd sp!, {r2, r4-r11, lr} /* Save registers. */
str sp, [r1] /* Save old stack pointer. */
@@
-50,4
+57,5
@@
asm_switch_context:
ldmfd sp!, {r2, r4-r11, lr} /* Load new registers. */
msr cpsr, r2 /* restore flags reg. */
ldmfd sp!, {r2, r4-r11, lr} /* Load new registers. */
msr cpsr, r2 /* restore flags reg. */
- mov pc, lr
+ pop {r0} /* pop on stack address of the process that we want to jump */
+ mov pc, r0