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 {
|
||||
pub fn is_unused(&self) -> bool {
|
||||
self.0 == 0;
|
||||
self.0 == 0
|
||||
}
|
||||
|
||||
pub fn set_unused(&mut self) {
|
||||
|
|
@ -27,21 +27,21 @@ impl Entry {
|
|||
}
|
||||
|
||||
pub fn flags(&self) -> EntryFlags {
|
||||
EntryFlags::from_bits_truncate(self.0);
|
||||
EntryFlags::from_bits_truncate(self.0)
|
||||
}
|
||||
|
||||
pub fn pointed_frame(&self) -> Option<Frame> {
|
||||
if self.flags().contains(PRESENT) {
|
||||
if self.flags().contains(EntryFlags::PRESENT) {
|
||||
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 {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
mod entry;
|
||||
mod table;
|
||||
|
||||
use memory::PAGE_SIZE;
|
||||
|
||||
const ENTRY_COUNT: usize = 512;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ pub struct Table {
|
|||
}
|
||||
|
||||
impl Table {
|
||||
for entry in self.entries.iter_mut() {
|
||||
entry.set_unused();
|
||||
pub fn zero(&mut self) {
|
||||
for entry in self.entries.iter_mut() {
|
||||
entry.set_unused();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +24,7 @@ impl Index<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]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue