From 496f93ccdbc5256697bbf1c16eac00087d3be3e4 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 21 Aug 2020 12:18:07 -0700 Subject: [PATCH] kern: expose mesosphere meta over GetInfo instead of GetSystemInfo --- .../source/svc/kern_svc_info.cpp | 37 ++++++++++++------- .../svc/svc_stratosphere_shims.hpp | 2 +- .../include/vapours/svc/svc_types_common.hpp | 10 +++-- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/libraries/libmesosphere/source/svc/kern_svc_info.cpp b/libraries/libmesosphere/source/svc/kern_svc_info.cpp index a1e0d66ea..42a8b4cd3 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_info.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_info.cpp @@ -235,6 +235,30 @@ namespace ams::kern::svc { *out = tick_count; } break; + case ams::svc::InfoType_MesosphereMeta: + { + /* Verify the handle is invalid. */ + R_UNLESS(handle == ams::svc::InvalidHandle, svc::ResultInvalidHandle()); + + switch (static_cast(info_subtype)) { + case ams::svc::MesosphereMetaInfo_KernelVersion: + { + /* Return the supported kernel version. */ + *out = ams::svc::SupportedKernelVersion; + } + break; + case ams::svc::MesosphereMetaInfo_IsKTraceEnabled: + { + /* Return whether the kernel supports tracing. */ + constexpr u64 KTraceValue = ams::kern::IsKTraceEnabled ? 1 : 0; + *out = KTraceValue; + } + break; + default: + return svc::ResultInvalidCombination(); + } + } + break; default: { /* For debug, log the invalid info call. */ @@ -294,19 +318,6 @@ namespace ams::kern::svc { R_TRY(GetInitialProcessIdRange(out, static_cast(info_subtype))); } break; - case ams::svc::SystemInfoType_IsMesosphere: - { - /* Verify the handle is invalid. */ - R_UNLESS(handle == ams::svc::InvalidHandle, svc::ResultInvalidHandle()); - - /* Verify that the sub-type is zero. */ - R_UNLESS(info_subtype == 0, svc::ResultInvalidCombination()); - - /* We don't actually have any data to return. */ - /* Clear the output. */ - *out = 0; - } - break; default: return svc::ResultInvalidEnumValue(); } diff --git a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp index cc1a3e955..58be481ee 100644 --- a/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp +++ b/libraries/libstratosphere/include/stratosphere/svc/svc_stratosphere_shims.hpp @@ -500,7 +500,7 @@ ALWAYS_INLINE bool IsKernelMesosphere() { uint64_t dummy; - return R_SUCCEEDED(::ams::svc::GetSystemInfo(std::addressof(dummy), ::ams::svc::SystemInfoType_IsMesosphere, ::ams::svc::InvalidHandle, 0)); + return R_SUCCEEDED(::ams::svc::GetInfo(std::addressof(dummy), ::ams::svc::InfoType_MesosphereMeta, ::ams::svc::InvalidHandle, ::ams::svc::MesosphereMetaInfo_KernelVersion)); } } diff --git a/libraries/libvapours/include/vapours/svc/svc_types_common.hpp b/libraries/libvapours/include/vapours/svc/svc_types_common.hpp index bcfcb4236..29f4fa1eb 100644 --- a/libraries/libvapours/include/vapours/svc/svc_types_common.hpp +++ b/libraries/libvapours/include/vapours/svc/svc_types_common.hpp @@ -157,6 +157,8 @@ namespace ams::svc { InfoType_UsedNonSystemMemorySize = 22, InfoType_IsApplication = 23, + InfoType_MesosphereMeta = 65000, + InfoType_ThreadTickCount = 0xF0000002, }; @@ -169,13 +171,15 @@ namespace ams::svc { TickCountInfo_Total = std::numeric_limits::max(), }; + enum MesosphereMetaInfo : u64 { + MesosphereMetaInfo_KernelVersion = 0, + MesosphereMetaInfo_IsKTraceEnabled = 1, + }; + enum SystemInfoType : u32 { SystemInfoType_TotalPhysicalMemorySize = 0, SystemInfoType_UsedPhysicalMemorySize = 1, SystemInfoType_InitialProcessIdRange = 2, - - /* NOTE: This is potentially temporary, and highly subject to change. */ - SystemInfoType_IsMesosphere = 0xF0000000, }; enum InitialProcessIdRangeInfo : u64 {