aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/context_switch.s
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 22:37:35 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-14 22:37:35 +0100
commit73cf3eddd480f2bd7e987c58da82c243861a5314 (patch)
treeb6cf499e261cd2e4d87bd08b499ebdf1b97adf90 /src/kernel/core/context_switch.s
parentfcc321d0ef1771edff61a986df62d2cda2d7485e (diff)
downloadkogata-73cf3eddd480f2bd7e987c58da82c243861a5314.tar.gz
kogata-73cf3eddd480f2bd7e987c58da82c243861a5314.zip
Many things :
- fix context switching (it actually worked only because of optimizations!) - complete mchmap implementation - adjust elf parser to load binaries correctly even without FM_MMAP
Diffstat (limited to 'src/kernel/core/context_switch.s')
-rw-r--r--src/kernel/core/context_switch.s35
1 files changed, 6 insertions, 29 deletions
diff --git a/src/kernel/core/context_switch.s b/src/kernel/core/context_switch.s
index 6738a03..b8f6bb8 100644
--- a/src/kernel/core/context_switch.s
+++ b/src/kernel/core/context_switch.s
@@ -4,11 +4,10 @@
[GLOBAL save_context_and_enter_scheduler]
; void save_context_and_enter_scheduler(struct saved_context *ctx);
save_context_and_enter_scheduler:
- pushf
+ pushf ; push flags
cli
- pusha ; Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax
-
- mov eax, cr3
+ pusha ; push general registers
+ mov eax, cr3 ; push CR3
push eax
mov eax, [esp+44] ; get address of saved_context structure
@@ -19,32 +18,10 @@ save_context_and_enter_scheduler:
jmp run_scheduler
resume_saved_context:
- pop eax
- mov cr3, eax
-
- popa
- popf
- ret
-
-[GLOBAL irq0_save_context_and_enter_scheduler]
-; meant to be called on IRQ0
-; general registers already saved by IRQ handler stub
-; flags already saved by interruption and interruptions disabled
-; only saves CR3
-irq0_save_context_and_enter_scheduler:
- mov eax, cr3
- push eax
-
- mov eax, [esp+8] ; get address of saved_context structure
- mov [eax], esp ; save esp
- mov dword [eax+4], resume_saved_irq0_context ; save eip
-
- mov esp, kernel_stack_top
- jmp run_scheduler
-
-resume_saved_irq0_context:
- pop eax
+ pop eax ; restore CR3
mov cr3, eax
+ popa ; restore general registers
+ popf ; restore flags
ret