Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DescriptorTablePointer::base a VirtAddr #215

Merged
merged 2 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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,
}