@@ -13,7 +13,7 @@ extern crate gdt;
13
13
14
14
use spin:: Mutex ;
15
15
use x86_64:: structures:: {
16
- idt:: { LockedIdt , ExceptionStackFrame , PageFaultErrorCode } ,
16
+ idt:: { LockedIdt , InterruptStackFrame , PageFaultErrorCode } ,
17
17
tss:: TaskStateSegment ,
18
18
} ;
19
19
use gdt:: { Gdt , create_gdt} ;
@@ -43,7 +43,7 @@ pub fn init(double_fault_stack_top_unusable: Option<memory::VirtualAddress>) {
43
43
if let Some ( df_stack_top) = double_fault_stack_top_unusable {
44
44
// Create and load an initial TSS and GDT so we can handle early exceptions such as double faults.
45
45
let mut tss = TaskStateSegment :: new ( ) ;
46
- tss. interrupt_stack_table [ tss:: DOUBLE_FAULT_IST_INDEX ] = x86_64:: VirtualAddress ( df_stack_top. value ( ) ) ;
46
+ tss. interrupt_stack_table [ tss:: DOUBLE_FAULT_IST_INDEX ] = x86_64:: VirtAddr :: new ( df_stack_top. value ( ) as u64 ) ;
47
47
println_raw ! ( "exceptions_early(): Created TSS: {:?}" , tss) ;
48
48
* EARLY_TSS . lock ( ) = tss;
49
49
@@ -69,7 +69,7 @@ pub fn init(double_fault_stack_top_unusable: Option<memory::VirtualAddress>) {
69
69
let mut idt = EARLY_IDT . lock ( ) ; // withholds interrupts
70
70
71
71
// SET UP FIXED EXCEPTION HANDLERS
72
- idt. divide_by_zero . set_handler_fn ( divide_by_zero_handler ) ;
72
+ idt. divide_error . set_handler_fn ( divide_error_handler ) ;
73
73
// missing: 0x01 debug exception
74
74
idt. non_maskable_interrupt . set_handler_fn ( nmi_handler) ;
75
75
idt. breakpoint . set_handler_fn ( breakpoint_handler) ;
@@ -109,16 +109,16 @@ pub fn init(double_fault_stack_top_unusable: Option<memory::VirtualAddress>) {
109
109
110
110
111
111
/// exception 0x00
112
- pub extern "x86-interrupt" fn divide_by_zero_handler ( stack_frame : & mut ExceptionStackFrame ) {
113
- println_raw ! ( "\n EXCEPTION (early): DIVIDE BY ZERO \n {:#?}" , stack_frame) ;
112
+ pub extern "x86-interrupt" fn divide_error_handler ( stack_frame : InterruptStackFrame ) {
113
+ println_raw ! ( "\n EXCEPTION (early): DIVIDE ERROR \n {:#?}" , stack_frame) ;
114
114
115
115
loop { }
116
116
}
117
117
118
118
119
119
120
120
/// exception 0x02
121
- pub extern "x86-interrupt" fn nmi_handler ( stack_frame : & mut ExceptionStackFrame ) {
121
+ pub extern "x86-interrupt" fn nmi_handler ( stack_frame : InterruptStackFrame ) {
122
122
println_raw ! ( "\n EXCEPTION (early): NON-MASKABLE INTERRUPT at {:#x}\n {:#?}" ,
123
123
stack_frame. instruction_pointer,
124
124
stack_frame) ;
@@ -128,7 +128,7 @@ pub extern "x86-interrupt" fn nmi_handler(stack_frame: &mut ExceptionStackFrame)
128
128
129
129
130
130
/// exception 0x03
131
- pub extern "x86-interrupt" fn breakpoint_handler ( stack_frame : & mut ExceptionStackFrame ) {
131
+ pub extern "x86-interrupt" fn breakpoint_handler ( stack_frame : InterruptStackFrame ) {
132
132
println_raw ! ( "\n EXCEPTION (early): BREAKPOINT at {:#x}\n {:#?}" ,
133
133
stack_frame. instruction_pointer,
134
134
stack_frame) ;
@@ -137,7 +137,7 @@ pub extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStac
137
137
}
138
138
139
139
/// exception 0x06
140
- pub extern "x86-interrupt" fn invalid_opcode_handler ( stack_frame : & mut ExceptionStackFrame ) {
140
+ pub extern "x86-interrupt" fn invalid_opcode_handler ( stack_frame : InterruptStackFrame ) {
141
141
println_raw ! ( "\n EXCEPTION (early): INVALID OPCODE at {:#x}\n {:#?}" ,
142
142
stack_frame. instruction_pointer,
143
143
stack_frame) ;
@@ -149,7 +149,7 @@ pub extern "x86-interrupt" fn invalid_opcode_handler(stack_frame: &mut Exception
149
149
///
150
150
/// For more information about "spurious interrupts",
151
151
/// see [here](http://wiki.osdev.org/I_Cant_Get_Interrupts_Working#I_keep_getting_an_IRQ7_for_no_apparent_reason).
152
- pub extern "x86-interrupt" fn device_not_available_handler ( stack_frame : & mut ExceptionStackFrame ) {
152
+ pub extern "x86-interrupt" fn device_not_available_handler ( stack_frame : InterruptStackFrame ) {
153
153
println_raw ! ( "\n EXCEPTION (early): DEVICE_NOT_AVAILABLE at {:#x}\n {:#?}" ,
154
154
stack_frame. instruction_pointer,
155
155
stack_frame) ;
@@ -158,15 +158,15 @@ pub extern "x86-interrupt" fn device_not_available_handler(stack_frame: &mut Exc
158
158
}
159
159
160
160
161
- pub extern "x86-interrupt" fn double_fault_handler ( stack_frame : & mut ExceptionStackFrame , _error_code : u64 ) {
161
+ pub extern "x86-interrupt" fn double_fault_handler ( stack_frame : InterruptStackFrame , _error_code : u64 ) -> ! {
162
162
println_raw ! ( "\n EXCEPTION (early): DOUBLE FAULT\n {:#?}" , stack_frame) ;
163
163
println_raw ! ( "\n Note: this may be caused by stack overflow. Is the size of the initial_bsp_stack is too small?" ) ;
164
164
165
165
loop { }
166
166
}
167
167
168
168
169
- pub extern "x86-interrupt" fn segment_not_present_handler ( stack_frame : & mut ExceptionStackFrame , error_code : u64 ) {
169
+ pub extern "x86-interrupt" fn segment_not_present_handler ( stack_frame : InterruptStackFrame , error_code : u64 ) {
170
170
println_raw ! ( "\n EXCEPTION (early): SEGMENT_NOT_PRESENT FAULT\n error code: \
171
171
{:#b}\n {:#?}",
172
172
error_code,
@@ -176,7 +176,7 @@ pub extern "x86-interrupt" fn segment_not_present_handler(stack_frame: &mut Exce
176
176
}
177
177
178
178
179
- pub extern "x86-interrupt" fn general_protection_fault_handler ( stack_frame : & mut ExceptionStackFrame , error_code : u64 ) {
179
+ pub extern "x86-interrupt" fn general_protection_fault_handler ( stack_frame : InterruptStackFrame , error_code : u64 ) {
180
180
println_raw ! ( "\n EXCEPTION (early): GENERAL PROTECTION FAULT \n error code: \
181
181
{:#X}\n {:#?}",
182
182
error_code,
@@ -186,9 +186,8 @@ pub extern "x86-interrupt" fn general_protection_fault_handler(stack_frame: &mut
186
186
}
187
187
188
188
189
- pub extern "x86-interrupt" fn early_page_fault_handler ( stack_frame : & mut ExceptionStackFrame , error_code : PageFaultErrorCode ) {
190
- use x86_64:: registers:: control_regs;
191
- let accessed_address = control_regs:: cr2 ( ) ;
189
+ pub extern "x86-interrupt" fn early_page_fault_handler ( stack_frame : InterruptStackFrame , error_code : PageFaultErrorCode ) {
190
+ let accessed_address = x86_64:: registers:: control:: Cr2 :: read_raw ( ) ;
192
191
println_raw ! ( "\n EXCEPTION (early): PAGE FAULT (early handler) while accessing {:#x}\n error code: \
193
192
{:?}\n {:#?}",
194
193
accessed_address,
@@ -199,14 +198,14 @@ pub extern "x86-interrupt" fn early_page_fault_handler(stack_frame: &mut Excepti
199
198
println_raw ! ( "Exception IP {:#X} is at {:?}" ,
200
199
stack_frame. instruction_pointer,
201
200
mod_mgmt:: get_initial_kernel_namespace( ) . and_then( |ns| ns. get_section_containing_address(
202
- memory:: VirtualAddress :: new_canonical( stack_frame. instruction_pointer. 0 as usize ) ,
201
+ memory:: VirtualAddress :: new_canonical( stack_frame. instruction_pointer. as_u64 ( ) as usize ) ,
203
202
false // only look at .text sections, not all other types
204
203
) ) ,
205
204
) ;
206
205
println_raw ! ( "Faulted access address {:#X} is at {:?}" ,
207
206
accessed_address,
208
207
mod_mgmt:: get_initial_kernel_namespace( ) . and_then( |ns| ns. get_section_containing_address(
209
- memory:: VirtualAddress :: new_canonical( accessed_address. 0 as usize ) ,
208
+ memory:: VirtualAddress :: new_canonical( accessed_address as usize ) ,
210
209
true , // look at all sections (.data/.bss/.rodata), not just .text
211
210
) ) ,
212
211
) ;
0 commit comments