From 8a42b3ee3e1d9aad7f19e696dfd11ecec5e14d9c Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 23 Feb 2021 04:10:20 -0800 Subject: [PATCH] htc: configure usage via system setting --- libstratosphere/source/boot2/boot2_api.cpp | 15 +++++++++++++-- libstratosphere/source/htcs/impl/htcs_service.hpp | 2 -- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libstratosphere/source/boot2/boot2_api.cpp b/libstratosphere/source/boot2/boot2_api.cpp index baa539d6..04b35904 100644 --- a/libstratosphere/source/boot2/boot2_api.cpp +++ b/libstratosphere/source/boot2/boot2_api.cpp @@ -34,7 +34,6 @@ namespace ams::boot2 { constexpr size_t NumPreSdCardLaunchPrograms = util::size(PreSdCardLaunchPrograms); constexpr ncm::SystemProgramId AdditionalLaunchPrograms[] = { - ncm::SystemProgramId::Htc, /* htc */ /* TODO: should we do boot!use_htc_gen2, with default to on in custom settings? */ ncm::SystemProgramId::Am, /* am */ ncm::SystemProgramId::NvServices, /* nvservices */ ncm::SystemProgramId::NvnFlinger, /* nvnflinger */ @@ -80,7 +79,6 @@ namespace ams::boot2 { constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms); constexpr ncm::SystemProgramId AdditionalMaintenanceLaunchPrograms[] = { - ncm::SystemProgramId::Htc, /* htc */ ncm::SystemProgramId::Am, /* am */ ncm::SystemProgramId::NvServices, /* nvservices */ ncm::SystemProgramId::NvnFlinger, /* nvnflinger */ @@ -188,6 +186,12 @@ namespace ams::boot2 { return force_maintenance != 0; } + bool IsHtcEnabled() { + u8 enable_htc = 1; + settings::fwdbg::GetSettingsItemValue(&enable_htc, sizeof(enable_htc), "atmosphere", "enable_htc"); + return enable_htc != 0; + } + bool IsMaintenanceMode() { /* Contact set:sys, retrieve boot!force_maintenance. */ if (IsForceMaintenance()) { @@ -379,6 +383,13 @@ namespace ams::boot2 { /* Check for and forward declare non-atmosphere mitm modules. */ DetectAndDeclareFutureMitms(); + /* Device whether to launch tma or htc. */ + if (IsHtcEnabled()) { + LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Htc, ncm::StorageId::None), 0); + } else { + LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Tma, ncm::StorageId::None), 0); + } + /* Launch additional programs. */ if (maintenance) { LaunchList(AdditionalMaintenanceLaunchPrograms, NumAdditionalMaintenanceLaunchPrograms); diff --git a/libstratosphere/source/htcs/impl/htcs_service.hpp b/libstratosphere/source/htcs/impl/htcs_service.hpp index 8d656c86..84127d5f 100644 --- a/libstratosphere/source/htcs/impl/htcs_service.hpp +++ b/libstratosphere/source/htcs/impl/htcs_service.hpp @@ -30,8 +30,6 @@ namespace ams::htcs::impl { public: HtcsService(mem::StandardAllocator *allocator, htc::server::driver::IDriver *drv, htc::server::rpc::RpcClient *rc, rpc::DataChannelManager *dcm) : m_allocator(allocator), m_driver(drv), m_rpc_client(rc), m_data_channel_manager(dcm) { /* ... */ } - public: - /* TODO */ public: Result CreateSocket(s32 *out_err, s32 *out_desc, bool enable_disconnection_emulation); Result DestroySocket(s32 desc);