diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/dtables.rs | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/src/shared/dtables.rs b/src/shared/dtables.rs index c5337fb..5ec2117 100644 --- a/src/shared/dtables.rs +++ b/src/shared/dtables.rs @@ -17,8 +17,11 @@ pub struct DescriptorTablePointer<Entry> { } impl<T> DescriptorTablePointer<T> { - fn new(slice: &[T]) -> Self { - let len = slice.len() * size_of::<T>(); + pub fn new(slice: &[T]) -> Self { + // GDT, LDT, and IDT all expect the limit to be set to "one less". + // See Intel 3a, Section 3.5.1 "Segment Descriptor Tables" and + // Section 6.10 "Interrupt Descriptor Table (IDT)". + let len = slice.len() * size_of::<T>() - 1; assert!(len < 0x10000); DescriptorTablePointer { base: slice.as_ptr(), @@ -27,23 +30,6 @@ impl<T> DescriptorTablePointer<T> { } } -impl DescriptorTablePointer<SegmentDescriptor> { - pub fn new_gdtp(gdt: &[SegmentDescriptor]) -> Self { - let mut p = Self::new(gdt); - p.limit -= 1; - p - } - pub fn new_ldtp(ldt: &[SegmentDescriptor]) -> Self { - Self::new(ldt) - } -} - -impl DescriptorTablePointer<IdtEntry> { - pub fn new_idtp(idt: &[IdtEntry]) -> Self { - Self::new(idt) - } -} - /// Load GDT table. pub unsafe fn lgdt(gdt: &DescriptorTablePointer<SegmentDescriptor>) { |