Skip to content

Commit 27e2cc6

Browse files
committed
Make DescriptorTablePointer::base a VirtAddr
Makes it clear that segmentation is applied before paging.
1 parent eb9ccb5 commit 27e2cc6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/structures/gdt.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! Types for the Global Descriptor Table and segment selectors.
22
3-
use crate::structures::{tss::TaskStateSegment, DescriptorTablePointer};
43
use crate::PrivilegeLevel;
4+
use crate::{
5+
structures::{tss::TaskStateSegment, DescriptorTablePointer},
6+
VirtAddr,
7+
};
58
use bit_field::BitField;
69
use bitflags::bitflags;
710
use core::fmt;
@@ -169,7 +172,7 @@ impl GlobalDescriptorTable {
169172
fn pointer(&self) -> DescriptorTablePointer {
170173
use core::mem::size_of;
171174
DescriptorTablePointer {
172-
base: self.table.as_ptr() as u64,
175+
base: VirtAddr::new(self.table.as_ptr() as u64),
173176
limit: (self.next_free * size_of::<u64>() - 1) as u16,
174177
}
175178
}

src/structures/idt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl InterruptDescriptorTable {
440440
fn pointer(&self) -> DescriptorTablePointer {
441441
use core::mem::size_of;
442442
DescriptorTablePointer {
443-
base: self as *const _ as u64,
443+
base: VirtAddr::new(self as *const _ as u64),
444444
limit: (size_of::<Self>() - 1) as u16,
445445
}
446446
}

src/structures/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Representations of various x86 specific structures and descriptor tables.
22
3+
use crate::VirtAddr;
4+
35
pub mod gdt;
46

57
// idt needs `feature(abi_x86_interrupt)`, which is not available on stable rust
@@ -18,5 +20,5 @@ pub struct DescriptorTablePointer {
1820
/// Size of the DT.
1921
pub limit: u16,
2022
/// Pointer to the memory region containing the DT.
21-
pub base: u64,
23+
pub base: VirtAddr,
2224
}

0 commit comments

Comments
 (0)