diff --git a/docs/src/framework/a-100-line-kernel.md b/docs/src/framework/a-100-line-kernel.md
index 9b23c908b..c2aca4027 100644
--- a/docs/src/framework/a-100-line-kernel.md
+++ b/docs/src/framework/a-100-line-kernel.md
@@ -56,7 +56,7 @@ use aster_frame::cpu::UserContext;
use aster_frame::prelude::*;
use aster_frame::task::{Task, TaskOptions};
use aster_frame::user::{ReturnReason, UserMode, UserSpace};
-use aster_frame::mm::{PageFlags, PAGE_SIZE, Vaddr, VmAllocOptions, VmIo, VmMapOptions, VmSpace};
+use aster_frame::mm::{PageFlags, PAGE_SIZE, Vaddr, FrameAllocOptions, VmIo, VmMapOptions, VmSpace};
/// The kernel's boot and initialization process is managed by Asterinas Framework.
/// After the process is done, the kernel's execution environment
@@ -73,7 +73,7 @@ pub fn main() {
fn create_user_space(program: &[u8]) -> UserSpace {
let user_pages = {
let nframes = program.len().align_up(PAGE_SIZE) / PAGE_SIZE;
- let vm_frames = VmAllocOptions::new(nframes).alloc().unwrap();
+ let vm_frames = FrameAllocOptions::new(nframes).alloc().unwrap();
// Phyiscal memory pages can be only accessed
// via the Frame abstraction.
vm_frames.write_bytes(0, program).unwrap();
diff --git a/framework/aster-frame/src/arch/x86/iommu/context_table.rs b/framework/aster-frame/src/arch/x86/iommu/context_table.rs
index 16c010d5f..771b0ef8d 100644
--- a/framework/aster-frame/src/arch/x86/iommu/context_table.rs
+++ b/framework/aster-frame/src/arch/x86/iommu/context_table.rs
@@ -13,7 +13,7 @@ use crate::{
dma::Daddr,
page_prop::{CachePolicy, PageProperty, PrivilegedPageFlags as PrivFlags},
page_table::PageTableError,
- Frame, Paddr, PageFlags, PageTable, VmAllocOptions, VmIo, PAGE_SIZE,
+ Frame, FrameAllocOptions, Paddr, PageFlags, PageTable, VmIo, PAGE_SIZE,
},
};
@@ -51,7 +51,7 @@ pub enum ContextTableError {
impl RootTable {
pub fn new() -> Self {
Self {
- root_frame: VmAllocOptions::new(1).alloc_single().unwrap(),
+ root_frame: FrameAllocOptions::new(1).alloc_single().unwrap(),
context_tables: BTreeMap::new(),
}
}
@@ -240,7 +240,7 @@ pub struct ContextTable {
impl ContextTable {
fn new() -> Self {
Self {
- entries_frame: VmAllocOptions::new(1).alloc_single().unwrap(),
+ entries_frame: FrameAllocOptions::new(1).alloc_single().unwrap(),
page_tables: BTreeMap::new(),
}
}
diff --git a/framework/aster-frame/src/lib.rs b/framework/aster-frame/src/lib.rs
index 8d0993fb2..62969edfa 100644
--- a/framework/aster-frame/src/lib.rs
+++ b/framework/aster-frame/src/lib.rs
@@ -51,6 +51,14 @@ use tdx_guest::init_tdx;
pub use self::{cpu::CpuLocal, error::Error, prelude::Result};
+/// Initialize the framework.
+///
+/// This function represents the first phase booting up the system. It makes
+/// all functionalities of the framework available after the call.
+///
+/// TODO: We need to refactor this function to make it more modular and
+/// make inter-initialization-dependencies more clear and reduce usages of
+/// boot stage only global variables.
pub fn init() {
arch::before_all_init();
logger::init();
diff --git a/framework/aster-frame/src/mm/dma/dma_coherent.rs b/framework/aster-frame/src/mm/dma/dma_coherent.rs
index 95273018a..ab826bbbc 100644
--- a/framework/aster-frame/src/mm/dma/dma_coherent.rs
+++ b/framework/aster-frame/src/mm/dma/dma_coherent.rs
@@ -190,11 +190,11 @@ mod test {
use alloc::vec;
use super::*;
- use crate::mm::VmAllocOptions;
+ use crate::mm::FrameAllocOptions;
#[ktest]
fn map_with_coherent_device() {
- let vm_segment = VmAllocOptions::new(1)
+ let vm_segment = FrameAllocOptions::new(1)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
@@ -204,7 +204,7 @@ mod test {
#[ktest]
fn map_with_incoherent_device() {
- let vm_segment = VmAllocOptions::new(1)
+ let vm_segment = FrameAllocOptions::new(1)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
@@ -217,7 +217,7 @@ mod test {
#[ktest]
fn duplicate_map() {
- let vm_segment_parent = VmAllocOptions::new(2)
+ let vm_segment_parent = FrameAllocOptions::new(2)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
@@ -229,7 +229,7 @@ mod test {
#[ktest]
fn read_and_write() {
- let vm_segment = VmAllocOptions::new(2)
+ let vm_segment = FrameAllocOptions::new(2)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
@@ -244,7 +244,7 @@ mod test {
#[ktest]
fn reader_and_wirter() {
- let vm_segment = VmAllocOptions::new(2)
+ let vm_segment = FrameAllocOptions::new(2)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
diff --git a/framework/aster-frame/src/mm/dma/dma_stream.rs b/framework/aster-frame/src/mm/dma/dma_stream.rs
index e55299a57..96f337900 100644
--- a/framework/aster-frame/src/mm/dma/dma_stream.rs
+++ b/framework/aster-frame/src/mm/dma/dma_stream.rs
@@ -294,11 +294,11 @@ mod test {
use alloc::vec;
use super::*;
- use crate::mm::VmAllocOptions;
+ use crate::mm::FrameAllocOptions;
#[ktest]
fn streaming_map() {
- let vm_segment = VmAllocOptions::new(1)
+ let vm_segment = FrameAllocOptions::new(1)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
@@ -309,7 +309,7 @@ mod test {
#[ktest]
fn duplicate_map() {
- let vm_segment_parent = VmAllocOptions::new(2)
+ let vm_segment_parent = FrameAllocOptions::new(2)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
@@ -322,7 +322,7 @@ mod test {
#[ktest]
fn read_and_write() {
- let vm_segment = VmAllocOptions::new(2)
+ let vm_segment = FrameAllocOptions::new(2)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
@@ -338,7 +338,7 @@ mod test {
#[ktest]
fn reader_and_wirter() {
- let vm_segment = VmAllocOptions::new(2)
+ let vm_segment = FrameAllocOptions::new(2)
.is_contiguous(true)
.alloc_contiguous()
.unwrap();
diff --git a/framework/aster-frame/src/mm/page/vm_frame_vec.rs b/framework/aster-frame/src/mm/frame/frame_vec.rs
similarity index 92%
rename from framework/aster-frame/src/mm/page/vm_frame_vec.rs
rename to framework/aster-frame/src/mm/frame/frame_vec.rs
index 64e34552b..67acece27 100644
--- a/framework/aster-frame/src/mm/page/vm_frame_vec.rs
+++ b/framework/aster-frame/src/mm/frame/frame_vec.rs
@@ -9,15 +9,15 @@ use crate::{
/// A collection of base page frames (regular physical memory pages).
///
-/// For the most parts, `VmFrameVec` is like `Vec`. But the
+/// For the most parts, `FrameVec` is like `Vec`. But the
/// implementation may or may not be based on `Vec`. Having a dedicated
/// 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(pub(crate) Vec);
+pub struct FrameVec(pub(crate) Vec);
-impl VmFrameVec {
+impl FrameVec {
pub fn get(&self, index: usize) -> Option<&Frame> {
self.0.get(index)
}
@@ -47,7 +47,7 @@ impl VmFrameVec {
}
/// Append some frames.
- pub fn append(&mut self, more: &mut VmFrameVec) -> Result<()> {
+ pub fn append(&mut self, more: &mut FrameVec) -> Result<()> {
self.0.append(&mut more.0);
Ok(())
}
@@ -89,7 +89,7 @@ impl VmFrameVec {
}
}
-impl IntoIterator for VmFrameVec {
+impl IntoIterator for FrameVec {
type Item = Frame;
type IntoIter = alloc::vec::IntoIter;
@@ -99,7 +99,7 @@ impl IntoIterator for VmFrameVec {
}
}
-impl VmIo for VmFrameVec {
+impl VmIo for FrameVec {
fn read_bytes(&self, offset: usize, buf: &mut [u8]) -> Result<()> {
// Do bound check with potential integer overflow in mind
let max_offset = offset.checked_add(buf.len()).ok_or(Error::Overflow)?;
@@ -143,12 +143,12 @@ impl VmIo for VmFrameVec {
/// An iterator for frames.
pub struct FrameVecIter<'a> {
- frames: &'a VmFrameVec,
+ frames: &'a FrameVec,
current: usize,
}
impl<'a> FrameVecIter<'a> {
- pub fn new(frames: &'a VmFrameVec) -> Self {
+ pub fn new(frames: &'a FrameVec) -> Self {
Self { frames, current: 0 }
}
}
diff --git a/framework/aster-frame/src/mm/page/frame.rs b/framework/aster-frame/src/mm/frame/mod.rs
similarity index 90%
rename from framework/aster-frame/src/mm/page/frame.rs
rename to framework/aster-frame/src/mm/frame/mod.rs
index 3c3e3f348..b05b54915 100644
--- a/framework/aster-frame/src/mm/page/frame.rs
+++ b/framework/aster-frame/src/mm/frame/mod.rs
@@ -1,8 +1,23 @@
// SPDX-License-Identifier: MPL-2.0
+//! Untyped physical memory management.
+//!
+//! A frame is a special page (defined in [`super::page`]) that is _untyped_
+//! memory. It is used to store data irrelevant to the integrity of the kernel.
+//! All pages mapped to the virtual address space of the users are backed by
+//! frames. Frames, with all the properties of pages, can additionally be safely
+//! read and written by the kernel or the user.
+
+pub mod frame_vec;
+pub mod options;
+pub mod segment;
+
use core::mem::ManuallyDrop;
-use super::{
+pub use frame_vec::{FrameVec, FrameVecIter};
+pub use segment::Segment;
+
+use super::page::{
allocator,
meta::{FrameMeta, MetaSlot, PageMeta, PageUsage},
Page,
diff --git a/framework/aster-frame/src/mm/options.rs b/framework/aster-frame/src/mm/frame/options.rs
similarity index 90%
rename from framework/aster-frame/src/mm/options.rs
rename to framework/aster-frame/src/mm/frame/options.rs
index 1069705df..2be349226 100644
--- a/framework/aster-frame/src/mm/options.rs
+++ b/framework/aster-frame/src/mm/frame/options.rs
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
-use super::{page::allocator, Frame, Segment, VmFrameVec};
-use crate::{prelude::*, Error};
+use super::{Frame, FrameVec, Segment};
+use crate::{mm::page::allocator, prelude::*, Error};
/// Options for allocating physical memory pages (or frames).
///
@@ -10,13 +10,13 @@ use crate::{prelude::*, Error};
/// may store Rust objects or affect Rust memory safety, e.g.,
/// the code and data segments of the OS kernel, the stack and heap
/// allocated for the OS kernel.
-pub struct VmAllocOptions {
+pub struct FrameAllocOptions {
nframes: usize,
is_contiguous: bool,
uninit: bool,
}
-impl VmAllocOptions {
+impl FrameAllocOptions {
/// Creates new options for allocating the specified number of frames.
pub fn new(nframes: usize) -> Self {
Self {
@@ -46,7 +46,7 @@ impl VmAllocOptions {
}
/// Allocate a collection of page frames according to the given options.
- pub fn alloc(&self) -> Result {
+ pub fn alloc(&self) -> Result {
let frames = if self.is_contiguous {
allocator::alloc(self.nframes).ok_or(Error::NoMemory)?
} else {
@@ -54,7 +54,7 @@ impl VmAllocOptions {
for _ in 0..self.nframes {
frame_list.push(allocator::alloc_single().ok_or(Error::NoMemory)?);
}
- VmFrameVec(frame_list)
+ FrameVec(frame_list)
};
if !self.uninit {
for frame in frames.iter() {
@@ -102,9 +102,9 @@ impl VmAllocOptions {
fn test_alloc_dealloc() {
// Here we allocate and deallocate frames in random orders to test the allocator.
// We expect the test to fail if the underlying implementation panics.
- let single_options = VmAllocOptions::new(1);
- let multi_options = VmAllocOptions::new(10);
- let mut contiguous_options = VmAllocOptions::new(10);
+ let single_options = FrameAllocOptions::new(1);
+ let multi_options = FrameAllocOptions::new(10);
+ let mut contiguous_options = FrameAllocOptions::new(10);
contiguous_options.is_contiguous(true);
let mut remember_vec = Vec::new();
for i in 0..10 {
diff --git a/framework/aster-frame/src/mm/page/segment.rs b/framework/aster-frame/src/mm/frame/segment.rs
similarity index 93%
rename from framework/aster-frame/src/mm/page/segment.rs
rename to framework/aster-frame/src/mm/frame/segment.rs
index a925bc909..367b21a26 100644
--- a/framework/aster-frame/src/mm/page/segment.rs
+++ b/framework/aster-frame/src/mm/frame/segment.rs
@@ -2,19 +2,22 @@
use core::ops::Range;
-use super::{
- allocator,
- meta::{PageMeta, PageUsage, SegmentHeadMeta},
- Frame, Page,
-};
+use super::Frame;
use crate::{
- mm::{HasPaddr, Paddr, VmIo, VmReader, VmWriter, PAGE_SIZE},
+ mm::{
+ page::{
+ allocator,
+ meta::{PageMeta, PageUsage, SegmentHeadMeta},
+ Page,
+ },
+ HasPaddr, Paddr, VmIo, VmReader, VmWriter, PAGE_SIZE,
+ },
Error, Result,
};
/// A handle to a contiguous range of page frames (physical memory pages).
///
-/// The biggest difference between `Segment` and `VmFrameVec` is that
+/// The biggest difference between `Segment` and `FrameVec` is that
/// the page frames must be contiguous for `Segment`.
///
/// A cloned `Segment` refers to the same page frames as the original.
@@ -24,7 +27,7 @@ use crate::{
/// #Example
///
/// ```rust
-/// let vm_segment = VmAllocOptions::new(2)
+/// let vm_segment = FrameAllocOptions::new(2)
/// .is_contiguous(true)
/// .alloc_contiguous()?;
/// vm_segment.write_bytes(0, buf)?;
diff --git a/framework/aster-frame/src/mm/io.rs b/framework/aster-frame/src/mm/io.rs
index 278985d91..55ddbb83d 100644
--- a/framework/aster-frame/src/mm/io.rs
+++ b/framework/aster-frame/src/mm/io.rs
@@ -9,7 +9,7 @@ use pod::Pod;
use crate::prelude::*;
/// A trait that enables reading/writing data from/to a VM object,
-/// e.g., `VmSpace`, `VmFrameVec`, and `Frame`.
+/// e.g., `VmSpace`, `FrameVec`, and `Frame`.
///
/// # Concurrency
///
diff --git a/framework/aster-frame/src/mm/mod.rs b/framework/aster-frame/src/mm/mod.rs
index 94b4ce255..e65aac404 100644
--- a/framework/aster-frame/src/mm/mod.rs
+++ b/framework/aster-frame/src/mm/mod.rs
@@ -9,11 +9,11 @@ pub type Vaddr = usize;
pub type Paddr = usize;
pub(crate) mod dma;
+pub mod frame;
pub(crate) mod heap_allocator;
mod io;
pub(crate) mod kspace;
mod offset;
-mod options;
pub(crate) mod page;
pub(crate) mod page_prop;
pub(crate) mod page_table;
@@ -26,9 +26,8 @@ use spin::Once;
pub use self::{
dma::{Daddr, DmaCoherent, DmaDirection, DmaStream, DmaStreamSlice, HasDaddr},
+ frame::{options::FrameAllocOptions, Frame, FrameVec, FrameVecIter, Segment},
io::{VmIo, VmReader, VmWriter},
- options::VmAllocOptions,
- page::{Frame, FrameVecIter, Segment, VmFrameVec},
page_prop::{CachePolicy, PageFlags, PageProperty},
space::{VmMapOptions, VmSpace},
};
diff --git a/framework/aster-frame/src/mm/page/allocator.rs b/framework/aster-frame/src/mm/page/allocator.rs
index fa6209873..062f25d46 100644
--- a/framework/aster-frame/src/mm/page/allocator.rs
+++ b/framework/aster-frame/src/mm/page/allocator.rs
@@ -1,5 +1,10 @@
// SPDX-License-Identifier: MPL-2.0
+//! The physical page memory allocator.
+//!
+//! TODO: Decouple it with the frame allocator in [`crate::mm::frame::options`] by
+//! allocating pages rather untyped memory from this module.
+
use alloc::vec::Vec;
use align_ext::AlignExt;
@@ -7,12 +12,16 @@ use buddy_system_allocator::FrameAllocator;
use log::info;
use spin::Once;
-use super::{meta::FrameMeta, Frame, Page, Segment, VmFrameVec};
-use crate::{boot::memory_region::MemoryRegionType, mm::PAGE_SIZE, sync::SpinLock};
+use super::{meta::FrameMeta, Page};
+use crate::{
+ boot::memory_region::MemoryRegionType,
+ mm::{Frame, FrameVec, Segment, PAGE_SIZE},
+ sync::SpinLock,
+};
pub(in crate::mm) static FRAME_ALLOCATOR: Once> = Once::new();
-pub(crate) fn alloc(nframes: usize) -> Option {
+pub(crate) fn alloc(nframes: usize) -> Option {
FRAME_ALLOCATOR
.get()
.unwrap()
@@ -27,7 +36,7 @@ pub(crate) fn alloc(nframes: usize) -> Option {
};
vector.push(frame);
}
- VmFrameVec(vector)
+ FrameVec(vector)
})
}
diff --git a/framework/aster-frame/src/mm/page/meta.rs b/framework/aster-frame/src/mm/page/meta.rs
index f4d4f1c22..a78f7d16d 100644
--- a/framework/aster-frame/src/mm/page/meta.rs
+++ b/framework/aster-frame/src/mm/page/meta.rs
@@ -82,7 +82,7 @@ pub enum PageUsage {
}
#[repr(C)]
-pub(super) struct MetaSlot {
+pub(in crate::mm) struct MetaSlot {
/// The metadata of the page.
///
/// The implementation may cast a `*const MetaSlot` to a `*const PageMeta`.
@@ -139,7 +139,7 @@ impl Sealed for FrameMeta {}
#[repr(C)]
pub struct SegmentHeadMeta {
/// Length of the segment in bytes.
- pub(super) seg_len: u64,
+ pub(in crate::mm) seg_len: u64,
}
impl Sealed for SegmentHeadMeta {}
diff --git a/framework/aster-frame/src/mm/page/mod.rs b/framework/aster-frame/src/mm/page/mod.rs
index 6904b7099..6de4a3921 100644
--- a/framework/aster-frame/src/mm/page/mod.rs
+++ b/framework/aster-frame/src/mm/page/mod.rs
@@ -1,33 +1,31 @@
// SPDX-License-Identifier: MPL-2.0
-//! Managing pages or frames.
+//! Physical memory page management.
//!
//! A page is an aligned, contiguous range of bytes in physical memory. The sizes
//! of base pages and huge pages are architecture-dependent. A page can be mapped
//! to a virtual address using the page table.
//!
-//! A frame is a special page that is _untyped_ memory. It is used to store data
-//! irrelevant to the integrity of the kernel. All pages mapped to the virtual
-//! address space of the users are backed by frames.
+//! Pages can be accessed through page handles, namely, [`Page`]. A page handle
+//! is a reference-counted handle to a page. When all handles to a page are dropped,
+//! the page is released and can be reused.
+//!
+//! Pages can have dedicated metadata, which is implemented in the [`meta`] module.
+//! The reference count and usage of a page are stored in the metadata as well, leaving
+//! the handle only a pointer to the metadata.
pub(crate) mod allocator;
-mod frame;
pub(in crate::mm) mod meta;
-mod segment;
-mod vm_frame_vec;
use core::{
marker::PhantomData,
sync::atomic::{AtomicU32, AtomicUsize, Ordering},
};
-pub use frame::Frame;
use meta::{mapping, MetaSlot, PageMeta};
-pub use segment::Segment;
-pub use vm_frame_vec::{FrameVecIter, VmFrameVec};
use super::PAGE_SIZE;
-use crate::mm::{paddr_to_vaddr, Paddr, PagingConsts, Vaddr};
+use crate::mm::{Paddr, PagingConsts, Vaddr};
static MAX_PADDR: AtomicUsize = AtomicUsize::new(0);
@@ -35,8 +33,8 @@ static MAX_PADDR: AtomicUsize = AtomicUsize::new(0);
/// whose metadata is represented by `M`.
#[derive(Debug)]
pub struct Page {
- ptr: *const MetaSlot,
- _marker: PhantomData,
+ pub(super) ptr: *const MetaSlot,
+ pub(super) _marker: PhantomData,
}
unsafe impl Send for Page {}
diff --git a/framework/aster-frame/src/mm/page_table/boot_pt.rs b/framework/aster-frame/src/mm/page_table/boot_pt.rs
index 142c7f9ec..af520b8de 100644
--- a/framework/aster-frame/src/mm/page_table/boot_pt.rs
+++ b/framework/aster-frame/src/mm/page_table/boot_pt.rs
@@ -101,10 +101,10 @@ fn test_boot_pt() {
use super::page_walk;
use crate::{
arch::mm::{PageTableEntry, PagingConsts},
- mm::{CachePolicy, PageFlags, VmAllocOptions},
+ mm::{CachePolicy, FrameAllocOptions, PageFlags},
};
- let root_frame = VmAllocOptions::new(1).alloc_single().unwrap();
+ let root_frame = FrameAllocOptions::new(1).alloc_single().unwrap();
let root_paddr = root_frame.start_paddr();
let mut boot_pt = BootPageTable:: {
diff --git a/framework/aster-frame/src/mm/page_table/cursor.rs b/framework/aster-frame/src/mm/page_table/cursor.rs
index 9f9fb6ccc..26d59c83c 100644
--- a/framework/aster-frame/src/mm/page_table/cursor.rs
+++ b/framework/aster-frame/src/mm/page_table/cursor.rs
@@ -122,7 +122,7 @@ where
// Create a guard array that only hold the root node lock.
let guards = core::array::from_fn(|i| {
if i == 0 {
- Some(pt.root.copy_handle().lock())
+ Some(pt.root.clone_shallow().lock())
} else {
None
}
@@ -313,7 +313,7 @@ where
// Drop the lock on the guard level.
self.guards[C::NR_LEVELS - self.guard_level] = None;
// Re-walk the page table to retreive the locks.
- self.guards[0] = Some(self.pt.root.copy_handle().lock());
+ self.guards[0] = Some(self.pt.root.clone_shallow().lock());
self.level = C::NR_LEVELS;
let cur_pte = self.read_cur_pte();
let cur_child_is_pt = cur_pte.is_present() && !cur_pte.is_last(self.level);
diff --git a/framework/aster-frame/src/mm/page_table/mod.rs b/framework/aster-frame/src/mm/page_table/mod.rs
index d2aefa273..56e715fbb 100644
--- a/framework/aster-frame/src/mm/page_table/mod.rs
+++ b/framework/aster-frame/src/mm/page_table/mod.rs
@@ -135,7 +135,7 @@ impl PageTable {
/// Then, one can use a user page table to call [`fork_copy_on_write`], creating
/// other child page tables.
pub(crate) fn create_user_page_table(&self) -> PageTable {
- let root_frame = self.root.copy_handle().lock();
+ let root_frame = self.root.clone_shallow().lock();
const NR_PTES_PER_NODE: usize = nr_subpage_per_huge::();
let new_root_frame =
unsafe { root_frame.make_copy(0..0, NR_PTES_PER_NODE / 2..NR_PTES_PER_NODE) };
@@ -157,7 +157,7 @@ impl PageTable {
debug_assert!(start < NR_PTES_PER_NODE);
let end = root_index.end;
debug_assert!(end <= NR_PTES_PER_NODE);
- let mut root_frame = self.root.copy_handle().lock();
+ let mut root_frame = self.root.clone_shallow().lock();
for i in start..end {
if !root_frame.read_pte(i).is_present() {
let frame = PageTableNode::alloc(PagingConsts::NR_LEVELS - 1);
@@ -254,7 +254,7 @@ where
/// This is only useful for IOMMU page tables. Think twice before using it in other cases.
pub(crate) unsafe fn shallow_copy(&self) -> Self {
PageTable {
- root: self.root.copy_handle(),
+ root: self.root.clone_shallow(),
_phantom: PhantomData,
}
}
diff --git a/framework/aster-frame/src/mm/page_table/node.rs b/framework/aster-frame/src/mm/page_table/node.rs
index b5e93c2cb..07a02d068 100644
--- a/framework/aster-frame/src/mm/page_table/node.rs
+++ b/framework/aster-frame/src/mm/page_table/node.rs
@@ -89,7 +89,7 @@ where
}
/// Create a copy of the handle.
- pub(super) fn copy_handle(&self) -> Self {
+ pub(super) fn clone_shallow(&self) -> Self {
self.inc_ref();
Self {
raw: self.raw,
@@ -321,7 +321,7 @@ where
for i in deep {
match self.child(i, /*meaningless*/ true) {
Child::PageTable(pt) => {
- let guard = pt.copy_handle().lock();
+ let guard = pt.clone_shallow().lock();
let new_child = guard.make_copy(0..nr_subpage_per_huge::(), 0..0);
new_frame.set_child_pt(i, new_child.into_raw(), /*meaningless*/ true);
}
@@ -339,7 +339,7 @@ where
debug_assert_eq!(self.level(), C::NR_LEVELS);
match self.child(i, /*meaningless*/ true) {
Child::PageTable(pt) => {
- new_frame.set_child_pt(i, pt.copy_handle(), /*meaningless*/ true);
+ new_frame.set_child_pt(i, pt.clone_shallow(), /*meaningless*/ true);
}
Child::None => {}
Child::Frame(_) | Child::Untracked(_) => {
diff --git a/framework/aster-frame/src/mm/page_table/test.rs b/framework/aster-frame/src/mm/page_table/test.rs
index 9803cdf00..5b660640f 100644
--- a/framework/aster-frame/src/mm/page_table/test.rs
+++ b/framework/aster-frame/src/mm/page_table/test.rs
@@ -6,7 +6,7 @@ use super::*;
use crate::mm::{
kspace::LINEAR_MAPPING_BASE_VADDR,
page_prop::{CachePolicy, PageFlags},
- VmAllocOptions,
+ FrameAllocOptions,
};
const PAGE_SIZE: usize = 4096;
@@ -17,7 +17,7 @@ fn test_range_check() {
let good_va = 0..PAGE_SIZE;
let bad_va = 0..PAGE_SIZE + 1;
let bad_va2 = LINEAR_MAPPING_BASE_VADDR..LINEAR_MAPPING_BASE_VADDR + PAGE_SIZE;
- let to = VmAllocOptions::new(1).alloc().unwrap();
+ let to = FrameAllocOptions::new(1).alloc().unwrap();
assert!(pt.cursor_mut(&good_va).is_ok());
assert!(pt.cursor_mut(&bad_va).is_err());
assert!(pt.cursor_mut(&bad_va2).is_err());
@@ -31,7 +31,7 @@ fn test_tracked_map_unmap() {
let pt = PageTable::::empty();
let from = PAGE_SIZE..PAGE_SIZE * 2;
- let frame = VmAllocOptions::new(1).alloc_single().unwrap();
+ let frame = FrameAllocOptions::new(1).alloc_single().unwrap();
let start_paddr = frame.start_paddr();
let prop = PageProperty::new(PageFlags::RW, CachePolicy::Writeback);
unsafe { pt.cursor_mut(&from).unwrap().map(frame.clone(), prop) };
@@ -75,7 +75,7 @@ fn test_untracked_map_unmap() {
fn test_user_copy_on_write() {
let pt = PageTable::::empty();
let from = PAGE_SIZE..PAGE_SIZE * 2;
- let frame = VmAllocOptions::new(1).alloc_single().unwrap();
+ let frame = FrameAllocOptions::new(1).alloc_single().unwrap();
let start_paddr = frame.start_paddr();
let prop = PageProperty::new(PageFlags::RW, CachePolicy::Writeback);
unsafe { pt.cursor_mut(&from).unwrap().map(frame.clone(), prop) };
@@ -131,7 +131,7 @@ fn test_base_protect_query() {
let from_ppn = 1..1000;
let from = PAGE_SIZE * from_ppn.start..PAGE_SIZE * from_ppn.end;
- let to = VmAllocOptions::new(999).alloc().unwrap();
+ let to = FrameAllocOptions::new(999).alloc().unwrap();
let prop = PageProperty::new(PageFlags::RW, CachePolicy::Writeback);
unsafe {
let mut cursor = pt.cursor_mut(&from).unwrap();
diff --git a/framework/aster-frame/src/mm/space.rs b/framework/aster-frame/src/mm/space.rs
index 7819eeba9..c33601c6a 100644
--- a/framework/aster-frame/src/mm/space.rs
+++ b/framework/aster-frame/src/mm/space.rs
@@ -6,7 +6,7 @@ use super::{
is_page_aligned,
kspace::KERNEL_PAGE_TABLE,
page_table::{PageTable, PageTableMode, UserMode},
- CachePolicy, PageFlags, PageProperty, PagingConstsTrait, PrivilegedPageFlags, VmFrameVec,
+ CachePolicy, FrameVec, PageFlags, PageProperty, PagingConstsTrait, PrivilegedPageFlags,
PAGE_SIZE,
};
use crate::{
@@ -65,7 +65,7 @@ impl VmSpace {
/// The ownership of the frames will be transferred to the `VmSpace`.
///
/// For more information, see `VmMapOptions`.
- pub fn map(&self, frames: VmFrameVec, options: &VmMapOptions) -> Result {
+ pub fn map(&self, frames: FrameVec, options: &VmMapOptions) -> Result {
if options.addr.is_none() {
return Err(Error::InvalidArgs);
}
diff --git a/framework/aster-frame/src/task/task.rs b/framework/aster-frame/src/task/task.rs
index 9d4d45d8d..26949a653 100644
--- a/framework/aster-frame/src/task/task.rs
+++ b/framework/aster-frame/src/task/task.rs
@@ -12,7 +12,7 @@ use super::{
pub(crate) use crate::arch::task::{context_switch, TaskContext};
use crate::{
cpu::CpuSet,
- mm::{kspace::KERNEL_PAGE_TABLE, PageFlags, Segment, VmAllocOptions, PAGE_SIZE},
+ mm::{kspace::KERNEL_PAGE_TABLE, FrameAllocOptions, PageFlags, Segment, PAGE_SIZE},
prelude::*,
sync::{SpinLock, SpinLockGuard},
user::UserSpace,
@@ -42,7 +42,7 @@ pub struct KernelStack {
impl KernelStack {
pub fn new() -> Result {
Ok(Self {
- segment: VmAllocOptions::new(KERNEL_STACK_SIZE / PAGE_SIZE).alloc_contiguous()?,
+ segment: FrameAllocOptions::new(KERNEL_STACK_SIZE / PAGE_SIZE).alloc_contiguous()?,
has_guard_page: false,
})
}
@@ -51,7 +51,7 @@ impl KernelStack {
/// An additional page is allocated and be regarded as a guard page, which should not be accessed.
pub fn new_with_guard_page() -> Result {
let stack_segment =
- VmAllocOptions::new(KERNEL_STACK_SIZE / PAGE_SIZE + 1).alloc_contiguous()?;
+ FrameAllocOptions::new(KERNEL_STACK_SIZE / PAGE_SIZE + 1).alloc_contiguous()?;
// FIXME: modifying the the linear mapping is bad.
let page_table = KERNEL_PAGE_TABLE.get().unwrap();
let guard_page_vaddr = {
diff --git a/kernel/aster-nix/src/fs/exfat/inode.rs b/kernel/aster-nix/src/fs/exfat/inode.rs
index aee1e2349..3def7b4e1 100644
--- a/kernel/aster-nix/src/fs/exfat/inode.rs
+++ b/kernel/aster-nix/src/fs/exfat/inode.rs
@@ -9,7 +9,7 @@ use aster_block::{
id::{Bid, BlockId},
BLOCK_SIZE,
};
-use aster_frame::mm::{Frame, VmAllocOptions, VmIo};
+use aster_frame::mm::{Frame, FrameAllocOptions, VmIo};
use aster_rights::Full;
use super::{
@@ -1242,7 +1242,10 @@ impl Inode for ExfatInode {
.discard_range(read_off..read_off + read_len);
let mut buf_offset = 0;
- let frame = VmAllocOptions::new(1).uninit(true).alloc_single().unwrap();
+ let frame = FrameAllocOptions::new(1)
+ .uninit(true)
+ .alloc_single()
+ .unwrap();
let start_pos = inner.start_chain.walk_to_cluster_at_offset(read_off)?;
let cluster_size = inner.fs().cluster_size();
@@ -1355,7 +1358,10 @@ impl Inode for ExfatInode {
let mut cur_offset = start_pos.1;
for _ in Bid::from_offset(offset)..Bid::from_offset(end_offset) {
let frame = {
- let frame = VmAllocOptions::new(1).uninit(true).alloc_single().unwrap();
+ let frame = FrameAllocOptions::new(1)
+ .uninit(true)
+ .alloc_single()
+ .unwrap();
frame.write_bytes(0, &buf[buf_offset..buf_offset + BLOCK_SIZE])?;
frame
};
diff --git a/kernel/aster-nix/src/fs/exfat/mod.rs b/kernel/aster-nix/src/fs/exfat/mod.rs
index 0bd5af9a9..74b6ecf49 100644
--- a/kernel/aster-nix/src/fs/exfat/mod.rs
+++ b/kernel/aster-nix/src/fs/exfat/mod.rs
@@ -21,7 +21,7 @@ mod test {
bio::{BioEnqueueError, BioStatus, BioType, SubmittedBio},
BlockDevice,
};
- use aster_frame::mm::{Segment, VmAllocOptions, VmIo};
+ use aster_frame::mm::{FrameAllocOptions, Segment, VmIo};
use rand::{rngs::SmallRng, RngCore, SeedableRng};
use crate::{
@@ -102,7 +102,7 @@ mod test {
/// Read exfat disk image
fn new_vm_segment_from_image() -> Segment {
let vm_segment = {
- VmAllocOptions::new(EXFAT_IMAGE.len() / PAGE_SIZE)
+ FrameAllocOptions::new(EXFAT_IMAGE.len() / PAGE_SIZE)
.is_contiguous(true)
.uninit(true)
.alloc_contiguous()
diff --git a/kernel/aster-nix/src/fs/ext2/fs.rs b/kernel/aster-nix/src/fs/ext2/fs.rs
index 69594998e..aec05b45f 100644
--- a/kernel/aster-nix/src/fs/ext2/fs.rs
+++ b/kernel/aster-nix/src/fs/ext2/fs.rs
@@ -40,7 +40,7 @@ impl Ext2 {
let npages = ((super_block.block_groups_count() as usize)
* core::mem::size_of::())
.div_ceil(BLOCK_SIZE);
- let segment = VmAllocOptions::new(npages)
+ let segment = FrameAllocOptions::new(npages)
.uninit(true)
.alloc_contiguous()?;
match block_device.read_blocks_sync(super_block.group_descriptors_bid(0), &segment)? {
diff --git a/kernel/aster-nix/src/fs/ext2/indirect_block_cache.rs b/kernel/aster-nix/src/fs/ext2/indirect_block_cache.rs
index f6247b4eb..a9cd7de9b 100644
--- a/kernel/aster-nix/src/fs/ext2/indirect_block_cache.rs
+++ b/kernel/aster-nix/src/fs/ext2/indirect_block_cache.rs
@@ -132,7 +132,7 @@ impl IndirectBlock {
/// Allocates an uninitialized block whose bytes are to be populated with
/// data loaded from the disk.
fn alloc_uninit() -> Result {
- let frame = VmAllocOptions::new(1).uninit(true).alloc_single()?;
+ let frame = FrameAllocOptions::new(1).uninit(true).alloc_single()?;
Ok(Self {
frame,
state: State::Uninit,
@@ -141,7 +141,7 @@ impl IndirectBlock {
/// Allocates a new block with its bytes initialized to zero.
pub fn alloc() -> Result {
- let frame = VmAllocOptions::new(1).alloc_single()?;
+ let frame = FrameAllocOptions::new(1).alloc_single()?;
Ok(Self {
frame,
state: State::Dirty,
diff --git a/kernel/aster-nix/src/fs/ext2/inode.rs b/kernel/aster-nix/src/fs/ext2/inode.rs
index 9c6907a78..b68b34235 100644
--- a/kernel/aster-nix/src/fs/ext2/inode.rs
+++ b/kernel/aster-nix/src/fs/ext2/inode.rs
@@ -653,7 +653,10 @@ impl Inner {
let mut buf_offset = 0;
for bid in Bid::from_offset(offset)..Bid::from_offset(offset + read_len) {
- let frame = VmAllocOptions::new(1).uninit(true).alloc_single().unwrap();
+ let frame = FrameAllocOptions::new(1)
+ .uninit(true)
+ .alloc_single()
+ .unwrap();
self.inode_impl
.read_block_sync(bid.to_raw() as Ext2Bid, &frame)?;
frame.read_bytes(0, &mut buf[buf_offset..buf_offset + BLOCK_SIZE])?;
@@ -691,7 +694,10 @@ impl Inner {
let mut buf_offset = 0;
for bid in Bid::from_offset(offset)..Bid::from_offset(end_offset) {
let frame = {
- let frame = VmAllocOptions::new(1).uninit(true).alloc_single().unwrap();
+ let frame = FrameAllocOptions::new(1)
+ .uninit(true)
+ .alloc_single()
+ .unwrap();
frame.write_bytes(0, &buf[buf_offset..buf_offset + BLOCK_SIZE])?;
frame
};
@@ -1572,7 +1578,7 @@ impl InodeImpl {
pub fn sync_data_holes(&self) -> Result<()> {
let inner = self.0.read();
- let zero_frame = VmAllocOptions::new(1).alloc_single().unwrap();
+ let zero_frame = FrameAllocOptions::new(1).alloc_single().unwrap();
for bid in 0..inner.desc.blocks_count() {
let is_data_hole = inner.blocks_hole_desc.read().is_hole(bid as usize);
if is_data_hole {
diff --git a/kernel/aster-nix/src/fs/ext2/prelude.rs b/kernel/aster-nix/src/fs/ext2/prelude.rs
index 18ee16867..165a1b789 100644
--- a/kernel/aster-nix/src/fs/ext2/prelude.rs
+++ b/kernel/aster-nix/src/fs/ext2/prelude.rs
@@ -12,7 +12,7 @@ pub(super) use aster_block::{
BlockDevice, BLOCK_SIZE,
};
pub(super) use aster_frame::{
- mm::{Frame, Segment, VmAllocOptions, VmIo},
+ mm::{Frame, FrameAllocOptions, Segment, VmIo},
sync::{RwMutex, RwMutexReadGuard, RwMutexWriteGuard},
};
pub(super) use aster_rights::Full;
diff --git a/kernel/aster-nix/src/fs/utils/page_cache.rs b/kernel/aster-nix/src/fs/utils/page_cache.rs
index 8ad72e375..9201acbef 100644
--- a/kernel/aster-nix/src/fs/utils/page_cache.rs
+++ b/kernel/aster-nix/src/fs/utils/page_cache.rs
@@ -3,7 +3,7 @@
use core::ops::Range;
use aster_block::bio::{BioStatus, BioWaiter};
-use aster_frame::mm::{Frame, VmAllocOptions};
+use aster_frame::mm::{Frame, FrameAllocOptions};
use aster_rights::Full;
use lru::LruCache;
@@ -208,7 +208,7 @@ struct Page {
impl Page {
pub fn alloc() -> Result {
- let frame = VmAllocOptions::new(1).uninit(true).alloc_single()?;
+ let frame = FrameAllocOptions::new(1).uninit(true).alloc_single()?;
Ok(Self {
frame,
state: PageState::Uninit,
@@ -216,7 +216,7 @@ impl Page {
}
pub fn alloc_zero() -> Result {
- let frame = VmAllocOptions::new(1).alloc_single()?;
+ let frame = FrameAllocOptions::new(1).alloc_single()?;
Ok(Self {
frame,
state: PageState::Dirty,
diff --git a/kernel/aster-nix/src/vm/vmar/vm_mapping.rs b/kernel/aster-nix/src/vm/vmar/vm_mapping.rs
index 256688f44..35e3b9c3e 100644
--- a/kernel/aster-nix/src/vm/vmar/vm_mapping.rs
+++ b/kernel/aster-nix/src/vm/vmar/vm_mapping.rs
@@ -2,7 +2,7 @@
use core::ops::Range;
-use aster_frame::mm::{Frame, PageFlags, VmFrameVec, VmIo, VmMapOptions, VmSpace};
+use aster_frame::mm::{Frame, FrameVec, PageFlags, VmIo, VmMapOptions, VmSpace};
use super::{interval::Interval, is_intersected, Vmar, Vmar_};
use crate::{
@@ -484,7 +484,7 @@ impl VmMappingInner {
vm_space.unmap(&(map_addr..(map_addr + PAGE_SIZE))).unwrap();
}
- vm_space.map(VmFrameVec::from_one_frame(frame), &vm_map_options)?;
+ vm_space.map(FrameVec::from_one_frame(frame), &vm_map_options)?;
self.mapped_pages.insert(page_idx);
Ok(())
}
diff --git a/kernel/aster-nix/src/vm/vmo/mod.rs b/kernel/aster-nix/src/vm/vmo/mod.rs
index 33ab70a6e..81139336e 100644
--- a/kernel/aster-nix/src/vm/vmo/mod.rs
+++ b/kernel/aster-nix/src/vm/vmo/mod.rs
@@ -7,7 +7,7 @@ use core::ops::Range;
use align_ext::AlignExt;
use aster_frame::{
collections::xarray::{CursorMut, XArray, XMark},
- mm::{Frame, VmAllocOptions, VmReader, VmWriter},
+ mm::{Frame, FrameAllocOptions, VmReader, VmWriter},
};
use aster_rights::Rights;
@@ -195,7 +195,7 @@ pub(super) struct Vmo_ {
}
fn clone_page(page: &Frame) -> Result {
- let new_page = VmAllocOptions::new(1).alloc_single()?;
+ let new_page = FrameAllocOptions::new(1).alloc_single()?;
new_page.copy_from(page);
Ok(new_page)
}
@@ -221,7 +221,7 @@ impl Vmo_ {
None => {
// Condition 1. The new anonymous page only need to be marked as `ExclusivePage`
// when current VMO is a cow VMO, otherwise this mark is meaningless.
- (VmAllocOptions::new(1).alloc_single()?, is_cow_vmo)
+ (FrameAllocOptions::new(1).alloc_single()?, is_cow_vmo)
}
Some(pager) => {
let page = pager.commit_page(page_idx)?;
diff --git a/kernel/aster-nix/src/vm/vmo/options.rs b/kernel/aster-nix/src/vm/vmo/options.rs
index e12c342fc..6fa8d4664 100644
--- a/kernel/aster-nix/src/vm/vmo/options.rs
+++ b/kernel/aster-nix/src/vm/vmo/options.rs
@@ -7,7 +7,7 @@ use core::{marker::PhantomData, ops::Range};
use align_ext::AlignExt;
use aster_frame::{
collections::xarray::XArray,
- mm::{Frame, VmAllocOptions},
+ mm::{Frame, FrameAllocOptions},
};
use aster_rights::{Dup, Rights, TRightSet, TRights, Write};
use aster_rights_proc::require;
@@ -144,7 +144,7 @@ fn committed_pages_if_continuous(flags: VmoFlags, size: usize) -> Result,
) -> Result {
let dma_stream = {
- let vm_segment = VmAllocOptions::new(1).alloc_contiguous()?;
+ let vm_segment = FrameAllocOptions::new(1).alloc_contiguous()?;
DmaStream::map(vm_segment, direction, is_cache_coherent)
.map_err(|_| aster_frame::Error::AccessDenied)?
diff --git a/kernel/comps/virtio/src/device/block/device.rs b/kernel/comps/virtio/src/device/block/device.rs
index 3968e9450..732cc6bb9 100644
--- a/kernel/comps/virtio/src/device/block/device.rs
+++ b/kernel/comps/virtio/src/device/block/device.rs
@@ -9,7 +9,7 @@ use aster_block::{
};
use aster_frame::{
io_mem::IoMem,
- mm::{DmaDirection, DmaStream, DmaStreamSlice, VmAllocOptions, VmIo},
+ mm::{DmaDirection, DmaStream, DmaStreamSlice, FrameAllocOptions, VmIo},
sync::SpinLock,
trap::TrapFrame,
};
@@ -100,12 +100,12 @@ impl DeviceInner {
let queue = VirtQueue::new(0, Self::QUEUE_SIZE, transport.as_mut())
.expect("create virtqueue failed");
let block_requests = {
- let vm_segment = VmAllocOptions::new(1).alloc_contiguous().unwrap();
+ let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
DmaStream::map(vm_segment, DmaDirection::Bidirectional, false).unwrap()
};
assert!(Self::QUEUE_SIZE as usize * REQ_SIZE <= block_requests.nbytes());
let block_responses = {
- let vm_segment = VmAllocOptions::new(1).alloc_contiguous().unwrap();
+ let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
DmaStream::map(vm_segment, DmaDirection::Bidirectional, false).unwrap()
};
assert!(Self::QUEUE_SIZE as usize * RESP_SIZE <= block_responses.nbytes());
@@ -216,7 +216,7 @@ impl DeviceInner {
};
const MAX_ID_LENGTH: usize = 20;
let device_id_stream = {
- let segment = VmAllocOptions::new(1)
+ let segment = FrameAllocOptions::new(1)
.uninit(true)
.alloc_contiguous()
.unwrap();
diff --git a/kernel/comps/virtio/src/device/console/device.rs b/kernel/comps/virtio/src/device/console/device.rs
index 0e6f94c16..929a5ffb2 100644
--- a/kernel/comps/virtio/src/device/console/device.rs
+++ b/kernel/comps/virtio/src/device/console/device.rs
@@ -6,7 +6,7 @@ use core::hint::spin_loop;
use aster_console::{AnyConsoleDevice, ConsoleCallback};
use aster_frame::{
io_mem::IoMem,
- mm::{DmaDirection, DmaStream, DmaStreamSlice, VmAllocOptions, VmReader},
+ mm::{DmaDirection, DmaStream, DmaStreamSlice, FrameAllocOptions, VmReader},
sync::{RwLock, SpinLock},
trap::TrapFrame,
};
@@ -87,12 +87,12 @@ impl ConsoleDevice {
SpinLock::new(VirtQueue::new(TRANSMIT0_QUEUE_INDEX, 2, transport.as_mut()).unwrap());
let send_buffer = {
- let vm_segment = VmAllocOptions::new(1).alloc_contiguous().unwrap();
+ let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
DmaStream::map(vm_segment, DmaDirection::ToDevice, false).unwrap()
};
let receive_buffer = {
- let vm_segment = VmAllocOptions::new(1).alloc_contiguous().unwrap();
+ let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
DmaStream::map(vm_segment, DmaDirection::FromDevice, false).unwrap()
};
diff --git a/kernel/comps/virtio/src/device/input/device.rs b/kernel/comps/virtio/src/device/input/device.rs
index a79e22318..0cb0b9838 100644
--- a/kernel/comps/virtio/src/device/input/device.rs
+++ b/kernel/comps/virtio/src/device/input/device.rs
@@ -10,7 +10,7 @@ use core::{fmt::Debug, iter, mem};
use aster_frame::{
io_mem::IoMem,
- mm::{DmaDirection, DmaStream, HasDaddr, VmAllocOptions, VmIo, PAGE_SIZE},
+ mm::{DmaDirection, DmaStream, FrameAllocOptions, HasDaddr, VmIo, PAGE_SIZE},
offset_of,
sync::{RwLock, SpinLock},
trap::TrapFrame,
@@ -239,7 +239,7 @@ impl EventTable {
fn new(num_events: usize) -> Self {
assert!(num_events * mem::size_of::() <= PAGE_SIZE);
- let vm_segment = VmAllocOptions::new(1).alloc_contiguous().unwrap();
+ let vm_segment = FrameAllocOptions::new(1).alloc_contiguous().unwrap();
let default_event = VirtioInputEvent::default();
let iter = iter::repeat(&default_event).take(EVENT_SIZE);
diff --git a/kernel/comps/virtio/src/queue.rs b/kernel/comps/virtio/src/queue.rs
index 8631aa3b4..fc90cb93a 100644
--- a/kernel/comps/virtio/src/queue.rs
+++ b/kernel/comps/virtio/src/queue.rs
@@ -10,7 +10,7 @@ use core::{
use aster_frame::{
io_mem::IoMem,
- mm::{DmaCoherent, VmAllocOptions},
+ mm::{DmaCoherent, FrameAllocOptions},
offset_of,
};
use aster_rights::{Dup, TRightSet, TRights, Write};
@@ -82,7 +82,7 @@ impl VirtQueue {
let desc_size = size_of::() * size as usize;
let (seg1, seg2) = {
- let continue_segment = VmAllocOptions::new(2).alloc_contiguous().unwrap();
+ let continue_segment = FrameAllocOptions::new(2).alloc_contiguous().unwrap();
let seg1 = continue_segment.range(0..1);
let seg2 = continue_segment.range(1..2);
(seg1, seg2)
@@ -101,17 +101,17 @@ impl VirtQueue {
}
(
SafePtr::new(
- DmaCoherent::map(VmAllocOptions::new(1).alloc_contiguous().unwrap(), true)
+ DmaCoherent::map(FrameAllocOptions::new(1).alloc_contiguous().unwrap(), true)
.unwrap(),
0,
),
SafePtr::new(
- DmaCoherent::map(VmAllocOptions::new(1).alloc_contiguous().unwrap(), true)
+ DmaCoherent::map(FrameAllocOptions::new(1).alloc_contiguous().unwrap(), true)
.unwrap(),
0,
),
SafePtr::new(
- DmaCoherent::map(VmAllocOptions::new(1).alloc_contiguous().unwrap(), true)
+ DmaCoherent::map(FrameAllocOptions::new(1).alloc_contiguous().unwrap(), true)
.unwrap(),
0,
),