Skip to content

Commit

Permalink
Renames MemoryManager to Vm (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon authored Mar 30, 2024
1 parent b625915 commit 7b975ec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/kernel/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::signal::{
use crate::signal::{SigChldFlags, Signal};
use crate::syscalls::{SysErr, SysIn, SysOut, Syscalls};
use crate::ucred::{AuthInfo, Gid, Privilege, Ucred, Uid};
use crate::vm::{MemoryManager, MemoryManagerError};
use crate::vm::{MemoryManagerError, Vm};
use gmtx::{Gutex, GutexGroup, GutexReadGuard, GutexWriteGuard};
use macros::Errno;
use std::any::Any;
Expand Down Expand Up @@ -56,7 +56,7 @@ pub struct VProc {
threads: Gutex<Vec<Arc<VThread>>>, // p_threads
cred: Ucred, // p_ucred
group: Gutex<Option<VProcGroup>>, // p_pgrp
vm: Arc<MemoryManager>, // p_vmspace
vm: Arc<Vm>, // p_vmspace
sigacts: Gutex<SignalActs>, // p_sigacts
files: Arc<FileDesc>, // p_fd
system_path: String, // p_randomized_path
Expand Down Expand Up @@ -98,7 +98,7 @@ impl VProc {
threads: gg.spawn(Vec::new()),
cred,
group: gg.spawn(None),
vm: MemoryManager::new(sys)?,
vm: Vm::new(sys)?,
sigacts: gg.spawn(SignalActs::new()),
files: FileDesc::new(root),
system_path: system_path.into(),
Expand Down Expand Up @@ -140,7 +140,7 @@ impl VProc {
&self.cred
}

pub fn vm(&self) -> &MemoryManager {
pub fn vm(&self) -> &Arc<Vm> {
&self.vm
}

Expand Down
4 changes: 2 additions & 2 deletions src/kernel/src/sysctl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::errno::{
};
use crate::process::VThread;
use crate::syscalls::{SysErr, SysIn, SysOut, Syscalls};
use crate::vm::MemoryManager;
use crate::vm::Vm;
use std::any::Any;
use std::cmp::min;
use std::ptr::null_mut;
Expand Down Expand Up @@ -1080,7 +1080,7 @@ static HW_PAGESIZE: Oid = Oid {
number: Sysctl::HW_PAGESIZE,
kind: Sysctl::CTLFLAG_RD | Sysctl::CTLFLAG_MPSAFE | Sysctl::CTLFLAG_CAPRD | Sysctl::CTLTYPE_INT,
arg1: None,
arg2: MemoryManager::VIRTUAL_PAGE_SIZE,
arg2: Vm::VIRTUAL_PAGE_SIZE,
name: "pagesize",
handler: Some(Sysctl::handle_int),
fmt: "I",
Expand Down
10 changes: 5 additions & 5 deletions src/kernel/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ mod page;
mod stack;
mod storage;

/// Manage all paged memory that can be seen by a PS4 app.
/// Implementation of `vmspace` structure.
#[derive(Debug)]
pub struct MemoryManager {
pub struct Vm {
page_size: usize,
allocation_granularity: usize,
allocations: RwLock<BTreeMap<usize, Alloc>>, // Key is Alloc::addr.
stack: AppStack,
}

impl MemoryManager {
impl Vm {
/// Size of a memory page on PS4.
pub const VIRTUAL_PAGE_SIZE: usize = 0x4000;

Expand Down Expand Up @@ -555,7 +555,7 @@ impl MemoryManager {

// Check if the request is a guard for main stack.
if addr == self.stack.guard() {
assert_eq!(len, MemoryManager::VIRTUAL_PAGE_SIZE);
assert_eq!(len, Self::VIRTUAL_PAGE_SIZE);
assert!(prot.is_empty());
assert!(flags.intersects(MappingFlags::MAP_ANON));
assert_eq!(fd, -1);
Expand Down Expand Up @@ -650,7 +650,7 @@ impl MemoryManager {
}
}

unsafe impl Sync for MemoryManager {}
unsafe impl Sync for Vm {}

/// Contains information for an allocation of virtual pages.
#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions src/kernel/src/vm/page.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use super::MemoryManager;
use super::Vm;

/// Encapsulated one or more virtual pages.
pub struct VPages<'a> {
mm: &'a MemoryManager,
mm: &'a Vm,
ptr: *mut u8,
len: usize,
}

impl<'a> VPages<'a> {
pub(super) fn new(mm: &'a MemoryManager, ptr: *mut u8, len: usize) -> Self {
pub(super) fn new(mm: &'a Vm, ptr: *mut u8, len: usize) -> Self {
Self { mm, ptr, len }
}

Expand Down

0 comments on commit 7b975ec

Please sign in to comment.