diff options
author | bunnei <bunneidev@gmail.com> | 2022-02-21 21:33:17 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2022-02-21 21:41:31 +0100 |
commit | a74fddc98f5c02b2d0be90c6d87ec3779300ee11 (patch) | |
tree | b801352807790e645bca502bdfb0b9ad1195fef6 /src/core | |
parent | core: hle: kernel: KEvent: Pass in owner KProcess on event creation. (diff) | |
download | yuzu-a74fddc98f5c02b2d0be90c6d87ec3779300ee11.tar yuzu-a74fddc98f5c02b2d0be90c6d87ec3779300ee11.tar.gz yuzu-a74fddc98f5c02b2d0be90c6d87ec3779300ee11.tar.bz2 yuzu-a74fddc98f5c02b2d0be90c6d87ec3779300ee11.tar.lz yuzu-a74fddc98f5c02b2d0be90c6d87ec3779300ee11.tar.xz yuzu-a74fddc98f5c02b2d0be90c6d87ec3779300ee11.tar.zst yuzu-a74fddc98f5c02b2d0be90c6d87ec3779300ee11.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core.cpp | 11 | ||||
-rw-r--r-- | src/core/hle/kernel/k_process.cpp | 11 | ||||
-rw-r--r-- | src/core/hle/kernel/k_process.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/kernel_helpers.cpp | 15 |
4 files changed, 30 insertions, 9 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 3f9a7f44b..b0cfee3ee 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -28,7 +28,9 @@ #include "core/file_sys/vfs_real.h" #include "core/hardware_interrupt_manager.h" #include "core/hid/hid_core.h" +#include "core/hle/kernel/k_memory_manager.h" #include "core/hle/kernel/k_process.h" +#include "core/hle/kernel/k_resource_limit.h" #include "core/hle/kernel/k_scheduler.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/physical_core.h" @@ -252,9 +254,16 @@ struct System::Impl { } telemetry_session->AddInitialInfo(*app_loader, fs_controller, *content_provider); + + // Create a resource limit for the process. + const auto physical_memory_size = + kernel.MemoryManager().GetSize(Kernel::KMemoryManager::Pool::Application); + auto* resource_limit = Kernel::CreateResourceLimitForProcess(system, physical_memory_size); + + // Create the process. auto main_process = Kernel::KProcess::Create(system.Kernel()); ASSERT(Kernel::KProcess::Initialize(main_process, system, "main", - Kernel::KProcess::ProcessType::Userland) + Kernel::KProcess::ProcessType::Userland, resource_limit) .IsSuccess()); const auto [load_result, load_parameters] = app_loader->Load(*main_process, system); if (load_result != Loader::ResultStatus::Success) { diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 85c506979..9233261cd 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -123,12 +123,11 @@ private: }; ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::string process_name, - ProcessType type) { + ProcessType type, KResourceLimit* res_limit) { auto& kernel = system.Kernel(); process->name = std::move(process_name); - - process->resource_limit = kernel.GetSystemResourceLimit(); + process->resource_limit = res_limit; process->status = ProcessStatus::Created; process->program_id = 0; process->process_id = type == ProcessType::KernelInternal ? kernel.CreateNewKernelProcessID() @@ -143,9 +142,6 @@ ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::st kernel.AppendNewProcess(process); - // Open a reference to the resource limit. - process->resource_limit->Open(); - // Clear remaining fields. process->num_running_threads = 0; process->is_signaled = false; @@ -153,6 +149,9 @@ ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::st process->is_suspended = false; process->schedule_count = 0; + // Open a reference to the resource limit. + process->resource_limit->Open(); + return ResultSuccess; } diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index 38b446350..cf1b67428 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h @@ -91,7 +91,7 @@ public: static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4; static ResultCode Initialize(KProcess* process, Core::System& system, std::string process_name, - ProcessType type); + ProcessType type, KResourceLimit* res_limit); /// Gets a reference to the process' page table. KPageTable& PageTable() { diff --git a/src/core/hle/service/kernel_helpers.cpp b/src/core/hle/service/kernel_helpers.cpp index d0c7bc0ce..b8c2c6e51 100644 --- a/src/core/hle/service/kernel_helpers.cpp +++ b/src/core/hle/service/kernel_helpers.cpp @@ -3,7 +3,9 @@ // Refer to the license.txt file included. #include "core/core.h" +#include "core/core_timing.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/kernel/k_memory_manager.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/k_resource_limit.h" @@ -15,10 +17,21 @@ namespace Service::KernelHelpers { ServiceContext::ServiceContext(Core::System& system_, std::string name_) : kernel(system_.Kernel()) { + + // Create a resource limit for the process. + const auto physical_memory_size = + kernel.MemoryManager().GetSize(Kernel::KMemoryManager::Pool::System); + auto* resource_limit = Kernel::CreateResourceLimitForProcess(system_, physical_memory_size); + + // Create the process. process = Kernel::KProcess::Create(kernel); ASSERT(Kernel::KProcess::Initialize(process, system_, std::move(name_), - Kernel::KProcess::ProcessType::Userland) + Kernel::KProcess::ProcessType::KernelInternal, + resource_limit) .IsSuccess()); + + // Close reference to our resource limit, as the process opens one. + resource_limit->Close(); } ServiceContext::~ServiceContext() { |