Initial work on paging, also complete ish interrupt registration
This commit is contained in:
73
x86_drivers/src/idt/vectors.rs
Normal file
73
x86_drivers/src/idt/vectors.rs
Normal file
@@ -0,0 +1,73 @@
|
||||
use crate::idt::{
|
||||
DPL, Error, Gate, GdtSelector, ISR, ISRWithIdx, ISRWithIdxNeverReturns, Idt, IdtTableEntry, Ist,
|
||||
};
|
||||
|
||||
macro_rules! vector {
|
||||
($(
|
||||
$(~$idx_:literal)?
|
||||
$($idx:literal: $name:ident => $type:ty)?
|
||||
);*) => {
|
||||
pub trait Vector {
|
||||
type FunctionSignature;
|
||||
const IDX:usize;
|
||||
fn register_handler<const REGISTERD:bool>(table:&mut Idt<REGISTERD>, isr: Self::FunctionSignature, selector: GdtSelector, ist: Ist, gate: Gate, priority: DPL) -> Result<&mut Idt<REGISTERD>,Error>;
|
||||
}
|
||||
|
||||
pub mod named_isr {
|
||||
$(
|
||||
$(pub struct $name;)?
|
||||
)*
|
||||
}
|
||||
|
||||
$(
|
||||
$(
|
||||
impl Vector for named_isr::$name {
|
||||
type FunctionSignature = $type;
|
||||
const IDX:usize = $idx;
|
||||
|
||||
fn register_handler<const REGISTERD:bool>(table:&mut Idt<REGISTERD>, isr: Self::FunctionSignature, selector: GdtSelector, ist: Ist, gate: Gate, priority: DPL) -> Result<&mut Idt<REGISTERD>,Error> {
|
||||
let offset = (isr as *const ()) as u64;
|
||||
let desc = IdtTableEntry::build(offset, selector, ist, gate, priority);
|
||||
table.register_handler(Self::IDX, desc)
|
||||
}
|
||||
}
|
||||
)?
|
||||
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
vector!(
|
||||
0: DivisionError => ISR;
|
||||
1: Debug => ISR;
|
||||
2: NonMaskableInterrupt => ISR;
|
||||
3: Breakpoint => ISR;
|
||||
4: Overflow => ISR;
|
||||
5: BoundRangeExceeded => ISR;
|
||||
6: InvalidOpcode => ISR;
|
||||
7: DeviceNotAvailable => ISR;
|
||||
8: DoubleFault => ISRWithIdxNeverReturns;
|
||||
9: CoprocessorSegmentOverrun => ISR;
|
||||
10: InvalidTSS => ISRWithIdx;
|
||||
11: SegmentNotPresent => ISRWithIdx;
|
||||
12: StackSegmentFault => ISRWithIdx;
|
||||
13: GeneralProtectionFault => ISRWithIdx;
|
||||
14: PageFault => ISRWithIdx;
|
||||
~15;
|
||||
16: X87FloatingPointException => ISR;
|
||||
17: AlignmentCheck => ISRWithIdx;
|
||||
18: MachineCheck => ISR;
|
||||
19: SIMDFloatingPointException => ISR;
|
||||
20: VirtualizationException => ISR;
|
||||
21: ControlProtectionException => ISRWithIdx;
|
||||
~22;
|
||||
~23;
|
||||
~24;
|
||||
~25;
|
||||
~26;
|
||||
~27;
|
||||
28: HypervisorInjectionException => ISR;
|
||||
29: VMMCommunicationException => ISRWithIdx;
|
||||
30: SecurityException => ISRWithIdx;
|
||||
~31;
|
||||
);
|
||||
Reference in New Issue
Block a user