mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-10 06:01:52 +00:00
60 lines
No EOL
2 KiB
C++
60 lines
No EOL
2 KiB
C++
/*
|
|
* Copyright (c) 2018-2019 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 <switch.h>
|
|
#include <stratosphere.hpp>
|
|
#include <cstring>
|
|
#include "debug.hpp"
|
|
|
|
#include "amsmitm_modules.hpp"
|
|
|
|
#include "fs_mitm/fsmitm_main.hpp"
|
|
#include "set_mitm/setmitm_main.hpp"
|
|
#include "bpc_mitm/bpcmitm_main.hpp"
|
|
#include "ns_mitm/nsmitm_main.hpp"
|
|
|
|
static HosThread g_module_threads[MitmModuleId_Count];
|
|
|
|
static const struct {
|
|
ThreadFunc main;
|
|
u32 priority;
|
|
u32 stack_size;
|
|
} g_module_definitions[MitmModuleId_Count] = {
|
|
{ &FsMitmMain, FsMitmPriority, FsMitmStackSize }, /* FsMitm */
|
|
{ &SetMitmMain, SetMitmPriority, SetMitmStackSize }, /* SetMitm */
|
|
{ &BpcMitmMain, BpcMitmPriority, BpcMitmStackSize }, /* BpcMitm */
|
|
{ &NsMitmMain, NsMitmPriority, NsMitmStackSize }, /* NsMitm */
|
|
};
|
|
|
|
void LaunchAllMitmModules() {
|
|
/* Create thread for each module. */
|
|
for (u32 i = 0; i < static_cast<u32>(MitmModuleId_Count); i++) {
|
|
const auto cur_module = &g_module_definitions[i];
|
|
R_ASSERT(g_module_threads[i].Initialize(cur_module->main, nullptr, cur_module->stack_size, cur_module->priority));
|
|
}
|
|
|
|
/* Start thread for each module. */
|
|
for (u32 i = 0; i < static_cast<u32>(MitmModuleId_Count); i++) {
|
|
R_ASSERT(g_module_threads[i].Start());
|
|
}
|
|
}
|
|
|
|
void WaitAllMitmModules() {
|
|
/* Wait on thread for each module. */
|
|
for (u32 i = 0; i < static_cast<u32>(MitmModuleId_Count); i++) {
|
|
g_module_threads[i].Join();
|
|
}
|
|
} |