diff options
Diffstat (limited to 'src/kernel/asm.s')
-rw-r--r-- | src/kernel/asm.s | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/src/kernel/asm.s b/src/kernel/asm.s new file mode 100644 index 0000000..1022817 --- /dev/null +++ b/src/kernel/asm.s | |||
@@ -0,0 +1,146 @@ | |||
1 | /* | ||
2 | * linux/kernel/asm.s | ||
3 | * | ||
4 | * (C) 1991 Linus Torvalds | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * asm.s contains the low-level code for most hardware faults. | ||
9 | * page_exception is handled by the mm, so that isn't here. This | ||
10 | * file also handles (hopefully) fpu-exceptions due to TS-bit, as | ||
11 | * the fpu must be properly saved/resored. This hasn't been tested. | ||
12 | */ | ||
13 | |||
14 | .globl divide_error,debug,nmi,int3,overflow,bounds,invalid_op | ||
15 | .globl double_fault,coprocessor_segment_overrun | ||
16 | .globl invalid_TSS,segment_not_present,stack_segment | ||
17 | .globl general_protection,coprocessor_error,irq13,reserved | ||
18 | |||
19 | divide_error: | ||
20 | pushl $do_divide_error | ||
21 | no_error_code: | ||
22 | xchgl %eax,(%esp) | ||
23 | pushl %ebx | ||
24 | pushl %ecx | ||
25 | pushl %edx | ||
26 | pushl %edi | ||
27 | pushl %esi | ||
28 | pushl %ebp | ||
29 | push %ds | ||
30 | push %es | ||
31 | push %fs | ||
32 | pushl $0 # "error code" | ||
33 | lea 44(%esp),%edx | ||
34 | pushl %edx | ||
35 | movl $0x10,%edx | ||
36 | mov %dx,%ds | ||
37 | mov %dx,%es | ||
38 | mov %dx,%fs | ||
39 | call *%eax | ||
40 | addl $8,%esp | ||
41 | pop %fs | ||
42 | pop %es | ||
43 | pop %ds | ||
44 | popl %ebp | ||
45 | popl %esi | ||
46 | popl %edi | ||
47 | popl %edx | ||
48 | popl %ecx | ||
49 | popl %ebx | ||
50 | popl %eax | ||
51 | iret | ||
52 | |||
53 | debug: | ||
54 | pushl $do_int3 # _do_debug | ||
55 | jmp no_error_code | ||
56 | |||
57 | nmi: | ||
58 | pushl $do_nmi | ||
59 | jmp no_error_code | ||
60 | |||
61 | int3: | ||
62 | pushl $do_int3 | ||
63 | jmp no_error_code | ||
64 | |||
65 | overflow: | ||
66 | pushl $do_overflow | ||
67 | jmp no_error_code | ||
68 | |||
69 | bounds: | ||
70 | pushl $do_bounds | ||
71 | jmp no_error_code | ||
72 | |||
73 | invalid_op: | ||
74 | pushl $do_invalid_op | ||
75 | jmp no_error_code | ||
76 | |||
77 | coprocessor_segment_overrun: | ||
78 | pushl $do_coprocessor_segment_overrun | ||
79 | jmp no_error_code | ||
80 | |||
81 | reserved: | ||
82 | pushl $do_reserved | ||
83 | jmp no_error_code | ||
84 | |||
85 | irq13: | ||
86 | pushl %eax | ||
87 | xorb %al,%al | ||
88 | outb %al,$0xF0 | ||
89 | movb $0x20,%al | ||
90 | outb %al,$0x20 | ||
91 | jmp 1f | ||
92 | 1: jmp 1f | ||
93 | 1: outb %al,$0xA0 | ||
94 | popl %eax | ||
95 | jmp coprocessor_error | ||
96 | |||
97 | double_fault: | ||
98 | pushl $do_double_fault | ||
99 | error_code: | ||
100 | xchgl %eax,4(%esp) # error code <-> %eax | ||
101 | xchgl %ebx,(%esp) # &function <-> %ebx | ||
102 | pushl %ecx | ||
103 | pushl %edx | ||
104 | pushl %edi | ||
105 | pushl %esi | ||
106 | pushl %ebp | ||
107 | push %ds | ||
108 | push %es | ||
109 | push %fs | ||
110 | pushl %eax # error code | ||
111 | lea 44(%esp),%eax # offset | ||
112 | pushl %eax | ||
113 | movl $0x10,%eax | ||
114 | mov %ax,%ds | ||
115 | mov %ax,%es | ||
116 | mov %ax,%fs | ||
117 | call *%ebx | ||
118 | addl $8,%esp | ||
119 | pop %fs | ||
120 | pop %es | ||
121 | pop %ds | ||
122 | popl %ebp | ||
123 | popl %esi | ||
124 | popl %edi | ||
125 | popl %edx | ||
126 | popl %ecx | ||
127 | popl %ebx | ||
128 | popl %eax | ||
129 | iret | ||
130 | |||
131 | invalid_TSS: | ||
132 | pushl $do_invalid_TSS | ||
133 | jmp error_code | ||
134 | |||
135 | segment_not_present: | ||
136 | pushl $do_segment_not_present | ||
137 | jmp error_code | ||
138 | |||
139 | stack_segment: | ||
140 | pushl $do_stack_segment | ||
141 | jmp error_code | ||
142 | |||
143 | general_protection: | ||
144 | pushl $do_general_protection | ||
145 | jmp error_code | ||
146 | |||