Skip to content

Commit

Permalink
Merge pull request #215 from rust-osdev/descriptor-table-pointer-base
Browse files Browse the repository at this point in the history
Make `DescriptorTablePointer::base` a `VirtAddr`
  • Loading branch information
phil-opp authored Dec 28, 2020
2 parents 99ff6c4 + b7588c7 commit 9343bbc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `ExceptionStackFrame`
- `VirtAddr::new_unchecked`
- `interrupts::enable_interrupts_and_hlt`
- **Breaking:** Make `DescriptorTablePointer::base` a `VirtAddr` ([#215](https://github.com/rust-osdev/x86_64/pull/215))
- Relaxe `Sized` requirement for `FrameAllocator` in `Mapper::map_to` ([204](https://github.com/rust-osdev/x86_64/pull/204))

# 0.12.3 – 2020-10-31
Expand Down
7 changes: 5 additions & 2 deletions src/structures/gdt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//! Types for the Global Descriptor Table and segment selectors.
use crate::structures::{tss::TaskStateSegment, DescriptorTablePointer};
use crate::PrivilegeLevel;
use crate::{
structures::{tss::TaskStateSegment, DescriptorTablePointer},
VirtAddr,
};
use bit_field::BitField;
use bitflags::bitflags;
use core::fmt;
Expand Down Expand Up @@ -169,7 +172,7 @@ impl GlobalDescriptorTable {
fn pointer(&self) -> DescriptorTablePointer {
use core::mem::size_of;
DescriptorTablePointer {
base: self.table.as_ptr() as u64,
base: VirtAddr::new(self.table.as_ptr() as u64),
limit: (self.next_free * size_of::<u64>() - 1) as u16,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ impl InterruptDescriptorTable {
fn pointer(&self) -> DescriptorTablePointer {
use core::mem::size_of;
DescriptorTablePointer {
base: self as *const _ as u64,
base: VirtAddr::new(self as *const _ as u64),
limit: (size_of::<Self>() - 1) as u16,
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/structures/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Representations of various x86 specific structures and descriptor tables.
use crate::VirtAddr;

pub mod gdt;

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

0 comments on commit 9343bbc

Please sign in to comment.