diff --git a/libraries/libstratosphere/include/stratosphere.hpp b/libraries/libstratosphere/include/stratosphere.hpp index 398bf579e..bc308430d 100644 --- a/libraries/libstratosphere/include/stratosphere.hpp +++ b/libraries/libstratosphere/include/stratosphere.hpp @@ -28,8 +28,8 @@ #include "stratosphere/dd.hpp" #include "stratosphere/lmem.hpp" -/* Lots of things depend on NCM, for Program IDs. */ -#include "stratosphere/ncm.hpp" +/* Pull in all ID definitions from NCM. */ +#include "stratosphere/ncm/ncm_ids.hpp" /* At this point, just include the rest alphabetically. */ /* TODO: Figure out optimal order. */ diff --git a/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp b/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp index e4e2292f6..6f2bffc40 100644 --- a/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/cfg/cfg_types.hpp @@ -15,8 +15,8 @@ */ #pragma once -#include "../os/os_common_types.hpp" -#include "../ncm/ncm_types.hpp" +#include +#include namespace ams::cfg { diff --git a/libraries/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp b/libraries/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp index 576fc411d..017e73407 100644 --- a/libraries/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp @@ -15,9 +15,9 @@ */ #pragma once -#include "../os/os_common_types.hpp" -#include "../ncm/ncm_types.hpp" -#include "../sf/sf_buffer_tags.hpp" +#include +#include +#include namespace ams::dmnt::cheat { diff --git a/libraries/libstratosphere/include/stratosphere/fatal/fatal_types.hpp b/libraries/libstratosphere/include/stratosphere/fatal/fatal_types.hpp index ac429fc4a..592834889 100644 --- a/libraries/libstratosphere/include/stratosphere/fatal/fatal_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/fatal/fatal_types.hpp @@ -16,8 +16,8 @@ #pragma once #include -#include "../ncm/ncm_types.hpp" -#include "../sf/sf_buffer_tags.hpp" +#include +#include namespace ams::fatal { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_common.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_common.hpp index 0ebd91b37..4f6a6436d 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_common.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_common.hpp @@ -15,9 +15,9 @@ */ #pragma once #include -#include "../os.hpp" -#include "../ncm.hpp" -#include "../sf.hpp" +#include +#include +#include namespace ams::fs { diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp index 32d164090..60596272c 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp @@ -13,9 +13,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - #pragma once -#include "kvdb_auto_buffer.hpp" +#include namespace ams::kvdb { diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp index 23ab2c96e..db98774bf 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp @@ -13,7 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - #pragma once #include diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp index dcef1765c..0c85ddc76 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp @@ -13,7 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - #pragma once #include diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp index f69b9ab26..52f8b2708 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp @@ -13,9 +13,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include -#include "kvdb_bounded_string.hpp" -#include "kvdb_file_key_value_store.hpp" +#include +#include +#include +#include namespace ams::kvdb { diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp index e772897ec..40e5fbc84 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp @@ -14,8 +14,8 @@ * along with this program. If not, see . */ #pragma once -#include "../os.hpp" -#include "kvdb_bounded_string.hpp" +#include +#include namespace ams::kvdb { diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp index fb6caa277..65ca787ed 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp @@ -15,10 +15,11 @@ */ #pragma once -#include -#include "kvdb_auto_buffer.hpp" -#include "kvdb_archive.hpp" -#include "kvdb_bounded_string.hpp" +#include +#include +#include +#include +#include namespace ams::kvdb { diff --git a/libraries/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp b/libraries/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp index c680e07bc..1b1947557 100644 --- a/libraries/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp @@ -15,7 +15,7 @@ */ #pragma once -#include "ldr_types.hpp" +#include namespace ams::ldr::pm { diff --git a/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp b/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp index a2ecfdd35..462037f40 100644 --- a/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ldr/ldr_types.hpp @@ -16,8 +16,9 @@ #pragma once #include -#include "../ncm/ncm_types.hpp" -#include "../sf/sf_buffer_tags.hpp" +#include +#include +#include namespace ams::ldr { diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp index 8c6a8f719..c204898ba 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp @@ -42,17 +42,17 @@ namespace ams::lr { } public: /* Actual commands. */ - Result ResolveAddOnContentPath(Path *out, ncm::ProgramId id) { + Result ResolveAddOnContentPath(Path *out, ncm::DataId id) { AMS_ASSERT(this->interface); return this->interface->ResolveAddOnContentPath(out, id); } - Result RegisterAddOnContentStorage(ncm::StorageId storage_id, ncm::ProgramId id, ncm::ProgramId application_id) { + Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) { AMS_ASSERT(this->interface); if (hos::GetVersion() >= hos::Version_900) { - return this->interface->RegisterAddOnContentStorage(storage_id, id, application_id); + return this->interface->RegisterAddOnContentStorage(id, application_id, storage_id); } else { - return this->interface->RegisterAddOnContentStorageDeprecated(storage_id, id); + return this->interface->RegisterAddOnContentStorageDeprecated(id, storage_id); } } @@ -61,12 +61,12 @@ namespace ams::lr { return this->interface->UnregisterAllAddOnContentPath(); } - Result RefreshApplicationAddOnContent(const ncm::ProgramId *ids, size_t num_ids) { + Result RefreshApplicationAddOnContent(const ncm::ApplicationId *ids, size_t num_ids) { AMS_ASSERT(this->interface); - return this->interface->RefreshApplicationAddOnContent(sf::InArray(ids, num_ids)); + return this->interface->RefreshApplicationAddOnContent(sf::InArray(ids, num_ids)); } - Result UnregisterApplicationAddOnContent(ncm::ProgramId id) { + Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) { AMS_ASSERT(this->interface); return this->interface->UnregisterApplicationAddOnContent(id); } diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp index c19e22161..17080961c 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_i_add_on_content_location_resolver.hpp @@ -31,12 +31,12 @@ namespace ams::lr { }; public: /* Actual commands. */ - virtual Result ResolveAddOnContentPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result RegisterAddOnContentStorageDeprecated(ncm::StorageId storage_id, ncm::ProgramId id) = 0; - virtual Result RegisterAddOnContentStorage(ncm::StorageId storage_id, ncm::ProgramId id, ncm::ProgramId application_id) = 0; + virtual Result ResolveAddOnContentPath(sf::Out out, ncm::DataId id) = 0; + virtual Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) = 0; + virtual Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) = 0; virtual Result UnregisterAllAddOnContentPath() = 0; - virtual Result RefreshApplicationAddOnContent(const sf::InArray &ids) = 0; - virtual Result UnregisterApplicationAddOnContent(ncm::ProgramId id) = 0; + virtual Result RefreshApplicationAddOnContent(const sf::InArray &ids) = 0; + virtual Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) = 0; public: DEFINE_SERVICE_DISPATCH_TABLE { MAKE_SERVICE_COMMAND_META(ResolveAddOnContentPath, hos::Version_200), diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp index 59c8011fd..4e764ad2b 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_i_location_resolver.hpp @@ -59,7 +59,7 @@ namespace ams::lr { virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) = 0; virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) = 0; virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) = 0; - virtual Result ResolveDataPath(sf::Out out, ncm::ProgramId id) = 0; + virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) = 0; virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) = 0; virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) = 0; virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) = 0; diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp index b79414852..0291d7634 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp @@ -61,7 +61,7 @@ namespace ams::lr { return this->interface->ResolveApplicationHtmlDocumentPath(out, id); } - Result ResolveDataPath(Path *out, ncm::ProgramId id) { + Result ResolveDataPath(Path *out, ncm::DataId id) { AMS_ASSERT(this->interface != nullptr); return this->interface->ResolveDataPath(out, id); } diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_types.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_types.hpp index bfe6a0792..5b15c5135 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_types.hpp @@ -16,7 +16,6 @@ #pragma once #include -#include #include #include diff --git a/libraries/libstratosphere/include/stratosphere/ncm.hpp b/libraries/libstratosphere/include/stratosphere/ncm.hpp index 9836497cc..4efc4377e 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm.hpp @@ -16,7 +16,8 @@ #pragma once -#include +#include +#include #include #include #include diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp index 4d42dd3b9..a07fb6739 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp @@ -14,7 +14,6 @@ * along with this program. If not, see . */ #pragma once -#include #include #include #include diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_bounded_map.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_bounded_map.hpp index bfe47d638..9f4eb47f0 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_bounded_map.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_bounded_map.hpp @@ -15,7 +15,6 @@ */ #pragma once #include -#include namespace ams::ncm { @@ -60,7 +59,7 @@ namespace ams::ncm { Value &operator[](const Key &key) { /* Try to find an existing value. */ - if (Value *value = this->Find(key); value != nullptr) { + if (Value *value = this->Find(key); value != nullptr) { return *value; } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id.hpp new file mode 100644 index 000000000..2c727c843 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id.hpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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::ncm { + + struct alignas(4) ContentId { + util::Uuid uuid; + + bool operator==(const ContentId& other) const { + return this->uuid == other.uuid; + } + + bool operator!=(const ContentId& other) const { + return this->uuid != other.uuid; + } + + bool operator==(const util::Uuid& other) const { + return this->uuid == other; + } + + bool operator!=(const util::Uuid& other) const { + return this->uuid != other; + } + }; + + static_assert(alignof(ContentId) == 4); + + constexpr inline ContentId InvalidContentId = { util::InvalidUuid }; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp index 91e4e6bb3..95bff84ce 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_id_utils.hpp @@ -14,7 +14,9 @@ * along with this program. If not, see . */ #pragma once -#include +#include +#include +#include namespace ams::ncm { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info.hpp new file mode 100644 index 000000000..f555627d6 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info.hpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include + +namespace ams::ncm { + + struct ContentInfo { + ContentId content_id; + u32 size_low; + u16 size_high; + ContentType content_type; + u8 id_offset; + + constexpr const ContentId &GetId() const { + return this->content_id; + } + + constexpr u64 GetSize() const { + return (static_cast(this->size_high) << 32) | static_cast(this->size_low); + } + + constexpr ContentType GetType() const { + return this->content_type; + } + + constexpr u8 GetIdOffset() const { + return this->id_offset; + } + + static constexpr ContentInfo Make(ContentId id, u64 size, ContentType type, u8 id_ofs) { + const u32 size_low = size & 0xFFFFFFFFu; + const u16 size_high = static_cast(size >> 32); + return { + .content_id = id, + .size_low = size_low, + .size_high = size_high, + .content_type = type, + .id_offset = id_ofs, + }; + } + }; + + static_assert(sizeof(std::is_pod::value)); + static_assert(sizeof(ContentInfo) == 0x18); + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info_data.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info_data.hpp new file mode 100644 index 000000000..8a5af8517 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_info_data.hpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include +#include +#include + +namespace ams::ncm { + + struct Digest { + u8 data[crypto::Sha256Generator::HashSize]; + }; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp index af88f6bbc..75d52855a 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -14,9 +14,15 @@ * along with this program. If not, see . */ #pragma once -#include +#include +#include +#include +#include #include +#include +#include #include +#include namespace ams::ncm { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp index e8a3934a8..f25e81ef6 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp @@ -14,10 +14,43 @@ * along with this program. If not, see . */ #pragma once -#include +#include +#include +#include +#include +#include namespace ams::ncm { + enum ContentMetaAttribute : u8 { + ContentMetaAttribute_None = (0 << 0), + ContentMetaAttribute_IncludesExFatDriver = (1 << 0), + ContentMetaAttribute_Rebootless = (1 << 1), + }; + + struct ContentMetaInfo { + u64 id; + u32 version; + ContentMetaType type; + u8 attributes; + u8 padding[2]; + + static constexpr ContentMetaInfo Make(u64 id, u32 version, ContentMetaType type, u8 attributes) { + return { + .id = id, + .version = version, + .type = type, + .attributes = attributes, + }; + } + + constexpr ContentMetaKey ToKey() { + return ContentMetaKey::Make(this->id, this->version, this->type); + } + }; + + static_assert(sizeof(ContentMetaInfo) == 0x10); + struct ContentMetaHeader { u16 extended_header_size; u16 content_count; @@ -26,29 +59,29 @@ namespace ams::ncm { StorageId storage_id; }; - static_assert(sizeof(ContentMetaHeader) == 0x8, "ContentMetaHeader definition!"); + static_assert(sizeof(ContentMetaHeader) == 0x8); struct ApplicationMetaExtendedHeader { - ProgramId patch_id; + PatchId patch_id; u32 required_system_version; u32 required_application_version; }; struct PatchMetaExtendedHeader { - ProgramId application_id; + ApplicationId application_id; u32 required_system_version; u32 extended_data_size; u8 reserved[0x8]; }; struct AddOnContentMetaExtendedHeader { - ProgramId application_id; + ApplicationId application_id; u32 required_application_version; u32 padding; }; struct DeltaMetaExtendedHeader { - ProgramId application_id; + ApplicationId application_id; u32 extended_data_size; u32 padding; }; @@ -222,9 +255,9 @@ namespace ams::ncm { return false; } - std::optional GetApplicationId(const ContentMetaKey &key) const { + std::optional GetApplicationId(const ContentMetaKey &key) const { switch (key.type) { - case ContentMetaType::Application: return key.id; + case ContentMetaType::Application: return ApplicationId{ key.id }; case ContentMetaType::Patch: return this->GetExtendedHeader()->application_id; case ContentMetaType::AddOnContent: return this->GetExtendedHeader()->application_id; case ContentMetaType::Delta: return this->GetExtendedHeader()->application_id; @@ -232,7 +265,7 @@ namespace ams::ncm { } } - std::optional GetApplicationId() const { + std::optional GetApplicationId() const { return this->GetApplicationId(this->GetKey()); } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp index 3cb3d3879..0bda84139 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp @@ -14,7 +14,6 @@ * along with this program. If not, see . */ #pragma once -#include #include namespace ams::ncm { @@ -59,33 +58,42 @@ namespace ams::ncm { return ResultSuccess(); } - /* TODO: Proper ProgramId vs DataId vs ApplicationId for Get */ - #define AMS_NCM_DEFINE_GETTERS(Kind) \ - Result Get##Kind(ContentId *out, ProgramId id, u32 version) { \ - return this->interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id, version), ContentType::Kind); \ - } \ - \ - Result GetLatest##Kind(ContentId *out, ProgramId id) { \ - ContentMetaKey latest_key; \ - R_TRY(this->interface->GetLatestContentMetaKey(std::addressof(latest_key), id)); \ - return this->interface->GetContentIdByType(out, latest_key, ContentType::Kind); \ + #define AMS_NCM_DEFINE_GETTERS(Kind, IdType) \ + Result Get##Kind(ContentId *out, IdType##Id id, u32 version) { \ + return this->interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \ + } \ + \ + Result GetLatest##Kind(ContentId *out, IdType##Id id) { \ + ContentMetaKey latest_key; \ + R_TRY(this->interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \ + return this->interface->GetContentIdByType(out, latest_key, ContentType::Kind); \ } - AMS_NCM_DEFINE_GETTERS(Program) - AMS_NCM_DEFINE_GETTERS(Data) - AMS_NCM_DEFINE_GETTERS(Control) - AMS_NCM_DEFINE_GETTERS(HtmlDocument) - AMS_NCM_DEFINE_GETTERS(LegalInformation) + AMS_NCM_DEFINE_GETTERS(Program, Program) + AMS_NCM_DEFINE_GETTERS(Data, Data) + AMS_NCM_DEFINE_GETTERS(Control, Application) + AMS_NCM_DEFINE_GETTERS(HtmlDocument, Application) + AMS_NCM_DEFINE_GETTERS(LegalInformation, Application) #undef AMS_NCM_DEFINE_GETTERS - /* TODO: Remove(SystemProgramId) Remove(SystemDataId) Remove(ProgramId) */ - Result Remove(const ContentMetaKey &key) { AMS_ASSERT(this->interface != nullptr); return this->interface->Remove(key); } + Result Remove(SystemProgramId id, u32 version) { + return this->Remove(ContentMetaKey::Make(id, version)); + } + + Result Remove(SystemDataId id, u32 version) { + return this->Remove(ContentMetaKey::Make(id, version)); + } + + Result Remove(ApplicationId id, u32 version) { + return this->Remove(ContentMetaKey::Make(id, version)); + } + Result GetContentIdByType(ContentId *out_content_id, const ContentMetaKey &key, ContentType type) { AMS_ASSERT(this->interface != nullptr); return this->interface->GetContentIdByType(out_content_id, key, type); @@ -102,13 +110,13 @@ namespace ams::ncm { return lc; } - ListCount ListContentMeta(ContentMetaKey *dst, size_t dst_size, ContentMetaType type, ProgramId app_id = InvalidProgramId, u64 min = std::numeric_limits::min(), u64 max = std::numeric_limits::max(), ContentInstallType install_type = ContentInstallType::Full) { + ListCount ListContentMeta(ContentMetaKey *dst, size_t dst_size, ContentMetaType type, ApplicationId app_id = InvalidApplicationId, u64 min = std::numeric_limits::min(), u64 max = std::numeric_limits::max(), ContentInstallType install_type = ContentInstallType::Full) { ListCount lc = {}; R_ABORT_UNLESS(this->interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray(dst, dst_size), type, app_id, min, max, install_type)); return lc; } - Result GetLatest(ContentMetaKey *out_key, ProgramId id) { + Result GetLatest(ContentMetaKey *out_key, u64 id) { AMS_ASSERT(this->interface != nullptr); return this->interface->GetLatestContentMetaKey(out_key, id); } @@ -152,7 +160,7 @@ namespace ams::ncm { return this->interface->GetRequiredSystemVersion(out_version, key); } - Result GetPatchId(ProgramId *out_patch_id, const ContentMetaKey &key) { + Result GetPatchId(PatchId *out_patch_id, const ContentMetaKey &key) { AMS_ASSERT(this->interface != nullptr); return this->interface->GetPatchId(out_patch_id, key); } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_id.hpp new file mode 100644 index 000000000..e4733be56 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_id.hpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include + +namespace ams::ncm { + + struct ApplicationId { + u64 value; + + constexpr operator ProgramId() const { + return { this->value }; + } + + static const ApplicationId Start; + static const ApplicationId End; + }; + + constexpr inline const ApplicationId InvalidApplicationId = {}; + + inline constexpr const ApplicationId ApplicationId::Start = { 0x0100000000010000ul }; + inline constexpr const ApplicationId ApplicationId::End = { 0x01FFFFFFFFFFFFFFul }; + + inline constexpr bool IsApplicationId(const ProgramId &program_id) { + return ApplicationId::Start <= program_id && program_id <= ApplicationId::End; + } + + inline constexpr bool IsApplicationId(const ApplicationId &id) { + return true; + } + + struct ApplicationGroupId { + u64 value; + }; + + struct PatchId { + u64 value; + + constexpr operator ProgramId() const { + return { this->value }; + } + }; + + struct PatchGroupId { + u64 value; + }; + + struct AddOnContentId { + u64 value; + + constexpr operator DataId() const { + return { this->value }; + } + }; + + struct DeltaId { + u64 value; + + constexpr operator ProgramId() const { + return { this->value }; + } + }; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_key.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_key.hpp new file mode 100644 index 000000000..1ee1aa2f1 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_key.hpp @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include +#include +#include + +namespace ams::ncm { + + enum class ContentInstallType : u8 { + Full = 0, + FragmentOnly = 1, + Unknown = 7, + }; + + struct ContentMetaKey { + u64 id; + u32 version; + ContentMetaType type; + ContentInstallType install_type; + u8 padding[2]; + + bool operator<(const ContentMetaKey& other) const { + if (this->id < other.id) { + return true; + } else if (this->id != other.id) { + return false; + } + + if (this->version < other.version) { + return true; + } else if (this->version != other.version) { + return false; + } + + if (this->type < other.type) { + return true; + } else if (this->type != other.type) { + return false; + } + + return this->install_type < other.install_type; + } + + constexpr bool operator==(const ContentMetaKey& other) const { + return this->id == other.id && + this->version == other.version && + this->type == other.type && + this->install_type == other.install_type; + } + + constexpr bool operator!=(const ContentMetaKey& other) const { + return !(*this == other); + } + + static constexpr ContentMetaKey MakeUnknownType(u64 id, u32 version) { + return { .id = id, .version = version, .type = ContentMetaType::Unknown }; + } + + static constexpr ContentMetaKey Make(u64 id, u32 version, ContentMetaType type) { + return { .id = id, .version = version, .type = type }; + } + + static constexpr ContentMetaKey Make(u64 id, u32 version, ContentMetaType type, ContentInstallType install_type) { + return { .id = id, .version = version, .type = type, .install_type = install_type }; + } + + static constexpr ContentMetaKey Make(SystemProgramId id, u32 version) { + return { .id = id.value, .version = version, .type = ContentMetaType::SystemProgram }; + } + + static constexpr ContentMetaKey Make(SystemDataId id, u32 version) { + return { .id = id.value, .version = version, .type = ContentMetaType::SystemData }; + } + + static constexpr ContentMetaKey Make(SystemUpdateId id, u32 version) { + return { .id = id.value, .version = version, .type = ContentMetaType::SystemUpdate }; + } + + static constexpr ContentMetaKey Make(ApplicationId id, u32 version) { + return { .id = id.value, .version = version, .type = ContentMetaType::Application }; + } + + static constexpr ContentMetaKey Make(PatchId id, u32 version) { + return { .id = id.value, .version = version, .type = ContentMetaType::Patch }; + } + + static constexpr ContentMetaKey Make(PatchId id, u32 version, ContentInstallType install_type) { + return { .id = id.value, .version = version, .type = ContentMetaType::Patch, .install_type = install_type }; + } + + static constexpr ContentMetaKey Make(DeltaId id, u32 version) { + return { .id = id.value, .version = version, .type = ContentMetaType::Delta }; + } + }; + + static_assert(sizeof(ContentMetaKey) == 0x10); + + struct ApplicationContentMetaKey { + ContentMetaKey key; + ncm::ApplicationId application_id; + }; + + static_assert(sizeof(ApplicationContentMetaKey) == 0x18); + + struct StorageContentMetaKey { + ContentMetaKey key; + StorageId storage_id; + u8 reserved[7]; + + constexpr bool operator==(StorageContentMetaKey &rhs) const { + return this->key == rhs.key && this->storage_id == rhs.storage_id; + } + + constexpr bool operator<(StorageContentMetaKey &rhs) const { + return this->key == rhs.key ? this->storage_id < rhs.storage_id : this->key < rhs.key; + } + }; + static_assert(sizeof(StorageContentMetaKey) == 0x18); + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_type.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_type.hpp new file mode 100644 index 000000000..20252c844 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_type.hpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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::ncm { + + enum class ContentMetaType : u8 { + Unknown = 0x0, + SystemProgram = 0x1, + SystemData = 0x2, + SystemUpdate = 0x3, + BootImagePackage = 0x4, + BootImagePackageSafe = 0x5, + Application = 0x80, + Patch = 0x81, + AddOnContent = 0x82, + Delta = 0x83, + }; + + const char *GetContentMetaTypeString(ContentMetaType type); + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp index bd6e51f76..b776399d8 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp @@ -14,7 +14,6 @@ * along with this program. If not, see . */ #pragma once -#include #include namespace ams::ncm { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_type.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_type.hpp new file mode 100644 index 000000000..1aa71c6a7 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_type.hpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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::ncm { + + enum class ContentType : u8 { + Meta = 0, + Program = 1, + Data = 2, + Control = 3, + HtmlDocument = 4, + LegalInformation = 5, + DeltaFragment = 6, + }; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_data_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_data_id.hpp new file mode 100644 index 000000000..02d926be3 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_data_id.hpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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::ncm { + + struct DataId { + u64 value; + + static const DataId Invalid; + }; + + inline constexpr bool operator==(const DataId &lhs, const DataId &rhs) { + return lhs.value == rhs.value; + } + + inline constexpr bool operator!=(const DataId &lhs, const DataId &rhs) { + return lhs.value != rhs.value; + } + + inline constexpr bool operator<(const DataId &lhs, const DataId &rhs) { + return lhs.value < rhs.value; + } + + inline constexpr bool operator<=(const DataId &lhs, const DataId &rhs) { + return lhs.value <= rhs.value; + } + + inline constexpr bool operator>(const DataId &lhs, const DataId &rhs) { + return lhs.value > rhs.value; + } + + inline constexpr bool operator>=(const DataId &lhs, const DataId &rhs) { + return lhs.value >= rhs.value; + } + + inline constexpr const DataId DataId::Invalid = {}; + inline constexpr const DataId InvalidDataId = DataId::Invalid; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp index 66c6064df..cc3e06b12 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp @@ -14,9 +14,8 @@ * along with this program. If not, see . */ #pragma once -#include #include -#include +#include namespace ams::ncm { @@ -52,14 +51,14 @@ namespace ams::ncm { virtual Result Remove(const ContentMetaKey &key) = 0; virtual Result GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) = 0; virtual Result ListContentInfo(sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) = 0; - virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ProgramId application_id, u64 min, u64 max, ContentInstallType install_type) = 0; - virtual Result GetLatestContentMetaKey(sf::Out out_key, ProgramId id) = 0; + virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) = 0; + virtual Result GetLatestContentMetaKey(sf::Out out_key, u64 id) = 0; virtual Result ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type) = 0; virtual Result Has(sf::Out out, const ContentMetaKey &key) = 0; virtual Result HasAll(sf::Out out, const sf::InArray &keys) = 0; virtual Result GetSize(sf::Out out_size, const ContentMetaKey &key) = 0; virtual Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) = 0; - virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) = 0; + virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) = 0; virtual Result DisableForcibly() = 0; virtual Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) = 0; virtual Result Commit() = 0; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp index cd68010bf..6e40714bd 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp @@ -14,10 +14,11 @@ * along with this program. If not, see . */ #pragma once -#include -#include -#include #include +#include +#include +#include +#include namespace ams::ncm { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_ids.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_ids.hpp new file mode 100644 index 000000000..fe76f948c --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_ids.hpp @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include +#include +#include diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_make_path.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_make_path.hpp index eff6b36df..1babc6db9 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_make_path.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_make_path.hpp @@ -14,10 +14,15 @@ * along with this program. If not, see . */ #pragma once -#include +#include +#include +#include namespace ams::ncm { + using MakeContentPathFunction = void (*)(PathString *out, ContentId content_id, const char *root_path); + using MakePlaceHolderPathFunction = void (*)(PathString *out, PlaceHolderId placeholder_id,const char *root_path); + void MakeFlatContentFilePath(PathString *out, ContentId content_id, const char *root_path); void MakeSha256HierarchicalContentFilePath_ForFat4KCluster(PathString *out, ContentId content_id, const char *root_path); void MakeSha256HierarchicalContentFilePath_ForFat16KCluster(PathString *out, ContentId content_id, const char *root_path); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_path.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_path.hpp index 9179c474c..e3927c9a3 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_path.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_path.hpp @@ -15,10 +15,8 @@ */ #pragma once #include -#include #include #include -#include namespace ams::ncm { @@ -38,9 +36,4 @@ namespace ams::ncm { } }; - using PathString = kvdb::BoundedString; - - using MakeContentPathFunction = void (*)(PathString *out, ContentId content_id, const char *root_path); - using MakePlaceHolderPathFunction = void (*)(PathString *out, PlaceHolderId placeholder_id,const char *root_path); - } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_path_string.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_path_string.hpp new file mode 100644 index 000000000..5ec375421 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_path_string.hpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include + +namespace ams::ncm { + + using PathString = kvdb::BoundedString; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_placeholder_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_placeholder_id.hpp new file mode 100644 index 000000000..9b41a66d1 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_placeholder_id.hpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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::ncm { + + struct alignas(8) PlaceHolderId { + util::Uuid uuid; + + bool operator==(const PlaceHolderId& other) const { + return this->uuid == other.uuid; + } + + bool operator!=(const PlaceHolderId& other) const { + return this->uuid != other.uuid; + } + + bool operator==(const util::Uuid& other) const { + return this->uuid == other; + } + + bool operator!=(const util::Uuid& other) const { + return this->uuid != other; + } + }; + + static_assert(alignof(PlaceHolderId) == 8); + + constexpr inline PlaceHolderId InvalidPlaceHolderId = { util::InvalidUuid }; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_program_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_program_id.hpp new file mode 100644 index 000000000..20923ef52 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_program_id.hpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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::ncm { + + struct ProgramId { + u64 value; + + static const ProgramId Invalid; + + inline explicit operator svc::ProgramId() const { + static_assert(sizeof(value) == sizeof(svc::ProgramId)); + return { this->value }; + } + }; + + inline constexpr bool operator==(const ProgramId &lhs, const ProgramId &rhs) { + return lhs.value == rhs.value; + } + + inline constexpr bool operator!=(const ProgramId &lhs, const ProgramId &rhs) { + return lhs.value != rhs.value; + } + + inline constexpr bool operator<(const ProgramId &lhs, const ProgramId &rhs) { + return lhs.value < rhs.value; + } + + inline constexpr bool operator<=(const ProgramId &lhs, const ProgramId &rhs) { + return lhs.value <= rhs.value; + } + + inline constexpr bool operator>(const ProgramId &lhs, const ProgramId &rhs) { + return lhs.value > rhs.value; + } + + inline constexpr bool operator>=(const ProgramId &lhs, const ProgramId &rhs) { + return lhs.value >= rhs.value; + } + + inline constexpr const ProgramId ProgramId::Invalid = {}; + inline constexpr const ProgramId InvalidProgramId = ProgramId::Invalid; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_program_location.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_program_location.hpp new file mode 100644 index 000000000..3e2e53567 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_program_location.hpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include + +namespace ams::ncm { + + struct ProgramLocation { + ProgramId program_id; + u8 storage_id; + + static constexpr ProgramLocation Make(ProgramId program_id, StorageId storage_id) { + return { .program_id = program_id, .storage_id = static_cast(storage_id), }; + } + }; + static_assert(sizeof(ProgramLocation) == 0x10 && std::is_pod::value); + static_assert(sizeof(ProgramLocation) == sizeof(::NcmProgramLocation) && alignof(ProgramLocation) == alignof(::NcmProgramLocation), "ProgramLocation Libnx Compatibility"); + + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id.hpp new file mode 100644 index 000000000..03b520d94 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id.hpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include + +namespace ams::ncm { + + struct RightsId { + fs::RightsId id; + u8 key_generation; + u8 reserved[7]; + }; + static_assert(sizeof(RightsId) == 0x18); + static_assert(std::is_pod::value); + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp index 70bc60d11..bc41b4a7b 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp @@ -14,7 +14,9 @@ * along with this program. If not, see . */ #pragma once -#include +#include +#include +#include namespace ams::ncm { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_storage_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_storage_id.hpp new file mode 100644 index 000000000..532a79430 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_storage_id.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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::ncm { + + enum class StorageId : u8 { + None = 0, + Host = 1, + GameCard = 2, + BuiltInSystem = 3, + BuiltInUser = 4, + SdCard = 5, + Any = 6, + }; + + constexpr inline bool IsUniqueStorage(StorageId id) { + return id != StorageId::None && id != StorageId::Any; + } + + constexpr inline bool IsInstallableStorage(StorageId id) { + return id == StorageId::BuiltInSystem || id == StorageId::BuiltInUser || id == StorageId::SdCard || id == StorageId::Any; + } + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_system_content_meta_id.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_system_content_meta_id.hpp new file mode 100644 index 000000000..c05ae2a84 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_system_content_meta_id.hpp @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 +#include + +namespace ams::ncm { + + struct SystemProgramId { + u64 value; + + constexpr operator ProgramId() const { + return { this->value }; + } + + static const SystemProgramId Start; + + static const SystemProgramId Fs; + static const SystemProgramId Loader; + static const SystemProgramId Ncm; + static const SystemProgramId Pm; + static const SystemProgramId Sm; + static const SystemProgramId Boot; + static const SystemProgramId Usb; + static const SystemProgramId Tma; + static const SystemProgramId Boot2; + static const SystemProgramId Settings; + static const SystemProgramId Bus; + static const SystemProgramId Bluetooth; + static const SystemProgramId Bcat; + static const SystemProgramId Dmnt; + static const SystemProgramId Friends; + static const SystemProgramId Nifm; + static const SystemProgramId Ptm; + static const SystemProgramId Shell; + static const SystemProgramId BsdSockets; + static const SystemProgramId Hid; + static const SystemProgramId Audio; + static const SystemProgramId LogManager; + static const SystemProgramId Wlan; + static const SystemProgramId Cs; + static const SystemProgramId Ldn; + static const SystemProgramId NvServices; + static const SystemProgramId Pcv; + static const SystemProgramId Ppc; + static const SystemProgramId NvnFlinger; + static const SystemProgramId Pcie; + static const SystemProgramId Account; + static const SystemProgramId Ns; + static const SystemProgramId Nfc; + static const SystemProgramId Psc; + static const SystemProgramId CapSrv; + static const SystemProgramId Am; + static const SystemProgramId Ssl; + static const SystemProgramId Nim; + static const SystemProgramId Cec; + static const SystemProgramId Tspm; + static const SystemProgramId Spl; + static const SystemProgramId Lbl; + static const SystemProgramId Btm; + static const SystemProgramId Erpt; + static const SystemProgramId Time; + static const SystemProgramId Vi; + static const SystemProgramId Pctl; + static const SystemProgramId Npns; + static const SystemProgramId Eupld; + static const SystemProgramId Arp; + static const SystemProgramId Glue; + static const SystemProgramId Eclct; + static const SystemProgramId Es; + static const SystemProgramId Fatal; + static const SystemProgramId Grc; + static const SystemProgramId Creport; + static const SystemProgramId Ro; + static const SystemProgramId Profiler; + static const SystemProgramId Sdb; + static const SystemProgramId Migration; + static const SystemProgramId Jit; + static const SystemProgramId JpegDec; + static const SystemProgramId SafeMode; + static const SystemProgramId Olsc; + static const SystemProgramId Dt; + static const SystemProgramId Nd; + static const SystemProgramId Ngct; + + static const SystemProgramId End; + }; + + struct AtmosphereProgramId { + u64 value; + + constexpr operator SystemProgramId() const { + return { this->value }; + } + + constexpr operator ProgramId() const { + return static_cast(*this); + } + + static const AtmosphereProgramId Mitm; + }; + + inline constexpr const AtmosphereProgramId AtmosphereProgramId::Mitm = { 0x010041544D530000ul }; + + inline constexpr bool IsAtmosphereProgramId(const ProgramId &program_id) { + return program_id == AtmosphereProgramId::Mitm; + } + + inline constexpr bool IsSystemProgramId(const AtmosphereProgramId &program_id) { + return true; + } + + inline constexpr const SystemProgramId SystemProgramId::Start = { 0x0100000000000000ul }; + + inline constexpr const SystemProgramId SystemProgramId::Fs = { 0x0100000000000000ul }; + inline constexpr const SystemProgramId SystemProgramId::Loader = { 0x0100000000000001ul }; + inline constexpr const SystemProgramId SystemProgramId::Ncm = { 0x0100000000000002ul }; + inline constexpr const SystemProgramId SystemProgramId::Pm = { 0x0100000000000003ul }; + inline constexpr const SystemProgramId SystemProgramId::Sm = { 0x0100000000000004ul }; + inline constexpr const SystemProgramId SystemProgramId::Boot = { 0x0100000000000005ul }; + inline constexpr const SystemProgramId SystemProgramId::Usb = { 0x0100000000000006ul }; + inline constexpr const SystemProgramId SystemProgramId::Tma = { 0x0100000000000007ul }; + inline constexpr const SystemProgramId SystemProgramId::Boot2 = { 0x0100000000000008ul }; + inline constexpr const SystemProgramId SystemProgramId::Settings = { 0x0100000000000009ul }; + inline constexpr const SystemProgramId SystemProgramId::Bus = { 0x010000000000000Aul }; + inline constexpr const SystemProgramId SystemProgramId::Bluetooth = { 0x010000000000000Bul }; + inline constexpr const SystemProgramId SystemProgramId::Bcat = { 0x010000000000000Cul }; + inline constexpr const SystemProgramId SystemProgramId::Dmnt = { 0x010000000000000Dul }; + inline constexpr const SystemProgramId SystemProgramId::Friends = { 0x010000000000000Eul }; + inline constexpr const SystemProgramId SystemProgramId::Nifm = { 0x010000000000000Ful }; + inline constexpr const SystemProgramId SystemProgramId::Ptm = { 0x0100000000000010ul }; + inline constexpr const SystemProgramId SystemProgramId::Shell = { 0x0100000000000011ul }; + inline constexpr const SystemProgramId SystemProgramId::BsdSockets = { 0x0100000000000012ul }; + inline constexpr const SystemProgramId SystemProgramId::Hid = { 0x0100000000000013ul }; + inline constexpr const SystemProgramId SystemProgramId::Audio = { 0x0100000000000014ul }; + inline constexpr const SystemProgramId SystemProgramId::LogManager = { 0x0100000000000015ul }; + inline constexpr const SystemProgramId SystemProgramId::Wlan = { 0x0100000000000016ul }; + inline constexpr const SystemProgramId SystemProgramId::Cs = { 0x0100000000000017ul }; + inline constexpr const SystemProgramId SystemProgramId::Ldn = { 0x0100000000000018ul }; + inline constexpr const SystemProgramId SystemProgramId::NvServices = { 0x0100000000000019ul }; + inline constexpr const SystemProgramId SystemProgramId::Pcv = { 0x010000000000001Aul }; + inline constexpr const SystemProgramId SystemProgramId::Ppc = { 0x010000000000001Bul }; + inline constexpr const SystemProgramId SystemProgramId::NvnFlinger = { 0x010000000000001Cul }; + inline constexpr const SystemProgramId SystemProgramId::Pcie = { 0x010000000000001Dul }; + inline constexpr const SystemProgramId SystemProgramId::Account = { 0x010000000000001Eul }; + inline constexpr const SystemProgramId SystemProgramId::Ns = { 0x010000000000001Ful }; + inline constexpr const SystemProgramId SystemProgramId::Nfc = { 0x0100000000000020ul }; + inline constexpr const SystemProgramId SystemProgramId::Psc = { 0x0100000000000021ul }; + inline constexpr const SystemProgramId SystemProgramId::CapSrv = { 0x0100000000000022ul }; + inline constexpr const SystemProgramId SystemProgramId::Am = { 0x0100000000000023ul }; + inline constexpr const SystemProgramId SystemProgramId::Ssl = { 0x0100000000000024ul }; + inline constexpr const SystemProgramId SystemProgramId::Nim = { 0x0100000000000025ul }; + inline constexpr const SystemProgramId SystemProgramId::Cec = { 0x0100000000000026ul }; + inline constexpr const SystemProgramId SystemProgramId::Tspm = { 0x0100000000000027ul }; + inline constexpr const SystemProgramId SystemProgramId::Spl = { 0x0100000000000028ul }; + inline constexpr const SystemProgramId SystemProgramId::Lbl = { 0x0100000000000029ul }; + inline constexpr const SystemProgramId SystemProgramId::Btm = { 0x010000000000002Aul }; + inline constexpr const SystemProgramId SystemProgramId::Erpt = { 0x010000000000002Bul }; + inline constexpr const SystemProgramId SystemProgramId::Time = { 0x010000000000002Cul }; + inline constexpr const SystemProgramId SystemProgramId::Vi = { 0x010000000000002Dul }; + inline constexpr const SystemProgramId SystemProgramId::Pctl = { 0x010000000000002Eul }; + inline constexpr const SystemProgramId SystemProgramId::Npns = { 0x010000000000002Ful }; + inline constexpr const SystemProgramId SystemProgramId::Eupld = { 0x0100000000000030ul }; + inline constexpr const SystemProgramId SystemProgramId::Arp = { 0x0100000000000031ul }; + inline constexpr const SystemProgramId SystemProgramId::Glue = { 0x0100000000000031ul }; + inline constexpr const SystemProgramId SystemProgramId::Eclct = { 0x0100000000000032ul }; + inline constexpr const SystemProgramId SystemProgramId::Es = { 0x0100000000000033ul }; + inline constexpr const SystemProgramId SystemProgramId::Fatal = { 0x0100000000000034ul }; + inline constexpr const SystemProgramId SystemProgramId::Grc = { 0x0100000000000035ul }; + inline constexpr const SystemProgramId SystemProgramId::Creport = { 0x0100000000000036ul }; + inline constexpr const SystemProgramId SystemProgramId::Ro = { 0x0100000000000037ul }; + inline constexpr const SystemProgramId SystemProgramId::Profiler = { 0x0100000000000038ul }; + inline constexpr const SystemProgramId SystemProgramId::Sdb = { 0x0100000000000039ul }; + inline constexpr const SystemProgramId SystemProgramId::Migration = { 0x010000000000003Aul }; + inline constexpr const SystemProgramId SystemProgramId::Jit = { 0x010000000000003Bul }; + inline constexpr const SystemProgramId SystemProgramId::JpegDec = { 0x010000000000003Cul }; + inline constexpr const SystemProgramId SystemProgramId::SafeMode = { 0x010000000000003Dul }; + inline constexpr const SystemProgramId SystemProgramId::Olsc = { 0x010000000000003Eul }; + inline constexpr const SystemProgramId SystemProgramId::Dt = { 0x010000000000003Ful }; + inline constexpr const SystemProgramId SystemProgramId::Nd = { 0x0100000000000040ul }; + inline constexpr const SystemProgramId SystemProgramId::Ngct = { 0x0100000000000041ul }; + + inline constexpr const SystemProgramId SystemProgramId::End = { 0x01000000000007FFul }; + + inline constexpr bool IsSystemProgramId(const ProgramId &program_id) { + return (SystemProgramId::Start <= program_id && program_id <= SystemProgramId::End) || IsAtmosphereProgramId(program_id); + } + + inline constexpr bool IsSystemProgramId(const SystemProgramId &program_id) { + return true; + } + + struct SystemDataId { + u64 value; + + constexpr operator DataId() const { + return { this->value }; + } + + static const SystemDataId Start; + + static const SystemDataId CertStore; + static const SystemDataId ErrorMessage; + static const SystemDataId MiiModel; + static const SystemDataId BrowserDll; + static const SystemDataId Help; + static const SystemDataId SharedFont; + static const SystemDataId NgWord; + static const SystemDataId SsidList; + static const SystemDataId Dictionary; + static const SystemDataId SystemVersion; + static const SystemDataId AvatarImage; + static const SystemDataId LocalNews; + static const SystemDataId Eula; + static const SystemDataId UrlBlackList; + static const SystemDataId TimeZoneBinar; + static const SystemDataId CertStoreCruiser; + static const SystemDataId FontNintendoExtension; + static const SystemDataId FontStandard; + static const SystemDataId FontKorean; + static const SystemDataId FontChineseTraditional; + static const SystemDataId FontChineseSimple; + static const SystemDataId FontBfcpx; + static const SystemDataId SystemUpdate; + + static const SystemDataId FirmwareDebugSettings; + static const SystemDataId BootImagePackage; + static const SystemDataId BootImagePackageSafe; + static const SystemDataId BootImagePackageExFat; + static const SystemDataId BootImagePackageExFatSafe; + static const SystemDataId FatalMessage; + static const SystemDataId ControllerIcon; + static const SystemDataId PlatformConfigIcosa; + static const SystemDataId PlatformConfigCopper; + static const SystemDataId PlatformConfigHoag; + static const SystemDataId ControllerFirmware; + static const SystemDataId NgWord2; + static const SystemDataId PlatformConfigIcosaMariko; + static const SystemDataId ApplicationBlackList; + static const SystemDataId RebootlessSystemUpdateVersion; + static const SystemDataId ContentActionTable; + + static const SystemDataId End; + }; + + inline constexpr const SystemDataId SystemDataId::Start = { 0x0100000000000800ul }; + inline constexpr const SystemDataId SystemDataId::CertStore = { 0x0100000000000800ul }; + inline constexpr const SystemDataId SystemDataId::ErrorMessage = { 0x0100000000000801ul }; + inline constexpr const SystemDataId SystemDataId::MiiModel = { 0x0100000000000802ul }; + inline constexpr const SystemDataId SystemDataId::BrowserDll = { 0x0100000000000803ul }; + inline constexpr const SystemDataId SystemDataId::Help = { 0x0100000000000804ul }; + inline constexpr const SystemDataId SystemDataId::SharedFont = { 0x0100000000000805ul }; + inline constexpr const SystemDataId SystemDataId::NgWord = { 0x0100000000000806ul }; + inline constexpr const SystemDataId SystemDataId::SsidList = { 0x0100000000000807ul }; + inline constexpr const SystemDataId SystemDataId::Dictionary = { 0x0100000000000808ul }; + inline constexpr const SystemDataId SystemDataId::SystemVersion = { 0x0100000000000809ul }; + inline constexpr const SystemDataId SystemDataId::AvatarImage = { 0x010000000000080Aul }; + inline constexpr const SystemDataId SystemDataId::LocalNews = { 0x010000000000080Bul }; + inline constexpr const SystemDataId SystemDataId::Eula = { 0x010000000000080Cul }; + inline constexpr const SystemDataId SystemDataId::UrlBlackList = { 0x010000000000080Dul }; + inline constexpr const SystemDataId SystemDataId::TimeZoneBinar = { 0x010000000000080Eul }; + inline constexpr const SystemDataId SystemDataId::CertStoreCruiser = { 0x010000000000080Ful }; + inline constexpr const SystemDataId SystemDataId::FontNintendoExtension = { 0x0100000000000810ul }; + inline constexpr const SystemDataId SystemDataId::FontStandard = { 0x0100000000000811ul }; + inline constexpr const SystemDataId SystemDataId::FontKorean = { 0x0100000000000812ul }; + inline constexpr const SystemDataId SystemDataId::FontChineseTraditional = { 0x0100000000000813ul }; + inline constexpr const SystemDataId SystemDataId::FontChineseSimple = { 0x0100000000000814ul }; + inline constexpr const SystemDataId SystemDataId::FontBfcpx = { 0x0100000000000815ul }; + inline constexpr const SystemDataId SystemDataId::SystemUpdate = { 0x0100000000000816ul }; + + inline constexpr const SystemDataId SystemDataId::FirmwareDebugSettings = { 0x0100000000000818ul }; + inline constexpr const SystemDataId SystemDataId::BootImagePackage = { 0x0100000000000819ul }; + inline constexpr const SystemDataId SystemDataId::BootImagePackageSafe = { 0x010000000000081Aul }; + inline constexpr const SystemDataId SystemDataId::BootImagePackageExFat = { 0x010000000000081Bul }; + inline constexpr const SystemDataId SystemDataId::BootImagePackageExFatSafe = { 0x010000000000081Cul }; + inline constexpr const SystemDataId SystemDataId::FatalMessage = { 0x010000000000081Dul }; + inline constexpr const SystemDataId SystemDataId::ControllerIcon = { 0x010000000000081Eul }; + inline constexpr const SystemDataId SystemDataId::PlatformConfigIcosa = { 0x010000000000081Ful }; + inline constexpr const SystemDataId SystemDataId::PlatformConfigCopper = { 0x0100000000000820ul }; + inline constexpr const SystemDataId SystemDataId::PlatformConfigHoag = { 0x0100000000000821ul }; + inline constexpr const SystemDataId SystemDataId::ControllerFirmware = { 0x0100000000000822ul }; + inline constexpr const SystemDataId SystemDataId::NgWord2 = { 0x0100000000000823ul }; + inline constexpr const SystemDataId SystemDataId::PlatformConfigIcosaMariko = { 0x0100000000000824ul }; + inline constexpr const SystemDataId SystemDataId::ApplicationBlackList = { 0x0100000000000825ul }; + inline constexpr const SystemDataId SystemDataId::RebootlessSystemUpdateVersion = { 0x0100000000000826ul }; + inline constexpr const SystemDataId SystemDataId::ContentActionTable = { 0x0100000000000827ul }; + + inline constexpr const SystemDataId SystemDataId::End = { 0x0100000000000FFFul }; + + inline constexpr bool IsSystemDataId(const DataId &data_id) { + return SystemDataId::Start <= data_id && data_id <= SystemDataId::End; + } + + inline constexpr bool IsSystemDataId(const SystemDataId &data_id) { + return true; + } + + struct SystemUpdateId { + u64 value; + + constexpr operator DataId() const { + return { this->value }; + } + }; + + struct SystemAppletId { + u64 value; + + constexpr operator ProgramId() const { + return { this->value }; + } + + static const SystemAppletId Start; + + static const SystemAppletId Qlaunch; + static const SystemAppletId Auth; + static const SystemAppletId Cabinet; + static const SystemAppletId Controller; + static const SystemAppletId DataErase; + static const SystemAppletId Error; + static const SystemAppletId NetConnect; + static const SystemAppletId PlayerSelect; + static const SystemAppletId Swkbd; + static const SystemAppletId MiiEdit; + static const SystemAppletId Web; + static const SystemAppletId Shop; + static const SystemAppletId OverlayDisp; + static const SystemAppletId PhotoViewer; + static const SystemAppletId Set; + static const SystemAppletId OfflineWeb; + static const SystemAppletId LoginShare; + static const SystemAppletId WifiWebAuth; + static const SystemAppletId Starter; + static const SystemAppletId MyPage; + static const SystemAppletId PlayReport; + static const SystemAppletId MaintenanceMenu; + + static const SystemAppletId Gift; + static const SystemAppletId DummyShop; + static const SystemAppletId UserMigration; + static const SystemAppletId Encounter; + + static const SystemAppletId Story; + + static const SystemAppletId End; + }; + + inline constexpr const SystemAppletId SystemAppletId::Start = { 0x0100000000001000ul }; + + inline constexpr const SystemAppletId SystemAppletId::Qlaunch = { 0x0100000000001000ul }; + inline constexpr const SystemAppletId SystemAppletId::Auth = { 0x0100000000001001ul }; + inline constexpr const SystemAppletId SystemAppletId::Cabinet = { 0x0100000000001002ul }; + inline constexpr const SystemAppletId SystemAppletId::Controller = { 0x0100000000001003ul }; + inline constexpr const SystemAppletId SystemAppletId::DataErase = { 0x0100000000001004ul }; + inline constexpr const SystemAppletId SystemAppletId::Error = { 0x0100000000001005ul }; + inline constexpr const SystemAppletId SystemAppletId::NetConnect = { 0x0100000000001006ul }; + inline constexpr const SystemAppletId SystemAppletId::PlayerSelect = { 0x0100000000001007ul }; + inline constexpr const SystemAppletId SystemAppletId::Swkbd = { 0x0100000000001008ul }; + inline constexpr const SystemAppletId SystemAppletId::MiiEdit = { 0x0100000000001009ul }; + inline constexpr const SystemAppletId SystemAppletId::Web = { 0x010000000000100Aul }; + inline constexpr const SystemAppletId SystemAppletId::Shop = { 0x010000000000100Bul }; + inline constexpr const SystemAppletId SystemAppletId::OverlayDisp = { 0x010000000000100Cul }; + inline constexpr const SystemAppletId SystemAppletId::PhotoViewer = { 0x010000000000100Dul }; + inline constexpr const SystemAppletId SystemAppletId::Set = { 0x010000000000100Eul }; + inline constexpr const SystemAppletId SystemAppletId::OfflineWeb = { 0x010000000000100Ful }; + inline constexpr const SystemAppletId SystemAppletId::LoginShare = { 0x0100000000001010ul }; + inline constexpr const SystemAppletId SystemAppletId::WifiWebAuth = { 0x0100000000001011ul }; + inline constexpr const SystemAppletId SystemAppletId::Starter = { 0x0100000000001012ul }; + inline constexpr const SystemAppletId SystemAppletId::MyPage = { 0x0100000000001013ul }; + inline constexpr const SystemAppletId SystemAppletId::PlayReport = { 0x0100000000001014ul }; + inline constexpr const SystemAppletId SystemAppletId::MaintenanceMenu = { 0x0100000000001015ul }; + + inline constexpr const SystemAppletId SystemAppletId::Gift = { 0x010000000000101Aul }; + inline constexpr const SystemAppletId SystemAppletId::DummyShop = { 0x010000000000101Bul }; + inline constexpr const SystemAppletId SystemAppletId::UserMigration = { 0x010000000000101Cul }; + inline constexpr const SystemAppletId SystemAppletId::Encounter = { 0x010000000000101Dul }; + + inline constexpr const SystemAppletId SystemAppletId::Story = { 0x0100000000001020ul }; + + inline constexpr const SystemAppletId SystemAppletId::End = { 0x0100000000001FFFul }; + + inline constexpr bool IsSystemAppletId(const ProgramId &program_id) { + return SystemAppletId::Start <= program_id && program_id <= SystemAppletId::End; + } + + inline constexpr bool IsSystemAppletId(const SystemAppletId &program_id) { + return true; + } + + struct LibraryAppletId { + u64 value; + + constexpr operator SystemAppletId() const { + return { this->value }; + } + + constexpr operator ProgramId() const { + return static_cast(*this); + } + + static const LibraryAppletId Auth; + static const LibraryAppletId Controller; + static const LibraryAppletId Error; + static const LibraryAppletId PlayerSelect; + static const LibraryAppletId Swkbd; + static const LibraryAppletId Web; + static const LibraryAppletId Shop; + static const LibraryAppletId PhotoViewer; + static const LibraryAppletId OfflineWeb; + static const LibraryAppletId LoginShare; + static const LibraryAppletId WifiWebAuth; + static const LibraryAppletId MyPage; + + }; + + inline constexpr const LibraryAppletId LibraryAppletId::Auth = { SystemAppletId::Auth.value }; + inline constexpr const LibraryAppletId LibraryAppletId::Controller = { SystemAppletId::Controller.value }; + inline constexpr const LibraryAppletId LibraryAppletId::Error = { SystemAppletId::Error.value }; + inline constexpr const LibraryAppletId LibraryAppletId::PlayerSelect = { SystemAppletId::PlayerSelect.value }; + inline constexpr const LibraryAppletId LibraryAppletId::Swkbd = { SystemAppletId::Swkbd.value }; + inline constexpr const LibraryAppletId LibraryAppletId::Web = { SystemAppletId::Web.value }; + inline constexpr const LibraryAppletId LibraryAppletId::Shop = { SystemAppletId::Shop.value }; + inline constexpr const LibraryAppletId LibraryAppletId::PhotoViewer = { SystemAppletId::PhotoViewer.value }; + inline constexpr const LibraryAppletId LibraryAppletId::OfflineWeb = { SystemAppletId::OfflineWeb.value }; + inline constexpr const LibraryAppletId LibraryAppletId::LoginShare = { SystemAppletId::LoginShare.value }; + inline constexpr const LibraryAppletId LibraryAppletId::WifiWebAuth = { SystemAppletId::WifiWebAuth.value }; + inline constexpr const LibraryAppletId LibraryAppletId::MyPage = { SystemAppletId::MyPage.value }; + + inline constexpr bool IsLibraryAppletId(const ProgramId &id) { + return id == LibraryAppletId::Auth || + id == LibraryAppletId::Controller || + id == LibraryAppletId::Error || + id == LibraryAppletId::PlayerSelect || + id == LibraryAppletId::Swkbd || + id == LibraryAppletId::Web || + id == LibraryAppletId::Shop || + id == LibraryAppletId::PhotoViewer || + id == LibraryAppletId::OfflineWeb || + id == LibraryAppletId::LoginShare || + id == LibraryAppletId::WifiWebAuth || + id == LibraryAppletId::MyPage; + } + + inline constexpr bool IsLibraryAppletId(const LibraryAppletId &id) { + return true; + } + + struct WebAppletId { + u64 value; + + constexpr operator LibraryAppletId() const { + return { this->value }; + } + + constexpr operator SystemAppletId() const { + return static_cast(*this); + } + + constexpr operator ProgramId() const { + return static_cast(*this); + } + + static const WebAppletId Web; + static const WebAppletId Shop; + static const WebAppletId OfflineWeb; + static const WebAppletId LoginShare; + static const WebAppletId WifiWebAuth; + }; + + inline constexpr const WebAppletId WebAppletId::Web = { LibraryAppletId::Web.value }; + inline constexpr const WebAppletId WebAppletId::Shop = { LibraryAppletId::Shop.value }; + inline constexpr const WebAppletId WebAppletId::OfflineWeb = { LibraryAppletId::OfflineWeb.value }; + inline constexpr const WebAppletId WebAppletId::LoginShare = { LibraryAppletId::LoginShare.value }; + inline constexpr const WebAppletId WebAppletId::WifiWebAuth = { LibraryAppletId::WifiWebAuth.value }; + + inline constexpr bool IsWebAppletId(const ProgramId &id) { + return id == WebAppletId::Web || + id == WebAppletId::Shop || + id == WebAppletId::OfflineWeb || + id == WebAppletId::LoginShare || + id == WebAppletId::WifiWebAuth; + } + + inline constexpr bool IsWebAppletId(const WebAppletId &id) { + return true; + } + + struct SystemApplicationId { + u64 value; + + constexpr operator ProgramId() const { + return { this->value }; + } + }; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_types.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_types.hpp deleted file mode 100644 index ec3c79320..000000000 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_types.hpp +++ /dev/null @@ -1,670 +0,0 @@ -/* - * Copyright (c) 2018-2020 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 -#include - -namespace ams::ncm { - - enum class ContentMetaType : u8 { - Unknown = 0x0, - SystemProgram = 0x1, - SystemData = 0x2, - SystemUpdate = 0x3, - BootImagePackage = 0x4, - BootImagePackageSafe = 0x5, - Application = 0x80, - Patch = 0x81, - AddOnContent = 0x82, - Delta = 0x83, - }; - - enum class ContentType : u8 { - Meta = 0, - Program = 1, - Data = 2, - Control = 3, - HtmlDocument = 4, - LegalInformation = 5, - DeltaFragment = 6, - }; - - enum ContentMetaAttribute : u8 { - ContentMetaAttribute_None = (0 << 0), - ContentMetaAttribute_IncludesExFatDriver = (1 << 0), - ContentMetaAttribute_Rebootless = (1 << 1), - }; - - enum class ContentInstallType : u8 { - Full = 0, - FragmentOnly = 1, - Unknown = 7, - }; - - struct alignas(8) PlaceHolderId { - util::Uuid uuid; - - bool operator==(const PlaceHolderId& other) const { - return this->uuid == other.uuid; - } - - bool operator!=(const PlaceHolderId& other) const { - return this->uuid != other.uuid; - } - - bool operator==(const util::Uuid& other) const { - return this->uuid == other; - } - - bool operator!=(const util::Uuid& other) const { - return this->uuid != other; - } - }; - - static_assert(alignof(PlaceHolderId) == 8, "PlaceHolderId definition!"); - - struct alignas(4) ContentId { - util::Uuid uuid; - - bool operator==(const ContentId& other) const { - return this->uuid == other.uuid; - } - - bool operator!=(const ContentId& other) const { - return this->uuid != other.uuid; - } - - bool operator==(const util::Uuid& other) const { - return this->uuid == other; - } - - bool operator!=(const util::Uuid& other) const { - return this->uuid != other; - } - }; - - static_assert(alignof(ContentId) == 4, "ContentId definition!"); - - constexpr inline PlaceHolderId InvalidPlaceHolderId = { util::InvalidUuid }; - constexpr inline ContentId InvalidContentId = { util::InvalidUuid }; - - struct ContentInfo { - ContentId content_id; - u32 size_low; - u16 size_high; - ContentType content_type; - u8 id_offset; - - constexpr const ContentId &GetId() const { - return this->content_id; - } - - constexpr u64 GetSize() const { - return (static_cast(this->size_high) << 32) | static_cast(this->size_low); - } - - constexpr ContentType GetType() const { - return this->content_type; - } - - constexpr u8 GetIdOffset() const { - return this->id_offset; - } - - static constexpr ContentInfo Make(ContentId id, u64 size, ContentType type, u8 id_ofs) { - const u32 size_low = size & 0xFFFFFFFFu; - const u16 size_high = static_cast(size >> 32); - return { - .content_id = id, - .size_low = size_low, - .size_high = size_high, - .content_type = type, - .id_offset = id_ofs, - }; - } - }; - - static_assert(sizeof(std::is_pod::value)); - static_assert(sizeof(ContentInfo) == 0x18); - - /* Storage IDs. */ - enum class StorageId : u8 { - #define DEFINE_ENUM_MEMBER(nm) nm = NcmStorageId_##nm - DEFINE_ENUM_MEMBER(None), - DEFINE_ENUM_MEMBER(Host), - DEFINE_ENUM_MEMBER(GameCard), - DEFINE_ENUM_MEMBER(BuiltInSystem), - DEFINE_ENUM_MEMBER(BuiltInUser), - DEFINE_ENUM_MEMBER(SdCard), - DEFINE_ENUM_MEMBER(Any), - #undef DEFINE_ENUM_MEMBER - }; - - constexpr inline bool IsUniqueStorage(StorageId id) { - return id != StorageId::None && id != StorageId::Any; - } - - /* Program IDs (Formerly: Title IDs). */ - struct ProgramId { - svc::ProgramId value; - - inline explicit operator svc::ProgramId() const { - return this->value; - } - - /* Invalid Program ID. */ - static const ProgramId Invalid; - - /* System Modules. */ - static const ProgramId SystemStart; - - static const ProgramId Fs; - static const ProgramId Loader; - static const ProgramId Ncm; - static const ProgramId Pm; - static const ProgramId Sm; - static const ProgramId Boot; - static const ProgramId Usb; - static const ProgramId Tma; - static const ProgramId Boot2; - static const ProgramId Settings; - static const ProgramId Bus; - static const ProgramId Bluetooth; - static const ProgramId Bcat; - static const ProgramId Dmnt; - static const ProgramId Friends; - static const ProgramId Nifm; - static const ProgramId Ptm; - static const ProgramId Shell; - static const ProgramId BsdSockets; - static const ProgramId Hid; - static const ProgramId Audio; - static const ProgramId LogManager; - static const ProgramId Wlan; - static const ProgramId Cs; - static const ProgramId Ldn; - static const ProgramId NvServices; - static const ProgramId Pcv; - static const ProgramId Ppc; - static const ProgramId NvnFlinger; - static const ProgramId Pcie; - static const ProgramId Account; - static const ProgramId Ns; - static const ProgramId Nfc; - static const ProgramId Psc; - static const ProgramId CapSrv; - static const ProgramId Am; - static const ProgramId Ssl; - static const ProgramId Nim; - static const ProgramId Cec; - static const ProgramId Tspm; - static const ProgramId Spl; - static const ProgramId Lbl; - static const ProgramId Btm; - static const ProgramId Erpt; - static const ProgramId Time; - static const ProgramId Vi; - static const ProgramId Pctl; - static const ProgramId Npns; - static const ProgramId Eupld; - static const ProgramId Arp; - static const ProgramId Glue; - static const ProgramId Eclct; - static const ProgramId Es; - static const ProgramId Fatal; - static const ProgramId Grc; - static const ProgramId Creport; - static const ProgramId Ro; - static const ProgramId Profiler; - static const ProgramId Sdb; - static const ProgramId Migration; - static const ProgramId Jit; - static const ProgramId JpegDec; - static const ProgramId SafeMode; - static const ProgramId Olsc; - static const ProgramId Dt; - static const ProgramId Nd; - static const ProgramId Ngct; - - static const ProgramId SystemEnd; - - /* System Data Archives. */ - static const ProgramId ArchiveStart; - static const ProgramId ArchiveCertStore; - static const ProgramId ArchiveErrorMessage; - static const ProgramId ArchiveMiiModel; - static const ProgramId ArchiveBrowserDll; - static const ProgramId ArchiveHelp; - static const ProgramId ArchiveSharedFont; - static const ProgramId ArchiveNgWord; - static const ProgramId ArchiveSsidList; - static const ProgramId ArchiveDictionary; - static const ProgramId ArchiveSystemVersion; - static const ProgramId ArchiveAvatarImage; - static const ProgramId ArchiveLocalNews; - static const ProgramId ArchiveEula; - static const ProgramId ArchiveUrlBlackList; - static const ProgramId ArchiveTimeZoneBinar; - static const ProgramId ArchiveCertStoreCruiser; - static const ProgramId ArchiveFontNintendoExtension; - static const ProgramId ArchiveFontStandard; - static const ProgramId ArchiveFontKorean; - static const ProgramId ArchiveFontChineseTraditional; - static const ProgramId ArchiveFontChineseSimple; - static const ProgramId ArchiveFontBfcpx; - static const ProgramId ArchiveSystemUpdate; - - static const ProgramId ArchiveFirmwareDebugSettings; - static const ProgramId ArchiveBootImagePackage; - static const ProgramId ArchiveBootImagePackageSafe; - static const ProgramId ArchiveBootImagePackageExFat; - static const ProgramId ArchiveBootImagePackageExFatSafe; - static const ProgramId ArchiveFatalMessage; - static const ProgramId ArchiveControllerIcon; - static const ProgramId ArchivePlatformConfigIcosa; - static const ProgramId ArchivePlatformConfigCopper; - static const ProgramId ArchivePlatformConfigHoag; - static const ProgramId ArchiveControllerFirmware; - static const ProgramId ArchiveNgWord2; - static const ProgramId ArchivePlatformConfigIcosaMariko; - static const ProgramId ArchiveApplicationBlackList; - static const ProgramId ArchiveRebootlessSystemUpdateVersion; - static const ProgramId ArchiveContentActionTable; - - static const ProgramId ArchiveEnd; - - /* System Applets. */ - static const ProgramId AppletStart; - - static const ProgramId AppletQlaunch; - static const ProgramId AppletAuth; - static const ProgramId AppletCabinet; - static const ProgramId AppletController; - static const ProgramId AppletDataErase; - static const ProgramId AppletError; - static const ProgramId AppletNetConnect; - static const ProgramId AppletPlayerSelect; - static const ProgramId AppletSwkbd; - static const ProgramId AppletMiiEdit; - static const ProgramId AppletWeb; - static const ProgramId AppletShop; - static const ProgramId AppletOverlayDisp; - static const ProgramId AppletPhotoViewer; - static const ProgramId AppletSet; - static const ProgramId AppletOfflineWeb; - static const ProgramId AppletLoginShare; - static const ProgramId AppletWifiWebAuth; - static const ProgramId AppletStarter; - static const ProgramId AppletMyPage; - static const ProgramId AppletPlayReport; - static const ProgramId AppletMaintenanceMenu; - - static const ProgramId AppletGift; - static const ProgramId AppletDummyShop; - static const ProgramId AppletUserMigration; - static const ProgramId AppletEncounter; - - static const ProgramId AppletStory; - - static const ProgramId AppletEnd; - - /* Debug Applets. */ - - /* Debug Modules. */ - - /* Factory Setup. */ - - /* Applications. */ - static const ProgramId ApplicationStart; - static const ProgramId ApplicationEnd; - - /* Atmosphere Extensions. */ - static const ProgramId AtmosphereMitm; - }; - - /* Invalid Program ID. */ - inline constexpr const ProgramId ProgramId::Invalid = {}; - - inline constexpr const ProgramId InvalidProgramId = ProgramId::Invalid; - - /* System Modules. */ - inline constexpr const ProgramId ProgramId::SystemStart = { 0x0100000000000000ul }; - - inline constexpr const ProgramId ProgramId::Fs = { 0x0100000000000000ul }; - inline constexpr const ProgramId ProgramId::Loader = { 0x0100000000000001ul }; - inline constexpr const ProgramId ProgramId::Ncm = { 0x0100000000000002ul }; - inline constexpr const ProgramId ProgramId::Pm = { 0x0100000000000003ul }; - inline constexpr const ProgramId ProgramId::Sm = { 0x0100000000000004ul }; - inline constexpr const ProgramId ProgramId::Boot = { 0x0100000000000005ul }; - inline constexpr const ProgramId ProgramId::Usb = { 0x0100000000000006ul }; - inline constexpr const ProgramId ProgramId::Tma = { 0x0100000000000007ul }; - inline constexpr const ProgramId ProgramId::Boot2 = { 0x0100000000000008ul }; - inline constexpr const ProgramId ProgramId::Settings = { 0x0100000000000009ul }; - inline constexpr const ProgramId ProgramId::Bus = { 0x010000000000000Aul }; - inline constexpr const ProgramId ProgramId::Bluetooth = { 0x010000000000000Bul }; - inline constexpr const ProgramId ProgramId::Bcat = { 0x010000000000000Cul }; - inline constexpr const ProgramId ProgramId::Dmnt = { 0x010000000000000Dul }; - inline constexpr const ProgramId ProgramId::Friends = { 0x010000000000000Eul }; - inline constexpr const ProgramId ProgramId::Nifm = { 0x010000000000000Ful }; - inline constexpr const ProgramId ProgramId::Ptm = { 0x0100000000000010ul }; - inline constexpr const ProgramId ProgramId::Shell = { 0x0100000000000011ul }; - inline constexpr const ProgramId ProgramId::BsdSockets = { 0x0100000000000012ul }; - inline constexpr const ProgramId ProgramId::Hid = { 0x0100000000000013ul }; - inline constexpr const ProgramId ProgramId::Audio = { 0x0100000000000014ul }; - inline constexpr const ProgramId ProgramId::LogManager = { 0x0100000000000015ul }; - inline constexpr const ProgramId ProgramId::Wlan = { 0x0100000000000016ul }; - inline constexpr const ProgramId ProgramId::Cs = { 0x0100000000000017ul }; - inline constexpr const ProgramId ProgramId::Ldn = { 0x0100000000000018ul }; - inline constexpr const ProgramId ProgramId::NvServices = { 0x0100000000000019ul }; - inline constexpr const ProgramId ProgramId::Pcv = { 0x010000000000001Aul }; - inline constexpr const ProgramId ProgramId::Ppc = { 0x010000000000001Bul }; - inline constexpr const ProgramId ProgramId::NvnFlinger = { 0x010000000000001Cul }; - inline constexpr const ProgramId ProgramId::Pcie = { 0x010000000000001Dul }; - inline constexpr const ProgramId ProgramId::Account = { 0x010000000000001Eul }; - inline constexpr const ProgramId ProgramId::Ns = { 0x010000000000001Ful }; - inline constexpr const ProgramId ProgramId::Nfc = { 0x0100000000000020ul }; - inline constexpr const ProgramId ProgramId::Psc = { 0x0100000000000021ul }; - inline constexpr const ProgramId ProgramId::CapSrv = { 0x0100000000000022ul }; - inline constexpr const ProgramId ProgramId::Am = { 0x0100000000000023ul }; - inline constexpr const ProgramId ProgramId::Ssl = { 0x0100000000000024ul }; - inline constexpr const ProgramId ProgramId::Nim = { 0x0100000000000025ul }; - inline constexpr const ProgramId ProgramId::Cec = { 0x0100000000000026ul }; - inline constexpr const ProgramId ProgramId::Tspm = { 0x0100000000000027ul }; - inline constexpr const ProgramId ProgramId::Spl = { 0x0100000000000028ul }; - inline constexpr const ProgramId ProgramId::Lbl = { 0x0100000000000029ul }; - inline constexpr const ProgramId ProgramId::Btm = { 0x010000000000002Aul }; - inline constexpr const ProgramId ProgramId::Erpt = { 0x010000000000002Bul }; - inline constexpr const ProgramId ProgramId::Time = { 0x010000000000002Cul }; - inline constexpr const ProgramId ProgramId::Vi = { 0x010000000000002Dul }; - inline constexpr const ProgramId ProgramId::Pctl = { 0x010000000000002Eul }; - inline constexpr const ProgramId ProgramId::Npns = { 0x010000000000002Ful }; - inline constexpr const ProgramId ProgramId::Eupld = { 0x0100000000000030ul }; - inline constexpr const ProgramId ProgramId::Arp = { 0x0100000000000031ul }; - inline constexpr const ProgramId ProgramId::Glue = { 0x0100000000000031ul }; - inline constexpr const ProgramId ProgramId::Eclct = { 0x0100000000000032ul }; - inline constexpr const ProgramId ProgramId::Es = { 0x0100000000000033ul }; - inline constexpr const ProgramId ProgramId::Fatal = { 0x0100000000000034ul }; - inline constexpr const ProgramId ProgramId::Grc = { 0x0100000000000035ul }; - inline constexpr const ProgramId ProgramId::Creport = { 0x0100000000000036ul }; - inline constexpr const ProgramId ProgramId::Ro = { 0x0100000000000037ul }; - inline constexpr const ProgramId ProgramId::Profiler = { 0x0100000000000038ul }; - inline constexpr const ProgramId ProgramId::Sdb = { 0x0100000000000039ul }; - inline constexpr const ProgramId ProgramId::Migration = { 0x010000000000003Aul }; - inline constexpr const ProgramId ProgramId::Jit = { 0x010000000000003Bul }; - inline constexpr const ProgramId ProgramId::JpegDec = { 0x010000000000003Cul }; - inline constexpr const ProgramId ProgramId::SafeMode = { 0x010000000000003Dul }; - inline constexpr const ProgramId ProgramId::Olsc = { 0x010000000000003Eul }; - inline constexpr const ProgramId ProgramId::Dt = { 0x010000000000003Ful }; - inline constexpr const ProgramId ProgramId::Nd = { 0x0100000000000040ul }; - inline constexpr const ProgramId ProgramId::Ngct = { 0x0100000000000041ul }; - - inline constexpr const ProgramId ProgramId::SystemEnd = { 0x01000000000007FFul }; - - /* System Data Archives. */ - inline constexpr const ProgramId ProgramId::ArchiveStart = { 0x0100000000000800ul }; - inline constexpr const ProgramId ProgramId::ArchiveCertStore = { 0x0100000000000800ul }; - inline constexpr const ProgramId ProgramId::ArchiveErrorMessage = { 0x0100000000000801ul }; - inline constexpr const ProgramId ProgramId::ArchiveMiiModel = { 0x0100000000000802ul }; - inline constexpr const ProgramId ProgramId::ArchiveBrowserDll = { 0x0100000000000803ul }; - inline constexpr const ProgramId ProgramId::ArchiveHelp = { 0x0100000000000804ul }; - inline constexpr const ProgramId ProgramId::ArchiveSharedFont = { 0x0100000000000805ul }; - inline constexpr const ProgramId ProgramId::ArchiveNgWord = { 0x0100000000000806ul }; - inline constexpr const ProgramId ProgramId::ArchiveSsidList = { 0x0100000000000807ul }; - inline constexpr const ProgramId ProgramId::ArchiveDictionary = { 0x0100000000000808ul }; - inline constexpr const ProgramId ProgramId::ArchiveSystemVersion = { 0x0100000000000809ul }; - inline constexpr const ProgramId ProgramId::ArchiveAvatarImage = { 0x010000000000080Aul }; - inline constexpr const ProgramId ProgramId::ArchiveLocalNews = { 0x010000000000080Bul }; - inline constexpr const ProgramId ProgramId::ArchiveEula = { 0x010000000000080Cul }; - inline constexpr const ProgramId ProgramId::ArchiveUrlBlackList = { 0x010000000000080Dul }; - inline constexpr const ProgramId ProgramId::ArchiveTimeZoneBinar = { 0x010000000000080Eul }; - inline constexpr const ProgramId ProgramId::ArchiveCertStoreCruiser = { 0x010000000000080Ful }; - inline constexpr const ProgramId ProgramId::ArchiveFontNintendoExtension = { 0x0100000000000810ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontStandard = { 0x0100000000000811ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontKorean = { 0x0100000000000812ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontChineseTraditional = { 0x0100000000000813ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontChineseSimple = { 0x0100000000000814ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontBfcpx = { 0x0100000000000815ul }; - inline constexpr const ProgramId ProgramId::ArchiveSystemUpdate = { 0x0100000000000816ul }; - - inline constexpr const ProgramId ProgramId::ArchiveFirmwareDebugSettings = { 0x0100000000000818ul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackage = { 0x0100000000000819ul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackageSafe = { 0x010000000000081Aul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackageExFat = { 0x010000000000081Bul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackageExFatSafe = { 0x010000000000081Cul }; - inline constexpr const ProgramId ProgramId::ArchiveFatalMessage = { 0x010000000000081Dul }; - inline constexpr const ProgramId ProgramId::ArchiveControllerIcon = { 0x010000000000081Eul }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigIcosa = { 0x010000000000081Ful }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigCopper = { 0x0100000000000820ul }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigHoag = { 0x0100000000000821ul }; - inline constexpr const ProgramId ProgramId::ArchiveControllerFirmware = { 0x0100000000000822ul }; - inline constexpr const ProgramId ProgramId::ArchiveNgWord2 = { 0x0100000000000823ul }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigIcosaMariko = { 0x0100000000000824ul }; - inline constexpr const ProgramId ProgramId::ArchiveApplicationBlackList = { 0x0100000000000825ul }; - inline constexpr const ProgramId ProgramId::ArchiveRebootlessSystemUpdateVersion = { 0x0100000000000826ul }; - inline constexpr const ProgramId ProgramId::ArchiveContentActionTable = { 0x0100000000000827ul }; - - inline constexpr const ProgramId ProgramId::ArchiveEnd = { 0x0100000000000FFFul }; - - /* System Applets. */ - inline constexpr const ProgramId ProgramId::AppletStart = { 0x0100000000001000ul }; - - inline constexpr const ProgramId ProgramId::AppletQlaunch = { 0x0100000000001000ul }; - inline constexpr const ProgramId ProgramId::AppletAuth = { 0x0100000000001001ul }; - inline constexpr const ProgramId ProgramId::AppletCabinet = { 0x0100000000001002ul }; - inline constexpr const ProgramId ProgramId::AppletController = { 0x0100000000001003ul }; - inline constexpr const ProgramId ProgramId::AppletDataErase = { 0x0100000000001004ul }; - inline constexpr const ProgramId ProgramId::AppletError = { 0x0100000000001005ul }; - inline constexpr const ProgramId ProgramId::AppletNetConnect = { 0x0100000000001006ul }; - inline constexpr const ProgramId ProgramId::AppletPlayerSelect = { 0x0100000000001007ul }; - inline constexpr const ProgramId ProgramId::AppletSwkbd = { 0x0100000000001008ul }; - inline constexpr const ProgramId ProgramId::AppletMiiEdit = { 0x0100000000001009ul }; - inline constexpr const ProgramId ProgramId::AppletWeb = { 0x010000000000100Aul }; - inline constexpr const ProgramId ProgramId::AppletShop = { 0x010000000000100Bul }; - inline constexpr const ProgramId ProgramId::AppletOverlayDisp = { 0x010000000000100Cul }; - inline constexpr const ProgramId ProgramId::AppletPhotoViewer = { 0x010000000000100Dul }; - inline constexpr const ProgramId ProgramId::AppletSet = { 0x010000000000100Eul }; - inline constexpr const ProgramId ProgramId::AppletOfflineWeb = { 0x010000000000100Ful }; - inline constexpr const ProgramId ProgramId::AppletLoginShare = { 0x0100000000001010ul }; - inline constexpr const ProgramId ProgramId::AppletWifiWebAuth = { 0x0100000000001011ul }; - inline constexpr const ProgramId ProgramId::AppletStarter = { 0x0100000000001012ul }; - inline constexpr const ProgramId ProgramId::AppletMyPage = { 0x0100000000001013ul }; - inline constexpr const ProgramId ProgramId::AppletPlayReport = { 0x0100000000001014ul }; - inline constexpr const ProgramId ProgramId::AppletMaintenanceMenu = { 0x0100000000001015ul }; - - inline constexpr const ProgramId ProgramId::AppletGift = { 0x010000000000101Aul }; - inline constexpr const ProgramId ProgramId::AppletDummyShop = { 0x010000000000101Bul }; - inline constexpr const ProgramId ProgramId::AppletUserMigration = { 0x010000000000101Cul }; - inline constexpr const ProgramId ProgramId::AppletEncounter = { 0x010000000000101Dul }; - - inline constexpr const ProgramId ProgramId::AppletStory = { 0x0100000000001020ul }; - - inline constexpr const ProgramId ProgramId::AppletEnd = { 0x0100000000001FFFul }; - - /* Debug Applets. */ - - /* Debug Modules. */ - - /* Factory Setup. */ - - /* Applications. */ - inline constexpr const ProgramId ProgramId::ApplicationStart = { 0x0100000000010000ul }; - inline constexpr const ProgramId ProgramId::ApplicationEnd = { 0x01FFFFFFFFFFFFFFul }; - - /* Atmosphere Extensions. */ - inline constexpr const ProgramId ProgramId::AtmosphereMitm = { 0x010041544D530000ul }; - - inline constexpr bool operator==(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value == rhs.value; - } - - inline constexpr bool operator!=(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value != rhs.value; - } - - inline constexpr bool operator<(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value < rhs.value; - } - - inline constexpr bool operator<=(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value <= rhs.value; - } - - inline constexpr bool operator>(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value > rhs.value; - } - - inline constexpr bool operator>=(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value >= rhs.value; - } - - inline constexpr bool IsSystemProgramId(const ProgramId &program_id) { - return ProgramId::SystemStart <= program_id && program_id <= ProgramId::SystemEnd; - } - - inline constexpr bool IsArchiveProgramId(const ProgramId &program_id) { - return ProgramId::ArchiveStart <= program_id && program_id <= ProgramId::ArchiveEnd; - } - - inline constexpr bool IsAppletProgramId(const ProgramId &program_id) { - return ProgramId::AppletStart <= program_id && program_id <= ProgramId::AppletEnd; - } - - inline constexpr bool IsApplicationProgramId(const ProgramId &program_id) { - return ProgramId::ApplicationStart <= program_id && program_id <= ProgramId::ApplicationEnd; - } - - inline constexpr bool IsWebAppletProgramId(const ProgramId &program_id) { - return program_id == ProgramId::AppletWeb || - program_id == ProgramId::AppletShop || - program_id == ProgramId::AppletOfflineWeb || - program_id == ProgramId::AppletLoginShare || - program_id == ProgramId::AppletWifiWebAuth; - } - - static_assert(sizeof(ProgramId) == sizeof(u64) && std::is_pod::value, "ProgramId definition!"); - - /* Program Location. */ - struct ProgramLocation { - ProgramId program_id; - u8 storage_id; - - static constexpr ProgramLocation Make(ProgramId program_id, StorageId storage_id) { - return { .program_id = program_id, .storage_id = static_cast(storage_id), }; - } - }; - - static_assert(sizeof(ProgramLocation) == 0x10 && std::is_pod::value, "ProgramLocation definition!"); - static_assert(sizeof(ProgramLocation) == sizeof(::NcmProgramLocation) && alignof(ProgramLocation) == alignof(::NcmProgramLocation), "ProgramLocation Libnx Compatibility"); - - struct RightsId { - fs::RightsId id; - u8 key_generation; - u8 reserved[7]; - }; - static_assert(sizeof(RightsId) == 0x18); - static_assert(std::is_pod::value); - - struct ContentMetaKey { - ProgramId id; - u32 version; - ContentMetaType type; - ContentInstallType install_type; - u8 padding[2]; - - bool operator<(const ContentMetaKey& other) const { - if (this->id < other.id) { - return true; - } else if (this->id != other.id) { - return false; - } - - if (this->version < other.version) { - return true; - } else if (this->version != other.version) { - return false; - } - - if (this->type < other.type) { - return true; - } else if (this->type != other.type) { - return false; - } - - return this->install_type < other.install_type; - } - - bool operator==(const ContentMetaKey& other) const { - return this->id == other.id && - this->version == other.version && - this->type == other.type && - this->install_type == other.install_type; - } - - bool operator!=(const ContentMetaKey& other) const { - return !(*this == other); - } - - static constexpr ContentMetaKey MakeUnknownType(ProgramId program_id, u32 version) { - return { .id = program_id, .version = version, .type = ContentMetaType::Unknown }; - } - - static constexpr ContentMetaKey Make(ProgramId program_id, u32 version, ContentMetaType type) { - return { .id = program_id, .version = version, .type = type }; - } - - static constexpr ContentMetaKey Make(ProgramId program_id, u32 version, ContentMetaType type, ContentInstallType install_type) { - return { .id = program_id, .version = version, .type = type, .install_type = install_type }; - } - }; - - static_assert(sizeof(ContentMetaKey) == 0x10, "ContentMetaKey definition!"); - - /* Used by system updates. */ - struct ContentMetaInfo { - ProgramId id; - u32 version; - ContentMetaType type; - u8 attributes; - u8 padding[2]; - - static constexpr ContentMetaInfo Make(ProgramId program_id, u32 version, ContentMetaType type, u8 attributes) { - return { - .id = program_id, - .version = version, - .type = type, - .attributes = attributes, - }; - } - - constexpr ContentMetaKey ToKey() { - return ContentMetaKey::Make(this->id, this->version, this->type); - } - }; - - static_assert(sizeof(ContentMetaInfo) == 0x10); - - struct ApplicationContentMetaKey { - ContentMetaKey key; - ProgramId application_program_id; - }; - - static_assert(sizeof(ApplicationContentMetaKey) == 0x18, "ApplicationContentMetaKey definition!"); - - struct Digest { - u8 data[crypto::Sha256Generator::HashSize]; - }; - -} diff --git a/libraries/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp b/libraries/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp index 78492e883..e37998e9a 100644 --- a/libraries/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp @@ -16,8 +16,9 @@ #pragma once -#include "../ldr.hpp" -#include "pm_types.hpp" +#include +#include +#include namespace ams::pm::dmnt { diff --git a/libraries/libstratosphere/include/stratosphere/pm/pm_info_api.hpp b/libraries/libstratosphere/include/stratosphere/pm/pm_info_api.hpp index 374c5f1d0..940621f05 100644 --- a/libraries/libstratosphere/include/stratosphere/pm/pm_info_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/pm/pm_info_api.hpp @@ -16,8 +16,11 @@ #pragma once -#include "pm_types.hpp" -#include "../ncm/ncm_types.hpp" +#include +#include +#include +#include +#include namespace ams::pm::info { diff --git a/libraries/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp b/libraries/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp index fde8a89b1..9464b01b5 100644 --- a/libraries/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp @@ -16,8 +16,9 @@ #pragma once -#include "../ldr.hpp" -#include "pm_types.hpp" +#include +#include +#include namespace ams::pm::shell { diff --git a/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp b/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp index 44856cc34..eafde873c 100644 --- a/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp @@ -16,7 +16,7 @@ #pragma once #include -#include "../ncm/ncm_types.hpp" +#include namespace ams::ro { diff --git a/libraries/libstratosphere/include/stratosphere/sm/sm_manager_api.hpp b/libraries/libstratosphere/include/stratosphere/sm/sm_manager_api.hpp index a01086b6b..6531923ab 100644 --- a/libraries/libstratosphere/include/stratosphere/sm/sm_manager_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/sm/sm_manager_api.hpp @@ -15,10 +15,10 @@ */ #pragma once - -#include "sm_types.hpp" -#include "../ncm/ncm_types.hpp" -#include "../os/os_common_types.hpp" +#include +#include +#include +#include namespace ams::sm::manager { diff --git a/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp b/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp index 983925a0c..3a9dc531d 100644 --- a/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/sm/sm_types.hpp @@ -16,8 +16,8 @@ #pragma once #include -#include "../ncm/ncm_types.hpp" -#include "../cfg/cfg_types.hpp" +#include +#include namespace ams::sm { diff --git a/libraries/libstratosphere/source/boot2/boot2_api.cpp b/libraries/libstratosphere/source/boot2/boot2_api.cpp index 29b0ff0e6..ded458209 100644 --- a/libraries/libstratosphere/source/boot2/boot2_api.cpp +++ b/libraries/libstratosphere/source/boot2/boot2_api.cpp @@ -23,99 +23,99 @@ namespace ams::boot2 { /* psc, bus, pcv is the minimal set of required programs to get SD card. */ /* bus depends on pcie, and pcv depends on settings. */ - constexpr ncm::ProgramId PreSdCardLaunchPrograms[] = { - ncm::ProgramId::Psc, /* psc */ - ncm::ProgramId::Pcie, /* pcie */ - ncm::ProgramId::Bus, /* bus */ - ncm::ProgramId::Settings, /* settings */ - ncm::ProgramId::Pcv, /* pcv */ - ncm::ProgramId::Usb, /* usb */ + constexpr ncm::SystemProgramId PreSdCardLaunchPrograms[] = { + ncm::SystemProgramId::Psc, /* psc */ + ncm::SystemProgramId::Pcie, /* pcie */ + ncm::SystemProgramId::Bus, /* bus */ + ncm::SystemProgramId::Settings, /* settings */ + ncm::SystemProgramId::Pcv, /* pcv */ + ncm::SystemProgramId::Usb, /* usb */ }; constexpr size_t NumPreSdCardLaunchPrograms = util::size(PreSdCardLaunchPrograms); - constexpr ncm::ProgramId AdditionalLaunchPrograms[] = { - ncm::ProgramId::Tma, /* tma */ - ncm::ProgramId::Am, /* am */ - ncm::ProgramId::NvServices, /* nvservices */ - ncm::ProgramId::NvnFlinger, /* nvnflinger */ - ncm::ProgramId::Vi, /* vi */ - ncm::ProgramId::Ns, /* ns */ - ncm::ProgramId::LogManager, /* lm */ - ncm::ProgramId::Ppc, /* ppc */ - ncm::ProgramId::Ptm, /* ptm */ - ncm::ProgramId::Hid, /* hid */ - ncm::ProgramId::Audio, /* audio */ - ncm::ProgramId::Lbl, /* lbl */ - ncm::ProgramId::Wlan, /* wlan */ - ncm::ProgramId::Bluetooth, /* bluetooth */ - ncm::ProgramId::BsdSockets, /* bsdsockets */ - ncm::ProgramId::Nifm, /* nifm */ - ncm::ProgramId::Ldn, /* ldn */ - ncm::ProgramId::Account, /* account */ - ncm::ProgramId::Friends, /* friends */ - ncm::ProgramId::Nfc, /* nfc */ - ncm::ProgramId::JpegDec, /* jpegdec */ - ncm::ProgramId::CapSrv, /* capsrv */ - ncm::ProgramId::Ssl, /* ssl */ - ncm::ProgramId::Nim, /* nim */ - ncm::ProgramId::Bcat, /* bcat */ - ncm::ProgramId::Erpt, /* erpt */ - ncm::ProgramId::Es, /* es */ - ncm::ProgramId::Pctl, /* pctl */ - ncm::ProgramId::Btm, /* btm */ - ncm::ProgramId::Eupld, /* eupld */ - ncm::ProgramId::Glue, /* glue */ - /* ncm::ProgramId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ - ncm::ProgramId::Npns, /* npns */ - ncm::ProgramId::Fatal, /* fatal */ - ncm::ProgramId::Ro, /* ro */ - ncm::ProgramId::Profiler, /* profiler */ - ncm::ProgramId::Sdb, /* sdb */ - ncm::ProgramId::Migration, /* migration */ - ncm::ProgramId::Grc, /* grc */ - ncm::ProgramId::Olsc, /* olsc */ - ncm::ProgramId::Ngct, /* ngct */ + constexpr ncm::SystemProgramId AdditionalLaunchPrograms[] = { + ncm::SystemProgramId::Tma, /* tma */ + ncm::SystemProgramId::Am, /* am */ + ncm::SystemProgramId::NvServices, /* nvservices */ + ncm::SystemProgramId::NvnFlinger, /* nvnflinger */ + ncm::SystemProgramId::Vi, /* vi */ + ncm::SystemProgramId::Ns, /* ns */ + ncm::SystemProgramId::LogManager, /* lm */ + ncm::SystemProgramId::Ppc, /* ppc */ + ncm::SystemProgramId::Ptm, /* ptm */ + ncm::SystemProgramId::Hid, /* hid */ + ncm::SystemProgramId::Audio, /* audio */ + ncm::SystemProgramId::Lbl, /* lbl */ + ncm::SystemProgramId::Wlan, /* wlan */ + ncm::SystemProgramId::Bluetooth, /* bluetooth */ + ncm::SystemProgramId::BsdSockets, /* bsdsockets */ + ncm::SystemProgramId::Nifm, /* nifm */ + ncm::SystemProgramId::Ldn, /* ldn */ + ncm::SystemProgramId::Account, /* account */ + ncm::SystemProgramId::Friends, /* friends */ + ncm::SystemProgramId::Nfc, /* nfc */ + ncm::SystemProgramId::JpegDec, /* jpegdec */ + ncm::SystemProgramId::CapSrv, /* capsrv */ + ncm::SystemProgramId::Ssl, /* ssl */ + ncm::SystemProgramId::Nim, /* nim */ + ncm::SystemProgramId::Bcat, /* bcat */ + ncm::SystemProgramId::Erpt, /* erpt */ + ncm::SystemProgramId::Es, /* es */ + ncm::SystemProgramId::Pctl, /* pctl */ + ncm::SystemProgramId::Btm, /* btm */ + ncm::SystemProgramId::Eupld, /* eupld */ + ncm::SystemProgramId::Glue, /* glue */ + /* ncm::SystemProgramId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ + ncm::SystemProgramId::Npns, /* npns */ + ncm::SystemProgramId::Fatal, /* fatal */ + ncm::SystemProgramId::Ro, /* ro */ + ncm::SystemProgramId::Profiler, /* profiler */ + ncm::SystemProgramId::Sdb, /* sdb */ + ncm::SystemProgramId::Migration, /* migration */ + ncm::SystemProgramId::Grc, /* grc */ + ncm::SystemProgramId::Olsc, /* olsc */ + ncm::SystemProgramId::Ngct, /* ngct */ }; constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms); - constexpr ncm::ProgramId AdditionalMaintenanceLaunchPrograms[] = { - ncm::ProgramId::Tma, /* tma */ - ncm::ProgramId::Am, /* am */ - ncm::ProgramId::NvServices, /* nvservices */ - ncm::ProgramId::NvnFlinger, /* nvnflinger */ - ncm::ProgramId::Vi, /* vi */ - ncm::ProgramId::Ns, /* ns */ - ncm::ProgramId::LogManager, /* lm */ - ncm::ProgramId::Ppc, /* ppc */ - ncm::ProgramId::Ptm, /* ptm */ - ncm::ProgramId::Hid, /* hid */ - ncm::ProgramId::Audio, /* audio */ - ncm::ProgramId::Lbl, /* lbl */ - ncm::ProgramId::Wlan, /* wlan */ - ncm::ProgramId::Bluetooth, /* bluetooth */ - ncm::ProgramId::BsdSockets, /* bsdsockets */ - ncm::ProgramId::Nifm, /* nifm */ - ncm::ProgramId::Ldn, /* ldn */ - ncm::ProgramId::Account, /* account */ - ncm::ProgramId::Nfc, /* nfc */ - ncm::ProgramId::JpegDec, /* jpegdec */ - ncm::ProgramId::CapSrv, /* capsrv */ - ncm::ProgramId::Ssl, /* ssl */ - ncm::ProgramId::Nim, /* nim */ - ncm::ProgramId::Erpt, /* erpt */ - ncm::ProgramId::Es, /* es */ - ncm::ProgramId::Pctl, /* pctl */ - ncm::ProgramId::Btm, /* btm */ - ncm::ProgramId::Glue, /* glue */ - /* ncm::ProgramId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ - ncm::ProgramId::Fatal, /* fatal */ - ncm::ProgramId::Ro, /* ro */ - ncm::ProgramId::Profiler, /* profiler */ - ncm::ProgramId::Sdb, /* sdb */ - ncm::ProgramId::Migration, /* migration */ - ncm::ProgramId::Grc, /* grc */ - ncm::ProgramId::Olsc, /* olsc */ - ncm::ProgramId::Ngct, /* ngct */ + constexpr ncm::SystemProgramId AdditionalMaintenanceLaunchPrograms[] = { + ncm::SystemProgramId::Tma, /* tma */ + ncm::SystemProgramId::Am, /* am */ + ncm::SystemProgramId::NvServices, /* nvservices */ + ncm::SystemProgramId::NvnFlinger, /* nvnflinger */ + ncm::SystemProgramId::Vi, /* vi */ + ncm::SystemProgramId::Ns, /* ns */ + ncm::SystemProgramId::LogManager, /* lm */ + ncm::SystemProgramId::Ppc, /* ppc */ + ncm::SystemProgramId::Ptm, /* ptm */ + ncm::SystemProgramId::Hid, /* hid */ + ncm::SystemProgramId::Audio, /* audio */ + ncm::SystemProgramId::Lbl, /* lbl */ + ncm::SystemProgramId::Wlan, /* wlan */ + ncm::SystemProgramId::Bluetooth, /* bluetooth */ + ncm::SystemProgramId::BsdSockets, /* bsdsockets */ + ncm::SystemProgramId::Nifm, /* nifm */ + ncm::SystemProgramId::Ldn, /* ldn */ + ncm::SystemProgramId::Account, /* account */ + ncm::SystemProgramId::Nfc, /* nfc */ + ncm::SystemProgramId::JpegDec, /* jpegdec */ + ncm::SystemProgramId::CapSrv, /* capsrv */ + ncm::SystemProgramId::Ssl, /* ssl */ + ncm::SystemProgramId::Nim, /* nim */ + ncm::SystemProgramId::Erpt, /* erpt */ + ncm::SystemProgramId::Es, /* es */ + ncm::SystemProgramId::Pctl, /* pctl */ + ncm::SystemProgramId::Btm, /* btm */ + ncm::SystemProgramId::Glue, /* glue */ + /* ncm::SystemProgramId::Eclct, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */ + ncm::SystemProgramId::Fatal, /* fatal */ + ncm::SystemProgramId::Ro, /* ro */ + ncm::SystemProgramId::Profiler, /* profiler */ + ncm::SystemProgramId::Sdb, /* sdb */ + ncm::SystemProgramId::Migration, /* migration */ + ncm::SystemProgramId::Grc, /* grc */ + ncm::SystemProgramId::Olsc, /* olsc */ + ncm::SystemProgramId::Ngct, /* ngct */ }; constexpr size_t NumAdditionalMaintenanceLaunchPrograms = util::size(AdditionalMaintenanceLaunchPrograms); @@ -149,7 +149,7 @@ namespace ams::boot2 { } } - void LaunchList(const ncm::ProgramId *launch_list, size_t num_entries) { + void LaunchList(const ncm::SystemProgramId *launch_list, size_t num_entries) { for (size_t i = 0; i < num_entries; i++) { LaunchProgram(nullptr, ncm::ProgramLocation::Make(launch_list[i], ncm::StorageId::BuiltInSystem), 0); } @@ -315,7 +315,7 @@ namespace ams::boot2 { } /* Launch Atmosphere boot2, using NcmStorageId_None to force SD card boot. */ - LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Boot2, ncm::StorageId::None), 0); + LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Boot2, ncm::StorageId::None), 0); } void LaunchPostSdCardBootPrograms() { @@ -328,7 +328,7 @@ namespace ams::boot2 { } /* Launch Atmosphere dmnt, using NcmStorageId_None to force SD card boot. */ - LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Dmnt, ncm::StorageId::None), 0); + LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Dmnt, ncm::StorageId::None), 0); /* Check for and forward declare non-atmosphere mitm modules. */ DetectAndDeclareFutureMitms(); @@ -338,7 +338,7 @@ namespace ams::boot2 { LaunchList(AdditionalMaintenanceLaunchPrograms, NumAdditionalMaintenanceLaunchPrograms); /* Starting in 7.0.0, npns is launched during maintenance boot. */ if (hos::GetVersion() >= hos::Version_700) { - LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::ProgramId::Npns, ncm::StorageId::BuiltInSystem), 0); + LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Npns, ncm::StorageId::BuiltInSystem), 0); } } else { LaunchList(AdditionalLaunchPrograms, NumAdditionalLaunchPrograms); diff --git a/libraries/libstratosphere/source/cfg/cfg_override.cpp b/libraries/libstratosphere/source/cfg/cfg_override.cpp index e1159b82c..f12e5193c 100644 --- a/libraries/libstratosphere/source/cfg/cfg_override.cpp +++ b/libraries/libstratosphere/source/cfg/cfg_override.cpp @@ -38,7 +38,7 @@ namespace ams::cfg { .key_combination = KEY_R, .override_by_default = true, }, - .program_id = ncm::ProgramId::AppletPhotoViewer, + .program_id = ncm::SystemAppletId::PhotoViewer, }; constexpr size_t MaxProgramOverrideKeys = 8; @@ -269,7 +269,7 @@ namespace ams::cfg { } inline bool IsAnyApplicationHblProgramId(ncm::ProgramId program_id) { - return g_hbl_override_config.override_any_app && ncm::IsApplicationProgramId(program_id) && !IsAnySpecificHblProgramId(program_id); + return g_hbl_override_config.override_any_app && ncm::IsApplicationId(program_id) && !IsAnySpecificHblProgramId(program_id); } void ParseIniFile(util::ini::Handler handler, const char *path, void *user_ctx) { @@ -320,7 +320,7 @@ namespace ams::cfg { } /* For system modules and anything launched before the home menu, always override. */ - if (program_id < ncm::ProgramId::AppletStart || !pm::info::HasLaunchedProgram(ncm::ProgramId::AppletQlaunch)) { + if (program_id < ncm::SystemAppletId::Start || !pm::info::HasLaunchedProgram(ncm::SystemAppletId::Qlaunch)) { status.SetProgramSpecific(); return status; } diff --git a/libraries/libstratosphere/source/hid/hid_api.cpp b/libraries/libstratosphere/source/hid/hid_api.cpp index 909202928..e5d3bfc7d 100644 --- a/libraries/libstratosphere/source/hid/hid_api.cpp +++ b/libraries/libstratosphere/source/hid/hid_api.cpp @@ -35,7 +35,7 @@ namespace ams::hid { Result EnsureHidInitialized() { if (!g_initialized_hid) { if (!serviceIsActive(hidGetServiceSession())) { - if (!pm::info::HasLaunchedProgram(ncm::ProgramId::Hid)) { + if (!pm::info::HasLaunchedProgram(ncm::SystemProgramId::Hid)) { return MAKERESULT(Module_Libnx, LibnxError_InitFail_HID); } InitializeHid(); diff --git a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp index 66299f35d..74bd49e7e 100644 --- a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp @@ -18,7 +18,7 @@ namespace ams::lr { - Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out out, ncm::ProgramId id) { + Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out out, ncm::DataId id) { /* Find a storage that contains the given program id. */ ncm::StorageId storage_id = ncm::StorageId::None; R_UNLESS(this->registered_storages.Find(&storage_id, id), lr::ResultAddOnContentNotFound()); @@ -42,13 +42,13 @@ namespace ams::lr { return ResultSuccess(); } - Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorageDeprecated(ncm::StorageId storage_id, ncm::ProgramId id) { + Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) { /* Register storage for the given program id. 2.0.0-8.1.0 did not require an owner application id. */ - R_UNLESS(this->registered_storages.Register(id, storage_id, ncm::ProgramId::Invalid), lr::ResultTooManyRegisteredPaths()); + R_UNLESS(this->registered_storages.Register(id, storage_id, ncm::InvalidApplicationId), lr::ResultTooManyRegisteredPaths()); return ResultSuccess(); } - Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorage(ncm::StorageId storage_id, ncm::ProgramId id, ncm::ProgramId application_id) { + Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) { /* Register storage for the given program id and owner application. */ R_UNLESS(this->registered_storages.Register(id, storage_id, application_id), lr::ResultTooManyRegisteredPaths()); return ResultSuccess(); @@ -59,19 +59,19 @@ namespace ams::lr { return ResultSuccess(); } - Result AddOnContentLocationResolverImpl::RefreshApplicationAddOnContent(const sf::InArray &ids) { + Result AddOnContentLocationResolverImpl::RefreshApplicationAddOnContent(const sf::InArray &ids) { if (ids.GetSize() == 0) { /* Clear all registered storages. */ this->registered_storages.Clear(); } else { /* Clear all registered storages excluding the provided program ids. */ - this->registered_storages.ClearExcluding(ids.GetPointer(), ids.GetSize()); + this->registered_storages.ClearExcluding(reinterpret_cast(ids.GetPointer()), ids.GetSize()); } return ResultSuccess(); } - Result AddOnContentLocationResolverImpl::UnregisterApplicationAddOnContent(ncm::ProgramId id) { + Result AddOnContentLocationResolverImpl::UnregisterApplicationAddOnContent(ncm::ApplicationId id) { /* Remove entries belonging to the provided application. */ this->registered_storages.UnregisterOwnerProgram(id); return ResultSuccess(); diff --git a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp index 080255365..c80238a3c 100644 --- a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp @@ -23,18 +23,18 @@ namespace ams::lr { class AddOnContentLocationResolverImpl : public IAddOnContentLocationResolver { private: - /* Storage for RegisteredData entries by program id. */ - RegisteredStorages registered_storages; + /* Storage for RegisteredData entries by data id. */ + RegisteredStorages registered_storages; public: AddOnContentLocationResolverImpl() : registered_storages(hos::GetVersion() < hos::Version_900 ? 0x800 : 0x2) { /* ... */ } /* Actual commands. */ - virtual Result ResolveAddOnContentPath(sf::Out out, ncm::ProgramId id) override; - virtual Result RegisterAddOnContentStorageDeprecated(ncm::StorageId storage_id, ncm::ProgramId id) override; - virtual Result RegisterAddOnContentStorage(ncm::StorageId storage_id, ncm::ProgramId id, ncm::ProgramId application_id) override; + virtual Result ResolveAddOnContentPath(sf::Out out, ncm::DataId id) override; + virtual Result RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) override; + virtual Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) override; virtual Result UnregisterAllAddOnContentPath() override; - virtual Result RefreshApplicationAddOnContent(const sf::InArray &ids) override; - virtual Result UnregisterApplicationAddOnContent(ncm::ProgramId id) override; + virtual Result RefreshApplicationAddOnContent(const sf::InArray &ids) override; + virtual Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) override; }; } diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp index 46c58f90a..57cdbe411 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp @@ -59,7 +59,7 @@ namespace ams::lr { return ResultSuccess(); } - Result ContentLocationResolverImpl::ResolveDataPath(sf::Out out, ncm::ProgramId id) { + Result ContentLocationResolverImpl::ResolveDataPath(sf::Out out, ncm::DataId id) { /* Find the latest data content for the program id. */ ncm::ContentId data_content_id; R_TRY(this->content_meta_database.GetLatestData(&data_content_id, id)); diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp index 04a8c55a7..5553962da 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp @@ -39,7 +39,7 @@ namespace ams::lr { virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override; virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) override; virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) override; - virtual Result ResolveDataPath(sf::Out out, ncm::ProgramId id) override; + virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) override; virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override; virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; diff --git a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp index 5874cc2bb..29aa4c06e 100644 --- a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp @@ -43,7 +43,7 @@ namespace ams::lr { return ResultSuccess(); } - Result RedirectOnlyLocationResolverImpl::ResolveDataPath(sf::Out out, ncm::ProgramId id) { + Result RedirectOnlyLocationResolverImpl::ResolveDataPath(sf::Out out, ncm::DataId id) { return ResultDataNotFound(); } diff --git a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp index 382706662..a204169d1 100644 --- a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.hpp @@ -28,7 +28,7 @@ namespace ams::lr { virtual Result RedirectProgramPath(const Path &path, ncm::ProgramId id) override; virtual Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) override; virtual Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) override; - virtual Result ResolveDataPath(sf::Out out, ncm::ProgramId id) override; + virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) override; virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override; virtual Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) override; virtual Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) override; diff --git a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp index ba32d53e2..5ac2b47e4 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp @@ -43,8 +43,8 @@ namespace ams::lr { return lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), static_cast(id), out->str); } - virtual Result ResolveDataPath(sf::Out out, ncm::ProgramId id) override { - return lrLrResolveDataPath(std::addressof(this->srv), static_cast(id), out->str); + virtual Result ResolveDataPath(sf::Out out, ncm::DataId id) override { + return lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str); } virtual Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) override { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp index fed1745f5..aba7f79c9 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp @@ -18,7 +18,7 @@ namespace ams::ncm { - Result ContentMetaDatabaseImpl::GetContentIdByTypeImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional id_offset) { + Result ContentMetaDatabaseImpl::GetContentIdImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional id_offset) const { R_TRY(this->EnsureEnabled()); /* Find the meta key. */ @@ -47,13 +47,13 @@ namespace ams::ncm { return ResultSuccess(); } - Result ContentMetaDatabaseImpl::GetLatestContentMetaKeyImpl(ContentMetaKey *out_key, ProgramId id) { + Result ContentMetaDatabaseImpl::GetLatestKeyImpl(ContentMetaKey *out_key, u64 id) const { R_TRY(this->EnsureEnabled()); std::optional found_key = std::nullopt; /* Find the last key with the desired program id. */ - for (auto entry = this->kvs->lower_bound(ContentMetaKey::Make(id, 0, ContentMetaType::Unknown)); entry != this->kvs->end(); entry++) { + for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) { /* No further entries will match the program id, discontinue. */ if (entry->GetKey().id != id) { break; @@ -88,7 +88,7 @@ namespace ams::ncm { } Result ContentMetaDatabaseImpl::GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) { - return this->GetContentIdByTypeImpl(out_content_id.GetPointer(), key, type, std::nullopt); + return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, std::nullopt); } Result ContentMetaDatabaseImpl::ListContentInfo(sf::Out out_count, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) { @@ -113,7 +113,7 @@ namespace ams::ncm { return ResultSuccess(); } - Result ContentMetaDatabaseImpl::List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ProgramId application_id, u64 min, u64 max, ContentInstallType install_type) { + Result ContentMetaDatabaseImpl::List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) { R_TRY(this->EnsureEnabled()); size_t entries_total = 0; @@ -124,7 +124,7 @@ namespace ams::ncm { ContentMetaKey key = entry->GetKey(); /* Check if this entry matches the given filters. */ - if (!((meta_type == ContentMetaType::Unknown || key.type == meta_type) && (min <= static_cast(key.id) && static_cast(key.id) <= max) && (install_type == ContentInstallType::Unknown || key.install_type == install_type))) { + if (!((meta_type == ContentMetaType::Unknown || key.type == meta_type) && (min <= key.id && key.id <= max) && (install_type == ContentInstallType::Unknown || key.install_type == install_type))) { continue; } @@ -156,9 +156,9 @@ namespace ams::ncm { return ResultSuccess(); } - Result ContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out out_key, ProgramId program_id) { + Result ContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out out_key, u64 id) { R_TRY(this->EnsureEnabled()); - return this->GetLatestContentMetaKeyImpl(out_key.GetPointer(), program_id); + return this->GetLatestKeyImpl(out_key.GetPointer(), id); } Result ContentMetaDatabaseImpl::ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType type) { @@ -259,7 +259,7 @@ namespace ams::ncm { return ResultSuccess(); } - Result ContentMetaDatabaseImpl::GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { + Result ContentMetaDatabaseImpl::GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { R_TRY(this->EnsureEnabled()); R_UNLESS(key.type == ContentMetaType::Application, ncm::ResultInvalidContentMetaKey()); @@ -409,7 +409,7 @@ namespace ams::ncm { } Result ContentMetaDatabaseImpl::GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { - return this->GetContentIdByTypeImpl(out_content_id.GetPointer(), key, type, std::make_optional(id_offset)); + return this->GetContentIdImpl(out_content_id.GetPointer(), key, type, std::make_optional(id_offset)); } } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp index deb267edd..a03ef5152 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp @@ -25,8 +25,8 @@ namespace ams::ncm { ContentMetaDatabaseImpl(ContentMetaKeyValueStore *kvs) : ContentMetaDatabaseImplBase(kvs) { /* ... */ } private: /* Helpers. */ - Result GetContentIdByTypeImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional id_offset); - Result GetLatestContentMetaKeyImpl(ContentMetaKey *out_key, ProgramId id); + Result GetContentIdImpl(ContentId *out, const ContentMetaKey& key, ContentType type, std::optional id_offset) const; + Result GetLatestKeyImpl(ContentMetaKey *out_key, u64 id) const; public: /* Actual commands. */ virtual Result Set(const ContentMetaKey &key, sf::InBuffer value) override; @@ -34,14 +34,14 @@ namespace ams::ncm { virtual Result Remove(const ContentMetaKey &key) override; virtual Result GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) override; virtual Result ListContentInfo(sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) override; - virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ProgramId application_id, u64 min, u64 max, ContentInstallType install_type) override; - virtual Result GetLatestContentMetaKey(sf::Out out_key, ProgramId id) override; + virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) override; + virtual Result GetLatestContentMetaKey(sf::Out out_key, u64 id) override; virtual Result ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type) override; virtual Result Has(sf::Out out, const ContentMetaKey &key) override; virtual Result HasAll(sf::Out out, const sf::InArray &keys) override; virtual Result GetSize(sf::Out out_size, const ContentMetaKey &key) override; virtual Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) override; - virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) override; + virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) override; virtual Result DisableForcibly() override; virtual Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) override; virtual Result Commit() override; diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_type.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_type.cpp new file mode 100644 index 000000000..4b9ffdfbb --- /dev/null +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_type.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2019-2020 Adubbz, 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 . + */ +#include + +namespace ams::ncm { + + const char *GetContentMetaTypeString(ContentMetaType type) { + switch (type) { + case ContentMetaType::Application: return "Application"; + case ContentMetaType::Patch: return "Patch"; + case ContentMetaType::AddOnContent: return "AddOnContent"; + default: return "(unknown)"; + } + } + +} diff --git a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp index 33a5b3d8b..2f0c28225 100644 --- a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp @@ -18,15 +18,15 @@ namespace ams::ncm { - Result OnMemoryContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out out_key, ProgramId program_id) { + Result OnMemoryContentMetaDatabaseImpl::GetLatestContentMetaKey(sf::Out out_key, u64 id) { R_TRY(this->EnsureEnabled()); std::optional found_key; /* Find the last key with the desired program id. */ - for (auto entry = this->kvs->lower_bound(ContentMetaKey::Make(program_id, 0, ContentMetaType::Unknown)); entry != this->kvs->end(); entry++) { + for (auto entry = this->kvs->lower_bound(ContentMetaKey::Make(id, 0, ContentMetaType::Unknown)); entry != this->kvs->end(); entry++) { /* No further entries will match the program id, discontinue. */ - if (entry->GetKey().id != program_id) { + if (entry->GetKey().id != id) { break; } diff --git a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.hpp index 401ec8545..d51ceed54 100644 --- a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.hpp @@ -24,7 +24,7 @@ namespace ams::ncm { OnMemoryContentMetaDatabaseImpl(ams::kvdb::MemoryKeyValueStore *kvs) : ContentMetaDatabaseImpl(kvs) { /* ... */ } public: /* Actual commands. */ - virtual Result GetLatestContentMetaKey(sf::Out out_key, ProgramId id) override; + virtual Result GetLatestContentMetaKey(sf::Out out_key, u64 id) override; virtual Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) override; virtual Result Commit() override; }; diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp index 4317abffa..9d8c72be4 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp @@ -91,11 +91,11 @@ namespace ams::ncm { return ncmContentMetaDatabaseListContentInfo(std::addressof(this->srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset); } - virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ProgramId application_id, u64 min, u64 max, ContentInstallType install_type) override { - return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), static_cast(application_id), min, max, static_cast<::NcmContentInstallType>(install_type)); + virtual Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) override { + return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type)); } - virtual Result GetLatestContentMetaKey(sf::Out out_key, ProgramId id) override { + virtual Result GetLatestContentMetaKey(sf::Out out_key, u64 id) override { return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(this->srv), Convert(out_key.GetPointer()), static_cast(id)); } @@ -119,7 +119,7 @@ namespace ams::ncm { return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key)); } - virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) override { + virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) override { return ncmContentMetaDatabaseGetPatchId(std::addressof(this->srv), reinterpret_cast(out_patch_id.GetPointer()), Convert(key)); } diff --git a/stratosphere/ams_mitm/source/amsmitm_main.cpp b/stratosphere/ams_mitm/source/amsmitm_main.cpp index e2dd87f91..7e47169dd 100644 --- a/stratosphere/ams_mitm/source/amsmitm_main.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_main.cpp @@ -40,7 +40,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::AtmosphereMitm; + ncm::ProgramId CurrentProgramId = ncm::AtmosphereProgramId::Mitm; namespace result { diff --git a/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp b/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp index df104ff7d..b4bd1d4bd 100644 --- a/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/bpc_mitm/bpc_mitm_service.hpp @@ -31,8 +31,8 @@ namespace ams::mitm::bpc { * - fatal, to simplify payload reboot logic significantly * - hbl, to allow homebrew to take advantage of the feature. */ - return client_info.program_id == ncm::ProgramId::Am || - client_info.program_id == ncm::ProgramId::Fatal || + return client_info.program_id == ncm::SystemProgramId::Am || + client_info.program_id == ncm::SystemProgramId::Fatal || client_info.override_status.IsHbl(); } public: diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp index 9b9065e4f..e6ad2d423 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp @@ -67,7 +67,7 @@ namespace ams::mitm::fs { Result OpenHblWebContentFileSystem(sf::Out> &out, ncm::ProgramId client_program_id, ncm::ProgramId program_id, FsFileSystemType filesystem_type) { /* Verify eligibility. */ bool is_hbl; - R_UNLESS(ncm::IsWebAppletProgramId(client_program_id), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(ncm::IsWebAppletId(client_program_id), sm::mitm::ResultShouldForwardToSession()); R_UNLESS(filesystem_type == FsFileSystemType_ContentManual, sm::mitm::ResultShouldForwardToSession()); R_UNLESS(R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, program_id)), sm::mitm::ResultShouldForwardToSession()); R_UNLESS(is_hbl, sm::mitm::ResultShouldForwardToSession()); @@ -101,8 +101,8 @@ namespace ams::mitm::fs { Result FsMitmService::OpenSdCardFileSystem(sf::Out> out) { /* We only care about redirecting this for NS/emummc. */ - R_UNLESS(this->client_info.program_id == ncm::ProgramId::Ns, sm::mitm::ResultShouldForwardToSession()); - R_UNLESS(emummc::IsActive(), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(this->client_info.program_id == ncm::SystemProgramId::Ns, sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(emummc::IsActive(), sm::mitm::ResultShouldForwardToSession()); /* Create a new SD card filesystem. */ FsFileSystem sd_fs; @@ -117,7 +117,7 @@ namespace ams::mitm::fs { Result FsMitmService::OpenSaveDataFileSystem(sf::Out> out, u8 _space_id, const FsSaveDataAttribute &attribute) { /* We only want to intercept saves for games, right now. */ - const bool is_game_or_hbl = this->client_info.override_status.IsHbl() || ncm::IsApplicationProgramId(this->client_info.program_id); + const bool is_game_or_hbl = this->client_info.override_status.IsHbl() || ncm::IsApplicationId(this->client_info.program_id); R_UNLESS(is_game_or_hbl, sm::mitm::ResultShouldForwardToSession()); /* Only redirect if the appropriate system setting is set. */ @@ -272,10 +272,13 @@ namespace ams::mitm::fs { return ResultSuccess(); } - Result FsMitmService::OpenDataStorageByDataId(sf::Out> out, ncm::ProgramId /* TODO: ncm::DataId */ data_id, u8 storage_id) { + Result FsMitmService::OpenDataStorageByDataId(sf::Out> out, ncm::DataId _data_id, u8 storage_id) { /* Only mitm if we should override contents for the current process. */ R_UNLESS(this->client_info.override_status.IsProgramSpecific(), sm::mitm::ResultShouldForwardToSession()); + /* TODO: Decide how to handle DataId vs ProgramId for this API. */ + const ncm::ProgramId data_id = {_data_id.value}; + /* Only mitm if there is actually an override romfs. */ R_UNLESS(mitm::fs::HasSdRomfsContent(data_id), sm::mitm::ResultShouldForwardToSession()); diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp index 8367396e0..63ff73700 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.hpp @@ -50,12 +50,12 @@ namespace ams::mitm::fs { } /* We want to mitm ns, to intercept SD card requests. */ - if (program_id == ncm::ProgramId::Ns) { + if (program_id == ncm::SystemProgramId::Ns) { return true; } /* We want to mitm sdb, to support sd-romfs redirection of common system archives (like system font, etc). */ - if (program_id == ncm::ProgramId::Sdb) { + if (program_id == ncm::SystemProgramId::Sdb) { return true; } @@ -69,7 +69,7 @@ namespace ams::mitm::fs { /* Figure out why, and address it. */ /* TODO: This may be because pre-rewrite code really mismanaged domain objects in a way that would cause bad things. */ /* Need to verify if this is fixed now. */ - if (client_info.program_id == ncm::ProgramId::AppletQlaunch || client_info.program_id == ncm::ProgramId::AppletMaintenanceMenu) { + if (client_info.program_id == ncm::SystemAppletId::Qlaunch || client_info.program_id == ncm::SystemAppletId::MaintenanceMenu) { has_launched_qlaunch = true; } @@ -85,7 +85,7 @@ namespace ams::mitm::fs { Result OpenSaveDataFileSystem(sf::Out> out, u8 space_id, const FsSaveDataAttribute &attribute); Result OpenBisStorage(sf::Out> out, u32 bis_partition_id); Result OpenDataStorageByCurrentProcess(sf::Out> out); - Result OpenDataStorageByDataId(sf::Out> out, ncm::ProgramId /* TODO: ncm::DataId */ data_id, u8 storage_id); + Result OpenDataStorageByDataId(sf::Out> out, ncm::DataId data_id, u8 storage_id); public: DEFINE_SERVICE_DISPATCH_TABLE { MAKE_SERVICE_COMMAND_META(OpenFileSystemWithPatch, hos::Version_200), diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp index dee285d74..311a3d4e2 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp @@ -31,7 +31,7 @@ namespace ams::mitm::fs { /* RCM bug patched. */ /* Only allow NS to update the BCT pubks. */ /* AutoRCM on a patched unit will cause a brick, so homebrew should NOT be allowed to write. */ - return this->client_info.program_id == ncm::ProgramId::Ns; + return this->client_info.program_id == ncm::SystemProgramId::Ns; } else { /* RCM bug unpatched. */ /* Allow homebrew but not NS to update the BCT pubks. */ diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.hpp b/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.hpp index 63ffde9f5..d01e7dcb6 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.hpp @@ -30,7 +30,7 @@ namespace ams::mitm::ns { /* We will mitm: * - web applets, to facilitate hbl web browser launching. */ - return ncm::IsWebAppletProgramId(client_info.program_id); + return ncm::IsWebAppletId(client_info.program_id); } public: SF_MITM_SERVICE_OBJECT_CTOR(NsAmMitmService) { /* ... */ } diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp index 9fcf23008..3b2c7b9f2 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp @@ -59,7 +59,7 @@ namespace ams::mitm::ns { /* We will mitm: * - web applets, to facilitate hbl web browser launching. */ - return ncm::IsWebAppletProgramId(client_info.program_id); + return ncm::IsWebAppletId(client_info.program_id); } public: SF_MITM_SERVICE_OBJECT_CTOR(NsWebMitmService) { /* ... */ } diff --git a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp index d9736ff7d..25becb56f 100644 --- a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp @@ -22,12 +22,12 @@ namespace ams::mitm::settings { Result SetMitmService::EnsureLocale() { std::scoped_lock lk(this->lock); - const bool is_ns = this->client_info.program_id == ncm::ProgramId::Ns; + const bool is_ns = this->client_info.program_id == ncm::SystemProgramId::Ns; if (!this->got_locale) { std::memset(&this->locale, 0xCC, sizeof(this->locale)); ncm::ProgramId program_id = this->client_info.program_id; - if (program_id == ncm::ProgramId::Ns) { + if (is_ns) { /* When NS asks for a locale, refresh to get the current application locale. */ os::ProcessId application_process_id; R_TRY(pm::dmnt::GetApplicationProcessId(&application_process_id)); diff --git a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp index 605569646..778f3748d 100644 --- a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp @@ -33,8 +33,8 @@ namespace ams::mitm::settings { /* We will mitm: * - ns and games, to allow for overriding game locales. */ - const bool is_game = (ncm::IsApplicationProgramId(client_info.program_id) && !client_info.override_status.IsHbl()); - return client_info.program_id == ncm::ProgramId::Ns || is_game; + const bool is_game = (ncm::IsApplicationId(client_info.program_id) && !client_info.override_status.IsHbl()); + return client_info.program_id == ncm::SystemProgramId::Ns || is_game; } public: SF_MITM_SERVICE_OBJECT_CTOR(SetMitmService) { 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 fc3425dce..9bbf89df1 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp @@ -35,7 +35,7 @@ namespace ams::mitm::settings { } /* Mount firmware version data archive. */ - R_ABORT_UNLESS(romfsMountFromDataArchive(static_cast(ncm::ProgramId::ArchiveSystemVersion), NcmStorageId_BuiltInSystem, "sysver")); + R_ABORT_UNLESS(romfsMountFromDataArchive(ncm::SystemDataId::SystemVersion.value, NcmStorageId_BuiltInSystem, "sysver")); { ON_SCOPE_EXIT { romfsUnmount("sysver"); }; @@ -75,7 +75,7 @@ namespace ams::mitm::settings { /* We want to give a special firmware version to the home menu title, and nothing else. */ /* This means Qlaunch + Maintenance Menu, and nothing else. */ - if (client_info.program_id == ncm::ProgramId::AppletQlaunch || client_info.program_id == ncm::ProgramId::AppletMaintenanceMenu) { + if (client_info.program_id == ncm::SystemAppletId::Qlaunch || client_info.program_id == ncm::SystemAppletId::MaintenanceMenu) { *out = g_ams_firmware_version; } else { *out = g_firmware_version; diff --git a/stratosphere/boot/source/boot_main.cpp b/stratosphere/boot/source/boot_main.cpp index 6494f8857..a46c4097a 100644 --- a/stratosphere/boot/source/boot_main.cpp +++ b/stratosphere/boot/source/boot_main.cpp @@ -52,7 +52,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Boot; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Boot; void ExceptionHandler(FatalErrorContext *ctx) { /* We're boot sysmodule, so manually reboot to fatal error. */ diff --git a/stratosphere/boot2/source/boot2_main.cpp b/stratosphere/boot2/source/boot2_main.cpp index 390b87929..37c2f6aa9 100644 --- a/stratosphere/boot2/source/boot2_main.cpp +++ b/stratosphere/boot2/source/boot2_main.cpp @@ -38,7 +38,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Boot2; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Boot2; namespace result { diff --git a/stratosphere/creport/source/creport_main.cpp b/stratosphere/creport/source/creport_main.cpp index 025210fc6..61d935512 100644 --- a/stratosphere/creport/source/creport_main.cpp +++ b/stratosphere/creport/source/creport_main.cpp @@ -40,7 +40,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Creport; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Creport; namespace result { diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp index 01a1c5f28..119cb65bd 100644 --- a/stratosphere/dmnt/source/dmnt_main.cpp +++ b/stratosphere/dmnt/source/dmnt_main.cpp @@ -35,7 +35,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Dmnt; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Dmnt; namespace result { diff --git a/stratosphere/eclct.stub/source/eclct_stub.cpp b/stratosphere/eclct.stub/source/eclct_stub.cpp index 10f651726..fe9e52254 100644 --- a/stratosphere/eclct.stub/source/eclct_stub.cpp +++ b/stratosphere/eclct.stub/source/eclct_stub.cpp @@ -36,7 +36,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Eclct; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Eclct; namespace result { diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp index 50afb99a1..1f6735842 100644 --- a/stratosphere/fatal/source/fatal_main.cpp +++ b/stratosphere/fatal/source/fatal_main.cpp @@ -44,7 +44,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Fatal; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Fatal; namespace result { diff --git a/stratosphere/fatal/source/fatal_service.cpp b/stratosphere/fatal/source/fatal_service.cpp index 9e403af0f..f5c5fa198 100644 --- a/stratosphere/fatal/source/fatal_service.cpp +++ b/stratosphere/fatal/source/fatal_service.cpp @@ -83,7 +83,7 @@ namespace ams::fatal::srv { /* Get program id. */ pm::info::GetProgramId(&this->context.program_id, process_id); - this->context.is_creport = (this->context.program_id == ncm::ProgramId::Creport); + this->context.is_creport = (this->context.program_id == ncm::SystemProgramId::Creport); if (!this->context.is_creport) { /* On firmware version 2.0.0, use debugging SVCs to collect information. */ diff --git a/stratosphere/loader/source/ldr_anti_downgrade_tables.inc b/stratosphere/loader/source/ldr_anti_downgrade_tables.inc index 5184d8a65..30f6498f0 100644 --- a/stratosphere/loader/source/ldr_anti_downgrade_tables.inc +++ b/stratosphere/loader/source/ldr_anti_downgrade_tables.inc @@ -23,158 +23,158 @@ constexpr u32 MakeSystemVersion(u32 major, u32 minor, u32 micro) { } constexpr MinimumProgramVersion g_MinimumProgramVersions810[] = { - {ncm::ProgramId::Settings, 1}, - {ncm::ProgramId::Bus, 1}, - {ncm::ProgramId::Audio, 1}, - {ncm::ProgramId::NvServices, 1}, - {ncm::ProgramId::Ns, 1}, - {ncm::ProgramId::Ssl, 1}, - {ncm::ProgramId::Es, 1}, - {ncm::ProgramId::Creport, 1}, - {ncm::ProgramId::Ro, 1}, + {ncm::SystemProgramId::Settings, 1}, + {ncm::SystemProgramId::Bus, 1}, + {ncm::SystemProgramId::Audio, 1}, + {ncm::SystemProgramId::NvServices, 1}, + {ncm::SystemProgramId::Ns, 1}, + {ncm::SystemProgramId::Ssl, 1}, + {ncm::SystemProgramId::Es, 1}, + {ncm::SystemProgramId::Creport, 1}, + {ncm::SystemProgramId::Ro, 1}, }; constexpr size_t g_MinimumProgramVersionsCount810 = util::size(g_MinimumProgramVersions810); constexpr MinimumProgramVersion g_MinimumProgramVersions900[] = { /* All non-Development System Modules. */ - {ncm::ProgramId::Usb, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Tma, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Boot2, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Settings, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Bus, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Bluetooth, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Bcat, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Dmnt, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Friends, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Nifm, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Ptm, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Shell, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::BsdSockets, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Hid, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Audio, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::LogManager, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Wlan, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Cs, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Ldn, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::NvServices, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Pcv, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Ppc, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::NvnFlinger, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Pcie, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Account, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Ns, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Nfc, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Psc, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::CapSrv, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Am, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Ssl, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Nim, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Cec, MakeSystemVersion(9, 0, 0)}, */ - /* {ncm::ProgramId::Tspm, MakeSystemVersion(9, 0, 0)}, */ - /* {ncm::ProgramId::Spl, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Lbl, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Btm, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Erpt, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Time, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Vi, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Pctl, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Npns, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Eupld, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Glue, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Eclct, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Es, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Fatal, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Grc, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Creport, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Ro, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Profiler, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Sdb, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Migration, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Jit, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::JpegDec, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::SafeMode, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Olsc, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Dt, MakeSystemVersion(9, 0, 0)}, */ - /* {ncm::ProgramId::Nd, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Ngct, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Usb, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Tma, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Boot2, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Settings, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Bus, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Bluetooth, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Bcat, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Dmnt, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Friends, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Nifm, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Ptm, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Shell, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::BsdSockets, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Hid, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Audio, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::LogManager, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Wlan, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Cs, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Ldn, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::NvServices, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Pcv, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Ppc, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::NvnFlinger, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Pcie, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Account, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Ns, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Nfc, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Psc, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::CapSrv, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Am, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Ssl, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Nim, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Cec, MakeSystemVersion(9, 0, 0)}, */ + /* {ncm::SystemProgramId::Tspm, MakeSystemVersion(9, 0, 0)}, */ + /* {ncm::SystemProgramId::Spl, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Lbl, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Btm, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Erpt, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Time, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Vi, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Pctl, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Npns, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Eupld, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Glue, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Eclct, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Es, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Fatal, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Grc, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Creport, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Ro, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Profiler, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Sdb, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Migration, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Jit, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::JpegDec, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::SafeMode, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Olsc, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Dt, MakeSystemVersion(9, 0, 0)}, */ + /* {ncm::SystemProgramId::Nd, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Ngct, MakeSystemVersion(9, 0, 0)}, /* All Web Applets. */ - {ncm::ProgramId::AppletWeb, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::AppletShop, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::AppletOfflineWeb, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::AppletLoginShare, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::AppletWifiWebAuth, MakeSystemVersion(9, 0, 0)}, + {ncm::WebAppletId::Web, MakeSystemVersion(9, 0, 0)}, + {ncm::WebAppletId::Shop, MakeSystemVersion(9, 0, 0)}, + {ncm::WebAppletId::OfflineWeb, MakeSystemVersion(9, 0, 0)}, + {ncm::WebAppletId::LoginShare, MakeSystemVersion(9, 0, 0)}, + {ncm::WebAppletId::WifiWebAuth, MakeSystemVersion(9, 0, 0)}, }; constexpr size_t g_MinimumProgramVersionsCount900 = util::size(g_MinimumProgramVersions900); constexpr MinimumProgramVersion g_MinimumProgramVersions910[] = { /* All non-Development System Modules. */ - {ncm::ProgramId::Usb, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Tma, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Boot2, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Settings, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Bus, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Bluetooth, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Bcat, MakeSystemVersion(9, 1, 0)}, - /* {ncm::ProgramId::Dmnt, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Friends, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Nifm, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Ptm, MakeSystemVersion(9, 0, 0)}, - /* {ncm::ProgramId::Shell, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::BsdSockets, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Hid, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Audio, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::LogManager, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Wlan, MakeSystemVersion(9, 1, 0)}, - /* {ncm::ProgramId::Cs, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Ldn, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::NvServices, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Pcv, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Ppc, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::NvnFlinger, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Pcie, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Account, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Ns, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Nfc, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Psc, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::CapSrv, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Am, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Ssl, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Nim, MakeSystemVersion(9, 1, 0)}, - /* {ncm::ProgramId::Cec, MakeSystemVersion(9, 0, 0)}, */ - /* {ncm::ProgramId::Tspm, MakeSystemVersion(9, 0, 0)}, */ - /* {ncm::ProgramId::Spl, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Lbl, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Btm, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Erpt, MakeSystemVersion(9, 1, 0)}, - /* {ncm::ProgramId::Time, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Vi, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Pctl, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Npns, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Eupld, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Glue, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Eclct, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Es, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Fatal, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Grc, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Creport, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::Ro, MakeSystemVersion(9, 1, 0)}, - /* {ncm::ProgramId::Profiler, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Sdb, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Migration, MakeSystemVersion(9, 1, 0)}, - /* {ncm::ProgramId::Jit, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::JpegDec, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::SafeMode, MakeSystemVersion(9, 0, 0)}, - {ncm::ProgramId::Olsc, MakeSystemVersion(9, 1, 0)}, - /* {ncm::ProgramId::Dt, MakeSystemVersion(9, 0, 0)}, */ - /* {ncm::ProgramId::Nd, MakeSystemVersion(9, 0, 0)}, */ - {ncm::ProgramId::Ngct, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Usb, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Tma, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Boot2, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Settings, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Bus, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Bluetooth, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Bcat, MakeSystemVersion(9, 1, 0)}, + /* {ncm::SystemProgramId::Dmnt, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Friends, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Nifm, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Ptm, MakeSystemVersion(9, 0, 0)}, + /* {ncm::SystemProgramId::Shell, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::BsdSockets, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Hid, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Audio, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::LogManager, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Wlan, MakeSystemVersion(9, 1, 0)}, + /* {ncm::SystemProgramId::Cs, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Ldn, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::NvServices, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Pcv, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Ppc, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::NvnFlinger, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Pcie, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Account, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Ns, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Nfc, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Psc, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::CapSrv, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Am, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Ssl, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Nim, MakeSystemVersion(9, 1, 0)}, + /* {ncm::SystemProgramId::Cec, MakeSystemVersion(9, 0, 0)}, */ + /* {ncm::SystemProgramId::Tspm, MakeSystemVersion(9, 0, 0)}, */ + /* {ncm::SystemProgramId::Spl, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Lbl, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Btm, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Erpt, MakeSystemVersion(9, 1, 0)}, + /* {ncm::SystemProgramId::Time, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Vi, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Pctl, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Npns, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Eupld, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Glue, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Eclct, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Es, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Fatal, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Grc, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Creport, MakeSystemVersion(9, 1, 0)}, + {ncm::SystemProgramId::Ro, MakeSystemVersion(9, 1, 0)}, + /* {ncm::SystemProgramId::Profiler, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Sdb, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Migration, MakeSystemVersion(9, 1, 0)}, + /* {ncm::SystemProgramId::Jit, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::JpegDec, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::SafeMode, MakeSystemVersion(9, 0, 0)}, + {ncm::SystemProgramId::Olsc, MakeSystemVersion(9, 1, 0)}, + /* {ncm::SystemProgramId::Dt, MakeSystemVersion(9, 0, 0)}, */ + /* {ncm::SystemProgramId::Nd, MakeSystemVersion(9, 0, 0)}, */ + {ncm::SystemProgramId::Ngct, MakeSystemVersion(9, 1, 0)}, /* All Web Applets. */ - {ncm::ProgramId::AppletWeb, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::AppletShop, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::AppletOfflineWeb, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::AppletLoginShare, MakeSystemVersion(9, 1, 0)}, - {ncm::ProgramId::AppletWifiWebAuth, MakeSystemVersion(9, 1, 0)}, + {ncm::WebAppletId::Web, MakeSystemVersion(9, 1, 0)}, + {ncm::WebAppletId::Shop, MakeSystemVersion(9, 1, 0)}, + {ncm::WebAppletId::OfflineWeb, MakeSystemVersion(9, 1, 0)}, + {ncm::WebAppletId::LoginShare, MakeSystemVersion(9, 1, 0)}, + {ncm::WebAppletId::WifiWebAuth, MakeSystemVersion(9, 1, 0)}, }; constexpr size_t g_MinimumProgramVersionsCount910 = util::size(g_MinimumProgramVersions910); diff --git a/stratosphere/loader/source/ldr_main.cpp b/stratosphere/loader/source/ldr_main.cpp index fad45b6d7..327e91e92 100644 --- a/stratosphere/loader/source/ldr_main.cpp +++ b/stratosphere/loader/source/ldr_main.cpp @@ -39,7 +39,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Loader; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Loader; namespace result { diff --git a/stratosphere/ncm/source/ncm_main.cpp b/stratosphere/ncm/source/ncm_main.cpp index 9df88642f..d44efde10 100644 --- a/stratosphere/ncm/source/ncm_main.cpp +++ b/stratosphere/ncm/source/ncm_main.cpp @@ -37,7 +37,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Ncm; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Ncm; namespace result { diff --git a/stratosphere/pm/source/impl/pm_process_manager.cpp b/stratosphere/pm/source/impl/pm_process_manager.cpp index 1f3feb7b1..de092f277 100644 --- a/stratosphere/pm/source/impl/pm_process_manager.cpp +++ b/stratosphere/pm/source/impl/pm_process_manager.cpp @@ -352,7 +352,7 @@ namespace ams::pm::impl { /* Process hooks/signaling. */ if (location.program_id == g_program_id_hook) { g_hook_to_create_process_event.Signal(); - g_program_id_hook = ncm::ProgramId::Invalid; + g_program_id_hook = ncm::InvalidProgramId; } else if (is_application && g_application_hook) { g_hook_to_create_application_process_event.Signal(); g_application_hook = false; @@ -666,7 +666,7 @@ namespace ams::pm::impl { *out_hook = INVALID_HANDLE; { - ncm::ProgramId old_value = ncm::ProgramId::Invalid; + ncm::ProgramId old_value = ncm::InvalidProgramId; R_UNLESS(g_program_id_hook.compare_exchange_strong(old_value, program_id), pm::ResultDebugHookInUse()); } @@ -688,7 +688,7 @@ namespace ams::pm::impl { Result ClearHook(u32 which) { if (which & HookType_ProgramId) { - g_program_id_hook = ncm::ProgramId::Invalid; + g_program_id_hook = ncm::InvalidProgramId; } if (which & HookType_Application) { g_application_hook = false; diff --git a/stratosphere/pm/source/pm_main.cpp b/stratosphere/pm/source/pm_main.cpp index cc4f6e1c3..b963dd883 100644 --- a/stratosphere/pm/source/pm_main.cpp +++ b/stratosphere/pm/source/pm_main.cpp @@ -41,7 +41,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Pm; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Pm; namespace result { diff --git a/stratosphere/ro/source/impl/ro_service_impl.cpp b/stratosphere/ro/source/impl/ro_service_impl.cpp index 88ddee35a..93a87227a 100644 --- a/stratosphere/ro/source/impl/ro_service_impl.cpp +++ b/stratosphere/ro/source/impl/ro_service_impl.cpp @@ -87,7 +87,7 @@ namespace ams::ro::impl { process_h = other_process_h; } - ncm::ProgramId program_id = ncm::ProgramId::Invalid; + ncm::ProgramId program_id = ncm::InvalidProgramId; if (hos::GetVersion() >= hos::Version_300) { /* 3.0.0+: Use svcGetInfo. */ R_ABORT_UNLESS(svcGetInfo(&program_id.value, InfoType_ProgramId, process_h, 0)); diff --git a/stratosphere/ro/source/ro_main.cpp b/stratosphere/ro/source/ro_main.cpp index b27ddb87a..36344558f 100644 --- a/stratosphere/ro/source/ro_main.cpp +++ b/stratosphere/ro/source/ro_main.cpp @@ -34,7 +34,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Ro; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Ro; namespace result { diff --git a/stratosphere/sm/source/impl/sm_service_manager.cpp b/stratosphere/sm/source/impl/sm_service_manager.cpp index ff2d03ac4..19248a7e3 100644 --- a/stratosphere/sm/source/impl/sm_service_manager.cpp +++ b/stratosphere/sm/source/impl/sm_service_manager.cpp @@ -239,10 +239,13 @@ namespace ams::sm::impl { bool IsMitmDisallowed(ncm::ProgramId program_id) { /* Mitm used on certain programs can prevent the boot process from completing. */ /* TODO: Is there a way to do this that's less hardcoded? Needs design thought. */ - return program_id == ncm::ProgramId::Loader || - program_id == ncm::ProgramId::Boot || - program_id == ncm::ProgramId::AtmosphereMitm || - program_id == ncm::ProgramId::Creport; + return program_id == ncm::SystemProgramId::Loader || + program_id == ncm::SystemProgramId::Pm || + program_id == ncm::SystemProgramId::Spl || + program_id == ncm::SystemProgramId::Boot || + program_id == ncm::SystemProgramId::Ncm || + program_id == ncm::AtmosphereProgramId::Mitm || + program_id == ncm::SystemProgramId::Creport; } Result AddFutureMitmDeclaration(ServiceName service) { diff --git a/stratosphere/sm/source/sm_main.cpp b/stratosphere/sm/source/sm_main.cpp index 3fc050a3e..b588397ca 100644 --- a/stratosphere/sm/source/sm_main.cpp +++ b/stratosphere/sm/source/sm_main.cpp @@ -40,7 +40,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Sm; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Sm; namespace result { diff --git a/stratosphere/sm/source/sm_manager_service.cpp b/stratosphere/sm/source/sm_manager_service.cpp index 7e6af932f..230bf9e8b 100644 --- a/stratosphere/sm/source/sm_manager_service.cpp +++ b/stratosphere/sm/source/sm_manager_service.cpp @@ -19,7 +19,7 @@ namespace ams::sm { Result ManagerService::RegisterProcess(os::ProcessId process_id, const sf::InBuffer &acid_sac, const sf::InBuffer &aci_sac) { - return impl::RegisterProcess(process_id, ncm::ProgramId::Invalid, cfg::OverrideStatus{}, acid_sac.GetPointer(), acid_sac.GetSize(), aci_sac.GetPointer(), aci_sac.GetSize()); + return impl::RegisterProcess(process_id, ncm::InvalidProgramId, cfg::OverrideStatus{}, acid_sac.GetPointer(), acid_sac.GetSize(), aci_sac.GetPointer(), aci_sac.GetSize()); } Result ManagerService::UnregisterProcess(os::ProcessId process_id) { diff --git a/stratosphere/spl/source/spl_main.cpp b/stratosphere/spl/source/spl_main.cpp index f08a6a165..32fb16f05 100644 --- a/stratosphere/spl/source/spl_main.cpp +++ b/stratosphere/spl/source/spl_main.cpp @@ -46,7 +46,7 @@ extern "C" { namespace ams { - ncm::ProgramId CurrentProgramId = ncm::ProgramId::Spl; + ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Spl; namespace result {