@@ -34,6 +34,31 @@ pub fn install() {
34
34
set_general_handler ! ( idt, unhandle, 32 ..64 ) ;
35
35
set_general_handler ! ( idt, unknown, 64 ..) ;
36
36
37
+ idt. divide_error . set_handler_fn ( divide_error_exception) ;
38
+ idt. debug . set_handler_fn ( debug_exception) ;
39
+ idt. breakpoint . set_handler_fn ( breakpoint_exception) ;
40
+ idt. overflow . set_handler_fn ( overflow_exception) ;
41
+ idt. bound_range_exceeded
42
+ . set_handler_fn ( bound_range_exceeded_exception) ;
43
+ idt. invalid_opcode . set_handler_fn ( invalid_opcode_exception) ;
44
+ idt. device_not_available
45
+ . set_handler_fn ( device_not_available_exception) ;
46
+ idt. invalid_tss . set_handler_fn ( invalid_tss_exception) ;
47
+ idt. segment_not_present
48
+ . set_handler_fn ( segment_not_present_exception) ;
49
+ idt. stack_segment_fault
50
+ . set_handler_fn ( stack_segment_fault_exception) ;
51
+ idt. general_protection_fault
52
+ . set_handler_fn ( general_protection_exception) ;
53
+ idt. page_fault . set_handler_fn ( page_fault_handler) ;
54
+ idt. x87_floating_point
55
+ . set_handler_fn ( floating_point_exception) ;
56
+ idt. alignment_check
57
+ . set_handler_fn ( alignment_check_exception) ;
58
+ idt. simd_floating_point
59
+ . set_handler_fn ( simd_floating_point_exception) ;
60
+ idt. virtualization . set_handler_fn ( virtualization_exception) ;
61
+
37
62
unsafe {
38
63
idt. double_fault
39
64
. set_handler_fn ( double_fault_exception)
@@ -78,11 +103,41 @@ fn unknown(_stack_frame: ExceptionStackFrame, index: u8, _error_code: Option<u64
78
103
apic:: eoi ( ) ;
79
104
}
80
105
106
+ extern "x86-interrupt" fn divide_error_exception ( stack_frame : ExceptionStackFrame ) {
107
+ error ! ( "Divide Error (#DE) Exception: {:#?}" , stack_frame) ;
108
+ scheduler:: abort ( ) ;
109
+ }
110
+
111
+ extern "x86-interrupt" fn debug_exception ( stack_frame : ExceptionStackFrame ) {
112
+ error ! ( "Debug (#DB) Exception: {:#?}" , stack_frame) ;
113
+ scheduler:: abort ( ) ;
114
+ }
115
+
81
116
extern "x86-interrupt" fn nmi_exception ( stack_frame : ExceptionStackFrame ) {
82
117
error ! ( "Non-Maskable Interrupt (NMI) Exception: {:#?}" , stack_frame) ;
83
118
scheduler:: abort ( ) ;
84
119
}
85
120
121
+ extern "x86-interrupt" fn breakpoint_exception ( stack_frame : ExceptionStackFrame ) {
122
+ error ! ( "Breakpoint (#BP) Exception: {:#?}" , stack_frame) ;
123
+ scheduler:: abort ( ) ;
124
+ }
125
+
126
+ extern "x86-interrupt" fn overflow_exception ( stack_frame : ExceptionStackFrame ) {
127
+ error ! ( "Overflow (#OF) Exception: {:#?}" , stack_frame) ;
128
+ scheduler:: abort ( ) ;
129
+ }
130
+
131
+ extern "x86-interrupt" fn bound_range_exceeded_exception ( stack_frame : ExceptionStackFrame ) {
132
+ error ! ( "BOUND Range Exceeded (#BR) Exception: {:#?}" , stack_frame) ;
133
+ scheduler:: abort ( ) ;
134
+ }
135
+
136
+ extern "x86-interrupt" fn invalid_opcode_exception ( stack_frame : ExceptionStackFrame ) {
137
+ error ! ( "Invalid Opcode (#UD) Exception: {:#?}" , stack_frame) ;
138
+ scheduler:: abort ( ) ;
139
+ }
140
+
86
141
extern "x86-interrupt" fn device_not_available_exception ( _stack_frame : ExceptionStackFrame ) {
87
142
// We set the CR0_TASK_SWITCHED flag every time we switch to a task.
88
143
// This causes the "Device Not Available" Exception (int #7) to be thrown as soon as we use the FPU for the first time.
@@ -98,6 +153,46 @@ extern "x86-interrupt" fn device_not_available_exception(_stack_frame: Exception
98
153
core_scheduler ( ) . fpu_switch ( ) ;
99
154
}
100
155
156
+ extern "x86-interrupt" fn invalid_tss_exception ( stack_frame : ExceptionStackFrame , _code : u64 ) {
157
+ error ! ( "Invalid TSS (#TS) Exception: {:#?}" , stack_frame) ;
158
+ scheduler:: abort ( ) ;
159
+ }
160
+
161
+ extern "x86-interrupt" fn segment_not_present_exception (
162
+ stack_frame : ExceptionStackFrame ,
163
+ _code : u64 ,
164
+ ) {
165
+ error ! ( "Segment Not Present (#NP) Exception: {:#?}" , stack_frame) ;
166
+ scheduler:: abort ( ) ;
167
+ }
168
+
169
+ extern "x86-interrupt" fn stack_segment_fault_exception (
170
+ stack_frame : ExceptionStackFrame ,
171
+ error_code : u64 ,
172
+ ) {
173
+ error ! (
174
+ "Stack Segment Fault (#SS) Exception: {:#?}, error {:#X}" ,
175
+ stack_frame, error_code
176
+ ) ;
177
+ scheduler:: abort ( ) ;
178
+ }
179
+
180
+ extern "x86-interrupt" fn general_protection_exception (
181
+ stack_frame : ExceptionStackFrame ,
182
+ error_code : u64 ,
183
+ ) {
184
+ error ! (
185
+ "General Protection (#GP) Exception: {:#?}, error {:#X}" ,
186
+ stack_frame, error_code
187
+ ) ;
188
+ error ! (
189
+ "fs = {:#X}, gs = {:#X}" ,
190
+ processor:: readfs( ) ,
191
+ processor:: readgs( )
192
+ ) ;
193
+ scheduler:: abort ( ) ;
194
+ }
195
+
101
196
extern "x86-interrupt" fn double_fault_exception (
102
197
stack_frame : ExceptionStackFrame ,
103
198
error_code : u64 ,
@@ -109,6 +204,16 @@ extern "x86-interrupt" fn double_fault_exception(
109
204
scheduler:: abort ( )
110
205
}
111
206
207
+ extern "x86-interrupt" fn floating_point_exception ( stack_frame : ExceptionStackFrame ) {
208
+ error ! ( "Floating-Point Error (#MF) Exception: {:#?}" , stack_frame) ;
209
+ scheduler:: abort ( ) ;
210
+ }
211
+
212
+ extern "x86-interrupt" fn alignment_check_exception ( stack_frame : ExceptionStackFrame , _code : u64 ) {
213
+ error ! ( "Alignment Check (#AC) Exception: {:#?}" , stack_frame) ;
214
+ scheduler:: abort ( ) ;
215
+ }
216
+
112
217
pub extern "x86-interrupt" fn page_fault_handler (
113
218
stack_frame : ExceptionStackFrame ,
114
219
error_code : PageFaultErrorCode ,
@@ -127,6 +232,16 @@ extern "x86-interrupt" fn machine_check_exception(stack_frame: ExceptionStackFra
127
232
scheduler:: abort ( )
128
233
}
129
234
235
+ extern "x86-interrupt" fn simd_floating_point_exception ( stack_frame : ExceptionStackFrame ) {
236
+ error ! ( "SIMD Floating-Point (#XM) Exception: {:#?}" , stack_frame) ;
237
+ scheduler:: abort ( ) ;
238
+ }
239
+
240
+ extern "x86-interrupt" fn virtualization_exception ( stack_frame : ExceptionStackFrame ) {
241
+ error ! ( "Virtualization (#VE) Exception: {:#?}" , stack_frame) ;
242
+ scheduler:: abort ( ) ;
243
+ }
244
+
130
245
static IRQ_NAMES : InterruptTicketMutex < HashMap < u32 , & ' static str , RandomState > > =
131
246
InterruptTicketMutex :: new ( HashMap :: with_hasher ( RandomState :: with_seeds ( 0 , 0 , 0 , 0 ) ) ) ;
132
247
0 commit comments