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

Release version v0.13.0 #223

Merged
merged 32 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
15ce8dd
feat(paging): Also return flags for `MapperAllSizes::translate()` (#207)
haraldh Dec 28, 2020
5b0eac1
Update changelog for #207
phil-opp Dec 28, 2020
13f2079
Relaxe `Sized` requirement for `Mapper::map_to`
phil-opp Nov 7, 2020
9a8d1dc
Update changelog for #204
phil-opp Dec 28, 2020
f316ad4
Merge pull request #204 from rust-osdev/mapper_unsized
phil-opp Dec 28, 2020
54403fd
Use custom error types instead of `()`
phil-opp Oct 30, 2020
7544957
Update changelog for #199
phil-opp Dec 28, 2020
c4a51ea
Merge pull request #199 from rust-osdev/custom-error-types
phil-opp Dec 28, 2020
274e3dc
Restructure the `TranslateResult` type
phil-opp Dec 28, 2020
663a2eb
Update changelog for #211
phil-opp Dec 28, 2020
5c795ad
Fix doc links
phil-opp Dec 28, 2020
ec87383
Make `MappedFrame::start_address` public and const add add `size` method
phil-opp Dec 28, 2020
728c39b
Group hex literal by four to resolve clippy warning
phil-opp Dec 28, 2020
d9bc78a
Merge pull request #211 from rust-osdev/translate-redesign
phil-opp Dec 28, 2020
2df2b97
Remove deprecated items
phil-opp Dec 28, 2020
eb9ccb5
Remove internal `deny_warnings` feature
phil-opp Dec 28, 2020
146e119
Rename `PhysToVirt` trait to `PageTableFrameMapping`
phil-opp Dec 28, 2020
f2940dd
Update changelog for #214
phil-opp Dec 28, 2020
27e2cc6
Make `DescriptorTablePointer::base` a `VirtAddr`
phil-opp Dec 28, 2020
99ff6c4
Merge pull request #214 from rust-osdev/rename-phys-to-virt
phil-opp Dec 28, 2020
b7588c7
Update changelog for #215
phil-opp Dec 28, 2020
9343bbc
Merge pull request #215 from rust-osdev/descriptor-table-pointer-base
phil-opp Dec 28, 2020
1b96f95
Change return type of `read_rip` to `VirtAddr`
phil-opp Dec 28, 2020
cbf0cb2
Merge pull request #216 from rust-osdev/read-rip-virt-addr
phil-opp Dec 28, 2020
9a0cf90
Remove `PortReadWrite` trait, which is no longer needed
phil-opp Dec 28, 2020
aa5d781
Merge pull request #217 from rust-osdev/remove-port-read-write
phil-opp Dec 28, 2020
d4c01a0
Make writing the RFLAGS register unsafe
phil-opp Dec 28, 2020
ed49449
Merge pull request #219 from rust-osdev/unsafe-rflags-write
phil-opp Dec 28, 2020
29ac343
Don't create a tag on `cargo release`
phil-opp Dec 28, 2020
cb4b478
Change `cargo release` commit message
phil-opp Dec 28, 2020
00b5634
Bump version to 0.13.0
phil-opp Dec 28, 2020
dbeb826
Merge branch 'master' into next
phil-opp Dec 28, 2020
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ license = "MIT/Apache-2.0"
name = "x86_64"
readme = "README.md"
repository = "https://github.com/rust-osdev/x86_64"
version = "0.12.4"
version = "0.13.0"
edition = "2018"

[dependencies]
Expand All @@ -35,7 +35,6 @@ cc = { version = "1.0.37", optional = true }
[features]
default = [ "nightly", "instructions" ]
instructions = []
deny-warnings = []
external_asm = [ "cc" ]
nightly = [ "inline_asm", "const_fn", "abi_x86_interrupt" ]
inline_asm = []
Expand All @@ -47,6 +46,7 @@ no-dev-version = true
pre-release-replacements = [
{ file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 },
]
pre-release-commit-message = "Release version {{version}}"
pre-release-commit-message = "Bump version to {{version}}"
disable-push = true
disable-publish = true
disable-tag = true
17 changes: 17 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Unreleased

# 0.13.0 – 2020-12-28

- **Breaking:** Also return flags for `MapperAllSizes::translate()` ([#207](https://github.com/rust-osdev/x86_64/pull/207))
- **Breaking:** Restructure the `TranslateResult` type and create separate `Translate` trait ([#211](https://github.com/rust-osdev/x86_64/pull/211))
- **Breaking:** Rename `PhysToVirt` trait to `PageTableFrameMapping` ([#214](https://github.com/rust-osdev/x86_64/pull/214))
- **Breaking:** Use custom error types instead of `()` ([#199](https://github.com/rust-osdev/x86_64/pull/199))
- **Breaking:** Remove deprecated items
- `UnusedPhysFrame`
- `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))
- **Breaking:** Change return type of `read_rip` to `VirtAddr` ([#216](https://github.com/rust-osdev/x86_64/pull/216))
- **Breaking:** Make writing the RFLAGS register unsafe ([#219](https://github.com/rust-osdev/x86_64/pull/219))
- **Breaking:** Remove `PortReadWrite` trait, which is no longer needed ([#217](https://github.com/rust-osdev/x86_64/pull/217))
- Relaxe `Sized` requirement for `FrameAllocator` in `Mapper::map_to` ([204](https://github.com/rust-osdev/x86_64/pull/204))

# 0.12.4 – 2020-12-28

- Fix bad conversion from llvm_asm! to asm! ([#218](https://github.com/rust-osdev/x86_64/pull/218))
Expand Down
7 changes: 0 additions & 7 deletions src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ impl VirtAddr {
VirtAddr(((addr << 16) as i64 >> 16) as u64)
}

/// Alias for [`new_truncate`][VirtAddr::new_truncate] for backwards compatibility.
#[inline]
#[deprecated(note = "Use new_truncate or new_unsafe instead")]
pub const fn new_unchecked(addr: u64) -> VirtAddr {
Self::new_truncate(addr)
}

/// Creates a new virtual address, without any checks.
///
/// ## Safety
Expand Down
7 changes: 0 additions & 7 deletions src/instructions/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,6 @@ pub fn enable_and_hlt() {
}
}

/// Alias for [`enable_and_hlt`][enable_and_hlt] for backwards compatibility.
#[inline]
#[deprecated(note = "Use enable_and_hlt instead")]
pub fn enable_interrupts_and_hlt() {
enable_and_hlt();
}

/// Cause a breakpoint exception by invoking the `int3` instruction.
#[inline]
pub fn int3() {
Expand Down
6 changes: 4 additions & 2 deletions src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

//! Special x86_64 instructions.

use crate::VirtAddr;

pub mod interrupts;
pub mod port;
pub mod random;
Expand Down Expand Up @@ -56,12 +58,12 @@ pub fn bochs_breakpoint() {
/// instructions to execute.
#[cfg(feature = "inline_asm")]
#[inline(always)]
pub fn read_rip() -> u64 {
pub fn read_rip() -> VirtAddr {
let rip: u64;
unsafe {
asm!(
"lea {}, [rip]", out(reg) rip, options(nostack, nomem)
);
}
rip
VirtAddr::new(rip)
}
10 changes: 4 additions & 6 deletions src/instructions/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use core::marker::PhantomData;

pub use crate::structures::port::{PortRead, PortReadWrite, PortWrite};
pub use crate::structures::port::{PortRead, PortWrite};

impl PortRead for u8 {
#[cfg(feature = "inline_asm")]
Expand Down Expand Up @@ -94,10 +94,6 @@ impl PortWrite for u32 {
}
}

impl PortReadWrite for u8 {}
impl PortReadWrite for u16 {}
impl PortReadWrite for u32 {}

/// A read only I/O port.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PortReadOnly<T> {
Expand Down Expand Up @@ -178,7 +174,7 @@ impl<T> Port<T> {
}
}

impl<T: PortReadWrite> Port<T> {
impl<T: PortRead> Port<T> {
/// Reads from the port.
///
/// ## Safety
Expand All @@ -189,7 +185,9 @@ impl<T: PortReadWrite> Port<T> {
pub unsafe fn read(&mut self) -> T {
T::read_from_port(self.port)
}
}

impl<T: PortWrite> Port<T> {
/// Writes to the port.
///
/// ## Safety
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#![cfg_attr(feature = "const_fn", feature(const_in_array_repeat_expressions))]
#![cfg_attr(feature = "inline_asm", feature(asm))]
#![cfg_attr(feature = "abi_x86_interrupt", feature(abi_x86_interrupt))]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
#![cfg_attr(feature = "deny-warnings", deny(missing_docs))]
#![cfg_attr(not(feature = "deny-warnings"), warn(missing_docs))]
#![warn(missing_docs)]
#![deny(missing_debug_implementations)]

pub use crate::addr::{align_down, align_up, PhysAddr, VirtAddr};
Expand Down
21 changes: 17 additions & 4 deletions src/registers/rflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ mod x86_64 {
}

/// Writes the RFLAGS register, preserves reserved bits.
///
/// ## Safety
///
/// Unsafe because undefined becavior can occur if certain flags are modified. For example,
/// the `DF` flag must be unset in all Rust code. Also, modifying `CF`, `PF`, or any other
/// flags also used by Rust/LLVM can result in undefined behavior too.
#[inline]
pub fn write(flags: RFlags) {
pub unsafe fn write(flags: RFlags) {
let old_value = read_raw();
let reserved = old_value & !(RFlags::all().bits());
let new_value = reserved | flags.bits();
Expand All @@ -104,16 +110,23 @@ mod x86_64 {
/// Writes the RFLAGS register.
///
/// Does not preserve any bits, including reserved bits.
///
///
/// ## Safety
///
/// Unsafe because undefined becavior can occur if certain flags are modified. For example,
/// the `DF` flag must be unset in all Rust code. Also, modifying `CF`, `PF`, or any other
/// flags also used by Rust/LLVM can result in undefined behavior too.
#[inline]
pub fn write_raw(val: u64) {
pub unsafe fn write_raw(val: u64) {
#[cfg(feature = "inline_asm")]
unsafe {
{
// FIXME - There's probably a better way than saying we preserve the flags even though we actually don't
asm!("push {}; popf", in(reg) val, options(preserves_flags))
};

#[cfg(not(feature = "inline_asm"))]
unsafe {
{
crate::asm::x86_64_asm_write_rflags(val)
}
}
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 @@ -221,7 +224,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
8 changes: 1 addition & 7 deletions 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 Expand Up @@ -706,12 +706,6 @@ impl EntryOptions {
}
}

/// Wrapper type for the exception stack frame pushed by the CPU.
///
/// Identical to [`InterruptStackFrame`].
#[deprecated(note = "This type was renamed to InterruptStackFrame.")]
pub type ExceptionStackFrame = InterruptStackFrame;

/// Wrapper type for the interrupt stack frame pushed by the CPU.
///
/// This type derefs to an [`InterruptStackFrameValue`], which allows reading the actual values.
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,
}
5 changes: 3 additions & 2 deletions src/structures/paging/frame.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Abstractions for default-sized and huge physical memory frames.

use super::page::AddressNotAligned;
use crate::structures::paging::page::{PageSize, Size4KiB};
use crate::PhysAddr;
use core::fmt;
Expand All @@ -19,9 +20,9 @@ impl<S: PageSize> PhysFrame<S> {
///
/// Returns an error if the address is not correctly aligned (i.e. is not a valid frame start).
#[inline]
pub fn from_start_address(address: PhysAddr) -> Result<Self, ()> {
pub fn from_start_address(address: PhysAddr) -> Result<Self, AddressNotAligned> {
if !address.is_aligned(S::SIZE) {
return Err(());
return Err(AddressNotAligned);
}
Ok(PhysFrame::containing_address(address))
}
Expand Down
46 changes: 1 addition & 45 deletions src/structures/paging/frame_alloc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Traits for abstracting away frame allocation and deallocation.

use crate::structures::paging::{PageSize, PhysFrame, Size4KiB};
use core::ops::{Deref, DerefMut};
use crate::structures::paging::{PageSize, PhysFrame};

/// A trait for types that can allocate a frame of memory.
///
Expand All @@ -21,46 +20,3 @@ pub trait FrameDeallocator<S: PageSize> {
/// The caller must ensure that the passed frame is unused.
unsafe fn deallocate_frame(&mut self, frame: PhysFrame<S>);
}

/// Represents a physical frame that is not used for any mapping.
#[deprecated(note = "This wrapper type is no longer used. Use `PhysFrame` instead.")]
#[derive(Debug)]
pub struct UnusedPhysFrame<S: PageSize = Size4KiB>(PhysFrame<S>);

#[allow(deprecated)]
impl<S: PageSize> UnusedPhysFrame<S> {
/// Creates a new UnusedPhysFrame from the given frame.
///
/// ## Safety
///
/// This method is unsafe because the caller must guarantee
/// that the given frame is unused.
#[inline]
pub unsafe fn new(frame: PhysFrame<S>) -> Self {
Self(frame)
}

/// Returns the physical frame as `PhysFrame` type.
#[inline]
pub fn frame(self) -> PhysFrame<S> {
self.0
}
}

#[allow(deprecated)]
impl<S: PageSize> Deref for UnusedPhysFrame<S> {
type Target = PhysFrame<S>;

#[inline]
fn deref(&self) -> &Self::Target {
&self.0
}
}

#[allow(deprecated)]
impl<S: PageSize> DerefMut for UnusedPhysFrame<S> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
Loading