|
@ -3,11 +3,16 @@ |
|
|
//! Extremely ripped off from Phil Oppermann's tutorials, because I don't feel like writing
|
|
|
//! Extremely ripped off from Phil Oppermann's tutorials, because I don't feel like writing
|
|
|
//! a paging system off the top of my head today.
|
|
|
//! a paging system off the top of my head today.
|
|
|
|
|
|
|
|
|
|
|
|
use core::ptr::Unique;
|
|
|
use super::PAGE_SIZE;
|
|
|
use super::PAGE_SIZE;
|
|
|
|
|
|
use super::{Frame, FrameAllocator};
|
|
|
|
|
|
|
|
|
mod entry;
|
|
|
mod entry;
|
|
|
mod table;
|
|
|
mod table;
|
|
|
|
|
|
|
|
|
|
|
|
use self::entry::*;
|
|
|
|
|
|
use self::table::{Table, Level4};
|
|
|
|
|
|
|
|
|
/// Upper bound on entries per page table
|
|
|
/// Upper bound on entries per page table
|
|
|
const ENTRY_COUNT: usize = 512;
|
|
|
const ENTRY_COUNT: usize = 512;
|
|
|
|
|
|
|
|
@ -15,7 +20,23 @@ const ENTRY_COUNT: usize = 512; |
|
|
pub type PhysicalAddress = usize;
|
|
|
pub type PhysicalAddress = usize;
|
|
|
pub type VirtualAddress = usize;
|
|
|
pub type VirtualAddress = usize;
|
|
|
|
|
|
|
|
|
/// A representation of a virtual page
|
|
|
|
|
|
|
|
|
/// Owns the top-level active page table (P4).
|
|
|
|
|
|
pub struct ActivePageTable {
|
|
|
|
|
|
p4: Unique<Table<Level4>>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ActivePageTable {
|
|
|
|
|
|
/// There **must** be ***only one*** ActivePageTable instance.
|
|
|
|
|
|
/// Since we cannot guarantee this trivially, the constructor is unsafe.
|
|
|
|
|
|
pub unsafe fn new() -> ActivePageTable {
|
|
|
|
|
|
ActivePageTable {
|
|
|
|
|
|
p4: Unique::new(table::P4),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// A representation of a virtual page.
|
|
|
|
|
|
#[derive(Clone, Copy, Debug)]
|
|
|
pub struct Page {
|
|
|
pub struct Page {
|
|
|
index: usize,
|
|
|
index: usize,
|
|
|
}
|
|
|
}
|