Skip to content

Commit 8a54bca

Browse files
authored
Merge pull request #223 from rust-osdev/next
Release version v0.13.0
2 parents bd471fa + dbeb826 commit 8a54bca

21 files changed

+288
-225
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ license = "MIT/Apache-2.0"
2222
name = "x86_64"
2323
readme = "README.md"
2424
repository = "https://github.com/rust-osdev/x86_64"
25-
version = "0.12.4"
25+
version = "0.13.0"
2626
edition = "2018"
2727

2828
[dependencies]
@@ -35,7 +35,6 @@ cc = { version = "1.0.37", optional = true }
3535
[features]
3636
default = [ "nightly", "instructions" ]
3737
instructions = []
38-
deny-warnings = []
3938
external_asm = [ "cc" ]
4039
nightly = [ "inline_asm", "const_fn", "abi_x86_interrupt" ]
4140
inline_asm = []
@@ -47,6 +46,7 @@ no-dev-version = true
4746
pre-release-replacements = [
4847
{ file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 },
4948
]
50-
pre-release-commit-message = "Release version {{version}}"
49+
pre-release-commit-message = "Bump version to {{version}}"
5150
disable-push = true
5251
disable-publish = true
52+
disable-tag = true

Changelog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Unreleased
22

3+
# 0.13.0 – 2020-12-28
4+
5+
- **Breaking:** Also return flags for `MapperAllSizes::translate()` ([#207](https://github.com/rust-osdev/x86_64/pull/207))
6+
- **Breaking:** Restructure the `TranslateResult` type and create separate `Translate` trait ([#211](https://github.com/rust-osdev/x86_64/pull/211))
7+
- **Breaking:** Rename `PhysToVirt` trait to `PageTableFrameMapping` ([#214](https://github.com/rust-osdev/x86_64/pull/214))
8+
- **Breaking:** Use custom error types instead of `()` ([#199](https://github.com/rust-osdev/x86_64/pull/199))
9+
- **Breaking:** Remove deprecated items
10+
- `UnusedPhysFrame`
11+
- `ExceptionStackFrame`
12+
- `VirtAddr::new_unchecked`
13+
- `interrupts::enable_interrupts_and_hlt`
14+
- **Breaking:** Make `DescriptorTablePointer::base` a `VirtAddr` ([#215](https://github.com/rust-osdev/x86_64/pull/215))
15+
- **Breaking:** Change return type of `read_rip` to `VirtAddr` ([#216](https://github.com/rust-osdev/x86_64/pull/216))
16+
- **Breaking:** Make writing the RFLAGS register unsafe ([#219](https://github.com/rust-osdev/x86_64/pull/219))
17+
- **Breaking:** Remove `PortReadWrite` trait, which is no longer needed ([#217](https://github.com/rust-osdev/x86_64/pull/217))
18+
- Relaxe `Sized` requirement for `FrameAllocator` in `Mapper::map_to` ([204](https://github.com/rust-osdev/x86_64/pull/204))
19+
320
# 0.12.4 – 2020-12-28
421

522
- Fix bad conversion from llvm_asm! to asm! ([#218](https://github.com/rust-osdev/x86_64/pull/218))

src/addr.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ impl VirtAddr {
8585
VirtAddr(((addr << 16) as i64 >> 16) as u64)
8686
}
8787

88-
/// Alias for [`new_truncate`][VirtAddr::new_truncate] for backwards compatibility.
89-
#[inline]
90-
#[deprecated(note = "Use new_truncate or new_unsafe instead")]
91-
pub const fn new_unchecked(addr: u64) -> VirtAddr {
92-
Self::new_truncate(addr)
93-
}
94-
9588
/// Creates a new virtual address, without any checks.
9689
///
9790
/// ## Safety

src/instructions/interrupts.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ pub fn enable_and_hlt() {
139139
}
140140
}
141141

142-
/// Alias for [`enable_and_hlt`][enable_and_hlt] for backwards compatibility.
143-
#[inline]
144-
#[deprecated(note = "Use enable_and_hlt instead")]
145-
pub fn enable_interrupts_and_hlt() {
146-
enable_and_hlt();
147-
}
148-
149142
/// Cause a breakpoint exception by invoking the `int3` instruction.
150143
#[inline]
151144
pub fn int3() {

src/instructions/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
//! Special x86_64 instructions.
44
5+
use crate::VirtAddr;
6+
57
pub mod interrupts;
68
pub mod port;
79
pub mod random;
@@ -56,12 +58,12 @@ pub fn bochs_breakpoint() {
5658
/// instructions to execute.
5759
#[cfg(feature = "inline_asm")]
5860
#[inline(always)]
59-
pub fn read_rip() -> u64 {
61+
pub fn read_rip() -> VirtAddr {
6062
let rip: u64;
6163
unsafe {
6264
asm!(
6365
"lea {}, [rip]", out(reg) rip, options(nostack, nomem)
6466
);
6567
}
66-
rip
68+
VirtAddr::new(rip)
6769
}

src/instructions/port.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use core::marker::PhantomData;
44

5-
pub use crate::structures::port::{PortRead, PortReadWrite, PortWrite};
5+
pub use crate::structures::port::{PortRead, PortWrite};
66

77
impl PortRead for u8 {
88
#[cfg(feature = "inline_asm")]
@@ -94,10 +94,6 @@ impl PortWrite for u32 {
9494
}
9595
}
9696

97-
impl PortReadWrite for u8 {}
98-
impl PortReadWrite for u16 {}
99-
impl PortReadWrite for u32 {}
100-
10197
/// A read only I/O port.
10298
#[derive(Debug, Clone, PartialEq, Eq)]
10399
pub struct PortReadOnly<T> {
@@ -178,7 +174,7 @@ impl<T> Port<T> {
178174
}
179175
}
180176

181-
impl<T: PortReadWrite> Port<T> {
177+
impl<T: PortRead> Port<T> {
182178
/// Reads from the port.
183179
///
184180
/// ## Safety
@@ -189,7 +185,9 @@ impl<T: PortReadWrite> Port<T> {
189185
pub unsafe fn read(&mut self) -> T {
190186
T::read_from_port(self.port)
191187
}
188+
}
192189

190+
impl<T: PortWrite> Port<T> {
193191
/// Writes to the port.
194192
///
195193
/// ## Safety

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
#![cfg_attr(feature = "const_fn", feature(const_in_array_repeat_expressions))]
1010
#![cfg_attr(feature = "inline_asm", feature(asm))]
1111
#![cfg_attr(feature = "abi_x86_interrupt", feature(abi_x86_interrupt))]
12-
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
13-
#![cfg_attr(feature = "deny-warnings", deny(missing_docs))]
14-
#![cfg_attr(not(feature = "deny-warnings"), warn(missing_docs))]
12+
#![warn(missing_docs)]
1513
#![deny(missing_debug_implementations)]
1614

1715
pub use crate::addr::{align_down, align_up, PhysAddr, VirtAddr};

src/registers/rflags.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,14 @@ mod x86_64 {
9292
}
9393

9494
/// Writes the RFLAGS register, preserves reserved bits.
95+
///
96+
/// ## Safety
97+
///
98+
/// Unsafe because undefined becavior can occur if certain flags are modified. For example,
99+
/// the `DF` flag must be unset in all Rust code. Also, modifying `CF`, `PF`, or any other
100+
/// flags also used by Rust/LLVM can result in undefined behavior too.
95101
#[inline]
96-
pub fn write(flags: RFlags) {
102+
pub unsafe fn write(flags: RFlags) {
97103
let old_value = read_raw();
98104
let reserved = old_value & !(RFlags::all().bits());
99105
let new_value = reserved | flags.bits();
@@ -104,16 +110,23 @@ mod x86_64 {
104110
/// Writes the RFLAGS register.
105111
///
106112
/// Does not preserve any bits, including reserved bits.
113+
///
114+
///
115+
/// ## Safety
116+
///
117+
/// Unsafe because undefined becavior can occur if certain flags are modified. For example,
118+
/// the `DF` flag must be unset in all Rust code. Also, modifying `CF`, `PF`, or any other
119+
/// flags also used by Rust/LLVM can result in undefined behavior too.
107120
#[inline]
108-
pub fn write_raw(val: u64) {
121+
pub unsafe fn write_raw(val: u64) {
109122
#[cfg(feature = "inline_asm")]
110-
unsafe {
123+
{
111124
// FIXME - There's probably a better way than saying we preserve the flags even though we actually don't
112125
asm!("push {}; popf", in(reg) val, options(preserves_flags))
113126
};
114127

115128
#[cfg(not(feature = "inline_asm"))]
116-
unsafe {
129+
{
117130
crate::asm::x86_64_asm_write_rflags(val)
118131
}
119132
}

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;
@@ -221,7 +224,7 @@ impl GlobalDescriptorTable {
221224
fn pointer(&self) -> DescriptorTablePointer {
222225
use core::mem::size_of;
223226
DescriptorTablePointer {
224-
base: self.table.as_ptr() as u64,
227+
base: VirtAddr::new(self.table.as_ptr() as u64),
225228
limit: (self.next_free * size_of::<u64>() - 1) as u16,
226229
}
227230
}

src/structures/idt.rs

Lines changed: 1 addition & 7 deletions
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
}
@@ -706,12 +706,6 @@ impl EntryOptions {
706706
}
707707
}
708708

709-
/// Wrapper type for the exception stack frame pushed by the CPU.
710-
///
711-
/// Identical to [`InterruptStackFrame`].
712-
#[deprecated(note = "This type was renamed to InterruptStackFrame.")]
713-
pub type ExceptionStackFrame = InterruptStackFrame;
714-
715709
/// Wrapper type for the interrupt stack frame pushed by the CPU.
716710
///
717711
/// This type derefs to an [`InterruptStackFrameValue`], which allows reading the actual values.

0 commit comments

Comments
 (0)