From 57e15f3622829fd1fc7fb07f91f3a8a4dfa999d5 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 29 Oct 2024 19:24:52 -0700 Subject: [PATCH] strat: ldr::PlatformId -> ncm::ContentMetaPlatform --- .../fssystem_crypto_configuration.hpp | 8 +++--- .../stratosphere/ldr/ldr_platform_id.hpp | 27 ------------------- .../include/stratosphere/ldr/ldr_types.hpp | 2 +- .../source/erpt/srv/erpt_srv_reporter.cpp | 2 ++ .../fssystem_crypto_configuration.cpp | 12 ++++----- .../loader/source/ldr_content_management.cpp | 12 ++++----- .../loader/source/ldr_content_management.hpp | 10 +++---- .../loader/source/ldr_loader_service.cpp | 12 ++++----- stratosphere/loader/source/ldr_meta.cpp | 10 +++---- stratosphere/loader/source/ldr_meta.hpp | 4 +-- .../loader/source/ldr_process_creation.cpp | 4 +-- .../loader/source/ldr_process_creation.hpp | 4 +-- 12 files changed, 41 insertions(+), 66 deletions(-) delete mode 100644 libraries/libstratosphere/include/stratosphere/ldr/ldr_platform_id.hpp diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_crypto_configuration.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_crypto_configuration.hpp index 90f2ccdb0..17dfb656b 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_crypto_configuration.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_crypto_configuration.hpp @@ -16,7 +16,7 @@ #pragma once #include #include -#include +#include namespace ams::fssystem { @@ -26,10 +26,10 @@ namespace ams::fssystem { void InvalidateHardwareAesKey(); - bool IsValidSignatureKeyGeneration(ldr::PlatformId platform, size_t key_generation); + bool IsValidSignatureKeyGeneration(ncm::ContentMetaPlatform platform, size_t key_generation); - const u8 *GetAcidSignatureKeyModulus(ldr::PlatformId platform, bool prod, size_t key_generation, bool unk_unused); - size_t GetAcidSignatureKeyModulusSize(ldr::PlatformId platform, bool unk_unused); + const u8 *GetAcidSignatureKeyModulus(ncm::ContentMetaPlatform platform, bool prod, size_t key_generation, bool unk_unused); + size_t GetAcidSignatureKeyModulusSize(ncm::ContentMetaPlatform platform, bool unk_unused); const u8 *GetAcidSignatureKeyPublicExponent(); diff --git a/libraries/libstratosphere/include/stratosphere/ldr/ldr_platform_id.hpp b/libraries/libstratosphere/include/stratosphere/ldr/ldr_platform_id.hpp deleted file mode 100644 index 884cd0945..000000000 --- a/libraries/libstratosphere/include/stratosphere/ldr/ldr_platform_id.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 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 . - */ - -#pragma once -#include - -namespace ams::ldr { - - /* TODO: Is this really a FS type? What namespace does this actually live inside? */ - enum PlatformId { - PlatformId_Nx = 0, - }; - -} diff --git a/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp b/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp index 7d1a94aa1..524657042 100644 --- a/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace ams::ldr { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp index 274f9d5ab..eb291db67 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp @@ -537,6 +537,8 @@ namespace ams::erpt::srv { /* NOTE: Nintendo ignores the result of this call. */ SubmitFsInfo(); } + #else + AMS_UNUSED(flags); #endif diff --git a/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp b/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp index dbd2f86cd..23e4d0b3b 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_crypto_configuration.cpp @@ -297,20 +297,20 @@ namespace ams::fssystem { } } - bool IsValidSignatureKeyGeneration(ldr::PlatformId platform, size_t key_generation) { + bool IsValidSignatureKeyGeneration(ncm::ContentMetaPlatform platform, size_t key_generation) { switch (platform) { - case ldr::PlatformId_Nx: + case ncm::ContentMetaPlatform::Nx: return key_generation <= NxAcidSignatureKeyGenerationMax; AMS_UNREACHABLE_DEFAULT_CASE(); } } - const u8 *GetAcidSignatureKeyModulus(ldr::PlatformId platform, bool prod, size_t key_generation, bool unk_unused) { + const u8 *GetAcidSignatureKeyModulus(ncm::ContentMetaPlatform platform, bool prod, size_t key_generation, bool unk_unused) { AMS_ASSERT(IsValidSignatureKeyGeneration(platform, key_generation)); AMS_UNUSED(unk_unused); switch (platform) { - case ldr::PlatformId_Nx: + case ncm::ContentMetaPlatform::Nx: { const size_t used_keygen = (key_generation % (NxAcidSignatureKeyGenerationMax + 1)); return prod ? NxAcidSignatureKeyModulusProd[used_keygen] : NxAcidSignatureKeyModulusDev[used_keygen]; @@ -319,11 +319,11 @@ namespace ams::fssystem { } } - size_t GetAcidSignatureKeyModulusSize(ldr::PlatformId platform, bool unk_unused) { + size_t GetAcidSignatureKeyModulusSize(ncm::ContentMetaPlatform platform, bool unk_unused) { AMS_UNUSED(unk_unused); switch (platform) { - case ldr::PlatformId_Nx: + case ncm::ContentMetaPlatform::Nx: return NxAcidSignatureKeyModulusSize; AMS_UNREACHABLE_DEFAULT_CASE(); } diff --git a/stratosphere/loader/source/ldr_content_management.cpp b/stratosphere/loader/source/ldr_content_management.cpp index 2a704bcd5..dbab1983f 100644 --- a/stratosphere/loader/source/ldr_content_management.cpp +++ b/stratosphere/loader/source/ldr_content_management.cpp @@ -25,11 +25,11 @@ namespace ams::ldr { } /* ScopedCodeMount functionality. */ - ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, PlatformId platform) : m_lk(g_scoped_code_mount_lock), m_has_status(false), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) { + ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) : m_lk(g_scoped_code_mount_lock), m_has_status(false), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) { m_result = this->Initialize(loc, platform); } - ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &o, PlatformId platform) : m_lk(g_scoped_code_mount_lock), m_override_status(o), m_has_status(true), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) { + ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &o, ncm::ContentMetaPlatform platform) : m_lk(g_scoped_code_mount_lock), m_override_status(o), m_has_status(true), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) { m_result = this->Initialize(loc, platform); } @@ -46,7 +46,7 @@ namespace ams::ldr { } } - Result ScopedCodeMount::Initialize(const ncm::ProgramLocation &loc, PlatformId platform) { + Result ScopedCodeMount::Initialize(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) { /* Capture override status, if necessary. */ this->EnsureOverrideStatus(loc); AMS_ABORT_UNLESS(m_has_status); @@ -83,7 +83,7 @@ namespace ams::ldr { } /* Redirection API. */ - Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, PlatformId platform) { + Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) { /* Check for storage id none. */ if (static_cast(loc.storage_id) == ncm::StorageId::None) { std::memset(out_path, 0, out_size); @@ -166,9 +166,9 @@ namespace ams::ldr { R_SUCCEED(); } - fs::ContentAttributes GetPlatformContentAttributes(PlatformId platform) { + fs::ContentAttributes GetPlatformContentAttributes(ncm::ContentMetaPlatform platform) { switch (platform) { - case PlatformId_Nx: + case ncm::ContentMetaPlatform::Nx: return fs::ContentAttributes_None; AMS_UNREACHABLE_DEFAULT_CASE(); } diff --git a/stratosphere/loader/source/ldr_content_management.hpp b/stratosphere/loader/source/ldr_content_management.hpp index bc5848826..f44ef738e 100644 --- a/stratosphere/loader/source/ldr_content_management.hpp +++ b/stratosphere/loader/source/ldr_content_management.hpp @@ -34,8 +34,8 @@ namespace ams::ldr { bool m_mounted_sd_or_code; bool m_mounted_code; public: - ScopedCodeMount(const ncm::ProgramLocation &loc, PlatformId platform); - ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, PlatformId platform); + ScopedCodeMount(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform); + ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, ncm::ContentMetaPlatform platform); ~ScopedCodeMount(); Result GetResult() const { @@ -59,7 +59,7 @@ namespace ams::ldr { return m_base_code_verification_data; } private: - Result Initialize(const ncm::ProgramLocation &loc, PlatformId platform); + Result Initialize(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform); void EnsureOverrideStatus(const ncm::ProgramLocation &loc); }; @@ -76,10 +76,10 @@ namespace ams::ldr { #define ENCODE_CMPT_PATH(relative) "cmpt:" relative /* Redirection API. */ - Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, PlatformId platform); + Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform); Result RedirectProgramPath(const char *path, size_t size, const ncm::ProgramLocation &loc); Result RedirectHtmlDocumentPathForHbl(const ncm::ProgramLocation &loc); - fs::ContentAttributes GetPlatformContentAttributes(PlatformId platform); + fs::ContentAttributes GetPlatformContentAttributes(ncm::ContentMetaPlatform platform); } diff --git a/stratosphere/loader/source/ldr_loader_service.cpp b/stratosphere/loader/source/ldr_loader_service.cpp index 8a888caac..b363d6b13 100644 --- a/stratosphere/loader/source/ldr_loader_service.cpp +++ b/stratosphere/loader/source/ldr_loader_service.cpp @@ -27,11 +27,11 @@ namespace ams::ldr { constinit ArgumentStore g_argument_store; - bool IsValidPlatform(PlatformId platform) { - return platform == PlatformId_Nx; + bool IsValidPlatform(ncm::ContentMetaPlatform platform) { + return platform == ncm::ContentMetaPlatform::Nx; } - Result CreateProcessByPlatform(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit, PlatformId platform) { + Result CreateProcessByPlatform(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit, ncm::ContentMetaPlatform platform) { /* Check that the platform is valid. */ R_UNLESS(IsValidPlatform(platform), ldr::ResultInvalidPlatformId()); @@ -49,7 +49,7 @@ namespace ams::ldr { R_RETURN(ldr::CreateProcess(out, pin_id, loc, override_status, path, g_argument_store.Get(loc.program_id), flags, resource_limit, platform)); } - Result GetProgramInfoByPlatform(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, PlatformId platform) { + Result GetProgramInfoByPlatform(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) { /* Check that the platform is valid. */ R_UNLESS(IsValidPlatform(platform), ldr::ResultInvalidPlatformId()); @@ -88,11 +88,11 @@ namespace ams::ldr { Result LoaderService::CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit) { - R_RETURN(CreateProcessByPlatform(out, pin_id, flags, resource_limit, PlatformId_Nx)); + R_RETURN(CreateProcessByPlatform(out, pin_id, flags, resource_limit, ncm::ContentMetaPlatform::Nx)); } Result LoaderService::GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) { - R_RETURN(GetProgramInfoByPlatform(out, out_status, loc, PlatformId_Nx)); + R_RETURN(GetProgramInfoByPlatform(out, out_status, loc, ncm::ContentMetaPlatform::Nx)); } Result LoaderService::PinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) { diff --git a/stratosphere/loader/source/ldr_meta.cpp b/stratosphere/loader/source/ldr_meta.cpp index b1d1a85ad..04e71d38b 100644 --- a/stratosphere/loader/source/ldr_meta.cpp +++ b/stratosphere/loader/source/ldr_meta.cpp @@ -103,15 +103,15 @@ namespace ams::ldr { R_SUCCEED(); } - const u8 *GetAcidSignatureModulus(PlatformId platform, u8 key_generation, bool unk_unused) { + const u8 *GetAcidSignatureModulus(ncm::ContentMetaPlatform platform, u8 key_generation, bool unk_unused) { return fssystem::GetAcidSignatureKeyModulus(platform, !IsDevelopmentForAcidSignatureCheck(), key_generation, unk_unused); } - size_t GetAcidSignatureModulusSize(PlatformId platform, bool unk_unused) { + size_t GetAcidSignatureModulusSize(ncm::ContentMetaPlatform platform, bool unk_unused) { return fssystem::GetAcidSignatureKeyModulusSize(platform, unk_unused); } - Result ValidateAcidSignature(Meta *meta, PlatformId platform, bool unk_unused) { + Result ValidateAcidSignature(Meta *meta, ncm::ContentMetaPlatform platform, bool unk_unused) { /* Loader did not check signatures prior to 10.0.0. */ if (hos::GetVersion() < hos::Version_10_0_0) { meta->check_verification_data = false; @@ -190,7 +190,7 @@ namespace ams::ldr { } /* API. */ - Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform, bool unk_unused) { + Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform, bool unk_unused) { /* Set the cached program id back to zero. */ g_cached_program_id = {}; @@ -282,7 +282,7 @@ namespace ams::ldr { R_SUCCEED(); } - Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform) { + Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform) { if (g_cached_program_id != loc.program_id || g_cached_override_status != status) { R_RETURN(LoadMeta(out_meta, loc, status, platform, false)); } diff --git a/stratosphere/loader/source/ldr_meta.hpp b/stratosphere/loader/source/ldr_meta.hpp index 2ac88b63b..4d3ce3fb8 100644 --- a/stratosphere/loader/source/ldr_meta.hpp +++ b/stratosphere/loader/source/ldr_meta.hpp @@ -36,8 +36,8 @@ namespace ams::ldr { }; /* Meta API. */ - Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform, bool unk_unused); - Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform); + Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform, bool unk_unused); + Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform); void InvalidateMetaCache(); } diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index c1daeeb9f..ad94e85d6 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -664,7 +664,7 @@ namespace ams::ldr { } /* Process Creation API. */ - Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, PlatformId platform) { + Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, ncm::ContentMetaPlatform platform) { /* Mount code. */ AMS_UNUSED(path); ScopedCodeMount mount(loc, override_status, platform); @@ -720,7 +720,7 @@ namespace ams::ldr { R_SUCCEED(); } - Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, PlatformId platform) { + Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, ncm::ContentMetaPlatform platform) { Meta meta; /* Load Meta. */ diff --git a/stratosphere/loader/source/ldr_process_creation.hpp b/stratosphere/loader/source/ldr_process_creation.hpp index 79a622169..5e224a72a 100644 --- a/stratosphere/loader/source/ldr_process_creation.hpp +++ b/stratosphere/loader/source/ldr_process_creation.hpp @@ -19,8 +19,8 @@ namespace ams::ldr { /* Process Creation API. */ - Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, PlatformId platform); - Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, PlatformId platform); + Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, ncm::ContentMetaPlatform platform); + Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, ncm::ContentMetaPlatform platform); Result PinProgram(PinId *out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status); Result UnpinProgram(PinId id);