MapMemory now accepts MappingSource

This commit is contained in:
Mark Poliakov 2023-12-22 13:34:11 +02:00
parent 37d2471965
commit 84d2c40a3c
2 changed files with 13 additions and 3 deletions

View File

@ -28,7 +28,11 @@ pub mod io {
};
}
/// Type alias for a raw file descriptor
pub mod mem {
//! Memory-related data structures
pub use abi::mem::MappingSource;
}
#[no_mangle]
unsafe extern "C" fn bcmp(p0: *const c_void, p1: *const c_void, len: usize) -> i32 {

View File

@ -8,6 +8,7 @@ use abi::{
DeviceRequest, DirectoryEntry, FileAttr, FileMode, MountOptions, OpenOptions, PollControl,
RawFd, SeekFrom, UnmountOptions,
},
mem::MappingSource,
process::{
ExitCode, MutexOperation, Signal, SignalEntryData, SpawnOptions, ThreadSpawnOptions,
},
@ -70,12 +71,17 @@ pub unsafe fn get_random(buffer: &mut [u8]) {
/// # Safety
///
/// Unsafe: direct system call.
pub unsafe fn map_memory(virt: Option<usize>, len: usize) -> Result<usize, Error> {
pub unsafe fn map_memory(
virt: Option<usize>,
len: usize,
source: &MappingSource,
) -> Result<usize, Error> {
let virt = virt.unwrap_or(0);
usize::from_syscall_result(syscall!(
SyscallFunction::MapMemory,
argn!(virt),
argn!(len)
argn!(len),
argp!(source as *const _)
))
}