Skip to content

Commit

Permalink
remove useless member in VmEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6D70 committed Jan 19, 2024
1 parent c760351 commit d4a645d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions xernel/kernel/src/mem/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ use super::MMAP_START_ADDR;

pub struct VmEntry {
start: VirtAddr,
end: VirtAddr, // TODO: remove end
length: usize,
pub prot: ProtectionFlags,
pub flags: MapFlags,
// TODO: add something to represent to which file this entry belongs to
file: Option<()>,
}

impl VmEntry {
pub fn end(&self) -> VirtAddr {
self.start + self.length
}
}

pub struct Vm {
entries: Vec<VmEntry>,
}
Expand All @@ -29,10 +34,8 @@ impl Vm {
}

pub fn add_entry(&mut self, start: VirtAddr, length: usize, prot: ProtectionFlags, flags: MapFlags) {
let end = start + length;
self.entries.push(VmEntry {
start,
end,
length,
prot,
flags,
Expand All @@ -44,7 +47,7 @@ impl Vm {
let last_entry = self.entries.last();

if let Some(last_entry) = last_entry {
VirtAddr::new(align_up(last_entry.end.as_u64(), Size4KiB::SIZE))
VirtAddr::new(align_up(last_entry.end().as_u64(), Size4KiB::SIZE))
} else {
VirtAddr::new(MMAP_START_ADDR as u64)
}
Expand All @@ -53,7 +56,7 @@ impl Vm {
pub fn get_entry_from_address(&self, addr: VirtAddr) -> Option<&VmEntry> {
self.entries
.iter()
.find(|entry| entry.start <= addr && entry.end > addr)
.find(|entry| entry.start <= addr && entry.end() > addr)
}

pub fn clean_up(&mut self) {
Expand Down

0 comments on commit d4a645d

Please sign in to comment.