@@ -13,7 +13,7 @@ extern crate gdt;
1313
1414use spin:: Mutex ;
1515use x86_64:: structures:: {
16- idt:: { LockedIdt , ExceptionStackFrame , PageFaultErrorCode } ,
16+ idt:: { LockedIdt , InterruptStackFrame , PageFaultErrorCode } ,
1717 tss:: TaskStateSegment ,
1818} ;
1919use gdt:: { Gdt , create_gdt} ;
@@ -43,7 +43,7 @@ pub fn init(double_fault_stack_top_unusable: Option<memory::VirtualAddress>) {
4343 if let Some ( df_stack_top) = double_fault_stack_top_unusable {
4444 // Create and load an initial TSS and GDT so we can handle early exceptions such as double faults.
4545 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 ) ;
4747 println_raw ! ( "exceptions_early(): Created TSS: {:?}" , tss) ;
4848 * EARLY_TSS . lock ( ) = tss;
4949
@@ -69,7 +69,7 @@ pub fn init(double_fault_stack_top_unusable: Option<memory::VirtualAddress>) {
6969 let mut idt = EARLY_IDT . lock ( ) ; // withholds interrupts
7070
7171 // 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 ) ;
7373 // missing: 0x01 debug exception
7474 idt. non_maskable_interrupt . set_handler_fn ( nmi_handler) ;
7575 idt. breakpoint . set_handler_fn ( breakpoint_handler) ;
@@ -109,16 +109,16 @@ pub fn init(double_fault_stack_top_unusable: Option<memory::VirtualAddress>) {
109109
110110
111111/// 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) ;
114114
115115 loop { }
116116}
117117
118118
119119
120120/// 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 ) {
122122 println_raw ! ( "\n EXCEPTION (early): NON-MASKABLE INTERRUPT at {:#x}\n {:#?}" ,
123123 stack_frame. instruction_pointer,
124124 stack_frame) ;
@@ -128,7 +128,7 @@ pub extern "x86-interrupt" fn nmi_handler(stack_frame: &mut ExceptionStackFrame)
128128
129129
130130/// 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 ) {
132132 println_raw ! ( "\n EXCEPTION (early): BREAKPOINT at {:#x}\n {:#?}" ,
133133 stack_frame. instruction_pointer,
134134 stack_frame) ;
@@ -137,7 +137,7 @@ pub extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut ExceptionStac
137137}
138138
139139/// 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 ) {
141141 println_raw ! ( "\n EXCEPTION (early): INVALID OPCODE at {:#x}\n {:#?}" ,
142142 stack_frame. instruction_pointer,
143143 stack_frame) ;
@@ -149,7 +149,7 @@ pub extern "x86-interrupt" fn invalid_opcode_handler(stack_frame: &mut Exception
149149///
150150/// For more information about "spurious interrupts",
151151/// 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 ) {
153153 println_raw ! ( "\n EXCEPTION (early): DEVICE_NOT_AVAILABLE at {:#x}\n {:#?}" ,
154154 stack_frame. instruction_pointer,
155155 stack_frame) ;
@@ -158,15 +158,15 @@ pub extern "x86-interrupt" fn device_not_available_handler(stack_frame: &mut Exc
158158}
159159
160160
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 ) -> ! {
162162 println_raw ! ( "\n EXCEPTION (early): DOUBLE FAULT\n {:#?}" , stack_frame) ;
163163 println_raw ! ( "\n Note: this may be caused by stack overflow. Is the size of the initial_bsp_stack is too small?" ) ;
164164
165165 loop { }
166166}
167167
168168
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 ) {
170170 println_raw ! ( "\n EXCEPTION (early): SEGMENT_NOT_PRESENT FAULT\n error code: \
171171 {:#b}\n {:#?}",
172172 error_code,
@@ -176,7 +176,7 @@ pub extern "x86-interrupt" fn segment_not_present_handler(stack_frame: &mut Exce
176176}
177177
178178
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 ) {
180180 println_raw ! ( "\n EXCEPTION (early): GENERAL PROTECTION FAULT \n error code: \
181181 {:#X}\n {:#?}",
182182 error_code,
@@ -186,9 +186,8 @@ pub extern "x86-interrupt" fn general_protection_fault_handler(stack_frame: &mut
186186}
187187
188188
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 ( ) ;
192191 println_raw ! ( "\n EXCEPTION (early): PAGE FAULT (early handler) while accessing {:#x}\n error code: \
193192 {:?}\n {:#?}",
194193 accessed_address,
@@ -199,14 +198,14 @@ pub extern "x86-interrupt" fn early_page_fault_handler(stack_frame: &mut Excepti
199198 println_raw ! ( "Exception IP {:#X} is at {:?}" ,
200199 stack_frame. instruction_pointer,
201200 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 ) ,
203202 false // only look at .text sections, not all other types
204203 ) ) ,
205204 ) ;
206205 println_raw ! ( "Faulted access address {:#X} is at {:?}" ,
207206 accessed_address,
208207 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 ) ,
210209 true , // look at all sections (.data/.bss/.rodata), not just .text
211210 ) ) ,
212211 ) ;
0 commit comments