2015-05-20 20:37:07 -07:00
|
|
|
// Copyright 2015 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2015-06-21 07:11:32 -07:00
|
|
|
#include <iterator>
|
2018-07-18 16:02:47 -07:00
|
|
|
#include <utility>
|
2015-05-20 20:37:07 -07:00
|
|
|
#include "common/assert.h"
|
2018-01-01 12:59:31 -08:00
|
|
|
#include "common/logging/log.h"
|
2017-10-09 20:56:20 -07:00
|
|
|
#include "core/arm/arm_interface.h"
|
2018-01-16 10:05:21 -08:00
|
|
|
#include "core/core.h"
|
2017-05-21 00:11:36 -07:00
|
|
|
#include "core/hle/kernel/errors.h"
|
2016-09-20 23:52:38 -07:00
|
|
|
#include "core/hle/kernel/vm_manager.h"
|
2016-05-26 10:53:30 -07:00
|
|
|
#include "core/memory.h"
|
2018-01-27 07:16:39 -08:00
|
|
|
#include "core/memory_hook.h"
|
2015-05-20 20:37:07 -07:00
|
|
|
#include "core/memory_setup.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2015-07-17 17:55:48 -07:00
|
|
|
static const char* GetMemoryStateName(MemoryState state) {
|
2018-07-18 15:40:35 -07:00
|
|
|
static constexpr const char* names[] = {
|
|
|
|
"Unmapped", "Io",
|
|
|
|
"Normal", "CodeStatic",
|
|
|
|
"CodeMutable", "Heap",
|
|
|
|
"Shared", "Unknown1",
|
|
|
|
"ModuleCodeStatic", "ModuleCodeMutable",
|
|
|
|
"IpcBuffer0", "Mapped",
|
|
|
|
"ThreadLocal", "TransferMemoryIsolated",
|
|
|
|
"TransferMemory", "ProcessMemory",
|
|
|
|
"Unknown2", "IpcBuffer1",
|
|
|
|
"IpcBuffer3", "KernelStack",
|
2015-07-17 17:55:48 -07:00
|
|
|
};
|
|
|
|
|
2018-07-18 15:40:35 -07:00
|
|
|
return names[static_cast<int>(state)];
|
2015-07-17 17:55:48 -07:00
|
|
|
}
|
|
|
|
|
2015-05-20 20:37:07 -07:00
|
|
|
bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const {
|
|
|
|
ASSERT(base + size == next.base);
|
2016-09-17 17:38:01 -07:00
|
|
|
if (permissions != next.permissions || meminfo_state != next.meminfo_state ||
|
|
|
|
type != next.type) {
|
2015-05-20 20:37:07 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (type == VMAType::AllocatedMemoryBlock &&
|
2016-09-17 17:38:01 -07:00
|
|
|
(backing_block != next.backing_block || offset + size != next.offset)) {
|
2015-05-20 20:37:07 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (type == VMAType::BackingMemory && backing_memory + size != next.backing_memory) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (type == VMAType::MMIO && paddr + size != next.paddr) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
VMManager::VMManager() {
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
2015-07-09 18:52:15 -07:00
|
|
|
VMManager::~VMManager() {
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
2015-05-20 20:37:07 -07:00
|
|
|
void VMManager::Reset() {
|
|
|
|
vma_map.clear();
|
|
|
|
|
|
|
|
// Initialize the map with a single free region covering the entire managed space.
|
|
|
|
VirtualMemoryArea initial_vma;
|
|
|
|
initial_vma.size = MAX_ADDRESS;
|
|
|
|
vma_map.emplace(initial_vma.base, initial_vma);
|
|
|
|
|
2017-07-21 19:17:57 -07:00
|
|
|
page_table.pointers.fill(nullptr);
|
2018-01-27 07:16:39 -08:00
|
|
|
page_table.special_regions.clear();
|
2017-07-21 19:17:57 -07:00
|
|
|
page_table.attributes.fill(Memory::PageType::Unmapped);
|
|
|
|
|
2018-01-01 12:59:31 -08:00
|
|
|
UpdatePageTableForVMA(initial_vma);
|
2015-05-20 20:37:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
VMManager::VMAHandle VMManager::FindVMA(VAddr target) const {
|
2015-07-17 19:19:16 -07:00
|
|
|
if (target >= MAX_ADDRESS) {
|
|
|
|
return vma_map.end();
|
|
|
|
} else {
|
|
|
|
return std::prev(vma_map.upper_bound(target));
|
|
|
|
}
|
2015-05-20 20:37:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
|
2016-09-17 17:38:01 -07:00
|
|
|
std::shared_ptr<std::vector<u8>> block,
|
2017-09-01 20:10:03 -07:00
|
|
|
size_t offset, u64 size,
|
2016-09-17 17:38:01 -07:00
|
|
|
MemoryState state) {
|
2015-05-20 20:37:07 -07:00
|
|
|
ASSERT(block != nullptr);
|
|
|
|
ASSERT(offset + size <= block->size());
|
|
|
|
|
|
|
|
// This is the appropriately sized VMA that will turn into our allocation.
|
|
|
|
CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size));
|
|
|
|
VirtualMemoryArea& final_vma = vma_handle->second;
|
|
|
|
ASSERT(final_vma.size == size);
|
|
|
|
|
2018-05-02 19:36:51 -07:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
system.ArmInterface(0).MapBackingMemory(target, size, block->data() + offset,
|
|
|
|
VMAPermission::ReadWriteExecute);
|
|
|
|
system.ArmInterface(1).MapBackingMemory(target, size, block->data() + offset,
|
|
|
|
VMAPermission::ReadWriteExecute);
|
|
|
|
system.ArmInterface(2).MapBackingMemory(target, size, block->data() + offset,
|
|
|
|
VMAPermission::ReadWriteExecute);
|
|
|
|
system.ArmInterface(3).MapBackingMemory(target, size, block->data() + offset,
|
|
|
|
VMAPermission::ReadWriteExecute);
|
2017-10-09 20:56:20 -07:00
|
|
|
|
2015-05-20 20:37:07 -07:00
|
|
|
final_vma.type = VMAType::AllocatedMemoryBlock;
|
|
|
|
final_vma.permissions = VMAPermission::ReadWrite;
|
|
|
|
final_vma.meminfo_state = state;
|
2018-07-18 16:02:47 -07:00
|
|
|
final_vma.backing_block = std::move(block);
|
2015-05-20 20:37:07 -07:00
|
|
|
final_vma.offset = offset;
|
|
|
|
UpdatePageTableForVMA(final_vma);
|
|
|
|
|
|
|
|
return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
|
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
ResultVal<VMManager::VMAHandle> VMManager::MapBackingMemory(VAddr target, u8* memory, u64 size,
|
2016-09-17 17:38:01 -07:00
|
|
|
MemoryState state) {
|
2015-05-20 20:37:07 -07:00
|
|
|
ASSERT(memory != nullptr);
|
|
|
|
|
|
|
|
// This is the appropriately sized VMA that will turn into our allocation.
|
|
|
|
CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size));
|
|
|
|
VirtualMemoryArea& final_vma = vma_handle->second;
|
|
|
|
ASSERT(final_vma.size == size);
|
|
|
|
|
2018-05-02 19:36:51 -07:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
system.ArmInterface(0).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(3).MapBackingMemory(target, size, memory, VMAPermission::ReadWriteExecute);
|
2017-10-09 20:56:20 -07:00
|
|
|
|
2015-05-20 20:37:07 -07:00
|
|
|
final_vma.type = VMAType::BackingMemory;
|
|
|
|
final_vma.permissions = VMAPermission::ReadWrite;
|
|
|
|
final_vma.meminfo_state = state;
|
|
|
|
final_vma.backing_memory = memory;
|
|
|
|
UpdatePageTableForVMA(final_vma);
|
|
|
|
|
|
|
|
return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
|
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
ResultVal<VMManager::VMAHandle> VMManager::MapMMIO(VAddr target, PAddr paddr, u64 size,
|
2016-09-17 17:38:01 -07:00
|
|
|
MemoryState state,
|
2018-01-27 07:16:39 -08:00
|
|
|
Memory::MemoryHookPointer mmio_handler) {
|
2015-05-20 20:37:07 -07:00
|
|
|
// This is the appropriately sized VMA that will turn into our allocation.
|
|
|
|
CASCADE_RESULT(VMAIter vma_handle, CarveVMA(target, size));
|
|
|
|
VirtualMemoryArea& final_vma = vma_handle->second;
|
|
|
|
ASSERT(final_vma.size == size);
|
|
|
|
|
|
|
|
final_vma.type = VMAType::MMIO;
|
|
|
|
final_vma.permissions = VMAPermission::ReadWrite;
|
|
|
|
final_vma.meminfo_state = state;
|
|
|
|
final_vma.paddr = paddr;
|
2018-07-18 16:02:47 -07:00
|
|
|
final_vma.mmio_handler = std::move(mmio_handler);
|
2015-05-20 20:37:07 -07:00
|
|
|
UpdatePageTableForVMA(final_vma);
|
|
|
|
|
|
|
|
return MakeResult<VMAHandle>(MergeAdjacent(vma_handle));
|
|
|
|
}
|
|
|
|
|
2015-07-17 19:19:16 -07:00
|
|
|
VMManager::VMAIter VMManager::Unmap(VMAIter vma_handle) {
|
|
|
|
VirtualMemoryArea& vma = vma_handle->second;
|
2015-05-20 20:37:07 -07:00
|
|
|
vma.type = VMAType::Free;
|
|
|
|
vma.permissions = VMAPermission::None;
|
2018-03-10 14:46:23 -08:00
|
|
|
vma.meminfo_state = MemoryState::Unmapped;
|
2015-05-20 20:37:07 -07:00
|
|
|
|
|
|
|
vma.backing_block = nullptr;
|
|
|
|
vma.offset = 0;
|
|
|
|
vma.backing_memory = nullptr;
|
|
|
|
vma.paddr = 0;
|
|
|
|
|
|
|
|
UpdatePageTableForVMA(vma);
|
|
|
|
|
2015-07-17 19:19:16 -07:00
|
|
|
return MergeAdjacent(vma_handle);
|
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
ResultCode VMManager::UnmapRange(VAddr target, u64 size) {
|
2015-07-17 19:19:16 -07:00
|
|
|
CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
|
|
|
|
VAddr target_end = target + size;
|
|
|
|
|
|
|
|
VMAIter end = vma_map.end();
|
|
|
|
// The comparison against the end of the range must be done using addresses since VMAs can be
|
|
|
|
// merged during this process, causing invalidation of the iterators.
|
|
|
|
while (vma != end && vma->second.base < target_end) {
|
|
|
|
vma = std::next(Unmap(vma));
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(FindVMA(target)->second.size >= size);
|
2018-03-16 15:22:14 -07:00
|
|
|
|
2018-05-02 19:36:51 -07:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
system.ArmInterface(0).UnmapMemory(target, size);
|
|
|
|
system.ArmInterface(1).UnmapMemory(target, size);
|
|
|
|
system.ArmInterface(2).UnmapMemory(target, size);
|
|
|
|
system.ArmInterface(3).UnmapMemory(target, size);
|
2018-03-16 15:22:14 -07:00
|
|
|
|
2015-07-17 19:19:16 -07:00
|
|
|
return RESULT_SUCCESS;
|
2015-05-20 20:37:07 -07:00
|
|
|
}
|
|
|
|
|
2015-07-17 19:19:16 -07:00
|
|
|
VMManager::VMAHandle VMManager::Reprotect(VMAHandle vma_handle, VMAPermission new_perms) {
|
2015-05-20 20:37:07 -07:00
|
|
|
VMAIter iter = StripIterConstness(vma_handle);
|
|
|
|
|
|
|
|
VirtualMemoryArea& vma = iter->second;
|
|
|
|
vma.permissions = new_perms;
|
|
|
|
UpdatePageTableForVMA(vma);
|
|
|
|
|
2015-07-17 19:19:16 -07:00
|
|
|
return MergeAdjacent(iter);
|
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_perms) {
|
2015-07-17 19:19:16 -07:00
|
|
|
CASCADE_RESULT(VMAIter vma, CarveVMARange(target, size));
|
|
|
|
VAddr target_end = target + size;
|
|
|
|
|
|
|
|
VMAIter end = vma_map.end();
|
|
|
|
// The comparison against the end of the range must be done using addresses since VMAs can be
|
|
|
|
// merged during this process, causing invalidation of the iterators.
|
|
|
|
while (vma != end && vma->second.base < target_end) {
|
|
|
|
vma = std::next(StripIterConstness(Reprotect(vma, new_perms)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMManager::RefreshMemoryBlockMappings(const std::vector<u8>* block) {
|
|
|
|
// If this ever proves to have a noticeable performance impact, allow users of the function to
|
|
|
|
// specify a specific range of addresses to limit the scan to.
|
|
|
|
for (const auto& p : vma_map) {
|
|
|
|
const VirtualMemoryArea& vma = p.second;
|
|
|
|
if (block == vma.backing_block.get()) {
|
|
|
|
UpdatePageTableForVMA(vma);
|
|
|
|
}
|
|
|
|
}
|
2015-05-20 20:37:07 -07:00
|
|
|
}
|
|
|
|
|
2018-04-27 08:49:18 -07:00
|
|
|
void VMManager::LogLayout() const {
|
2015-07-09 18:52:15 -07:00
|
|
|
for (const auto& p : vma_map) {
|
|
|
|
const VirtualMemoryArea& vma = p.second;
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Kernel, "{:016X} - {:016X} size: {:016X} {}{}{} {}", vma.base,
|
2018-07-02 09:20:50 -07:00
|
|
|
vma.base + vma.size, vma.size,
|
|
|
|
(u8)vma.permissions & (u8)VMAPermission::Read ? 'R' : '-',
|
|
|
|
(u8)vma.permissions & (u8)VMAPermission::Write ? 'W' : '-',
|
|
|
|
(u8)vma.permissions & (u8)VMAPermission::Execute ? 'X' : '-',
|
|
|
|
GetMemoryStateName(vma.meminfo_state));
|
2015-07-09 18:52:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-17 17:38:01 -07:00
|
|
|
VMManager::VMAIter VMManager::StripIterConstness(const VMAHandle& iter) {
|
2015-05-20 20:37:07 -07:00
|
|
|
// This uses a neat C++ trick to convert a const_iterator to a regular iterator, given
|
|
|
|
// non-const access to its container.
|
|
|
|
return vma_map.erase(iter, iter); // Erases an empty range of elements
|
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
ResultVal<VMManager::VMAIter> VMManager::CarveVMA(VAddr base, u64 size) {
|
2018-05-02 06:14:28 -07:00
|
|
|
ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x{:016X}", size);
|
|
|
|
ASSERT_MSG((base & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x{:016X}", base);
|
2015-05-20 20:37:07 -07:00
|
|
|
|
|
|
|
VMAIter vma_handle = StripIterConstness(FindVMA(base));
|
|
|
|
if (vma_handle == vma_map.end()) {
|
|
|
|
// Target address is outside the range managed by the kernel
|
2015-07-17 18:34:50 -07:00
|
|
|
return ERR_INVALID_ADDRESS;
|
2015-05-20 20:37:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
VirtualMemoryArea& vma = vma_handle->second;
|
|
|
|
if (vma.type != VMAType::Free) {
|
|
|
|
// Region is already allocated
|
2015-07-17 18:34:50 -07:00
|
|
|
return ERR_INVALID_ADDRESS_STATE;
|
2015-05-20 20:37:07 -07:00
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
u64 start_in_vma = base - vma.base;
|
|
|
|
u64 end_in_vma = start_in_vma + size;
|
2015-05-20 20:37:07 -07:00
|
|
|
|
|
|
|
if (end_in_vma > vma.size) {
|
|
|
|
// Requested allocation doesn't fit inside VMA
|
2015-07-17 18:34:50 -07:00
|
|
|
return ERR_INVALID_ADDRESS_STATE;
|
2015-05-20 20:37:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (end_in_vma != vma.size) {
|
|
|
|
// Split VMA at the end of the allocated region
|
|
|
|
SplitVMA(vma_handle, end_in_vma);
|
|
|
|
}
|
|
|
|
if (start_in_vma != 0) {
|
|
|
|
// Split VMA at the start of the allocated region
|
|
|
|
vma_handle = SplitVMA(vma_handle, start_in_vma);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MakeResult<VMAIter>(vma_handle);
|
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u64 size) {
|
2018-05-02 06:14:28 -07:00
|
|
|
ASSERT_MSG((size & Memory::PAGE_MASK) == 0, "non-page aligned size: 0x{:016X}", size);
|
|
|
|
ASSERT_MSG((target & Memory::PAGE_MASK) == 0, "non-page aligned base: 0x{:016X}", target);
|
2015-07-17 19:19:16 -07:00
|
|
|
|
|
|
|
VAddr target_end = target + size;
|
|
|
|
ASSERT(target_end >= target);
|
|
|
|
ASSERT(target_end <= MAX_ADDRESS);
|
|
|
|
ASSERT(size > 0);
|
|
|
|
|
|
|
|
VMAIter begin_vma = StripIterConstness(FindVMA(target));
|
|
|
|
VMAIter i_end = vma_map.lower_bound(target_end);
|
|
|
|
for (auto i = begin_vma; i != i_end; ++i) {
|
|
|
|
if (i->second.type == VMAType::Free) {
|
|
|
|
return ERR_INVALID_ADDRESS_STATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target != begin_vma->second.base) {
|
|
|
|
begin_vma = SplitVMA(begin_vma, target - begin_vma->second.base);
|
|
|
|
}
|
|
|
|
|
|
|
|
VMAIter end_vma = StripIterConstness(FindVMA(target_end));
|
|
|
|
if (end_vma != vma_map.end() && target_end != end_vma->second.base) {
|
|
|
|
end_vma = SplitVMA(end_vma, target_end - end_vma->second.base);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MakeResult<VMAIter>(begin_vma);
|
|
|
|
}
|
|
|
|
|
2017-09-01 20:10:03 -07:00
|
|
|
VMManager::VMAIter VMManager::SplitVMA(VMAIter vma_handle, u64 offset_in_vma) {
|
2015-05-20 20:37:07 -07:00
|
|
|
VirtualMemoryArea& old_vma = vma_handle->second;
|
|
|
|
VirtualMemoryArea new_vma = old_vma; // Make a copy of the VMA
|
|
|
|
|
|
|
|
// For now, don't allow no-op VMA splits (trying to split at a boundary) because it's probably
|
|
|
|
// a bug. This restriction might be removed later.
|
|
|
|
ASSERT(offset_in_vma < old_vma.size);
|
|
|
|
ASSERT(offset_in_vma > 0);
|
|
|
|
|
|
|
|
old_vma.size = offset_in_vma;
|
|
|
|
new_vma.base += offset_in_vma;
|
|
|
|
new_vma.size -= offset_in_vma;
|
|
|
|
|
|
|
|
switch (new_vma.type) {
|
|
|
|
case VMAType::Free:
|
|
|
|
break;
|
|
|
|
case VMAType::AllocatedMemoryBlock:
|
|
|
|
new_vma.offset += offset_in_vma;
|
|
|
|
break;
|
|
|
|
case VMAType::BackingMemory:
|
|
|
|
new_vma.backing_memory += offset_in_vma;
|
|
|
|
break;
|
|
|
|
case VMAType::MMIO:
|
|
|
|
new_vma.paddr += offset_in_vma;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(old_vma.CanBeMergedWith(new_vma));
|
|
|
|
|
|
|
|
return vma_map.emplace_hint(std::next(vma_handle), new_vma.base, new_vma);
|
|
|
|
}
|
|
|
|
|
|
|
|
VMManager::VMAIter VMManager::MergeAdjacent(VMAIter iter) {
|
|
|
|
VMAIter next_vma = std::next(iter);
|
|
|
|
if (next_vma != vma_map.end() && iter->second.CanBeMergedWith(next_vma->second)) {
|
|
|
|
iter->second.size += next_vma->second.size;
|
|
|
|
vma_map.erase(next_vma);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iter != vma_map.begin()) {
|
|
|
|
VMAIter prev_vma = std::prev(iter);
|
|
|
|
if (prev_vma->second.CanBeMergedWith(iter->second)) {
|
|
|
|
prev_vma->second.size += iter->second.size;
|
|
|
|
vma_map.erase(iter);
|
|
|
|
iter = prev_vma;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMManager::UpdatePageTableForVMA(const VirtualMemoryArea& vma) {
|
|
|
|
switch (vma.type) {
|
|
|
|
case VMAType::Free:
|
2017-07-21 19:17:57 -07:00
|
|
|
Memory::UnmapRegion(page_table, vma.base, vma.size);
|
2015-05-20 20:37:07 -07:00
|
|
|
break;
|
|
|
|
case VMAType::AllocatedMemoryBlock:
|
2017-07-21 19:17:57 -07:00
|
|
|
Memory::MapMemoryRegion(page_table, vma.base, vma.size,
|
|
|
|
vma.backing_block->data() + vma.offset);
|
2015-05-20 20:37:07 -07:00
|
|
|
break;
|
|
|
|
case VMAType::BackingMemory:
|
2017-07-21 19:17:57 -07:00
|
|
|
Memory::MapMemoryRegion(page_table, vma.base, vma.size, vma.backing_memory);
|
2015-05-20 20:37:07 -07:00
|
|
|
break;
|
|
|
|
case VMAType::MMIO:
|
2017-07-21 19:17:57 -07:00
|
|
|
Memory::MapIoRegion(page_table, vma.base, vma.size, vma.mmio_handler);
|
2015-05-20 20:37:07 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-01-01 12:59:31 -08:00
|
|
|
|
|
|
|
u64 VMManager::GetTotalMemoryUsage() {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Kernel, "(STUBBED) called");
|
2018-04-14 19:04:10 -07:00
|
|
|
return 0xF8000000;
|
2018-01-01 12:59:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
u64 VMManager::GetTotalHeapUsage() {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Kernel, "(STUBBED) called");
|
2018-01-16 14:06:45 -08:00
|
|
|
return 0x0;
|
2018-01-01 12:59:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
VAddr VMManager::GetAddressSpaceBaseAddr() {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Kernel, "(STUBBED) called");
|
2018-01-01 12:59:31 -08:00
|
|
|
return 0x8000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
u64 VMManager::GetAddressSpaceSize() {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Kernel, "(STUBBED) called");
|
2018-01-01 12:59:31 -08:00
|
|
|
return MAX_ADDRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Kernel
|