blob: 01f3ca4b07c51c2c3329f37444ded1ab08f9af40 [file] [log] [blame]
swissChilicfd3c3c2021-04-03 15:04:24 -07001 [bits 32]
2 [extern _do_switch_task]
3 [global switch_task]
4switch_task:
5 pusha ; Save everything
6 push esp ; Arguments for _do_switch_task(eip, ebp, esp)
7 push ebp
8 push .after
9 call _do_switch_task
10.after:
swissChili172fd632021-04-04 19:02:36 -070011 ;; add esp, 12 ; Clear the arguments
swissChilicfd3c3c2021-04-03 15:04:24 -070012 popa ; Reset everything
13 xor eax, eax ; Return 0
swissChili172fd632021-04-04 19:02:36 -070014
15 pop ebx ; This is just to make debugging easy
16 jmp ebx
swissChilicfd3c3c2021-04-03 15:04:24 -070017
18 [global _switch_to_task]
swissChili7be32742021-04-03 21:17:24 -070019 ;; _switch_to_task(uint page_directory, uint eip, uint ebp, uint esp)
swissChilicfd3c3c2021-04-03 15:04:24 -070020_switch_to_task: ; (page_directory, eip, ebp, esp)
21 add esp, 4 ; We don't care about the return address
swissChilicfd3c3c2021-04-03 15:04:24 -070022
swissChili7be32742021-04-03 21:17:24 -070023 pop ecx ; Page directory
24 pop eax ; eip
25 pop ebp
26 pop ebx ; esp
27
swissChilicfd3c3c2021-04-03 15:04:24 -070028 mov esp, ebx ; Reset old stack
29
30 mov cr3, ecx ; Set page directory
31 sti
32 jmp eax ; Jump back to code