blob: 92e3f2e4dc1dad35a61880e82e60544b314bce02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
.globl task_switch
// This function takes a pointer
// to a PROC structure and jump
// to this process
task_switch:
push 12(%esi) # eax (cf PROC struct)
push 16(%esi) # ebx
push 20(%esi) # ecx
push 24(%esi) # edx
push 44(%esi) # ebp
push 48(%esi) # esi
push 52(%esi) # edi
push 56(%esi) # ds
push 60(%esi) # es
push 64(%esi) # fs
push 68(%esi) # gs
// Don't forget to clear the interrupt
movb $0x20, %al
outb %al, $0x20
// Setup process page directory
mov 8(%esi), %eax
mov %eax, %cr3
// Setup registers
pop %gs
pop %fs
pop %es
pop %ds
pop %edi
pop %esi
pop %ebp
pop %edx
pop %ecx
pop %ebx
pop %eax
// Perform the task switch
push 36(%esi) # ss
push 40(%esi) # esp
push 72(%esi) # eflags
push 28(%esi) # cs
push 32(%esi) # eip
iret
|