-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.S
137 lines (113 loc) · 2.83 KB
/
events.S
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// events.S, initial handling sequence of an event, build TF mainly
#include <spede/machine/asmacros.h> // do not use/include "spede.h"
#include "events.h" // for K_DATA, K_STACK_SIZE below
// set CPU DS and ES registers to K_DATA (data segment # registers)
#define SET_K_SEGS movw $(K_DATA), %ax; mov %ax, %ds; mov %ax, %es
.comm k_stack, K_STACK_SIZE, 1 // declare kernel stack space (global)
.text
//Phase 1
ENTRY(Loader) // loads the trapframe of the selected process in order to run it
movl 4(%esp), %eax // copy whats above stack pointer
movl %eax, %esp // copy esp to eax
popl %gs // pop regs
popl %fs
popl %es
popl %ds
popa // pop all
addl $8, %esp // skip timer event
iret // pop eip, cs, eflags
// push event_num then go into kernel
ENTRY(TimerEvent) // push eflags, cs, eip (by circuit)
pushl $0
pushl $TIMER_EVENT
jmp CommonPart
//Phase 2
ENTRY(SleepEvent)
pushl $0
pushl $SLEEP_EVENT
jmp CommonPart
ENTRY(GetPidEvent)
pushl $0
pushl $GETPID_EVENT
jmp CommonPart
CommonPart:
pusha // push all: e-a/c/d/b-x, e-s/b-p, e-s/d-i
pushl %ds // push 4 data seg registers
pushl %es
pushl %fs
pushl %gs
movl %esp, %ecx // copy TF addr (esp) to ecx
cld // clear direction flag bit
SET_K_SEGS // set kernel data segment registers
leal k_stack + K_STACK_SIZE, %esp // point esp to kernel stack
pushl %ecx // push ecx (TF addr) there
call CNAME(Kernel) // call Kernel code
//Phase 3
ENTRY(SemAllocEvent)
pushl $0
pushl $SEMALLOC_EVENT
jmp CommonPart
ENTRY(SemWaitEvent)
pushl $0
pushl $SEMWAIT_EVENT
jmp CommonPart
ENTRY(SemPostEvent)
pushl $0
pushl $SEMPOST_EVENT
jmp CommonPart
//Phase 4
ENTRY(SysPrintEvent)
pushl $0
pushl $SYSPRINT_EVENT
jmp CommonPart
//Phase 5
ENTRY(PortEvent)
pushl $0
pushl $PORT_EVENT
jmp CommonPart
ENTRY(PortAllocEvent)
pushl $0
pushl $PORTALLOC_EVENT
jmp CommonPart
ENTRY(PortWriteEvent)
pushl $0
pushl $PORTWRITE_EVENT
jmp CommonPart
ENTRY(PortReadEvent)
pushl $0
pushl $PORTREAD_EVENT
jmp CommonPart
//Phase 6
ENTRY(FSfindEvent)
pushl $0
pushl $FSFIND_EVENT
jmp CommonPart
ENTRY(FSopenEvent)
pushl $0
pushl $FSOPEN_EVENT
jmp CommonPart
ENTRY(FSreadEvent)
pushl $0
pushl $FSREAD_EVENT
jmp CommonPart
ENTRY(FScloseEvent)
pushl $0
pushl $FSCLOSE_EVENT
jmp CommonPart
//Phase 7
ENTRY(ForkEvent)
pushl $0
pushl $FORK_EVENT
jmp CommonPart
ENTRY(WaitEvent)
pushl $0
pushl $WAIT_EVENT
jmp CommonPart
ENTRY(ExitEvent)
pushl $0
pushl $EXIT_EVENT
jmp CommonPart
//Phase 9
ENTRY(PFEvent)
pushl $PF_EVENT
jmp CommonPart