From da208f8001e8167179b77c29b820425fb0e8b7a5 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 5 Sep 2021 10:08:30 -0700 Subject: [PATCH] ams-1.0.0: meso no longer optional, remove conditional logic --- .../source/ams/ams_environment.cpp | 3 --- .../source/boot2/boot2_api.cpp | 2 +- .../source/erpt/srv/erpt_srv_reporter.cpp | 6 ++---- .../source/hos/hos_stratosphere_api.cpp | 6 ++++++ .../os_aslr_space_manager_impl.os.horizon.hpp | 20 ++----------------- .../source/set_mitm/setsys_mitm_service.cpp | 8 +------- .../creport/source/creport_crash_report.cpp | 5 +---- .../fatal/source/fatal_task_screen.cpp | 2 +- .../loader/source/ldr_process_creation.cpp | 14 ++++--------- .../pm/source/impl/pm_resource_manager.cpp | 6 +----- 10 files changed, 19 insertions(+), 53 deletions(-) diff --git a/libraries/libstratosphere/source/ams/ams_environment.cpp b/libraries/libstratosphere/source/ams/ams_environment.cpp index ce4237f6e..04f8f4d1f 100644 --- a/libraries/libstratosphere/source/ams/ams_environment.cpp +++ b/libraries/libstratosphere/source/ams/ams_environment.cpp @@ -74,9 +74,6 @@ namespace ams { ams_ctx.pc = ctx->pc.x; ams_ctx.pstate = ctx->pstate; ams_ctx.afsr0 = static_cast(::ams::exosphere::GetVersion(ATMOSPHERE_RELEASE_VERSION)); - if (svc::IsKernelMesosphere()) { - ams_ctx.afsr0 |= (static_cast('M') << (BITSIZEOF(u32) - BITSIZEOF(u8))); - } ams_ctx.afsr1 = static_cast(hos::GetVersion()); ams_ctx.far = ctx->far.x; ams_ctx.report_identifier = armGetSystemTick(); diff --git a/libraries/libstratosphere/source/boot2/boot2_api.cpp b/libraries/libstratosphere/source/boot2/boot2_api.cpp index 1605d3e9b..3ba67a2ae 100644 --- a/libraries/libstratosphere/source/boot2/boot2_api.cpp +++ b/libraries/libstratosphere/source/boot2/boot2_api.cpp @@ -462,7 +462,7 @@ namespace ams::boot2 { DetectAndDeclareFutureMitms(); /* Device whether to launch tma or htc. */ - if (svc::IsKernelMesosphere() && IsHtcEnabled()) { + if (IsHtcEnabled()) { LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Htc, ncm::StorageId::None), 0); LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Cs, ncm::StorageId::None), 0); } else { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp index 28c2f8595..80e03c9ca 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp @@ -219,10 +219,8 @@ namespace ams::erpt::srv { } void SubmitResourceLimitContexts() { - if (hos::GetVersion() >= hos::Version_11_0_0 || svc::IsKernelMesosphere()) { - SubmitResourceLimitLimitContext(); - SubmitResourceLimitPeakContext(); - } + SubmitResourceLimitLimitContext(); + SubmitResourceLimitPeakContext(); } Result ValidateCreateReportContext(const ContextEntry *ctx) { diff --git a/libraries/libstratosphere/source/hos/hos_stratosphere_api.cpp b/libraries/libstratosphere/source/hos/hos_stratosphere_api.cpp index 10af44f29..90bf78cae 100644 --- a/libraries/libstratosphere/source/hos/hos_stratosphere_api.cpp +++ b/libraries/libstratosphere/source/hos/hos_stratosphere_api.cpp @@ -40,6 +40,9 @@ namespace ams::hos { /* Initialize hos::Version API. */ hos::SetVersionForLibnxInternal(); + + /* Check that we're running under mesosphere. */ + AMS_ABORT_UNLESS(svc::IsKernelMesosphere()); } void InitializeForStratosphereDebug(hos::Version debug_version) { @@ -48,6 +51,9 @@ namespace ams::hos { /* Initialize hos::Version API. */ hos::SetVersionForLibnxInternalDebug(debug_version); + + /* Check that we're running under mesosphere. */ + AMS_ABORT_UNLESS(svc::IsKernelMesosphere()); } } diff --git a/libraries/libstratosphere/source/os/impl/os_aslr_space_manager_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_aslr_space_manager_impl.os.horizon.hpp index ca1a7a4cd..76bcbd06a 100644 --- a/libraries/libstratosphere/source/os/impl/os_aslr_space_manager_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_aslr_space_manager_impl.os.horizon.hpp @@ -56,27 +56,11 @@ namespace ams::os::impl { } static u64 GetAslrSpaceBeginAddress() { - if (hos::GetVersion() >= hos::Version_2_0_0 || svc::IsKernelMesosphere()) { - return GetAslrInfo(svc::InfoType_AslrRegionAddress); - } else { - if (GetHeapSpaceBeginAddress() < AslrBase64BitDeprecated || GetAliasSpaceBeginAddress() < AslrBase64BitDeprecated) { - return AslrBase32Bit; - } else { - return AslrBase64BitDeprecated; - } - } + return GetAslrInfo(svc::InfoType_AslrRegionAddress); } static u64 GetAslrSpaceEndAddress() { - if (hos::GetVersion() >= hos::Version_2_0_0 || svc::IsKernelMesosphere()) { - return GetAslrInfo(svc::InfoType_AslrRegionAddress) + GetAslrInfo(svc::InfoType_AslrRegionSize); - } else { - if (GetHeapSpaceBeginAddress() < AslrBase64BitDeprecated || GetAliasSpaceBeginAddress() < AslrBase64BitDeprecated) { - return AslrBase32Bit + AslrSize32Bit; - } else { - return AslrBase64BitDeprecated + AslrSize64BitDeprecated; - } - } + return GetAslrInfo(svc::InfoType_AslrRegionAddress) + GetAslrInfo(svc::InfoType_AslrRegionSize); } }; diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp index de241b2fd..1f10c4449 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp @@ -56,17 +56,11 @@ namespace ams::mitm::settings { const auto api_info = exosphere::GetApiInfo(); const char emummc_char = emummc::IsActive() ? 'E' : 'S'; - /* NOTE: While Mesosphere is in experimental/opt-in, we will display it as part of the firmware. */ - const char mesosphere_char = svc::IsKernelMesosphere() ? 'M' : '0'; - - /* TODO: Remove separate display for mesosphere vs not mesosphere in Atmosphere 1.0.0. */ - AMS_ABORT_UNLESS(api_info.GetMajorVersion() == 0); - /* NOTE: We have carefully accounted for the size of the string we print. */ /* No truncation occurs assuming two-digits for all version number components. */ char display_version[sizeof(g_ams_firmware_version.display_version)]; - util::SNPrintf(display_version, sizeof(display_version), "%s|AMS %c.%u.%u|%c", g_ams_firmware_version.display_version, mesosphere_char, api_info.GetMinorVersion(), api_info.GetMicroVersion(), emummc_char); + util::SNPrintf(display_version, sizeof(display_version), "%s|AMS %u.%u.%u|%c", g_ams_firmware_version.display_version, api_info.GetMajorVersion(), api_info.GetMinorVersion(), api_info.GetMicroVersion(), emummc_char); std::memcpy(g_ams_firmware_version.display_version, display_version, sizeof(display_version)); } diff --git a/stratosphere/creport/source/creport_crash_report.cpp b/stratosphere/creport/source/creport_crash_report.cpp index 669da57dc..3df15b692 100644 --- a/stratosphere/creport/source/creport_crash_report.cpp +++ b/stratosphere/creport/source/creport_crash_report.cpp @@ -358,10 +358,7 @@ namespace ams::creport { } void CrashReport::SaveToFile(ScopedFile &file) { - file.WriteFormat("Atmosphère Crash Report (v1.5):\n"); - - /* TODO: Remove in Atmosphere 1.0.0. */ - file.WriteFormat("Mesosphere: %s\n", svc::IsKernelMesosphere() ? "Enabled" : "Disabled"); + file.WriteFormat("Atmosphère Crash Report (v1.6):\n"); file.WriteFormat("Result: 0x%X (2%03d-%04d)\n\n", this->result.GetValue(), this->result.GetModule(), this->result.GetDescription()); diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index 415163ae3..bed408f2a 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -235,7 +235,7 @@ namespace ams::fatal::srv { font::AddSpacingLines(0.5f); /* TODO: Remove Mesosphere identifier in 1.0.0. */ - font::PrintFormatLine("Firmware: %s (Atmosphère%s %u.%u.%u-%s)", config.GetFirmwareVersion().display_version, svc::IsKernelMesosphere() ? " M" : "", ATMOSPHERE_RELEASE_VERSION, ams::GetGitRevision()); + font::PrintFormatLine("Firmware: %s (Atmosphère %u.%u.%u-%s)", config.GetFirmwareVersion().display_version, ATMOSPHERE_RELEASE_VERSION, ams::GetGitRevision()); font::AddSpacingLines(1.5f); if (!exosphere::ResultVersionMismatch::Includes(this->context->result)) { font::Print(config.GetErrorDescription()); diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index 821c5390e..88f95ac64 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -265,11 +265,7 @@ namespace ams::ldr { flags |= svc::CreateProcessFlag_AddressSpace32BitWithoutAlias; break; case Npdm::AddressSpaceType_64Bit: - if (hos::GetVersion() >= hos::Version_2_0_0 || svc::IsKernelMesosphere()) { - flags |= svc::CreateProcessFlag_AddressSpace64Bit; - } else { - flags |= svc::CreateProcessFlag_AddressSpace64BitDeprecated; - } + flags |= svc::CreateProcessFlag_AddressSpace64Bit; break; default: return ResultInvalidMeta(); @@ -326,11 +322,9 @@ namespace ams::ldr { } } - /* 11.0.0+ Set Disable DAS merge. */ - if (hos::GetVersion() >= hos::Version_11_0_0 || svc::IsKernelMesosphere()) { - if (meta_flags & Npdm::MetaFlag_DisableDeviceAddressSpaceMerge) { - flags |= svc::CreateProcessFlag_DisableDeviceAddressSpaceMerge; - } + /* 11.0.0+/meso Set Disable DAS merge. */ + if (meta_flags & Npdm::MetaFlag_DisableDeviceAddressSpaceMerge) { + flags |= svc::CreateProcessFlag_DisableDeviceAddressSpaceMerge; } *out = flags; diff --git a/stratosphere/pm/source/impl/pm_resource_manager.cpp b/stratosphere/pm/source/impl/pm_resource_manager.cpp index 2a9e7e697..7ba5e0c90 100644 --- a/stratosphere/pm/source/impl/pm_resource_manager.cpp +++ b/stratosphere/pm/source/impl/pm_resource_manager.cpp @@ -171,10 +171,6 @@ namespace ams::pm::resource { } bool IsKTraceEnabled() { - if (!svc::IsKernelMesosphere()) { - return false; - } - u64 value = 0; R_ABORT_UNLESS(svc::GetInfo(std::addressof(value), svc::InfoType_MesosphereMeta, INVALID_HANDLE, svc::MesosphereMetaInfo_IsKTraceEnabled)); @@ -248,7 +244,7 @@ namespace ams::pm::resource { } /* Choose and initialize memory arrangement. */ - const bool use_dynamic_memory_arrangement = (hos_version >= hos::Version_6_0_0) || (svc::IsKernelMesosphere() && hos_version >= hos::Version_5_0_0); + const bool use_dynamic_memory_arrangement = (hos_version >= hos::Version_5_0_0); if (use_dynamic_memory_arrangement) { /* 6.0.0 retrieves memory limit information from the kernel, rather than using a hardcoded profile. */ g_memory_arrangement = spl::MemoryArrangement_Dynamic;