From 1032b60d9bb41f24dfa693896ad827f9c7df4d60 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Wed, 30 Sep 2020 21:54:42 -0400 Subject: [PATCH] Bump kernel version for 3DSX (#5446) --- src/core/hle/kernel/process.cpp | 16 ++++++++++++++++ src/core/hle/kernel/process.h | 5 +++++ src/core/loader/3dsx.cpp | 3 +-- src/core/loader/elf.cpp | 3 +-- src/core/loader/loader.cpp | 6 ------ src/core/loader/loader.h | 7 ------- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 9b03f30f97..173a9fdc4d 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -145,6 +145,22 @@ void Process::ParseKernelCaps(const u32* kernel_caps, std::size_t len) { } } +void Process::Set3dsxKernelCaps() { + svc_access_mask.set(); + + address_mappings = { + {0x1FF50000, 0x8000, true}, // part of DSP RAM + {0x1FF70000, 0x8000, true}, // part of DSP RAM + {0x1F000000, 0x600000, false}, // entire VRAM + }; + + // Similar to Rosalina, we set kernel version to a recent one. + // This is 11.2.0, to be consistent with core/hle/kernel/config_mem.cpp + // TODO: refactor kernel version out so it is configurable and consistent + // among all relevant places. + kernel_version = 0x234; +} + void Process::Run(s32 main_thread_priority, u32 stack_size) { memory_region = kernel.GetMemoryRegion(flags.memory_region); diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 4eca568d90..132570cc8d 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -190,6 +190,11 @@ public: */ void ParseKernelCaps(const u32* kernel_caps, std::size_t len); + /** + * Set up the default kernel capability for 3DSX. + */ + void Set3dsxKernelCaps(); + /** * Applies address space changes and launches the process main thread. */ diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index 40c2bd1fbb..95ef0f1edb 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp @@ -268,8 +268,7 @@ ResultStatus AppLoader_THREEDSX::Load(std::shared_ptr& process) codeset->name = filename; process = Core::System::GetInstance().Kernel().CreateProcess(std::move(codeset)); - process->svc_access_mask.set(); - process->address_mappings = default_address_mappings; + process->Set3dsxKernelCaps(); // Attach the default resource limit (APPLICATION) to the process process->resource_limit = Core::System::GetInstance().Kernel().ResourceLimit().GetForCategory( diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index d39181ebd2..2527471dfd 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp @@ -396,8 +396,7 @@ ResultStatus AppLoader_ELF::Load(std::shared_ptr& process) { codeset->name = filename; process = Core::System::GetInstance().Kernel().CreateProcess(std::move(codeset)); - process->svc_access_mask.set(); - process->address_mappings = default_address_mappings; + process->Set3dsxKernelCaps(); // Attach the default resource limit (APPLICATION) to the process process->resource_limit = Core::System::GetInstance().Kernel().ResourceLimit().GetForCategory( diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index a75c562492..9a172f9fd3 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -15,12 +15,6 @@ namespace Loader { -const std::initializer_list default_address_mappings = { - {0x1FF50000, 0x8000, true}, // part of DSP RAM - {0x1FF70000, 0x8000, true}, // part of DSP RAM - {0x1F000000, 0x600000, false}, // entire VRAM -}; - FileType IdentifyFile(FileUtil::IOFile& file) { FileType type; diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index f9a8e9296d..d42aab3a11 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -5,7 +5,6 @@ #pragma once #include -#include #include #include #include @@ -237,12 +236,6 @@ protected: bool is_loaded = false; }; -/** - * Common address mappings found in most games, used for binary formats that don't have this - * information. - */ -extern const std::initializer_list default_address_mappings; - /** * Identifies a bootable file and return a suitable loader * @param filename String filename of bootable file