aboutsummaryrefslogtreecommitdiff
path: root/kernel/l0/context_switch.s
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2014-12-07 20:26:57 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2014-12-07 20:26:57 +0100
commit42e92e7e9ab971acd6a1a55e38c0f4e999c1293c (patch)
tree558d2fe64a1c308a021ac1d3f2669f01b357a196 /kernel/l0/context_switch.s
parentbd1ed224590700c7568dd6a73a2dadcda238b1d5 (diff)
downloadkogata-42e92e7e9ab971acd6a1a55e38c0f4e999c1293c.tar.gz
kogata-42e92e7e9ab971acd6a1a55e38c0f4e999c1293c.zip
Optimize context switching code on IRQ0.
Diffstat (limited to 'kernel/l0/context_switch.s')
-rw-r--r--kernel/l0/context_switch.s32
1 files changed, 22 insertions, 10 deletions
diff --git a/kernel/l0/context_switch.s b/kernel/l0/context_switch.s
index 7351997..6738a03 100644
--- a/kernel/l0/context_switch.s
+++ b/kernel/l0/context_switch.s
@@ -11,10 +11,7 @@ save_context_and_enter_scheduler:
mov eax, cr3
push eax
- mov ax, ds ; Lower 16-bits of eax = ds.
- push eax ; save the data segment descriptor
-
- mov eax, [esp+48] ; get address of saved_context structure
+ mov eax, [esp+44] ; get address of saved_context structure
mov [eax], esp ; save esp
mov dword [eax+4], resume_saved_context ; save eip
@@ -23,18 +20,33 @@ save_context_and_enter_scheduler:
resume_saved_context:
pop eax
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov gs, ax
-
- 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
+ mov cr3, eax
+ ret
+
[GLOBAL resume_context]
resume_context: