mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-17 15:34:18 +08:00
Strongly typed virtual/physical memory seperation.
This minicommit introduces two newtpyes, `Physical` and `Virtual`, respectively. These serves as a way to segregate the different forms of addresses to avoid the issues we had in the old kernel.
This commit is contained in:
parent
f8bd171efd
commit
3967c0f291
@ -23,3 +23,5 @@ pub mod serial;
|
||||
|
||||
/// Task state segment.
|
||||
pub mod tss;
|
||||
|
||||
pub mod physical;
|
||||
|
||||
11
kernel/arch/x86_64/physical.rs
Normal file
11
kernel/arch/x86_64/physical.rs
Normal file
@ -0,0 +1,11 @@
|
||||
//! Typestrong address segregation.
|
||||
|
||||
/// A physical address in memory.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Physical {
|
||||
/// The position.
|
||||
///
|
||||
/// Note that we do not use a pointer here to avoid simple mistakes where the programmer
|
||||
/// confuse virtual and physical.
|
||||
pub inner: u64,
|
||||
}
|
||||
6
kernel/paging/mod.rs
Normal file
6
kernel/paging/mod.rs
Normal file
@ -0,0 +1,6 @@
|
||||
/// A newtype representing a virtual address.
|
||||
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct Virtual {
|
||||
/// The inner value.
|
||||
pub inner: usize,
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user