2021-07-16 06:38:00 +02:00
|
|
|
/*
|
2021-10-04 21:59:10 +02:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2021-07-16 06:38:00 +02:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
#include "dmnt2_debug_log.hpp"
|
2021-07-16 09:31:17 +02:00
|
|
|
#include "dmnt2_gdb_server.hpp"
|
2021-10-31 23:47:08 +01:00
|
|
|
#include "dmnt2_transport_layer.hpp"
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
namespace ams {
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-31 23:47:08 +01:00
|
|
|
namespace {
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-31 23:47:08 +01:00
|
|
|
bool IsHtcEnabled() {
|
|
|
|
u8 enable_htc = 0;
|
|
|
|
settings::fwdbg::GetSettingsItemValue(std::addressof(enable_htc), sizeof(enable_htc), "atmosphere", "enable_htc");
|
|
|
|
return enable_htc != 0;
|
|
|
|
}
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-31 23:47:08 +01:00
|
|
|
bool IsStandaloneGdbstubEnabled() {
|
|
|
|
u8 enable_gdbstub = 0;
|
|
|
|
settings::fwdbg::GetSettingsItemValue(std::addressof(enable_gdbstub), sizeof(enable_gdbstub), "atmosphere", "enable_standalone_gdbstub");
|
|
|
|
return enable_gdbstub != 0;
|
2021-10-08 02:44:54 +02:00
|
|
|
}
|
2021-07-16 06:38:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
namespace init {
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
void InitializeSystemModule() {
|
|
|
|
/* Initialize our connection to sm. */
|
|
|
|
R_ABORT_UNLESS(sm::Initialize());
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
/* Verify that we can sanely execute. */
|
|
|
|
ams::CheckApiVersion();
|
|
|
|
}
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
void FinalizeSystemModule() { /* ... */ }
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
void Startup() { /* ... */ }
|
2021-07-16 06:38:00 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
void Main() {
|
|
|
|
/* 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));
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-31 23:47:08 +01:00
|
|
|
bool use_htcs = false, use_tcp = false;
|
|
|
|
{
|
|
|
|
R_ABORT_UNLESS(::setsysInitialize());
|
|
|
|
ON_SCOPE_EXIT { ::setsysExit(); };
|
|
|
|
|
|
|
|
use_htcs = IsHtcEnabled();
|
|
|
|
use_tcp = IsStandaloneGdbstubEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize transport layer. */
|
|
|
|
if (use_htcs) {
|
|
|
|
dmnt::transport::InitializeByHtcs();
|
|
|
|
} else if (use_tcp) {
|
|
|
|
dmnt::transport::InitializeByTcp();
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
/* Initialize debug log thread. */
|
|
|
|
dmnt::InitializeDebugLog();
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
/* Start GdbServer. */
|
|
|
|
dmnt::InitializeGdbServer();
|
2021-07-16 06:38:00 +02:00
|
|
|
|
2021-10-08 02:44:54 +02:00
|
|
|
/* TODO */
|
|
|
|
while (true) {
|
|
|
|
os::SleepThread(TimeSpan::FromDays(1));
|
|
|
|
}
|
2021-07-16 06:38:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|