Skip to content

Commit 9343bbc

Browse files
authored
Merge pull request #215 from rust-osdev/descriptor-table-pointer-base
Make `DescriptorTablePointer::base` a `VirtAddr`
2 parents 99ff6c4 + b7588c7 commit 9343bbc

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- `ExceptionStackFrame`
1010
- `VirtAddr::new_unchecked`
1111
- `interrupts::enable_interrupts_and_hlt`
12+
- **Breaking:** Make `DescriptorTablePointer::base` a `VirtAddr` ([#215](https://github.com/rust-osdev/x86_64/pull/215))
1213
- Relaxe `Sized` requirement for `FrameAllocator` in `Mapper::map_to` ([204](https://github.com/rust-osdev/x86_64/pull/204))
1314

1415
# 0.12.3 – 2020-10-31

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)