From 6d60acf0f1afcae873988da5218f2f1c7bc9d151 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Mon, 4 May 2015 00:01:16 -0300 Subject: Kernel: Introduce skeleton Process class to hold process data --- src/core/hle/kernel/kernel.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/core/hle/kernel/kernel.cpp') diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 533fe65fd1..9c8d6fa367 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -10,6 +10,7 @@ #include "core/arm/arm_interface.h" #include "core/core.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/process.h" #include "core/hle/kernel/thread.h" #include "core/hle/kernel/timer.h" @@ -149,18 +150,7 @@ void Shutdown() { Kernel::ThreadingShutdown(); Kernel::TimersShutdown(); g_handle_table.Clear(); // Free all kernel objects -} - -/** - * Loads executable stored at specified address - * @entry_point Entry point in memory of loaded executable - * @return True on success, otherwise false - */ -bool LoadExec(u32 entry_point) { - // 0x30 is the typical main thread priority I've seen used so far - g_main_thread = Kernel::SetupMainThread(Kernel::DEFAULT_STACK_SIZE, entry_point, THREADPRIO_DEFAULT); - - return true; + g_current_process = nullptr; } } // namespace -- cgit v1.2.3 From a5eba2f98466cd2788aab96f1ad93bcb32c5656c Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 6 May 2015 21:40:39 -0300 Subject: Kernel: Remove g_program_id This has been obsoleted by the field in Process. --- src/core/file_sys/archive_savedata.cpp | 5 +++-- src/core/hle/kernel/kernel.cpp | 2 -- src/core/hle/kernel/kernel.h | 6 ------ src/core/loader/loader.cpp | 1 - src/core/loader/ncch.cpp | 4 ---- src/core/loader/ncch.h | 6 ------ 6 files changed, 3 insertions(+), 21 deletions(-) (limited to 'src/core/hle/kernel/kernel.cpp') diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cpp index 12624fa31d..8dff519663 100644 --- a/src/core/file_sys/archive_savedata.cpp +++ b/src/core/file_sys/archive_savedata.cpp @@ -11,6 +11,7 @@ #include "core/file_sys/archive_savedata.h" #include "core/file_sys/disk_archive.h" +#include "core/hle/kernel/process.h" #include "core/hle/service/fs/archive.h" #include "core/settings.h" @@ -36,7 +37,7 @@ ArchiveFactory_SaveData::ArchiveFactory_SaveData(const std::string& sdmc_directo } ResultVal> ArchiveFactory_SaveData::Open(const Path& path) { - std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id); + std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_current_process->program_id); if (!FileUtil::Exists(concrete_mount_point)) { // When a SaveData archive is created for the first time, it is not yet formatted // and the save file/directory structure expected by the game has not yet been initialized. @@ -51,7 +52,7 @@ ResultVal> ArchiveFactory_SaveData::Open(const P } ResultCode ArchiveFactory_SaveData::Format(const Path& path) { - std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_program_id); + std::string concrete_mount_point = GetSaveDataPath(mount_point, Kernel::g_current_process->program_id); FileUtil::DeleteDirRecursively(concrete_mount_point); FileUtil::CreateFullPath(concrete_mount_point); return RESULT_SUCCESS; diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 9c8d6fa367..5157ab2afb 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -19,7 +19,6 @@ namespace Kernel { unsigned int Object::next_object_id; SharedPtr g_main_thread; HandleTable g_handle_table; -u64 g_program_id; void WaitObject::AddWaitingThread(SharedPtr thread) { auto itr = std::find(waiting_threads.begin(), waiting_threads.end(), thread); @@ -141,7 +140,6 @@ void Init() { Kernel::TimersInit(); Object::next_object_id = 0; - g_program_id = 0; g_main_thread = nullptr; } diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index d0c69677ac..7c106d37c0 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -273,12 +273,6 @@ private: extern HandleTable g_handle_table; -/// The ID code of the currently running game -/// TODO(Subv): This variable should not be here, -/// we need a way to store information about the currently loaded application -/// for later query during runtime, maybe using the LDR service? -extern u64 g_program_id; - /// Initialize the kernel void Init(); diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 97525fbebe..2718e88c14 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -131,7 +131,6 @@ ResultStatus LoadFile(const std::string& filename) { // Load application and RomFS if (ResultStatus::Success == app_loader.Load()) { - Kernel::g_program_id = app_loader.GetProgramId(); Service::FS::RegisterArchiveType(Common::make_unique(app_loader), Service::FS::ArchiveIdCode::RomFS); return ResultStatus::Success; } diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 5310001378..0e2db2fbbe 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -293,8 +293,4 @@ ResultStatus AppLoader_NCCH::ReadRomFS(std::vector& buffer) const { return ResultStatus::ErrorNotUsed; } -u64 AppLoader_NCCH::GetProgramId() const { - return *reinterpret_cast(&ncch_header.program_id[0]); -} - } // namespace Loader diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index dec46e86c2..1be941f194 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -213,12 +213,6 @@ public: */ ResultStatus ReadRomFS(std::vector& buffer) const override; - /* - * Gets the program id from the NCCH header - * @return u64 Program id - */ - u64 GetProgramId() const; - private: /** -- cgit v1.2.3 From 7c50b999fa266ad1b3db422e4281f38648c362c9 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 8 May 2015 22:07:32 -0300 Subject: Kernel: Remove unused g_main_thread variable --- src/core/hle/kernel/kernel.cpp | 2 -- src/core/hle/kernel/process.cpp | 2 +- src/core/hle/kernel/thread.h | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) (limited to 'src/core/hle/kernel/kernel.cpp') diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 5157ab2afb..a3715e5559 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -17,7 +17,6 @@ namespace Kernel { unsigned int Object::next_object_id; -SharedPtr g_main_thread; HandleTable g_handle_table; void WaitObject::AddWaitingThread(SharedPtr thread) { @@ -140,7 +139,6 @@ void Init() { Kernel::TimersInit(); Object::next_object_id = 0; - g_main_thread = nullptr; } /// Shutdown the kernel diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 9d83d03d6b..a444e22e58 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -85,7 +85,7 @@ void Process::ParseKernelCaps(const u32* kernel_caps, size_t len) { } void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { - g_main_thread = Kernel::SetupMainThread(stack_size, entry_point, main_thread_priority); + Kernel::SetupMainThread(stack_size, entry_point, main_thread_priority); } Kernel::Process::Process() {} diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 233bcbdbda..9958b16e66 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -171,8 +171,6 @@ private: Handle callback_handle; }; -extern SharedPtr g_main_thread; - /** * Sets up the primary application thread * @param stack_size The size of the thread's stack -- cgit v1.2.3