rut stable, going to do some assembly now
This commit is contained in:
parent
5412334168
commit
d491624274
3 changed files with 14 additions and 9 deletions
|
|
@ -19,7 +19,7 @@ bitflags! {
|
||||||
|
|
||||||
impl Entry {
|
impl Entry {
|
||||||
pub fn is_unused(&self) -> bool {
|
pub fn is_unused(&self) -> bool {
|
||||||
self.0 == 0;
|
self.0 == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_unused(&mut self) {
|
pub fn set_unused(&mut self) {
|
||||||
|
|
@ -27,21 +27,21 @@ impl Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flags(&self) -> EntryFlags {
|
pub fn flags(&self) -> EntryFlags {
|
||||||
EntryFlags::from_bits_truncate(self.0);
|
EntryFlags::from_bits_truncate(self.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pointed_frame(&self) -> Option<Frame> {
|
pub fn pointed_frame(&self) -> Option<Frame> {
|
||||||
if self.flags().contains(PRESENT) {
|
if self.flags().contains(EntryFlags::PRESENT) {
|
||||||
Some(Frame::containing_address(
|
Some(Frame::containing_address(
|
||||||
self.0 as usize & 0x000fffff_fffff000 // actual addr is bits 12-51
|
// actual addr is bits 12-51
|
||||||
))
|
self.0 as usize & 0x000fffff_fffff000))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set(&mut self, frame: Frame, flags: EntryFlags) {
|
pub fn set(&mut self, frame: Frame, flags: EntryFlags) {
|
||||||
assert!!(frame.start_address() & !0x000fffff_fffff000 == 0);
|
assert!(frame.start_address() & !0x000fffff_fffff000 == 0);
|
||||||
self.0 = (frame.start_address() as u64) | flags.bits();
|
self.0 = (frame.start_address() as u64) | flags.bits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
mod entry;
|
||||||
|
mod table;
|
||||||
|
|
||||||
use memory::PAGE_SIZE;
|
use memory::PAGE_SIZE;
|
||||||
|
|
||||||
const ENTRY_COUNT: usize = 512;
|
const ENTRY_COUNT: usize = 512;
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ pub struct Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Table {
|
impl Table {
|
||||||
for entry in self.entries.iter_mut() {
|
pub fn zero(&mut self) {
|
||||||
entry.set_unused();
|
for entry in self.entries.iter_mut() {
|
||||||
|
entry.set_unused();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,7 +24,7 @@ impl Index<usize> for Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IndexMut<usize> for Table {
|
impl IndexMut<usize> for Table {
|
||||||
fn index(&self, index: usize) -> &mut Entry {
|
fn index_mut(&mut self, index: usize) -> &mut Entry {
|
||||||
&mut self.entries[index]
|
&mut self.entries[index]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue