@@ -197,14 +197,14 @@ fn _enable_pic() {
197
197
/// # Return
198
198
/// * `Ok(())` if successfully registered, or
199
199
/// * `Err(existing_handler_address)` if the given `interrupt_num` was already in use.
200
- pub fn register_interrupt ( interrupt_num : u8 , func : HandlerFunc ) -> Result < ( ) , u64 > {
200
+ pub fn register_interrupt ( interrupt_num : u8 , func : HandlerFunc ) -> Result < ( ) , usize > {
201
201
let mut idt = IDT . lock ( ) ;
202
202
203
203
// If the existing handler stored in the IDT is either missing (has an address of `0`)
204
204
// or is the default handler, that signifies the interrupt number is available.
205
205
let idt_entry = & mut idt[ interrupt_num as usize ] ;
206
- let existing_handler_addr = idt_entry. handler_addr ( ) . as_u64 ( ) ;
207
- if existing_handler_addr == 0 || existing_handler_addr == unimplemented_interrupt_handler as u64 {
206
+ let existing_handler_addr = idt_entry. handler_addr ( ) . as_u64 ( ) as usize ;
207
+ if existing_handler_addr == 0 || existing_handler_addr == unimplemented_interrupt_handler as usize {
208
208
idt_entry. set_handler_fn ( func) ;
209
209
Ok ( ( ) )
210
210
} else {
@@ -225,7 +225,7 @@ pub fn register_msi_interrupt(func: HandlerFunc) -> Result<u8, &'static str> {
225
225
// try to find an unused interrupt number in the IDT
226
226
let interrupt_num = idt. slice ( 32 ..=255 )
227
227
. iter ( )
228
- . rposition ( |& entry| entry. handler_addr ( ) . as_u64 ( ) == unimplemented_interrupt_handler as u64 )
228
+ . rposition ( |& entry| entry. handler_addr ( ) . as_u64 ( ) as usize == unimplemented_interrupt_handler as usize )
229
229
. map ( |entry| entry + 32 )
230
230
. ok_or ( "register_msi_interrupt: no available interrupt handlers (BUG: IDT is full?)" ) ?;
231
231
@@ -253,7 +253,7 @@ pub fn deregister_interrupt(interrupt_num: u8, func: HandlerFunc) -> Result<(),
253
253
254
254
// check if the handler stored is the same as the one provided
255
255
// this is to make sure no other application can deregister your interrupt
256
- if idt[ interrupt_num as usize ] . handler_addr ( ) . as_u64 ( ) == func as u64 {
256
+ if idt[ interrupt_num as usize ] . handler_addr ( ) . as_u64 ( ) as usize == func as usize {
257
257
idt[ interrupt_num as usize ] . set_handler_fn ( unimplemented_interrupt_handler) ;
258
258
Ok ( ( ) )
259
259
}
0 commit comments