implement map vmo to vmar

This commit is contained in:
Jianfeng Jiang
2022-12-05 19:36:28 +08:00
parent 31d644a0f3
commit 429341caa6
15 changed files with 748 additions and 463 deletions

View File

@ -15,6 +15,7 @@ use crate::mm::PhysFrame;
/// type to represent a series of page frames is convenient because,
/// more often than not, one needs to operate on a batch of frames rather
/// a single frame.
#[derive(Debug, Clone)]
pub struct VmFrameVec(Vec<VmFrame>);
impl VmFrameVec {
@ -44,6 +45,11 @@ impl VmFrameVec {
Ok(Self(frame_list))
}
/// returns an empty vmframe vec
pub fn empty() -> Self {
Self(Vec::new())
}
/// Pushs a new frame to the collection.
pub fn push(&mut self, new_frame: VmFrame) {
self.0.push(new_frame);
@ -74,6 +80,11 @@ impl VmFrameVec {
Ok(())
}
/// zero all internal vm frames
pub fn zero(&self) {
self.0.iter().for_each(|vm_frame| vm_frame.zero())
}
/// Truncate some frames.
///
/// If `new_len >= self.len()`, then this method has no effect.

View File

@ -129,6 +129,7 @@ impl VmIo for VmSpace {
/// Options for mapping physical memory pages into a VM address space.
/// See `VmSpace::map`.
#[derive(Clone)]
pub struct VmMapOptions {
/// start virtual address
addr: Option<Vaddr>,