kernel/vm_manager: Remove usages of global system accessors
Makes the dependency on the system instance explicit within VMManager's interface.
This commit is contained in:
parent
9186f76b07
commit
b6a87b422e
3 changed files with 11 additions and 7 deletions
|
@ -248,7 +248,8 @@ void Process::LoadModule(CodeSet module_, VAddr base_addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Process::Process(Core::System& system)
|
Process::Process(Core::System& system)
|
||||||
: WaitObject{system.Kernel()}, address_arbiter{system}, mutex{system}, system{system} {}
|
: WaitObject{system.Kernel()}, vm_manager{system},
|
||||||
|
address_arbiter{system}, mutex{system}, system{system} {}
|
||||||
|
|
||||||
Process::~Process() = default;
|
Process::~Process() = default;
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
VMManager::VMManager() {
|
VMManager::VMManager(Core::System& system) : system{system} {
|
||||||
// Default to assuming a 39-bit address space. This way we have a sane
|
// Default to assuming a 39-bit address space. This way we have a sane
|
||||||
// starting point with executables that don't provide metadata.
|
// starting point with executables that don't provide metadata.
|
||||||
Reset(FileSys::ProgramAddressSpaceType::Is39Bit);
|
Reset(FileSys::ProgramAddressSpaceType::Is39Bit);
|
||||||
|
@ -111,7 +111,6 @@ ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
|
||||||
VirtualMemoryArea& final_vma = vma_handle->second;
|
VirtualMemoryArea& final_vma = vma_handle->second;
|
||||||
ASSERT(final_vma.size == size);
|
ASSERT(final_vma.size == size);
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
system.ArmInterface(0).MapBackingMemory(target, size, block->data() + offset,
|
system.ArmInterface(0).MapBackingMemory(target, size, block->data() + offset,
|
||||||
VMAPermission::ReadWriteExecute);
|
VMAPermission::ReadWriteExecute);
|
||||||
system.ArmInterface(1).MapBackingMemory(target, size, block->data() + offset,
|
system.ArmInterface(1).MapBackingMemory(target, size, block->data() + offset,
|
||||||
|
@ -140,7 +139,6 @@ ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8* me
|
||||||
VirtualMemoryArea& final_vma = vma_handle->second;
|
VirtualMemoryArea& final_vma = vma_handle->second;
|
||||||
ASSERT(final_vma.size == size);
|
ASSERT(final_vma.size == size);
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
system.ArmInterface(0).MapBackingMemory(target, size, memory, VMAPermission::ReadWriteExecute);
|
system.ArmInterface(0).MapBackingMemory(target, size, memory, VMAPermission::ReadWriteExecute);
|
||||||
system.ArmInterface(1).MapBackingMemory(target, size, memory, VMAPermission::ReadWriteExecute);
|
system.ArmInterface(1).MapBackingMemory(target, size, memory, VMAPermission::ReadWriteExecute);
|
||||||
system.ArmInterface(2).MapBackingMemory(target, size, memory, VMAPermission::ReadWriteExecute);
|
system.ArmInterface(2).MapBackingMemory(target, size, memory, VMAPermission::ReadWriteExecute);
|
||||||
|
@ -223,7 +221,6 @@ ResultCode VMManager::UnmapRange(VAddr target, u64 size) {
|
||||||
|
|
||||||
ASSERT(FindVMA(target)->second.size >= size);
|
ASSERT(FindVMA(target)->second.size >= size);
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
system.ArmInterface(0).UnmapMemory(target, size);
|
system.ArmInterface(0).UnmapMemory(target, size);
|
||||||
system.ArmInterface(1).UnmapMemory(target, size);
|
system.ArmInterface(1).UnmapMemory(target, size);
|
||||||
system.ArmInterface(2).UnmapMemory(target, size);
|
system.ArmInterface(2).UnmapMemory(target, size);
|
||||||
|
@ -376,7 +373,7 @@ ResultCode VMManager::UnmapCodeMemory(VAddr dst_address, VAddr src_address, u64
|
||||||
Reprotect(src_vma_iter, VMAPermission::ReadWrite);
|
Reprotect(src_vma_iter, VMAPermission::ReadWrite);
|
||||||
|
|
||||||
if (dst_memory_state == MemoryState::ModuleCode) {
|
if (dst_memory_state == MemoryState::ModuleCode) {
|
||||||
Core::System::GetInstance().InvalidateCpuInstructionCaches();
|
system.InvalidateCpuInstructionCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
return unmap_result;
|
return unmap_result;
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
enum class ProgramAddressSpaceType : u8;
|
enum class ProgramAddressSpaceType : u8;
|
||||||
}
|
}
|
||||||
|
@ -321,7 +325,7 @@ class VMManager final {
|
||||||
public:
|
public:
|
||||||
using VMAHandle = VMAMap::const_iterator;
|
using VMAHandle = VMAMap::const_iterator;
|
||||||
|
|
||||||
VMManager();
|
explicit VMManager(Core::System& system);
|
||||||
~VMManager();
|
~VMManager();
|
||||||
|
|
||||||
/// Clears the address space map, re-initializing with a single free area.
|
/// Clears the address space map, re-initializing with a single free area.
|
||||||
|
@ -712,5 +716,7 @@ private:
|
||||||
// The end of the currently allocated heap. This is not an inclusive
|
// The end of the currently allocated heap. This is not an inclusive
|
||||||
// end of the range. This is essentially 'base_address + current_size'.
|
// end of the range. This is essentially 'base_address + current_size'.
|
||||||
VAddr heap_end = 0;
|
VAddr heap_end = 0;
|
||||||
|
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
Loading…
Reference in a new issue