diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_bis.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_bis.hpp index 01357eb45..4bdf4cf4c 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_bis.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_bis.hpp @@ -44,6 +44,8 @@ namespace ams::fs { SystemProperEncryption = 32, SystemProperPartition = 33, SignedSystemPartitionOnSafeMode = 34, + DeviceTreeBlob = 35, + System0 = 36, }; const char *GetBisMountName(BisPartitionId id); diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_content_storage.hpp index 9fa587a52..d2c378a52 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_content_storage.hpp @@ -15,16 +15,10 @@ */ #pragma once #include +#include namespace ams::fs { - /* ACCURATE_TO_VERSION: Unknown */ - enum class ContentStorageId : u32 { - System = 0, - User = 1, - SdCard = 2, - }; - constexpr inline const char * const ContentStorageDirectoryName = "Contents"; const char *GetContentStorageMountName(ContentStorageId id); diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_content_storage_id.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_content_storage_id.hpp new file mode 100644 index 000000000..9a4390877 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_content_storage_id.hpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include + +namespace ams::fs { + + /* ACCURATE_TO_VERSION: 16.2.0.0 */ + enum class ContentStorageId : u32 { + System = 0, + User = 1, + SdCard = 2, + System0 = 3, + }; + +} diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp index 50af90509..75e8f17a1 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_api.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace ams::ncm { @@ -46,6 +47,8 @@ namespace ams::ncm { Result InvalidateRightsIdCache(); + Result ActivateFsContentStorage(fs::ContentStorageId fs_content_storage_id); + /* Deprecated API. */ Result CloseContentStorageForcibly(StorageId storage_id); Result CloseContentMetaDatabaseForcibly(StorageId storage_id); 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 748202a79..b34cfd9cd 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -151,6 +151,7 @@ namespace ams::ncm { Result InactivateContentMetaDatabase(StorageId storage_id); Result InvalidateRightsIdCache(); Result GetMemoryReport(sf::Out out); + Result ActivateFsContentStorage(fs::ContentStorageId fs_content_storage_id); }; static_assert(IsIContentManager); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp index 75ca42304..c974689b3 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_manager.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #define AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO(C, H) \ AMS_SF_METHOD_INFO(C, H, 0, Result, CreateContentStorage, (ncm::StorageId storage_id), (storage_id)) \ @@ -33,6 +34,7 @@ AMS_SF_METHOD_INFO(C, H, 11, Result, ActivateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \ AMS_SF_METHOD_INFO(C, H, 12, Result, InactivateContentMetaDatabase, (ncm::StorageId storage_id), (storage_id), hos::Version_2_0_0) \ AMS_SF_METHOD_INFO(C, H, 13, Result, InvalidateRightsIdCache, (), (), hos::Version_9_0_0) \ - AMS_SF_METHOD_INFO(C, H, 14, Result, GetMemoryReport, (sf::Out out), (out), hos::Version_10_0_0) + AMS_SF_METHOD_INFO(C, H, 14, Result, GetMemoryReport, (sf::Out out), (out), hos::Version_10_0_0) \ + AMS_SF_METHOD_INFO(C, H, 15, Result, ActivateFsContentStorage, (fs::ContentStorageId fs_storage_id), (fs_storage_id)) /* Technically min 16.0.0, but used. */ AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentManager, AMS_NCM_I_CONTENT_MANAGER_INTERFACE_INFO, 0xFDB4FFE1); 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 index 9a470b38f..b02c38fc5 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_system_content_meta_id.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_system_content_meta_id.hpp @@ -98,6 +98,7 @@ namespace ams::ncm { static const SystemProgramId Pgl; static const SystemProgramId Omm; static const SystemProgramId Eth; + static const SystemProgramId Ngc; static const SystemProgramId End; @@ -205,6 +206,7 @@ namespace ams::ncm { inline constexpr const SystemProgramId SystemProgramId::Pgl = { 0x0100000000000042ul }; inline constexpr const SystemProgramId SystemProgramId::Omm = { 0x0100000000000045ul }; inline constexpr const SystemProgramId SystemProgramId::Eth = { 0x0100000000000046ul }; + inline constexpr const SystemProgramId SystemProgramId::Ngc = { 0x0100000000000050ul }; inline constexpr const SystemProgramId SystemProgramId::End = { 0x01000000000007FFul }; diff --git a/libraries/libstratosphere/source/boot2/boot2_api.board.nintendo_nx.cpp b/libraries/libstratosphere/source/boot2/boot2_api.board.nintendo_nx.cpp index 005e38e95..e5f27fce6 100644 --- a/libraries/libstratosphere/source/boot2/boot2_api.board.nintendo_nx.cpp +++ b/libraries/libstratosphere/source/boot2/boot2_api.board.nintendo_nx.cpp @@ -74,6 +74,7 @@ namespace ams::boot2 { ncm::SystemProgramId::Profiler, /* profiler */ ncm::SystemProgramId::Sdb, /* sdb */ ncm::SystemProgramId::Olsc, /* olsc */ + ncm::SystemProgramId::Ngc, /* ngc */ ncm::SystemProgramId::Ngct, /* ngct */ }; constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms); @@ -115,6 +116,7 @@ namespace ams::boot2 { ncm::SystemProgramId::Profiler, /* profiler */ ncm::SystemProgramId::Sdb, /* sdb */ ncm::SystemProgramId::Olsc, /* olsc */ + ncm::SystemProgramId::Ngc, /* ngc */ ncm::SystemProgramId::Ngct, /* ngct */ }; constexpr size_t NumAdditionalMaintenanceLaunchPrograms = util::size(AdditionalMaintenanceLaunchPrograms); @@ -399,6 +401,9 @@ namespace ams::boot2 { LaunchProgram(nullptr, ncm::ProgramLocation::Make(ncm::SystemProgramId::Usb, ncm::StorageId::BuiltInSystem), 0); } + /* Activate the system fs content storage. */ + R_ABORT_UNLESS(ncm::ActivateFsContentStorage(fs::ContentStorageId::System)); + /* Find out whether we are maintenance mode. */ const bool maintenance = IsMaintenanceMode(); if (maintenance) { diff --git a/libraries/libstratosphere/source/fs/fs_access_log.cpp b/libraries/libstratosphere/source/fs/fs_access_log.cpp index 18a760b61..157e1ca38 100644 --- a/libraries/libstratosphere/source/fs/fs_access_log.cpp +++ b/libraries/libstratosphere/source/fs/fs_access_log.cpp @@ -118,6 +118,7 @@ namespace ams::fs::impl { ADD_ENUM_CASE(User); ADD_ENUM_CASE(System); ADD_ENUM_CASE(SdCard); + ADD_ENUM_CASE(System0); default: return ToValueString(static_cast(id)); } } @@ -171,6 +172,8 @@ namespace ams::fs::impl { ADD_ENUM_CASE(System); ADD_ENUM_CASE(SystemProperEncryption); ADD_ENUM_CASE(SystemProperPartition); + ADD_ENUM_CASE(DeviceTreeBlob); + ADD_ENUM_CASE(System0); default: return ToValueString(static_cast(id)); } } diff --git a/libraries/libstratosphere/source/fs/impl/fs_id_string_impl.os.generic.cpp b/libraries/libstratosphere/source/fs/impl/fs_id_string_impl.os.generic.cpp index 072fee676..c1e99b108 100644 --- a/libraries/libstratosphere/source/fs/impl/fs_id_string_impl.os.generic.cpp +++ b/libraries/libstratosphere/source/fs/impl/fs_id_string_impl.os.generic.cpp @@ -21,7 +21,7 @@ namespace ams::fs::impl { #define ADD_ENUM_CASE(v) case v: return #v template<> const char *IdString::ToString(pkg1::KeyGeneration id) { - static_assert(pkg1::KeyGeneration_Current == pkg1::KeyGeneration_15_0_0); + static_assert(pkg1::KeyGeneration_Current == pkg1::KeyGeneration_16_0_0); switch (id) { using enum pkg1::KeyGeneration; case KeyGeneration_1_0_0: return "1.0.0-2.3.0"; @@ -38,7 +38,8 @@ namespace ams::fs::impl { case KeyGeneration_12_1_0: return "12.1.0"; case KeyGeneration_13_0_0: return "13.0.0-13.2.1"; case KeyGeneration_14_0_0: return "14.0.0-14.1.2"; - case KeyGeneration_15_0_0: return "15.0.0-"; + case KeyGeneration_15_0_0: return "15.0.0-15.0.1"; + case KeyGeneration_16_0_0: return "16.0.0-"; default: return "Unknown"; } } diff --git a/libraries/libstratosphere/source/ncm/ncm_api.cpp b/libraries/libstratosphere/source/ncm/ncm_api.cpp index e26492d2e..684a55a72 100644 --- a/libraries/libstratosphere/source/ncm/ncm_api.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_api.cpp @@ -114,6 +114,10 @@ namespace ams::ncm { R_RETURN(g_content_manager->InvalidateRightsIdCache()); } + Result ActivateFsContentStorage(fs::ContentStorageId fs_content_storage_id) { + R_RETURN(g_content_manager->ActivateFsContentStorage(fs_content_storage_id)); + } + /* Deprecated API. */ Result CloseContentStorageForcibly(StorageId storage_id) { AMS_ABORT_UNLESS(hos::GetVersion() == hos::Version_1_0_0); diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index f93883924..99857bec3 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -675,6 +675,12 @@ namespace ams::ncm { R_SUCCEED(); } + Result ContentManagerImpl::ActivateFsContentStorage(fs::ContentStorageId fs_content_storage_id) { + /* TODO */ + AMS_UNUSED(fs_content_storage_id); + R_SUCCEED(); + } + Result ContentManagerImpl::GetMemoryReport(sf::Out out) { /* Populate content meta resource states. */ MemoryReport report = { diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp index 25b412d6b..e9ee891ad 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_manager_impl.hpp @@ -99,6 +99,10 @@ namespace ams::ncm { AMS_UNUSED(out); AMS_ABORT(); } + + Result ActivateFsContentStorage(fs::ContentStorageId fs_content_storage_id) { + R_RETURN(::ncmActivateFsContentStorage(static_cast<::FsContentStorageId>(util::ToUnderlying(fs_content_storage_id)))); + } }; static_assert(ncm::IsIContentManager); #endif diff --git a/stratosphere/boot2/boot2.json b/stratosphere/boot2/boot2.json index d30b7ebc1..e98ff3d8e 100644 --- a/stratosphere/boot2/boot2.json +++ b/stratosphere/boot2/boot2.json @@ -16,7 +16,7 @@ "permissions": "0xFFFFFFFFFFFFFFFF" }, "service_host": ["*"], - "service_access": ["fsp-srv", "gpio", "htc", "lr", "pm:bm", "pm:shell", "pm:info", "set:sys"], + "service_access": ["fsp-srv", "gpio", "htc", "lr", "ncm", "pm:bm", "pm:shell", "pm:info", "set:sys"], "kernel_capabilities": [ { "type": "kernel_flags", diff --git a/stratosphere/boot2/source/boot2_main.cpp b/stratosphere/boot2/source/boot2_main.cpp index 57ef0453f..6a09b136e 100644 --- a/stratosphere/boot2/source/boot2_main.cpp +++ b/stratosphere/boot2/source/boot2_main.cpp @@ -61,6 +61,7 @@ namespace ams { R_ABORT_UNLESS(pmshellInitialize()); R_ABORT_UNLESS(setsysInitialize()); gpio::Initialize(); + ncm::Initialize(); /* Mount the SD card. */ R_ABORT_UNLESS(fs::MountSdCard("sdmc"));