Model page tables

This commit is contained in:
Philipp Oppermann
2015-12-08 22:47:39 +01:00
parent 14384fb27f
commit 96b0dc0c66
2 changed files with 30 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
mod entry; mod entry;
mod table;
const ENTRY_COUNT: usize = 512; const ENTRY_COUNT: usize = 512;

View 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]
}
}