mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 01:22:37 -06:00
Kernel: move memory_regions into Kernel instance
This commit is contained in:
parent
263290d48c
commit
ece96807c4
7 changed files with 21 additions and 28 deletions
|
@ -24,9 +24,7 @@ KernelSystem::KernelSystem(u32 system_mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shutdown the kernel
|
/// Shutdown the kernel
|
||||||
KernelSystem::~KernelSystem() {
|
KernelSystem::~KernelSystem() = default;
|
||||||
Kernel::MemoryShutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceLimitList& KernelSystem::ResourceLimit() {
|
ResourceLimitList& KernelSystem::ResourceLimit() {
|
||||||
return *resource_limits;
|
return *resource_limits;
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
#include <boost/smart_ptr/intrusive_ptr.hpp>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/kernel/memory.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace ConfigMem {
|
namespace ConfigMem {
|
||||||
|
@ -209,6 +211,10 @@ public:
|
||||||
SharedPage::Handler& GetSharedPageHandler();
|
SharedPage::Handler& GetSharedPageHandler();
|
||||||
const SharedPage::Handler& GetSharedPageHandler() const;
|
const SharedPage::Handler& GetSharedPageHandler() const;
|
||||||
|
|
||||||
|
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region);
|
||||||
|
|
||||||
|
std::array<MemoryRegionInfo, 3> memory_regions;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MemoryInit(u32 mem_type);
|
void MemoryInit(u32 mem_type);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/config_mem.h"
|
#include "core/hle/kernel/config_mem.h"
|
||||||
#include "core/hle/kernel/memory.h"
|
#include "core/hle/kernel/memory.h"
|
||||||
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/kernel/shared_page.h"
|
#include "core/hle/kernel/shared_page.h"
|
||||||
#include "core/hle/kernel/vm_manager.h"
|
#include "core/hle/kernel/vm_manager.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
@ -24,8 +25,6 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
MemoryRegionInfo memory_regions[3];
|
|
||||||
|
|
||||||
/// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system
|
/// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system
|
||||||
/// memory configuration type.
|
/// memory configuration type.
|
||||||
static const u32 memory_region_sizes[8][3] = {
|
static const u32 memory_region_sizes[8][3] = {
|
||||||
|
@ -77,16 +76,7 @@ void KernelSystem::MemoryInit(u32 mem_type) {
|
||||||
shared_page_handler = std::make_unique<SharedPage::Handler>();
|
shared_page_handler = std::make_unique<SharedPage::Handler>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryShutdown() {
|
MemoryRegionInfo* KernelSystem::GetMemoryRegion(MemoryRegion region) {
|
||||||
for (auto& region : memory_regions) {
|
|
||||||
region.base = 0;
|
|
||||||
region.size = 0;
|
|
||||||
region.used = 0;
|
|
||||||
region.linear_heap_memory = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region) {
|
|
||||||
switch (region) {
|
switch (region) {
|
||||||
case MemoryRegion::APPLICATION:
|
case MemoryRegion::APPLICATION:
|
||||||
return &memory_regions[0];
|
return &memory_regions[0];
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/kernel/process.h"
|
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
struct AddressMapping;
|
||||||
class VMManager;
|
class VMManager;
|
||||||
|
|
||||||
struct MemoryRegionInfo {
|
struct MemoryRegionInfo {
|
||||||
|
@ -20,10 +21,6 @@ struct MemoryRegionInfo {
|
||||||
std::shared_ptr<std::vector<u8>> linear_heap_memory;
|
std::shared_ptr<std::vector<u8>> linear_heap_memory;
|
||||||
};
|
};
|
||||||
|
|
||||||
void MemoryShutdown();
|
|
||||||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region);
|
|
||||||
|
|
||||||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping);
|
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping);
|
||||||
|
|
||||||
extern MemoryRegionInfo memory_regions[3];
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
|
@ -115,7 +115,7 @@ void Process::ParseKernelCaps(const u32* kernel_caps, std::size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process::Run(s32 main_thread_priority, u32 stack_size) {
|
void Process::Run(s32 main_thread_priority, u32 stack_size) {
|
||||||
memory_region = GetMemoryRegion(flags.memory_region);
|
memory_region = kernel.GetMemoryRegion(flags.memory_region);
|
||||||
|
|
||||||
auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions,
|
auto MapSegment = [&](CodeSet::Segment& segment, VMAPermission permissions,
|
||||||
MemoryState memory_state) {
|
MemoryState memory_state) {
|
||||||
|
|
|
@ -1233,22 +1233,24 @@ static ResultCode AcceptSession(Handle* out_server_session, Handle server_port_h
|
||||||
static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
|
static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
|
||||||
LOG_TRACE(Kernel_SVC, "called type={} param={}", type, param);
|
LOG_TRACE(Kernel_SVC, "called type={} param={}", type, param);
|
||||||
|
|
||||||
|
KernelSystem& kernel = Core::System::GetInstance().Kernel();
|
||||||
|
|
||||||
switch ((SystemInfoType)type) {
|
switch ((SystemInfoType)type) {
|
||||||
case SystemInfoType::REGION_MEMORY_USAGE:
|
case SystemInfoType::REGION_MEMORY_USAGE:
|
||||||
switch ((SystemInfoMemUsageRegion)param) {
|
switch ((SystemInfoMemUsageRegion)param) {
|
||||||
case SystemInfoMemUsageRegion::ALL:
|
case SystemInfoMemUsageRegion::ALL:
|
||||||
*out = GetMemoryRegion(MemoryRegion::APPLICATION)->used +
|
*out = kernel.GetMemoryRegion(MemoryRegion::APPLICATION)->used +
|
||||||
GetMemoryRegion(MemoryRegion::SYSTEM)->used +
|
kernel.GetMemoryRegion(MemoryRegion::SYSTEM)->used +
|
||||||
GetMemoryRegion(MemoryRegion::BASE)->used;
|
kernel.GetMemoryRegion(MemoryRegion::BASE)->used;
|
||||||
break;
|
break;
|
||||||
case SystemInfoMemUsageRegion::APPLICATION:
|
case SystemInfoMemUsageRegion::APPLICATION:
|
||||||
*out = GetMemoryRegion(MemoryRegion::APPLICATION)->used;
|
*out = kernel.GetMemoryRegion(MemoryRegion::APPLICATION)->used;
|
||||||
break;
|
break;
|
||||||
case SystemInfoMemUsageRegion::SYSTEM:
|
case SystemInfoMemUsageRegion::SYSTEM:
|
||||||
*out = GetMemoryRegion(MemoryRegion::SYSTEM)->used;
|
*out = kernel.GetMemoryRegion(MemoryRegion::SYSTEM)->used;
|
||||||
break;
|
break;
|
||||||
case SystemInfoMemUsageRegion::BASE:
|
case SystemInfoMemUsageRegion::BASE:
|
||||||
*out = GetMemoryRegion(MemoryRegion::BASE)->used;
|
*out = kernel.GetMemoryRegion(MemoryRegion::BASE)->used;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(Kernel_SVC, "unknown GetSystemInfo type=0 region: param={}", param);
|
LOG_ERROR(Kernel_SVC, "unknown GetSystemInfo type=0 region: param={}", param);
|
||||||
|
|
|
@ -305,7 +305,7 @@ u8* GetPhysicalPointer(PAddr address) {
|
||||||
target_pointer = Core::DSP().GetDspMemory().data() + offset_into_region;
|
target_pointer = Core::DSP().GetDspMemory().data() + offset_into_region;
|
||||||
break;
|
break;
|
||||||
case FCRAM_PADDR:
|
case FCRAM_PADDR:
|
||||||
for (const auto& region : Kernel::memory_regions) {
|
for (const auto& region : Core::System::GetInstance().Kernel().memory_regions) {
|
||||||
if (offset_into_region >= region.base &&
|
if (offset_into_region >= region.base &&
|
||||||
offset_into_region < region.base + region.size) {
|
offset_into_region < region.base + region.size) {
|
||||||
target_pointer =
|
target_pointer =
|
||||||
|
|
Loading…
Reference in a new issue