mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Model page tables
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
mod entry;
|
||||
mod table;
|
||||
|
||||
const ENTRY_COUNT: usize = 512;
|
||||
|
||||
|
||||
29
src/memory/paging/table.rs
Normal file
29
src/memory/paging/table.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use memory::paging::entry::*;
|
||||
use memory::paging::ENTRY_COUNT;
|
||||
use core::ops::{Index, IndexMut};
|
||||
|
||||
pub struct Table {
|
||||
entries: [Entry; ENTRY_COUNT],
|
||||
}
|
||||
|
||||
impl Table {
|
||||
pub fn zero(&mut self) {
|
||||
for entry in self.entries.iter_mut() {
|
||||
entry.set_unused();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<usize> for Table {
|
||||
type Output = Entry;
|
||||
|
||||
fn index(&self, index: usize) -> &Entry {
|
||||
&self.entries[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<usize> for Table {
|
||||
fn index_mut(&mut self, index: usize) -> &mut Entry {
|
||||
&mut self.entries[index]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user