mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
ams: centralize system thread definitions
This commit is contained in:
parent
d77fe98203
commit
3da0cda4ae
32 changed files with 254 additions and 40 deletions
|
@ -19,6 +19,9 @@
|
|||
/* libvapours (pulls in util, svc, results). */
|
||||
#include <vapours.hpp>
|
||||
|
||||
/* Libstratosphere definitions. */
|
||||
#include <stratosphere/ams/impl/ams_system_thread_definitions.hpp>
|
||||
|
||||
/* Libstratosphere-only utility. */
|
||||
#include <stratosphere/util.hpp>
|
||||
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
|
||||
namespace ams::impl {
|
||||
|
||||
struct SystemThreadDefinition {
|
||||
s32 priority;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
#define AMS_DEFINE_SYSTEM_THREAD(__AMS_THREAD_PRIORITY__, __AMS_MODULE__, __AMS_THREAD_NAME__) \
|
||||
constexpr inline const ::ams::impl::SystemThreadDefinition SystemThreadDefinition##__AMS_MODULE__##__AMS_THREAD_NAME__ = { __AMS_THREAD_PRIORITY__, "ams." # __AMS_MODULE__ "." #__AMS_THREAD_NAME__ }
|
||||
|
||||
/* sm. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, sm, Main);
|
||||
|
||||
/* spl. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, spl, Main);
|
||||
|
||||
/* Loader. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, ldr, Main);
|
||||
|
||||
/* Process Manager. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, pm, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, pm, ProcessTrack);
|
||||
|
||||
/* NCM. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, ncm, MainWaitThreads);
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, ncm, ContentManagerServerIpcSession);
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, ncm, LocationResolverServerIpcSession);
|
||||
|
||||
/* FS. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(16, fs, WorkerThreadPool);
|
||||
AMS_DEFINE_SYSTEM_THREAD(17, fs, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(17, fs, WorkerRealTimeAccess);
|
||||
AMS_DEFINE_SYSTEM_THREAD(18, fs, WorkerNormalPriorityAccess);
|
||||
AMS_DEFINE_SYSTEM_THREAD(19, fs, WorkerLowPriorityAccess);
|
||||
AMS_DEFINE_SYSTEM_THREAD(30, fs, WorkerBackgroundAccess);
|
||||
AMS_DEFINE_SYSTEM_THREAD(30, fs, PatrolReader);
|
||||
|
||||
/* Boot. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, boot, Main);
|
||||
|
||||
/* Mitm. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-7, mitm, InitializeThread);
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, mitm_sf, QueryServerProcessThread);
|
||||
AMS_DEFINE_SYSTEM_THREAD(16, mitm_fs, RomFileSystemInitializeThread);
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, mitm, DebugThrowThread);
|
||||
|
||||
/* boot2. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(20, boot2, Main);
|
||||
|
||||
/* dmnt. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-3, dmnt, MultiCoreEventManager);
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, dmnt, CheatDebugEvents);
|
||||
AMS_DEFINE_SYSTEM_THREAD(-1, dmnt, MultiCoreBP);
|
||||
AMS_DEFINE_SYSTEM_THREAD(11, dmnt, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(11, dmnt, Ipc);
|
||||
AMS_DEFINE_SYSTEM_THREAD(11, dmnt, CheatDetect);
|
||||
AMS_DEFINE_SYSTEM_THREAD(20, dmnt, CheatVirtualMachine);
|
||||
|
||||
/* fatal */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-13, fatal, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(-13, fatalsrv, FatalTaskThread);
|
||||
AMS_DEFINE_SYSTEM_THREAD( 9, fatalsrv, IpcDispatcher);
|
||||
|
||||
/* creport. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(16, creport, Main);
|
||||
|
||||
/* ro. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(16, ro, Main);
|
||||
|
||||
/* bpc. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(4, bpc, IpcServer);
|
||||
|
||||
/* hid. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(-10, hid, IpcServer);
|
||||
|
||||
/* ns.*/
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, ns, ApplicationManagerIpcSession);
|
||||
|
||||
/* settings. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, settings, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, settings, IpcServer);
|
||||
|
||||
/* erpt. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, erpt, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, erpt, IpcServer);
|
||||
|
||||
/* pgl. */
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, pgl, Main);
|
||||
AMS_DEFINE_SYSTEM_THREAD(21, pgl, ProcessControlTask);
|
||||
|
||||
#undef AMS_DEFINE_SYSTEM_THREAD
|
||||
|
||||
}
|
||||
|
||||
#define AMS_GET_SYSTEM_THREAD_PRIORITY(__AMS_MODULE__, __AMS_THREAD_NAME__) ::ams::impl::SystemThreadDefinition##__AMS_MODULE__##__AMS_THREAD_NAME__.priority
|
||||
#define AMS_GET_SYSTEM_THREAD_NAME(__AMS_MODULE__, __AMS_THREAD_NAME__) ::ams::impl::SystemThreadDefinition##__AMS_MODULE__##__AMS_THREAD_NAME__.name
|
|
@ -26,14 +26,33 @@ namespace ams::fssystem {
|
|||
Relative,
|
||||
};
|
||||
private:
|
||||
/* TODO */
|
||||
os::ThreadType *thread;
|
||||
s32 priority;
|
||||
public:
|
||||
ALWAYS_INLINE explicit ScopedThreadPriorityChanger(s32 priority, Mode mode) {
|
||||
/* TODO */
|
||||
ALWAYS_INLINE explicit ScopedThreadPriorityChanger(s32 prio, Mode mode) : thread(os::GetCurrentThread()), priority(0) {
|
||||
const auto result_priority = std::min((mode == Mode::Relative) ? os::GetThreadPriority(this->thread) + priority : priority, os::LowestSystemThreadPriority);
|
||||
this->priority = os::ChangeThreadPriority(thread, result_priority);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE ~ScopedThreadPriorityChanger() {
|
||||
/* TODO */
|
||||
os::ChangeThreadPriority(this->thread, this->priority);
|
||||
}
|
||||
};
|
||||
|
||||
class ScopedThreadPriorityChangerByAccessPriority {
|
||||
public:
|
||||
enum class AccessMode {
|
||||
Read,
|
||||
Write,
|
||||
};
|
||||
private:
|
||||
static s32 GetThreadPriorityByAccessPriority(AccessMode mode);
|
||||
private:
|
||||
ScopedThreadPriorityChanger scoped_changer;
|
||||
public:
|
||||
ALWAYS_INLINE explicit ScopedThreadPriorityChangerByAccessPriority(AccessMode mode) : scoped_changer(GetThreadPriorityByAccessPriority(mode), ScopedThreadPriorityChanger::Mode::Absolute) {
|
||||
/* ... */
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ namespace ams::erpt::srv {
|
|||
constexpr inline size_t ErrorReportContextSessions = 10;
|
||||
constexpr inline size_t ErrorReportMaxSessions = ErrorReportReportSessions + ErrorReportContextSessions;
|
||||
|
||||
constexpr inline s32 ErrorReportServerThreadPriority = 21;
|
||||
|
||||
constexpr inline sm::ServiceName ErrorReportContextServiceName = sm::ServiceName::Encode("erpt:c");
|
||||
constexpr inline sm::ServiceName ErrorReportReportServiceName = sm::ServiceName::Encode("erpt:r");
|
||||
|
||||
|
@ -64,7 +62,8 @@ namespace ams::erpt::srv {
|
|||
|
||||
this->ResumeProcessing();
|
||||
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_server_thread_stack, sizeof(g_server_thread_stack), ErrorReportServerThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_server_thread_stack, sizeof(g_server_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(erpt, IpcServer)));
|
||||
os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(erpt, IpcServer));
|
||||
|
||||
os::StartThread(std::addressof(this->thread));
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::fssystem {
|
||||
|
||||
s32 ScopedThreadPriorityChangerByAccessPriority::GetThreadPriorityByAccessPriority(AccessMode mode) {
|
||||
/* TODO: Actually implement this for real. */
|
||||
return os::GetThreadPriority(os::GetCurrentThread());
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,6 @@ namespace ams::pgl::srv {
|
|||
bool g_enable_jit_debug = false;
|
||||
|
||||
constexpr inline size_t ProcessControlTaskStackSize = 8_KB;
|
||||
constexpr inline s32 ProcessControlTaskPriority = 21;
|
||||
os::ThreadType g_process_control_task_thread;
|
||||
alignas(os::ThreadStackAlignment) u8 g_process_control_task_stack[ProcessControlTaskStackSize];
|
||||
|
||||
|
@ -322,7 +321,8 @@ namespace ams::pgl::srv {
|
|||
|
||||
void InitializeProcessControlTask() {
|
||||
/* Create the task thread. */
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_process_control_task_thread), ProcessControlTask, nullptr, g_process_control_task_stack, sizeof(g_process_control_task_stack), ProcessControlTaskPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_process_control_task_thread), ProcessControlTask, nullptr, g_process_control_task_stack, sizeof(g_process_control_task_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(pgl, ProcessControlTask)));
|
||||
os::SetThreadNamePointer(std::addressof(g_process_control_task_thread), AMS_GET_SYSTEM_THREAD_NAME(pgl, ProcessControlTask));
|
||||
|
||||
/* Retrieve settings. */
|
||||
settings::fwdbg::GetSettingsItemValue(std::addressof(g_enable_jit_debug), sizeof(g_enable_jit_debug), "jit_debug", "enable_jit_debug");
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace ams::sf::hipc::impl {
|
|||
}
|
||||
|
||||
constexpr size_t QueryServerProcessThreadStackSize = 0x4000;
|
||||
constexpr s32 QueryServerProcessThreadPriority = -1;
|
||||
alignas(os::ThreadStackAlignment) u8 g_server_process_thread_stack[QueryServerProcessThreadStackSize];
|
||||
os::ThreadType g_query_server_process_thread;
|
||||
|
||||
|
@ -70,7 +69,8 @@ namespace ams::sf::hipc::impl {
|
|||
R_ABORT_UNLESS(GetPointer(g_query_server_storage)->RegisterSession(query_handle, cmif::ServiceObjectHolder(std::make_shared<MitmQueryService>(query_func))));
|
||||
|
||||
if (AMS_UNLIKELY(!g_registered_any)) {
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_query_server_process_thread), &QueryServerProcessThreadMain, GetPointer(g_query_server_storage), g_server_process_thread_stack, sizeof(g_server_process_thread_stack), QueryServerProcessThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_query_server_process_thread), &QueryServerProcessThreadMain, GetPointer(g_query_server_storage), g_server_process_thread_stack, sizeof(g_server_process_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm_sf, QueryServerProcessThread)));
|
||||
os::SetThreadNamePointer(std::addressof(g_query_server_process_thread), AMS_GET_SYSTEM_THREAD_NAME(mitm_sf, QueryServerProcessThread));
|
||||
os::StartThread(std::addressof(g_query_server_process_thread));
|
||||
g_registered_any = true;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace ams::mitm {
|
|||
void DebugThrowThreadFunc(void *arg);
|
||||
|
||||
constexpr size_t DebugThrowThreadStackSize = 0x4000;
|
||||
constexpr int DebugThrowThreadPriority = 21;
|
||||
os::ThreadType g_debug_throw_thread;
|
||||
|
||||
alignas(os::ThreadStackAlignment) u8 g_debug_throw_thread_stack[DebugThrowThreadStackSize];
|
||||
|
@ -50,7 +49,8 @@ namespace ams::mitm {
|
|||
|
||||
g_throw_result = res;
|
||||
g_threw = true;
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_debug_throw_thread), DebugThrowThreadFunc, nullptr, g_debug_throw_thread_stack, sizeof(g_debug_throw_thread_stack), DebugThrowThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_debug_throw_thread), DebugThrowThreadFunc, nullptr, g_debug_throw_thread_stack, sizeof(g_debug_throw_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm, DebugThrowThread)));
|
||||
os::SetThreadNamePointer(std::addressof(g_debug_throw_thread), AMS_GET_SYSTEM_THREAD_NAME(mitm, DebugThrowThread));
|
||||
os::StartThread(std::addressof(g_debug_throw_thread));
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ namespace ams::mitm {
|
|||
void InitializeThreadFunc(void *arg);
|
||||
|
||||
constexpr size_t InitializeThreadStackSize = 0x4000;
|
||||
constexpr int InitializeThreadPriority = -7;
|
||||
|
||||
/* Globals. */
|
||||
os::Event g_init_event(os::EventClearMode_ManualClear);
|
||||
|
@ -223,7 +222,8 @@ namespace ams::mitm {
|
|||
}
|
||||
|
||||
void StartInitialize() {
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_initialize_thread), InitializeThreadFunc, nullptr, g_initialize_thread_stack, sizeof(g_initialize_thread_stack), InitializeThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_initialize_thread), InitializeThreadFunc, nullptr, g_initialize_thread_stack, sizeof(g_initialize_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm, InitializeThread)));
|
||||
os::SetThreadNamePointer(std::addressof(g_initialize_thread), AMS_GET_SYSTEM_THREAD_NAME(mitm, InitializeThread));
|
||||
os::StartThread(std::addressof(g_initialize_thread));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::mitm::bpc {
|
||||
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, 4);
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, AMS_GET_SYSTEM_THREAD_PRIORITY(bpc, IpcServer));
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ namespace ams::mitm::fs {
|
|||
}
|
||||
|
||||
constexpr size_t RomfsInitializerThreadStackSize = 0x8000;
|
||||
constexpr int RomfsInitializerThreadPriority = 16;
|
||||
os::ThreadType g_romfs_initializer_thread;
|
||||
alignas(os::ThreadStackAlignment) u8 g_romfs_initializer_thread_stack[RomfsInitializerThreadStackSize];
|
||||
|
||||
|
@ -47,7 +46,8 @@ namespace ams::mitm::fs {
|
|||
std::scoped_lock lk(g_mq_lock);
|
||||
|
||||
if (AMS_UNLIKELY(!g_started_req_thread)) {
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_romfs_initializer_thread), RomfsInitializerThreadFunction, nullptr, g_romfs_initializer_thread_stack, sizeof(g_romfs_initializer_thread_stack), RomfsInitializerThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_romfs_initializer_thread), RomfsInitializerThreadFunction, nullptr, g_romfs_initializer_thread_stack, sizeof(g_romfs_initializer_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(mitm_fs, RomFileSystemInitializeThread)));
|
||||
os::SetThreadNamePointer(std::addressof(g_romfs_initializer_thread), AMS_GET_SYSTEM_THREAD_NAME(mitm_fs, RomFileSystemInitializeThread));
|
||||
os::StartThread(std::addressof(g_romfs_initializer_thread));
|
||||
g_started_req_thread = true;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::mitm::fs {
|
||||
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, 15);
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, AMS_GET_SYSTEM_THREAD_PRIORITY(fs, WorkerThreadPool) - 1);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::mitm::hid {
|
||||
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, 19);
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, AMS_GET_SYSTEM_THREAD_PRIORITY(hid, IpcServer));
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::mitm::ns {
|
||||
|
||||
DEFINE_MITM_MODULE_CLASS(0x4000, 20);
|
||||
DEFINE_MITM_MODULE_CLASS(0x4000, AMS_GET_SYSTEM_THREAD_PRIORITY(ns, ApplicationManagerIpcSession) - 1);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,6 @@
|
|||
|
||||
namespace ams::mitm::settings {
|
||||
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, 20);
|
||||
DEFINE_MITM_MODULE_CLASS(0x8000, AMS_GET_SYSTEM_THREAD_PRIORITY(settings, IpcServer) - 1);
|
||||
|
||||
}
|
||||
|
|
|
@ -107,6 +107,10 @@ void __appExit(void) {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(boot, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(boot, Main));
|
||||
|
||||
/* Change voltage from 3.3v to 1.8v for select devices. */
|
||||
boot::ChangeGpioVoltageTo1_8v();
|
||||
|
||||
|
|
|
@ -96,6 +96,10 @@ void __appExit(void) {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(boot2, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(boot2, Main));
|
||||
|
||||
/* Launch all programs off of SYSTEM/the SD. */
|
||||
boot2::LaunchPostSdCardBootPrograms();
|
||||
}
|
||||
|
|
|
@ -85,6 +85,10 @@ void __appExit(void) {
|
|||
static creport::CrashReport g_crash_report;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(creport, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(creport, Main));
|
||||
|
||||
/* Validate arguments. */
|
||||
if (argc < 2) {
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -29,9 +29,6 @@ namespace ams::dmnt::cheat::impl {
|
|||
class CheatProcessManager {
|
||||
private:
|
||||
static constexpr size_t ThreadStackSize = 0x4000;
|
||||
static constexpr s32 DetectThreadPriority = 11;
|
||||
static constexpr s32 VirtualMachineThreadPriority = 20;
|
||||
static constexpr s32 DebugEventsThreadPriority = -1;
|
||||
private:
|
||||
os::Mutex cheat_lock;
|
||||
os::Event debug_events_event; /* Autoclear. */
|
||||
|
@ -200,9 +197,12 @@ namespace ams::dmnt::cheat::impl {
|
|||
}
|
||||
|
||||
/* Spawn application detection thread, spawn cheat vm thread. */
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->detect_thread), DetectLaunchThread, this, this->detect_thread_stack, ThreadStackSize, DetectThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->vm_thread), VirtualMachineThread, this, this->vm_thread_stack, ThreadStackSize, VirtualMachineThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->debug_events_thread), DebugEventsThread, this, this->debug_events_thread_stack, ThreadStackSize, DebugEventsThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->detect_thread), DetectLaunchThread, this, this->detect_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatDetect)));
|
||||
os::SetThreadNamePointer(std::addressof(this->detect_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatDetect));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->vm_thread), VirtualMachineThread, this, this->vm_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatVirtualMachine)));
|
||||
os::SetThreadNamePointer(std::addressof(this->vm_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatVirtualMachine));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->debug_events_thread), DebugEventsThread, this, this->debug_events_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatDebugEvents)));
|
||||
os::SetThreadNamePointer(std::addressof(this->debug_events_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatDebugEvents));
|
||||
|
||||
/* Start threads. */
|
||||
os::StartThread(std::addressof(this->detect_thread));
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace ams::dmnt::cheat::impl {
|
|||
public:
|
||||
static constexpr size_t NumCores = 4;
|
||||
static constexpr size_t ThreadStackSize = os::MemoryPageSize;
|
||||
static constexpr s32 ThreadPriority = -3;
|
||||
private:
|
||||
std::array<uintptr_t, NumCores> message_queue_buffers;
|
||||
std::array<os::MessageQueue, NumCores> message_queues;
|
||||
|
@ -103,7 +102,8 @@ namespace ams::dmnt::cheat::impl {
|
|||
{
|
||||
for (size_t i = 0; i < NumCores; i++) {
|
||||
/* Create thread. */
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->threads[i]), PerCoreThreadFunction, this, this->thread_stacks[i], ThreadStackSize, ThreadPriority, i));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->threads[i]), PerCoreThreadFunction, this, this->thread_stacks[i], ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, MultiCoreEventManager), i));
|
||||
os::SetThreadNamePointer(std::addressof(this->threads[i]), AMS_GET_SYSTEM_THREAD_NAME(dmnt, MultiCoreEventManager));
|
||||
|
||||
/* Set core mask. */
|
||||
os::SetThreadCoreMask(std::addressof(this->threads[i]), i, (1u << i));
|
||||
|
|
|
@ -129,6 +129,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(dmnt, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, Main));
|
||||
|
||||
/* Initialize the cheat manager. */
|
||||
ams::dmnt::cheat::impl::InitializeCheatManager();
|
||||
|
||||
|
@ -143,9 +147,10 @@ int main(int argc, char **argv)
|
|||
|
||||
/* Initialize threads. */
|
||||
if constexpr (NumExtraThreads > 0) {
|
||||
const s32 priority = os::GetThreadCurrentPriority(os::GetCurrentThread());
|
||||
static_assert(AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, Main) == AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, Ipc));
|
||||
for (size_t i = 0; i < NumExtraThreads; i++) {
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_extra_threads[i]), LoopServerThread, nullptr, g_extra_thread_stacks[i], ThreadStackSize, priority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_extra_threads[i]), LoopServerThread, nullptr, g_extra_thread_stacks[i], ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, Ipc)));
|
||||
os::SetThreadNamePointer(std::addressof(g_extra_threads[i]), AMS_GET_SYSTEM_THREAD_NAME(dmnt, Ipc));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,10 @@ namespace ams::erpt {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(erpt, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(erpt, Main));
|
||||
|
||||
/* Set the memory heap for erpt::srv namespace. */
|
||||
R_ABORT_UNLESS(erpt::srv::Initialize(erpt::g_memory_heap, erpt::MemoryHeapSize));
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ void __appInit(void) {
|
|||
R_ABORT_UNLESS(lblInitialize());
|
||||
R_ABORT_UNLESS(psmInitialize());
|
||||
R_ABORT_UNLESS(spsmInitialize());
|
||||
R_ABORT_UNLESS(plInitialize());
|
||||
R_ABORT_UNLESS(plInitialize(::PlServiceType_User));
|
||||
R_ABORT_UNLESS(gpioInitialize());
|
||||
R_ABORT_UNLESS(fsInitialize());
|
||||
});
|
||||
|
@ -141,6 +141,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(fatal, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(fatal, Main));
|
||||
|
||||
/* Load shared font. */
|
||||
R_ABORT_UNLESS(fatal::srv::font::InitializeSharedFont());
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ namespace ams::fatal::srv {
|
|||
|
||||
class TaskThread {
|
||||
NON_COPYABLE(TaskThread);
|
||||
private:
|
||||
static constexpr s32 TaskThreadPriority = -13;
|
||||
private:
|
||||
os::ThreadType thread;
|
||||
private:
|
||||
|
@ -42,7 +40,8 @@ namespace ams::fatal::srv {
|
|||
public:
|
||||
TaskThread() { /* ... */ }
|
||||
void StartTask(ITask *task) {
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->thread), RunTaskImpl, task, task->GetStack(), task->GetStackSize(), TaskThreadPriority, 3));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(this->thread), RunTaskImpl, task, task->GetStack(), task->GetStackSize(), AMS_GET_SYSTEM_THREAD_PRIORITY(fatalsrv, FatalTaskThread), 3));
|
||||
os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(fatalsrv, FatalTaskThread));
|
||||
os::StartThread(std::addressof(this->thread));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -115,6 +115,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(ldr, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(ldr, Main));
|
||||
|
||||
/* Configure development. */
|
||||
/* NOTE: Nintendo really does call the getter function three times instead of caching the value. */
|
||||
ldr::SetDevelopmentForAcidProductionCheck(spl::IsDevelopmentHardware());
|
||||
|
|
|
@ -174,7 +174,8 @@ namespace {
|
|||
}
|
||||
|
||||
ams::Result StartThreads() {
|
||||
R_TRY(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_content_manager_thread_stack, sizeof(g_content_manager_thread_stack), 21));
|
||||
R_TRY(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_content_manager_thread_stack, sizeof(g_content_manager_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, ContentManagerServerIpcSession)));
|
||||
os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(ncm, ContentManagerServerIpcSession));
|
||||
os::StartThread(std::addressof(this->thread));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -219,7 +220,8 @@ namespace {
|
|||
}
|
||||
|
||||
ams::Result StartThreads() {
|
||||
R_TRY(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_location_resolver_thread_stack, sizeof(g_location_resolver_thread_stack), 21));
|
||||
R_TRY(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_location_resolver_thread_stack, sizeof(g_location_resolver_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, LocationResolverServerIpcSession)));
|
||||
os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(ncm, LocationResolverServerIpcSession));
|
||||
os::StartThread(std::addressof(this->thread));
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -260,6 +262,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(ncm, MainWaitThreads));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(ncm, MainWaitThreads));
|
||||
|
||||
/* Create and initialize the content manager. */
|
||||
auto content_manager = GetSharedPointerToContentManager();
|
||||
R_ABORT_UNLESS(content_manager->Initialize(ManagerConfig));
|
||||
|
|
|
@ -145,6 +145,10 @@ void __appExit(void) {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(pgl, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(pgl, Main));
|
||||
|
||||
/* Register the pgl service. */
|
||||
pgl::RegisterServiceSession();
|
||||
|
||||
|
|
|
@ -117,7 +117,6 @@ namespace ams::pm::impl {
|
|||
/* Process Tracking globals. */
|
||||
void ProcessTrackingMain(void *arg);
|
||||
|
||||
constexpr int ProcessTrackThreadPriority = 21;
|
||||
os::ThreadType g_process_track_thread;
|
||||
alignas(os::ThreadStackAlignment) u8 g_process_track_thread_stack[16_KB];
|
||||
|
||||
|
@ -405,7 +404,8 @@ namespace ams::pm::impl {
|
|||
R_TRY(resource::InitializeResourceManager());
|
||||
|
||||
/* Create thread. */
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_process_track_thread), ProcessTrackingMain, nullptr, g_process_track_thread_stack, sizeof(g_process_track_thread_stack), ProcessTrackThreadPriority));
|
||||
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_process_track_thread), ProcessTrackingMain, nullptr, g_process_track_thread_stack, sizeof(g_process_track_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(pm, ProcessTrack)));
|
||||
os::SetThreadNamePointer(std::addressof(g_process_track_thread), AMS_GET_SYSTEM_THREAD_NAME(pm, ProcessTrack));
|
||||
|
||||
/* Start thread. */
|
||||
os::StartThread(std::addressof(g_process_track_thread));
|
||||
|
|
|
@ -184,6 +184,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(pm, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(pm, Main));
|
||||
|
||||
/* Initialize process manager implementation. */
|
||||
R_ABORT_UNLESS(pm::impl::InitializeProcessManager());
|
||||
|
||||
|
|
|
@ -107,6 +107,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(ro, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(ro, Main));
|
||||
|
||||
/* Initialize Debug config. */
|
||||
{
|
||||
ON_SCOPE_EXIT { splExit(); };
|
||||
|
|
|
@ -89,6 +89,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(sm, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(sm, Main));
|
||||
|
||||
/* NOTE: These handles are manually managed, but we don't save references to them to close on exit. */
|
||||
/* This is fine, because if SM crashes we have much bigger issues. */
|
||||
|
||||
|
|
|
@ -129,6 +129,10 @@ namespace {
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* Set thread name. */
|
||||
os::SetThreadNamePointer(os::GetCurrentThread(), AMS_GET_SYSTEM_THREAD_NAME(spl, Main));
|
||||
AMS_ASSERT(os::GetThreadPriority(os::GetCurrentThread()) == AMS_GET_SYSTEM_THREAD_PRIORITY(spl, Main));
|
||||
|
||||
/* Initialize global context. */
|
||||
spl::impl::Initialize();
|
||||
|
||||
|
|
Loading…
Reference in a new issue