summaryrefslogtreecommitdiff
path: root/src/core/loader
diff options
context:
space:
mode:
authorGravatar Subv2015-05-12 15:25:15 -0500
committerGravatar Subv2015-05-14 22:50:13 -0500
commitd3634d4bf4b1cbd8cc4fe6f22178054803b41e23 (patch)
tree2fa606ebac3e2e77e65e1196878a5f5345acfacf /src/core/loader
parentMerge pull request #762 from yuriks/memmap (diff)
downloadyuzu-d3634d4bf4b1cbd8cc4fe6f22178054803b41e23.tar.gz
yuzu-d3634d4bf4b1cbd8cc4fe6f22178054803b41e23.tar.xz
yuzu-d3634d4bf4b1cbd8cc4fe6f22178054803b41e23.zip
Core/ResourceLimits: Implemented the basic structure of ResourceLimits.
Implemented svcs GetResourceLimit, GetResourceLimitCurrentValues and GetResourceLimitLimitValues. Note that the resource limits do not currently keep track of used objects, since we have no way to distinguish between an object created by the application, and an object created by some HLE module once we're inside Kernel::T::Create.
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/3dsx.cpp4
-rw-r--r--src/core/loader/elf.cpp4
-rw-r--r--src/core/loader/ncch.cpp5
3 files changed, 13 insertions, 0 deletions
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp
index 84b13ee52..ad5e929ce 100644
--- a/src/core/loader/3dsx.cpp
+++ b/src/core/loader/3dsx.cpp
@@ -9,6 +9,7 @@
9 9
10#include "core/file_sys/archive_romfs.h" 10#include "core/file_sys/archive_romfs.h"
11#include "core/hle/kernel/process.h" 11#include "core/hle/kernel/process.h"
12#include "core/hle/kernel/resource_limit.h"
12#include "core/hle/service/fs/archive.h" 13#include "core/hle/service/fs/archive.h"
13#include "core/loader/elf.h" 14#include "core/loader/elf.h"
14#include "core/loader/ncch.h" 15#include "core/loader/ncch.h"
@@ -233,6 +234,9 @@ ResultStatus AppLoader_THREEDSX::Load() {
233 Kernel::g_current_process = Kernel::Process::Create(filename, 0); 234 Kernel::g_current_process = Kernel::Process::Create(filename, 0);
234 Kernel::g_current_process->svc_access_mask.set(); 235 Kernel::g_current_process->svc_access_mask.set();
235 Kernel::g_current_process->address_mappings = default_address_mappings; 236 Kernel::g_current_process->address_mappings = default_address_mappings;
237
238 // Attach the default resource limit (APPLICATION) to the process
239 Kernel::g_current_process->resource_limit = Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
236 240
237 Load3DSXFile(*file, Memory::PROCESS_IMAGE_VADDR); 241 Load3DSXFile(*file, Memory::PROCESS_IMAGE_VADDR);
238 242
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index a951bc80f..f00753a79 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -11,6 +11,7 @@
11#include "common/symbols.h" 11#include "common/symbols.h"
12 12
13#include "core/hle/kernel/kernel.h" 13#include "core/hle/kernel/kernel.h"
14#include "core/hle/kernel/resource_limit.h"
14#include "core/loader/elf.h" 15#include "core/loader/elf.h"
15#include "core/memory.h" 16#include "core/memory.h"
16 17
@@ -354,6 +355,9 @@ ResultStatus AppLoader_ELF::Load() {
354 Kernel::g_current_process->svc_access_mask.set(); 355 Kernel::g_current_process->svc_access_mask.set();
355 Kernel::g_current_process->address_mappings = default_address_mappings; 356 Kernel::g_current_process->address_mappings = default_address_mappings;
356 357
358 // Attach the default resource limit (APPLICATION) to the process
359 Kernel::g_current_process->resource_limit = Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
360
357 ElfReader elf_reader(&buffer[0]); 361 ElfReader elf_reader(&buffer[0]);
358 elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR); 362 elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR);
359 // TODO: Fill application title 363 // TODO: Fill application title
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 36e341fd4..08993c4fa 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -11,6 +11,7 @@
11#include "common/swap.h" 11#include "common/swap.h"
12 12
13#include "core/hle/kernel/kernel.h" 13#include "core/hle/kernel/kernel.h"
14#include "core/hle/kernel/resource_limit.h"
14#include "core/loader/ncch.h" 15#include "core/loader/ncch.h"
15#include "core/memory.h" 16#include "core/memory.h"
16 17
@@ -126,6 +127,10 @@ ResultStatus AppLoader_NCCH::LoadExec() const {
126 u64 program_id = *reinterpret_cast<u64_le const*>(&ncch_header.program_id[0]); 127 u64 program_id = *reinterpret_cast<u64_le const*>(&ncch_header.program_id[0]);
127 Kernel::g_current_process = Kernel::Process::Create(process_name, program_id); 128 Kernel::g_current_process = Kernel::Process::Create(process_name, program_id);
128 129
130 // Attach a resource limit to the process based on the resource limit category
131 Kernel::g_current_process->resource_limit = Kernel::ResourceLimit::GetForCategory(
132 static_cast<Kernel::ResourceLimitCategory>(exheader_header.arm11_system_local_caps.resource_limit_category));
133
129 // Copy data while converting endianess 134 // Copy data while converting endianess
130 std::array<u32, ARRAY_SIZE(exheader_header.arm11_kernel_caps.descriptors)> kernel_caps; 135 std::array<u32, ARRAY_SIZE(exheader_header.arm11_kernel_caps.descriptors)> kernel_caps;
131 std::copy_n(exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(), begin(kernel_caps)); 136 std::copy_n(exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(), begin(kernel_caps));