diff options
author | 2016-05-27 12:07:30 -0400 | |
---|---|---|
committer | 2016-05-27 12:07:30 -0400 | |
commit | 30b3409c75dfce783b430e3bf50fa5b1f6e344d8 (patch) | |
tree | 43ee88f31bd0ca93fdde4e8ea9da0eb239429596 | |
parent | 33658a99b13eec17ab34336e8ee65c25a95678b7 (diff) | |
download | rust-x86-30b3409c75dfce783b430e3bf50fa5b1f6e344d8.tar.gz rust-x86-30b3409c75dfce783b430e3bf50fa5b1f6e344d8.tar.zst rust-x86-30b3409c75dfce783b430e3bf50fa5b1f6e344d8.zip |
Modify irq::interrupt_gate() signature
This commit changes the intterupt_gate() constructor to 1) use a Vaddr
instead of a raw pointer for the interrupt handler and 2) declare it as
a const_fn.
Signed-off-by: Dan Schatzberg <schatzberg.dan@gmail.com>
-rw-r--r-- | src/irq.rs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,6 +1,7 @@ //! Interrupt description and set-up code. use core::fmt; +use paging::VAddr; /// x86 Exception description (see also Intel Vol. 3a Chapter 6). #[derive(Debug)] @@ -208,15 +209,15 @@ impl IdtEntry { /// Create an interrupt gate with the "Present" flag set, which is the /// most common case. If you need something else, you can construct it /// manually. - pub fn interrupt_gate(gdt_code_selector: u16, handler: *const u8) -> IdtEntry { + pub const fn interrupt_gate(gdt_code_selector: u16, handler: VAddr) -> IdtEntry { IdtEntry { - base_lo: ((handler as u64) & 0xFFFF) as u16, + base_lo: ((handler.as_usize() as u64) & 0xFFFF) as u16, sel: gdt_code_selector, res0: 0, // Bit 7: "Present" flag set. // Bits 0-4: This is an interrupt gate. flags: 0b1000_1110, - base_hi: (handler as u64) >> 16, + base_hi: handler.as_usize() as u64 >> 16, res1: 0, } } |