Skip to content
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 @@ -9,6 +9,7 @@
- `OffsetPageTable`'s `PageTableFrameMapping` implementation is now public as `PhysOffset`.
- [make range types `!Copy`](https://github.com/rust-osdev/x86_64/pull/581)
- To migrate, use `.clone()` if necessary.
- [make page types `repr(transparent)` and range types `repr(Rust)`](https://github.com/rust-osdev/x86_64/pull/584)

# 0.15.4 – 2025-11-24

Expand Down
8 changes: 8 additions & 0 deletions src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const ADDRESS_SPACE_SIZE: u64 = 0x1_0000_0000_0000;
/// On `x86_64`, only the 48 lower bits of a virtual address can be used. The top 16 bits need
/// to be copies of bit 47, i.e. the most significant bit. Addresses that fulfil this criterion
/// are called “canonical”. This type guarantees that it always represents a canonical address.
///
/// # Representation
///
/// This struct has the same representation as a [`u64`].
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct VirtAddr(u64);
Expand All @@ -41,6 +45,10 @@ pub struct VirtAddr(u64);
///
/// On `x86_64`, only the 52 lower bits of a physical address can be used. The top 12 bits need
/// to be zero. This type guarantees that it always represents a valid physical address.
///
/// # Representation
///
/// This struct has the same representation as a [`u64`].
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct PhysAddr(u64);
Expand Down
8 changes: 5 additions & 3 deletions src/structures/paging/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ use core::marker::PhantomData;
use core::ops::{Add, AddAssign, Sub, SubAssign};

/// A physical memory frame.
///
/// # Representation
///
/// This struct has the same representation as a [`u64`].
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[repr(transparent)]
pub struct PhysFrame<S: PageSize = Size4KiB> {
// TODO: Make private when our minimum supported stable Rust version is 1.61
pub(crate) start_address: PhysAddr,
Expand Down Expand Up @@ -134,7 +138,6 @@ impl<S: PageSize> Sub<PhysFrame<S>> for PhysFrame<S> {

/// An range of physical memory frames, exclusive the upper bound.
#[derive(Clone, PartialEq, Eq, Hash)]
#[repr(C)]
pub struct PhysFrameRange<S: PageSize = Size4KiB> {
/// The start of the range, inclusive.
pub start: PhysFrame<S>,
Expand Down Expand Up @@ -192,7 +195,6 @@ impl<S: PageSize> fmt::Debug for PhysFrameRange<S> {

/// An range of physical memory frames, inclusive the upper bound.
#[derive(Clone, PartialEq, Eq, Hash)]
#[repr(C)]
pub struct PhysFrameRangeInclusive<S: PageSize = Size4KiB> {
/// The start of the range, inclusive.
pub start: PhysFrame<S>,
Expand Down
8 changes: 5 additions & 3 deletions src/structures/paging/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ impl PageSize for Size1GiB {
impl Sealed for super::Size1GiB {}

/// A virtual memory page.
///
/// # Representation
///
/// This struct has the same representation as a [`u64`].
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
#[repr(transparent)]
pub struct Page<S: PageSize = Size4KiB> {
start_address: VirtAddr,
size: PhantomData<S>,
Expand Down Expand Up @@ -326,7 +330,6 @@ impl<S: PageSize> Step for Page<S> {

/// A range of pages with exclusive upper bound.
#[derive(Clone, PartialEq, Eq, Hash)]
#[repr(C)]
pub struct PageRange<S: PageSize = Size4KiB> {
/// The start of the range, inclusive.
pub start: Page<S>,
Expand Down Expand Up @@ -395,7 +398,6 @@ impl<S: PageSize> fmt::Debug for PageRange<S> {

/// A range of pages with inclusive upper bound.
#[derive(Clone, PartialEq, Eq, Hash)]
#[repr(C)]
pub struct PageRangeInclusive<S: PageSize = Size4KiB> {
/// The start of the range, inclusive.
pub start: Page<S>,
Expand Down
Loading