Add duplicate_frame method

This commit is contained in:
Chen Chengjun 2024-08-12 15:55:59 +08:00 committed by Tate, Hongliang Tian
parent 49692c2068
commit 24e7f77803
2 changed files with 13 additions and 0 deletions

View File

@ -18,5 +18,6 @@
pub mod page_fault_handler;
pub mod perms;
pub mod util;
pub mod vmar;
pub mod vmo;

View File

@ -0,0 +1,12 @@
// SPDX-License-Identifier: MPL-2.0
use ostd::mm::{Frame, FrameAllocOptions};
use crate::prelude::*;
/// Creates a new `Frame` and initializes it with the contents of the `src`.
pub fn duplicate_frame(src: &Frame) -> Result<Frame> {
let new_frame = FrameAllocOptions::new(1).uninit(true).alloc_single()?;
new_frame.copy_from(src);
Ok(new_frame)
}