Initial work on paging, also complete ish interrupt registration

This commit is contained in:
ivajon
2026-05-08 11:40:51 +02:00
parent aa5ce32dce
commit c68d3fab14
11 changed files with 456 additions and 18 deletions

View 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;
);