ams: centralize system thread definitions

This commit is contained in:
Michael Scire
2020-04-17 01:06:07 -07:00
parent d77fe98203
commit 3da0cda4ae
32 changed files with 254 additions and 40 deletions

View File

@@ -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));
}

View File

@@ -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));
}

View File

@@ -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));
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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));
}

View File

@@ -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);
}

View File

@@ -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);
}