sprofile: clean up and update for 23.0.0

This commit is contained in:
hexkyz
2026-09-17 00:34:00 +01:00
parent 7cc625946e
commit 98d64c28d8
20 changed files with 225 additions and 146 deletions

View File

@@ -18,18 +18,18 @@
namespace ams::sprofile { namespace ams::sprofile {
struct Identifier { struct HashKey {
u8 data[7]; u8 data[7];
friend bool operator==(const Identifier &lhs, const Identifier &rhs) { friend bool operator==(const HashKey &lhs, const HashKey &rhs) {
return std::memcmp(lhs.data, rhs.data, sizeof(lhs.data)) == 0; return std::memcmp(lhs.data, rhs.data, sizeof(lhs.data)) == 0;
} }
friend bool operator!=(const Identifier &lhs, const Identifier &rhs) { friend bool operator!=(const HashKey &lhs, const HashKey &rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
}; };
static_assert(sizeof(Identifier) == 7); static_assert(sizeof(HashKey) == 7);
static_assert(util::is_pod<Identifier>::value); static_assert(util::is_pod<HashKey>::value);
} }

View File

@@ -17,8 +17,8 @@
#include <stratosphere.hpp> #include <stratosphere.hpp>
#define AMS_SPROFILE_I_PROFILE_CONTROLLER_FOR_DEBUG_INTERFACE_INFO(C, H) \ #define AMS_SPROFILE_I_PROFILE_CONTROLLER_FOR_DEBUG_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 2000, Result, Reset, (), ()) \ AMS_SF_METHOD_INFO(C, H, 2000, Result, ClearSaveData, (), ()) \
AMS_SF_METHOD_INFO(C, H, 2001, Result, GetRaw, (sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::Identifier profile, sprofile::Identifier key), (out_type, out_value, profile, key)) AMS_SF_METHOD_INFO(C, H, 2001, Result, QueryValue, (sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::HashKey profile, sprofile::HashKey key), (out_type, out_value, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 2002, Result, QueryValueArray, (sf::Out<u8> out_type, sf::Out<u32> out_count, const sf::OutBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out_type, out_count, out_buffer, profile, key), hos::Version_23_0_0)
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileControllerForDebug, AMS_SPROFILE_I_PROFILE_CONTROLLER_FOR_DEBUG_INTERFACE_INFO, 0xA8C14F64) AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileControllerForDebug, AMS_SPROFILE_I_PROFILE_CONTROLLER_FOR_DEBUG_INTERFACE_INFO, 0xA8C14F64)

View File

@@ -18,8 +18,8 @@
#include "sprofile_srv_types.hpp" #include "sprofile_srv_types.hpp"
#define AMS_SPROFILE_I_PROFILE_IMPORTER_INTERFACE_INFO(C, H) \ #define AMS_SPROFILE_I_PROFILE_IMPORTER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, ImportProfile, (const sprofile::srv::ProfileDataForImportData &import), (import)) \ AMS_SF_METHOD_INFO(C, H, 0, Result, ImportProfile, (const sprofile::srv::ProfilePayload &import), (import)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Commit, (), ()) \ AMS_SF_METHOD_INFO(C, H, 1, Result, Commit, (), (), hos::Version_13_0_0, hos::Version_22_5_0) \
AMS_SF_METHOD_INFO(C, H, 2, Result, ImportMetadata, (const sprofile::srv::ProfileMetadataForImportMetadata &import), (import)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, ImportMetadata, (const sprofile::srv::MetadataPayload &import), (import), hos::Version_13_0_0, hos::Version_22_5_0)
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileImporter, AMS_SPROFILE_I_PROFILE_IMPORTER_INTERFACE_INFO, 0x1629C4E6) AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileImporter, AMS_SPROFILE_I_PROFILE_IMPORTER_INTERFACE_INFO, 0x1629C4E6)

View File

@@ -17,10 +17,18 @@
#include <stratosphere.hpp> #include <stratosphere.hpp>
#define AMS_SPROFILE_I_PROFILE_READER_INTERFACE_INFO(C, H) \ #define AMS_SPROFILE_I_PROFILE_READER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetSigned64, (sf::Out<s64> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \ AMS_SF_METHOD_INFO(C, H, 0, Result, GetInt64Value, (sf::Out<s64> out, sprofile::HashKey profile, sprofile::HashKey key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetUnsigned64, (sf::Out<u64> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, GetUInt64Value, (sf::Out<u64> out, sprofile::HashKey profile, sprofile::HashKey key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetSigned32, (sf::Out<s32> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, GetInt32Value, (sf::Out<s32> out, sprofile::HashKey profile, sprofile::HashKey key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetUnsigned32, (sf::Out<u32> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) \ AMS_SF_METHOD_INFO(C, H, 3, Result, GetUInt32Value, (sf::Out<u32> out, sprofile::HashKey profile, sprofile::HashKey key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetByte, (sf::Out<u8> out, sprofile::Identifier profile, sprofile::Identifier key), (out, profile, key)) AMS_SF_METHOD_INFO(C, H, 4, Result, GetBooleanValue, (sf::Out<u8> out, sprofile::HashKey profile, sprofile::HashKey key), (out, profile, key)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetAnyValue, (sf::Out<u64> out, sprofile::HashKey profile, sprofile::HashKey key), (out, profile, key), hos::Version_23_0_0) \
AMS_SF_METHOD_INFO(C, H, 6, Result, GetInt8ValueArray, (sf::Out<u32> out, const sf::OutBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out, out_buffer, profile, key), hos::Version_23_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetInt64ValueArray, (sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out, out_buffer, profile, key), hos::Version_23_0_0) \
AMS_SF_METHOD_INFO(C, H, 8, Result, GetUInt64ValueArray, (sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out, out_buffer, profile, key), hos::Version_23_0_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, GetInt32ValueArray, (sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out, out_buffer, profile, key), hos::Version_23_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, GetUInt32ValueArray, (sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out, out_buffer, profile, key), hos::Version_23_0_0) \
AMS_SF_METHOD_INFO(C, H, 11, Result, GetUInt8ValueArray, (sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out, out_buffer, profile, key), hos::Version_23_0_0) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GetAnyValueArray, (sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key), (out, out_buffer, profile, key), hos::Version_23_0_0)
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileReader, AMS_SPROFILE_I_PROFILE_READER_INTERFACE_INFO, 0x97090D4D) AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileReader, AMS_SPROFILE_I_PROFILE_READER_INTERFACE_INFO, 0x97090D4D)

View File

@@ -17,8 +17,8 @@
#include <stratosphere.hpp> #include <stratosphere.hpp>
#define AMS_SPROFILE_I_PROFILE_UPDATE_OBSERVER_INTERFACE_INFO(C, H) \ #define AMS_SPROFILE_I_PROFILE_UPDATE_OBSERVER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Listen, (sprofile::Identifier profile), (profile)) \ AMS_SF_METHOD_INFO(C, H, 0, Result, Subscribe, (sprofile::HashKey profile), (profile)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, Unlisten, (sprofile::Identifier profile), (profile)) \ AMS_SF_METHOD_INFO(C, H, 1, Result, Unsubscribe, (sprofile::HashKey profile), (profile)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetEventHandle, (ams::sf::OutCopyHandle out), (out)) AMS_SF_METHOD_INFO(C, H, 2, Result, GetUpdateEventNativeHandle, (ams::sf::OutCopyHandle out), (out))
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileUpdateObserver, AMS_SPROFILE_I_PROFILE_UPDATE_OBSERVER_INTERFACE_INFO, 0xB52A765C) AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, IProfileUpdateObserver, AMS_SPROFILE_I_PROFILE_UPDATE_OBSERVER_INTERFACE_INFO, 0xB52A765C)

View File

@@ -17,10 +17,10 @@
#include <stratosphere.hpp> #include <stratosphere.hpp>
#include "sprofile_srv_i_profile_importer.hpp" #include "sprofile_srv_i_profile_importer.hpp"
#define AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_BG_AGENT_INTERFACE_INFO(C, H) \ #define AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_BG_AGENT_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 100, Result, OpenProfileImporter, (sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileImporter>> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 100, Result, OpenProfileImporter, (sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileImporter>> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 200, Result, GetImportableProfileUrls, (sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::ProfileMetadataForImportMetadata &arg), (out_count, out, arg)) \ AMS_SF_METHOD_INFO(C, H, 200, Result, GetProfileDownloadUrlList, (sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::MetadataPayload &arg), (out_count, out, arg), hos::Version_13_0_0, hos::Version_22_5_0) \
AMS_SF_METHOD_INFO(C, H, 201, Result, IsUpdateNeeded, (sf::Out<bool> out, sprofile::Identifier revision_key), (out, revision_key)) \ AMS_SF_METHOD_INFO(C, H, 201, Result, GetMetadataNewness, (sf::Out<bool> out, sprofile::HashKey revision_key), (out, revision_key), hos::Version_13_0_0, hos::Version_22_5_0) \
AMS_SF_METHOD_INFO(C, H, 2000, Result, Reset, (), ()) AMS_SF_METHOD_INFO(C, H, 2000, Result, ClearSaveDataForTest, (), ())
AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, ISprofileServiceForBgAgent, AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_BG_AGENT_INTERFACE_INFO, 0xCCD828EC) AMS_SF_DEFINE_INTERFACE(ams::sprofile::srv, ISprofileServiceForBgAgent, AMS_SPROFILE_I_SPROFILE_SERVICE_FOR_BG_AGENT_INTERFACE_INFO, 0xCCD828EC)

View File

@@ -19,12 +19,18 @@
namespace ams::sprofile::srv { namespace ams::sprofile::srv {
Result ProfileControllerForDebugImpl::Reset() { Result ProfileControllerForDebugImpl::ClearSaveData() {
R_RETURN(m_manager->ResetSaveData()); R_RETURN(m_manager->ResetSaveData());
} }
Result ProfileControllerForDebugImpl::GetRaw(sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::Identifier profile, sprofile::Identifier key) { Result ProfileControllerForDebugImpl::QueryValue(sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::HashKey profile, sprofile::HashKey key) {
R_RETURN(m_manager->GetRaw(out_type.GetPointer(), out_value.GetPointer(), profile, key)); R_RETURN(m_manager->QueryValue(out_type.GetPointer(), out_value.GetPointer(), profile, key));
}
Result ProfileControllerForDebugImpl::QueryValueArray(sf::Out<u8> out_type, sf::Out<u32> out_count, const sf::OutBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out_type, out_count, out_buffer, profile, key);
R_SUCCEED();
} }
} }

View File

@@ -27,8 +27,9 @@ namespace ams::sprofile::srv {
public: public:
ProfileControllerForDebugImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ } ProfileControllerForDebugImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ }
public: public:
Result Reset(); Result ClearSaveData();
Result GetRaw(sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::Identifier profile, sprofile::Identifier key); Result QueryValue(sf::Out<u8> out_type, sf::Out<u64> out_value, sprofile::HashKey profile, sprofile::HashKey key);
Result QueryValueArray(sf::Out<u8> out_type, sf::Out<u32> out_count, const sf::OutBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
}; };
static_assert(IsIProfileControllerForDebug<ProfileControllerForDebugImpl>); static_assert(IsIProfileControllerForDebug<ProfileControllerForDebugImpl>);

View File

@@ -22,8 +22,8 @@ namespace ams::sprofile::srv {
class ProfileImporter { class ProfileImporter {
private: private:
struct ImportingProfile { struct ImportingProfile {
Identifier identifier_0; HashKey hash_key_0;
Identifier identifier_1; HashKey hash_key_1;
bool is_new_import; bool is_new_import;
}; };
private: private:
@@ -33,7 +33,7 @@ namespace ams::sprofile::srv {
util::optional<ProfileMetadata> m_metadata; util::optional<ProfileMetadata> m_metadata;
ImportingProfile m_importing_profiles[50]; ImportingProfile m_importing_profiles[50];
util::BitFlagSet<50> m_is_profile_importable; util::BitFlagSet<50> m_is_profile_importable;
Identifier m_revision_key; HashKey m_revision_key;
public: public:
ProfileImporter(const util::optional<ProfileMetadata> &meta) : m_committed(false), m_imported_metadata(false), m_importing_count(0), m_metadata(util::nullopt), m_is_profile_importable(), m_revision_key() { ProfileImporter(const util::optional<ProfileMetadata> &meta) : m_committed(false), m_imported_metadata(false), m_importing_count(0), m_metadata(util::nullopt), m_is_profile_importable(), m_revision_key() {
if (meta.has_value()) { if (meta.has_value()) {
@@ -41,12 +41,12 @@ namespace ams::sprofile::srv {
} }
} }
public: public:
bool HasProfile(Identifier id0, Identifier id1) { bool HasProfile(HashKey id0, HashKey id1) {
/* Require that we have metadata. */ /* Require that we have metadata. */
if (m_metadata.has_value()) { if (m_metadata.has_value()) {
for (auto i = 0u; i < std::min<size_t>(m_metadata->num_entries, util::size(m_metadata->entries)); ++i) { for (auto i = 0u; i < std::min<size_t>(m_metadata->num_entries, util::size(m_metadata->entries)); ++i) {
const auto &entry = m_metadata->entries[i]; const auto &entry = m_metadata->entries[i];
if (entry.identifier_0 == id0 && entry.identifier_1 == id1) { if (entry.hash_key_0 == id0 && entry.hash_key_1 == id1) {
return true; return true;
} }
} }
@@ -80,23 +80,23 @@ namespace ams::sprofile::srv {
for (auto i = 0; i < m_importing_count; ++i) { for (auto i = 0; i < m_importing_count; ++i) {
const auto &import_entry = meta.entries[i]; const auto &import_entry = meta.entries[i];
const bool is_new_import = !this->HasProfile(import_entry.identifier_0, import_entry.identifier_1); const bool is_new_import = !this->HasProfile(import_entry.hash_key_0, import_entry.hash_key_1);
m_importing_profiles[i] = { m_importing_profiles[i] = {
.identifier_0 = import_entry.identifier_0, .hash_key_0 = import_entry.hash_key_0,
.identifier_1 = import_entry.identifier_1, .hash_key_1 = import_entry.hash_key_1,
.is_new_import = is_new_import, .is_new_import = is_new_import,
}; };
m_is_profile_importable[i] = is_new_import; m_is_profile_importable[i] = is_new_import;
} }
} }
bool CanImportProfile(Identifier profile) { bool CanImportProfile(HashKey profile) {
/* Require that we imported metadata. */ /* Require that we imported metadata. */
if (m_imported_metadata) { if (m_imported_metadata) {
/* Find the specified profile. */ /* Find the specified profile. */
for (auto i = 0; i < m_importing_count; ++i) { for (auto i = 0; i < m_importing_count; ++i) {
if (m_importing_profiles[i].identifier_0 == profile) { if (m_importing_profiles[i].hash_key_0 == profile) {
/* Require the profile be importable. */ /* Require the profile be importable. */
return m_is_profile_importable[i]; return m_is_profile_importable[i];
} }
@@ -107,10 +107,10 @@ namespace ams::sprofile::srv {
return false; return false;
} }
void OnImportProfile(Identifier profile) { void OnImportProfile(HashKey profile) {
/* Set the profile as not importable (as it's imported). */ /* Set the profile as not importable (as it's imported). */
for (auto i = 0; i < m_importing_count; ++i) { for (auto i = 0; i < m_importing_count; ++i) {
if (m_importing_profiles[i].identifier_0 == profile) { if (m_importing_profiles[i].hash_key_0 == profile) {
m_is_profile_importable[i] = false; m_is_profile_importable[i] = false;
break; break;
} }
@@ -135,15 +135,15 @@ namespace ams::sprofile::srv {
int GetImportingCount() const { return m_importing_count; } int GetImportingCount() const { return m_importing_count; }
const ImportingProfile &GetImportingProfile(int i) const { return m_importing_profiles[i]; } const ImportingProfile &GetImportingProfile(int i) const { return m_importing_profiles[i]; }
Identifier GetRevisionKey() const { return m_revision_key; } HashKey GetRevisionKey() const { return m_revision_key; }
Result CleanupOrphanedProfiles(auto cleanup_impl) const { Result CleanupOrphanedProfiles(auto cleanup_impl) const {
/* Cleanup any orphaned profiles in our metadata. */ /* Cleanup any orphaned profiles in our metadata. */
if (m_metadata.has_value()) { if (m_metadata.has_value()) {
for (auto i = 0u; i < std::min<size_t>(m_metadata->num_entries, util::size(m_metadata->entries)); ++i) { for (auto i = 0u; i < std::min<size_t>(m_metadata->num_entries, util::size(m_metadata->entries)); ++i) {
const auto &entry = m_metadata->entries[i]; const auto &entry = m_metadata->entries[i];
if (!this->IsImportingProfile(entry.identifier_0)) { if (!this->IsImportingProfile(entry.hash_key_0)) {
R_TRY(cleanup_impl(entry.identifier_0)); R_TRY(cleanup_impl(entry.hash_key_0));
} }
} }
} }
@@ -151,10 +151,10 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
private: private:
bool IsImportingProfile(Identifier profile) const { bool IsImportingProfile(HashKey profile) const {
/* Check if we're importing the desired profile. */ /* Check if we're importing the desired profile. */
for (auto i = 0; i < m_importing_count; ++i) { for (auto i = 0; i < m_importing_count; ++i) {
if (m_importing_profiles[i].identifier_0 == profile) { if (m_importing_profiles[i].hash_key_0 == profile) {
return true; return true;
} }
} }

View File

@@ -19,7 +19,7 @@
namespace ams::sprofile::srv { namespace ams::sprofile::srv {
Result ProfileImporterImpl::ImportProfile(const sprofile::srv::ProfileDataForImportData &import) { Result ProfileImporterImpl::ImportProfile(const sprofile::srv::ProfilePayload &import) {
R_RETURN(m_manager->ImportProfile(import)); R_RETURN(m_manager->ImportProfile(import));
} }
@@ -27,7 +27,7 @@ namespace ams::sprofile::srv {
R_RETURN(m_manager->Commit()); R_RETURN(m_manager->Commit());
} }
Result ProfileImporterImpl::ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &import) { Result ProfileImporterImpl::ImportMetadata(const sprofile::srv::MetadataPayload &import) {
R_RETURN(m_manager->ImportMetadata(import)); R_RETURN(m_manager->ImportMetadata(import));
} }

View File

@@ -31,9 +31,9 @@ namespace ams::sprofile::srv {
m_manager->CloseProfileImporter(); m_manager->CloseProfileImporter();
} }
public: public:
Result ImportProfile(const sprofile::srv::ProfileDataForImportData &import); Result ImportProfile(const sprofile::srv::ProfilePayload &import);
Result Commit(); Result Commit();
Result ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &import); Result ImportMetadata(const sprofile::srv::MetadataPayload &import);
}; };
static_assert(IsIProfileImporter<ProfileImporterImpl>); static_assert(IsIProfileImporter<ProfileImporterImpl>);

View File

@@ -54,15 +54,15 @@ namespace ams::sprofile::srv {
CreateMetadataPathImpl(dst, dst_size, mount, TemporaryDirectoryName); CreateMetadataPathImpl(dst, dst_size, mount, TemporaryDirectoryName);
} }
void CreateProfilePathImpl(char *dst, size_t dst_size, const char *mount, const char *dir, const Identifier &id) { void CreateProfilePathImpl(char *dst, size_t dst_size, const char *mount, const char *dir, const HashKey &id) {
SafePrint(dst, dst_size, "%s:/%s/profiles/%02x%02x%02x%02x%02x%02x%02x", mount, dir, id.data[0], id.data[1], id.data[2], id.data[3], id.data[4], id.data[5], id.data[6]); SafePrint(dst, dst_size, "%s:/%s/profiles/%02x%02x%02x%02x%02x%02x%02x", mount, dir, id.data[0], id.data[1], id.data[2], id.data[3], id.data[4], id.data[5], id.data[6]);
} }
void CreatePrimaryProfilePath(char *dst, size_t dst_size, const char *mount, const Identifier &id) { void CreatePrimaryProfilePath(char *dst, size_t dst_size, const char *mount, const HashKey &id) {
CreateProfilePathImpl(dst, dst_size, mount, PrimaryDirectoryName, id); CreateProfilePathImpl(dst, dst_size, mount, PrimaryDirectoryName, id);
} }
void CreateTemporaryProfilePath(char *dst, size_t dst_size, const char *mount, const Identifier &id) { void CreateTemporaryProfilePath(char *dst, size_t dst_size, const char *mount, const HashKey &id) {
CreateProfilePathImpl(dst, dst_size, mount, TemporaryDirectoryName, id); CreateProfilePathImpl(dst, dst_size, mount, TemporaryDirectoryName, id);
} }
@@ -185,7 +185,12 @@ namespace ams::sprofile::srv {
this->CloseProfileImporterImpl(); this->CloseProfileImporterImpl();
} }
Result ProfileManager::ImportProfile(const sprofile::srv::ProfileDataForImportData &import) { Result ProfileManager::ImportProfile(const sprofile::srv::ProfilePayload &import) {
/* On 23.0.0+ profile importing is no longer supported. */
if (hos::GetVersion() >= hos::Version_23_0_0) {
R_THROW(sprofile::ResultNotImplemented());
}
/* Acquire locks. */ /* Acquire locks. */
std::scoped_lock lk1(m_profile_importer_mutex); std::scoped_lock lk1(m_profile_importer_mutex);
std::scoped_lock lk2(m_fs_mutex); std::scoped_lock lk2(m_fs_mutex);
@@ -211,21 +216,21 @@ namespace ams::sprofile::srv {
} }
/* Succeed if we already have the profile. */ /* Succeed if we already have the profile. */
R_SUCCEED_IF(m_profile_importer->HasProfile(import.header.identifier_0, import.header.identifier_1)); R_SUCCEED_IF(m_profile_importer->HasProfile(import.header.hash_key_0, import.header.hash_key_1));
/* Check that we're importing the profile. */ /* Check that we're importing the profile. */
R_UNLESS(m_profile_importer->CanImportProfile(import.header.identifier_0), sprofile::ResultInvalidState()); R_UNLESS(m_profile_importer->CanImportProfile(import.header.hash_key_0), sprofile::ResultInvalidState());
/* Create temporary directories. */ /* Create temporary directories. */
R_TRY(this->EnsureTemporaryDirectories()); R_TRY(this->EnsureTemporaryDirectories());
/* Create profile. */ /* Create profile. */
char path[0x30]; char path[0x30];
CreateTemporaryProfilePath(path, sizeof(path), m_save_data_info.mount_name, import.header.identifier_0); CreateTemporaryProfilePath(path, sizeof(path), m_save_data_info.mount_name, import.header.hash_key_0);
R_TRY(WriteFile(path, std::addressof(import.data), sizeof(import.data))); R_TRY(WriteFile(path, std::addressof(import.data), sizeof(import.data)));
/* Set profile imported. */ /* Set profile imported. */
m_profile_importer->OnImportProfile(import.header.identifier_0); m_profile_importer->OnImportProfile(import.header.hash_key_0);
R_SUCCEED(); R_SUCCEED();
} }
@@ -266,7 +271,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &import) { Result ProfileManager::ImportMetadata(const sprofile::srv::MetadataPayload &import) {
/* Acquire locks. */ /* Acquire locks. */
std::scoped_lock lk1(m_profile_importer_mutex); std::scoped_lock lk1(m_profile_importer_mutex);
std::scoped_lock lk2(m_fs_mutex); std::scoped_lock lk2(m_fs_mutex);
@@ -340,7 +345,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::LoadProfile(Identifier profile) { Result ProfileManager::LoadProfile(HashKey profile) {
/* Check if we already have the profile. */ /* Check if we already have the profile. */
if (m_service_profile.has_value()) { if (m_service_profile.has_value()) {
R_SUCCEED_IF(m_service_profile->name == profile); R_SUCCEED_IF(m_service_profile->name == profile);
@@ -362,7 +367,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::GetDataEntry(ProfileDataEntry *out, Identifier profile, Identifier key) { Result ProfileManager::GetDataEntry(ProfileDataEntry *out, HashKey profile, HashKey key) {
/* Acquire locks. */ /* Acquire locks. */
std::scoped_lock lk1(m_service_profile_mutex); std::scoped_lock lk1(m_service_profile_mutex);
std::scoped_lock lk2(m_general_mutex); std::scoped_lock lk2(m_general_mutex);
@@ -381,7 +386,7 @@ namespace ams::sprofile::srv {
R_THROW(sprofile::ResultKeyNotFound()); R_THROW(sprofile::ResultKeyNotFound());
} }
Result ProfileManager::GetSigned64(s64 *out, Identifier profile, Identifier key) { Result ProfileManager::GetInt64Value(s64 *out, HashKey profile, HashKey key) {
/* Get the data entry. */ /* Get the data entry. */
ProfileDataEntry entry; ProfileDataEntry entry;
R_TRY(this->GetDataEntry(std::addressof(entry), profile, key)); R_TRY(this->GetDataEntry(std::addressof(entry), profile, key));
@@ -394,7 +399,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::GetUnsigned64(u64 *out, Identifier profile, Identifier key) { Result ProfileManager::GetUInt64Value(u64 *out, HashKey profile, HashKey key) {
/* Get the data entry. */ /* Get the data entry. */
ProfileDataEntry entry; ProfileDataEntry entry;
R_TRY(this->GetDataEntry(std::addressof(entry), profile, key)); R_TRY(this->GetDataEntry(std::addressof(entry), profile, key));
@@ -407,7 +412,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::GetSigned32(s32 *out, Identifier profile, Identifier key) { Result ProfileManager::GetInt32Value(s32 *out, HashKey profile, HashKey key) {
/* Get the data entry. */ /* Get the data entry. */
ProfileDataEntry entry; ProfileDataEntry entry;
R_TRY(this->GetDataEntry(std::addressof(entry), profile, key)); R_TRY(this->GetDataEntry(std::addressof(entry), profile, key));
@@ -420,7 +425,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::GetUnsigned32(u32 *out, Identifier profile, Identifier key) { Result ProfileManager::GetUInt32Value(u32 *out, HashKey profile, HashKey key) {
/* Get the data entry. */ /* Get the data entry. */
ProfileDataEntry entry; ProfileDataEntry entry;
R_TRY(this->GetDataEntry(std::addressof(entry), profile, key)); R_TRY(this->GetDataEntry(std::addressof(entry), profile, key));
@@ -433,7 +438,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::GetByte(u8 *out, Identifier profile, Identifier key) { Result ProfileManager::GetBooleanValue(u8 *out, HashKey profile, HashKey key) {
/* Get the data entry. */ /* Get the data entry. */
ProfileDataEntry entry; ProfileDataEntry entry;
R_TRY(this->GetDataEntry(std::addressof(entry), profile, key)); R_TRY(this->GetDataEntry(std::addressof(entry), profile, key));
@@ -446,7 +451,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ProfileManager::GetRaw(u8 *out_type, u64 *out_value, Identifier profile, Identifier key) { Result ProfileManager::QueryValue(u8 *out_type, u64 *out_value, HashKey profile, HashKey key) {
/* Get the data entry. */ /* Get the data entry. */
ProfileDataEntry entry; ProfileDataEntry entry;
R_TRY(this->GetDataEntry(std::addressof(entry), profile, key)); R_TRY(this->GetDataEntry(std::addressof(entry), profile, key));
@@ -477,8 +482,8 @@ namespace ams::sprofile::srv {
const auto &profile = m_profile_importer->GetImportingProfile(i); const auto &profile = m_profile_importer->GetImportingProfile(i);
if (profile.is_new_import) { if (profile.is_new_import) {
CreateTemporaryProfilePath(tmp_path, sizeof(tmp_path), m_save_data_info.mount_name, profile.identifier_0); CreateTemporaryProfilePath(tmp_path, sizeof(tmp_path), m_save_data_info.mount_name, profile.hash_key_0);
CreatePrimaryProfilePath(pri_path, sizeof(pri_path), m_save_data_info.mount_name, profile.identifier_0); CreatePrimaryProfilePath(pri_path, sizeof(pri_path), m_save_data_info.mount_name, profile.hash_key_0);
R_TRY(MoveFile(tmp_path, pri_path)); R_TRY(MoveFile(tmp_path, pri_path));
} }
} }
@@ -494,7 +499,7 @@ namespace ams::sprofile::srv {
char pri_path[0x30]; char pri_path[0x30];
/* Cleanup the profiles. */ /* Cleanup the profiles. */
R_RETURN(m_profile_importer->CleanupOrphanedProfiles([&](Identifier profile) ALWAYS_INLINE_LAMBDA -> Result { R_RETURN(m_profile_importer->CleanupOrphanedProfiles([&](HashKey profile) ALWAYS_INLINE_LAMBDA -> Result {
CreatePrimaryProfilePath(pri_path, sizeof(pri_path), m_save_data_info.mount_name, profile); CreatePrimaryProfilePath(pri_path, sizeof(pri_path), m_save_data_info.mount_name, profile);
R_RETURN(DeleteFile(pri_path)); R_RETURN(DeleteFile(pri_path));
})); }));
@@ -506,7 +511,7 @@ namespace ams::sprofile::srv {
/* If we need to, invalidate the loaded service profile. */ /* If we need to, invalidate the loaded service profile. */
if (m_service_profile.has_value()) { if (m_service_profile.has_value()) {
for (auto i = 0; i < m_profile_importer->GetImportingCount(); ++i) { for (auto i = 0; i < m_profile_importer->GetImportingCount(); ++i) {
if (m_service_profile->name == m_profile_importer->GetImportingProfile(i).identifier_0) { if (m_service_profile->name == m_profile_importer->GetImportingProfile(i).hash_key_0) {
m_service_profile = util::nullopt; m_service_profile = util::nullopt;
break; break;
} }
@@ -521,7 +526,7 @@ namespace ams::sprofile::srv {
const auto &profile = m_profile_importer->GetImportingProfile(i); const auto &profile = m_profile_importer->GetImportingProfile(i);
if (profile.is_new_import) { if (profile.is_new_import) {
m_update_observer_manager.OnUpdate(profile.identifier_0); m_update_observer_manager.OnUpdate(profile.hash_key_0);
} }
} }

View File

@@ -52,19 +52,19 @@ namespace ams::sprofile::srv {
Result OpenProfileImporter(); Result OpenProfileImporter();
void CloseProfileImporter(); void CloseProfileImporter();
Result ImportProfile(const sprofile::srv::ProfileDataForImportData &data); Result ImportProfile(const sprofile::srv::ProfilePayload &data);
Result Commit(); Result Commit();
Result ImportMetadata(const sprofile::srv::ProfileMetadataForImportMetadata &data); Result ImportMetadata(const sprofile::srv::MetadataPayload &data);
Result LoadPrimaryMetadata(ProfileMetadata *out); Result LoadPrimaryMetadata(ProfileMetadata *out);
Result GetSigned64(s64 *out, Identifier profile, Identifier key); Result GetInt64Value(s64 *out, HashKey profile, HashKey key);
Result GetUnsigned64(u64 *out, Identifier profile, Identifier key); Result GetUInt64Value(u64 *out, HashKey profile, HashKey key);
Result GetSigned32(s32 *out, Identifier profile, Identifier key); Result GetInt32Value(s32 *out, HashKey profile, HashKey key);
Result GetUnsigned32(u32 *out, Identifier profile, Identifier key); Result GetUInt32Value(u32 *out, HashKey profile, HashKey key);
Result GetByte(u8 *out, Identifier profile, Identifier key); Result GetBooleanValue(u8 *out, HashKey profile, HashKey key);
Result GetRaw(u8 *out_type, u64 *out_value, Identifier profile, Identifier key); Result QueryValue(u8 *out_type, u64 *out_value, HashKey profile, HashKey key);
ProfileUpdateObserverManager &GetUpdateObserverManager() { return m_update_observer_manager; } ProfileUpdateObserverManager &GetUpdateObserverManager() { return m_update_observer_manager; }
private: private:
@@ -76,9 +76,9 @@ namespace ams::sprofile::srv {
void OnCommitted(); void OnCommitted();
Result GetDataEntry(ProfileDataEntry *out, Identifier profile, Identifier key); Result GetDataEntry(ProfileDataEntry *out, HashKey profile, HashKey key);
Result LoadProfile(Identifier profile); Result LoadProfile(HashKey profile);
Result EnsurePrimaryDirectories(); Result EnsurePrimaryDirectories();
Result EnsureTemporaryDirectories(); Result EnsureTemporaryDirectories();

View File

@@ -19,24 +19,72 @@
namespace ams::sprofile::srv { namespace ams::sprofile::srv {
Result ProfileReaderImpl::GetSigned64(sf::Out<s64> out, sprofile::Identifier profile, sprofile::Identifier key) { Result ProfileReaderImpl::GetInt64Value(sf::Out<s64> out, sprofile::HashKey profile, sprofile::HashKey key) {
R_RETURN(m_manager->GetSigned64(out.GetPointer(), profile, key)); R_RETURN(m_manager->GetInt64Value(out.GetPointer(), profile, key));
} }
Result ProfileReaderImpl::GetUnsigned64(sf::Out<u64> out, sprofile::Identifier profile, sprofile::Identifier key) { Result ProfileReaderImpl::GetUInt64Value(sf::Out<u64> out, sprofile::HashKey profile, sprofile::HashKey key) {
R_RETURN(m_manager->GetUnsigned64(out.GetPointer(), profile, key)); R_RETURN(m_manager->GetUInt64Value(out.GetPointer(), profile, key));
} }
Result ProfileReaderImpl::GetSigned32(sf::Out<s32> out, sprofile::Identifier profile, sprofile::Identifier key) { Result ProfileReaderImpl::GetInt32Value(sf::Out<s32> out, sprofile::HashKey profile, sprofile::HashKey key) {
R_RETURN(m_manager->GetSigned32(out.GetPointer(), profile, key)); R_RETURN(m_manager->GetInt32Value(out.GetPointer(), profile, key));
} }
Result ProfileReaderImpl::GetUnsigned32(sf::Out<u32> out, sprofile::Identifier profile, sprofile::Identifier key) { Result ProfileReaderImpl::GetUInt32Value(sf::Out<u32> out, sprofile::HashKey profile, sprofile::HashKey key) {
R_RETURN(m_manager->GetUnsigned32(out.GetPointer(), profile, key)); R_RETURN(m_manager->GetUInt32Value(out.GetPointer(), profile, key));
} }
Result ProfileReaderImpl::GetByte(sf::Out<u8> out, sprofile::Identifier profile, sprofile::Identifier key) { Result ProfileReaderImpl::GetBooleanValue(sf::Out<u8> out, sprofile::HashKey profile, sprofile::HashKey key) {
R_RETURN(m_manager->GetByte(out.GetPointer(), profile, key)); R_RETURN(m_manager->GetBooleanValue(out.GetPointer(), profile, key));
}
Result ProfileReaderImpl::GetAnyValue(sf::Out<u64> out, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, profile, key);
R_SUCCEED();
}
Result ProfileReaderImpl::GetInt8ValueArray(sf::Out<u32> out, const sf::OutBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, out_buffer, profile, key);
R_SUCCEED();
}
Result ProfileReaderImpl::GetInt64ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, out_buffer, profile, key);
R_SUCCEED();
}
Result ProfileReaderImpl::GetUInt64ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, out_buffer, profile, key);
R_SUCCEED();
}
Result ProfileReaderImpl::GetInt32ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, out_buffer, profile, key);
R_SUCCEED();
}
Result ProfileReaderImpl::GetUInt32ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, out_buffer, profile, key);
R_SUCCEED();
}
Result ProfileReaderImpl::GetUInt8ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, out_buffer, profile, key);
R_SUCCEED();
}
Result ProfileReaderImpl::GetAnyValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key) {
/* On 23.0.0+ this isn't reachable from HIPC. */
AMS_UNUSED(out, out_buffer, profile, key);
R_SUCCEED();
} }
} }

View File

@@ -27,11 +27,19 @@ namespace ams::sprofile::srv {
public: public:
ProfileReaderImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ } ProfileReaderImpl(ProfileManager *manager) : m_manager(manager) { /* ... */ }
public: public:
Result GetSigned64(sf::Out<s64> out, sprofile::Identifier profile, sprofile::Identifier key); Result GetInt64Value(sf::Out<s64> out, sprofile::HashKey profile, sprofile::HashKey key);
Result GetUnsigned64(sf::Out<u64> out, sprofile::Identifier profile, sprofile::Identifier key); Result GetUInt64Value(sf::Out<u64> out, sprofile::HashKey profile, sprofile::HashKey key);
Result GetSigned32(sf::Out<s32> out, sprofile::Identifier profile, sprofile::Identifier key); Result GetInt32Value(sf::Out<s32> out, sprofile::HashKey profile, sprofile::HashKey key);
Result GetUnsigned32(sf::Out<u32> out, sprofile::Identifier profile, sprofile::Identifier key); Result GetUInt32Value(sf::Out<u32> out, sprofile::HashKey profile, sprofile::HashKey key);
Result GetByte(sf::Out<u8> out, sprofile::Identifier profile, sprofile::Identifier key); Result GetBooleanValue(sf::Out<u8> out, sprofile::HashKey profile, sprofile::HashKey key);
Result GetAnyValue(sf::Out<u64> out, sprofile::HashKey profile, sprofile::HashKey key);
Result GetInt8ValueArray(sf::Out<u32> out, const sf::OutBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
Result GetInt64ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
Result GetUInt64ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
Result GetInt32ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
Result GetUInt32ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
Result GetUInt8ValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
Result GetAnyValueArray(sf::Out<u32> out, const sf::OutPointerBuffer &out_buffer, sprofile::HashKey profile, sprofile::HashKey key);
}; };
static_assert(IsIProfileReader<ProfileReaderImpl>); static_assert(IsIProfileReader<ProfileReaderImpl>);

View File

@@ -24,7 +24,7 @@ namespace ams::sprofile::srv {
static constexpr auto MaxProfiles = 4; static constexpr auto MaxProfiles = 4;
private: private:
os::SystemEvent m_event; os::SystemEvent m_event;
Identifier m_profiles[MaxProfiles]; HashKey m_profiles[MaxProfiles];
int m_profile_count; int m_profile_count;
os::SdkMutex m_mutex; os::SdkMutex m_mutex;
public: public:
@@ -34,7 +34,7 @@ namespace ams::sprofile::srv {
os::SystemEvent &GetEvent() { return m_event; } os::SystemEvent &GetEvent() { return m_event; }
const os::SystemEvent &GetEvent() const { return m_event; } const os::SystemEvent &GetEvent() const { return m_event; }
public: public:
Result Listen(Identifier profile) { Result Subscribe(HashKey profile) {
/* Lock ourselves. */ /* Lock ourselves. */
std::scoped_lock lk(m_mutex); std::scoped_lock lk(m_mutex);
@@ -51,7 +51,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result Unlisten(Identifier profile) { Result Unsubscribe(HashKey profile) {
/* Check that we're listening. */ /* Check that we're listening. */
for (auto i = 0; i < m_profile_count; ++i) { for (auto i = 0; i < m_profile_count; ++i) {
if (m_profiles[i] == profile) { if (m_profiles[i] == profile) {
@@ -64,12 +64,12 @@ namespace ams::sprofile::srv {
R_THROW(sprofile::ResultNotListening()); R_THROW(sprofile::ResultNotListening());
} }
Result GetEventHandle(sf::OutCopyHandle out) { Result GetUpdateEventNativeHandle(sf::OutCopyHandle out) {
out.SetValue(m_event.GetReadableHandle(), false); out.SetValue(m_event.GetReadableHandle(), false);
R_SUCCEED(); R_SUCCEED();
} }
public: public:
void OnUpdate(Identifier profile) { void OnUpdate(HashKey profile) {
for (auto i = 0; i < m_profile_count; ++i) { for (auto i = 0; i < m_profile_count; ++i) {
if (m_profiles[i] == profile) { if (m_profiles[i] == profile) {
m_event.Signal(); m_event.Signal();
@@ -93,7 +93,7 @@ namespace ams::sprofile::srv {
Result OpenObserver(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileUpdateObserver>> &out, MemoryResource *memory_resource); Result OpenObserver(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileUpdateObserver>> &out, MemoryResource *memory_resource);
void CloseObserver(ProfileUpdateObserverImpl *observer); void CloseObserver(ProfileUpdateObserverImpl *observer);
void OnUpdate(Identifier profile) { void OnUpdate(HashKey profile) {
std::scoped_lock lk(m_mutex); std::scoped_lock lk(m_mutex);
for (auto i = 0; i < m_observer_count; ++i) { for (auto i = 0; i < m_observer_count; ++i) {

View File

@@ -34,7 +34,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ServiceForBgAgent::GetImportableProfileUrls(sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::ProfileMetadataForImportMetadata &arg) { Result ServiceForBgAgent::GetProfileDownloadUrlList(sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::MetadataPayload &arg) {
/* Check size. */ /* Check size. */
R_UNLESS(out.GetSize() >= arg.metadata.num_entries, sprofile::ResultInvalidArgument()); R_UNLESS(out.GetSize() >= arg.metadata.num_entries, sprofile::ResultInvalidArgument());
@@ -57,7 +57,7 @@ namespace ams::sprofile::srv {
for (u32 j = 0; j < primary_metadata.num_entries; ++j) { for (u32 j = 0; j < primary_metadata.num_entries; ++j) {
const auto &pri_entry = primary_metadata.entries[j]; const auto &pri_entry = primary_metadata.entries[j];
if (pri_entry.identifier_0 == arg_entry.identifier_0 && pri_entry.identifier_1 == arg_entry.identifier_1) { if (pri_entry.hash_key_0 == arg_entry.hash_key_0 && pri_entry.hash_key_1 == arg_entry.hash_key_1) {
have_entry = true; have_entry = true;
break; break;
} }
@@ -75,7 +75,7 @@ namespace ams::sprofile::srv {
} }
Result ServiceForBgAgent::IsUpdateNeeded(sf::Out<bool> out, Identifier revision_key) { Result ServiceForBgAgent::GetMetadataNewness(sf::Out<bool> out, HashKey revision_key) {
/* Load primary metadata. */ /* Load primary metadata. */
bool loaded_metadata = true; bool loaded_metadata = true;
sprofile::srv::ProfileMetadata primary_metadata; sprofile::srv::ProfileMetadata primary_metadata;
@@ -91,7 +91,7 @@ namespace ams::sprofile::srv {
R_SUCCEED(); R_SUCCEED();
} }
Result ServiceForBgAgent::Reset() { Result ServiceForBgAgent::ClearSaveDataForTest() {
R_RETURN(m_profile_manager->ResetSaveData()); R_RETURN(m_profile_manager->ResetSaveData());
} }

View File

@@ -29,9 +29,9 @@ namespace ams::sprofile::srv {
constexpr ServiceForBgAgent(MemoryResource *mr, ProfileManager *pm) : m_memory_resource(mr), m_profile_manager(pm) { /* ... */ } constexpr ServiceForBgAgent(MemoryResource *mr, ProfileManager *pm) : m_memory_resource(mr), m_profile_manager(pm) { /* ... */ }
public: public:
Result OpenProfileImporter(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileImporter>> out); Result OpenProfileImporter(sf::Out<sf::SharedPointer<::ams::sprofile::srv::IProfileImporter>> out);
Result GetImportableProfileUrls(sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::ProfileMetadataForImportMetadata &arg); Result GetProfileDownloadUrlList(sf::Out<u32> out_count, const sf::OutArray<sprofile::srv::ProfileUrl> &out, const sprofile::srv::MetadataPayload &arg);
Result IsUpdateNeeded(sf::Out<bool> out, Identifier revision_key); Result GetMetadataNewness(sf::Out<bool> out, HashKey revision_key);
Result Reset(); Result ClearSaveDataForTest();
}; };
static_assert(sprofile::srv::IsISprofileServiceForBgAgent<ServiceForBgAgent>); static_assert(sprofile::srv::IsISprofileServiceForBgAgent<ServiceForBgAgent>);

View File

@@ -33,7 +33,7 @@ namespace ams::sprofile::srv {
}; };
struct ProfileDataEntry { struct ProfileDataEntry {
Identifier key; HashKey key;
ValueType type; ValueType type;
union { union {
s64 value_s64; s64 value_s64;
@@ -65,7 +65,7 @@ namespace ams::sprofile::srv {
static_assert(AMS_OFFSETOF(ProfileData, entries) == 0x30); static_assert(AMS_OFFSETOF(ProfileData, entries) == 0x30);
struct ServiceProfile { struct ServiceProfile {
Identifier name; HashKey name;
ProfileData data; ProfileData data;
}; };
static_assert(util::is_pod<ServiceProfile>::value); static_assert(util::is_pod<ServiceProfile>::value);
@@ -74,10 +74,10 @@ namespace ams::sprofile::srv {
static_assert(AMS_OFFSETOF(ServiceProfile, name) == 0x00); static_assert(AMS_OFFSETOF(ServiceProfile, name) == 0x00);
static_assert(AMS_OFFSETOF(ServiceProfile, data) == 0x08); static_assert(AMS_OFFSETOF(ServiceProfile, data) == 0x08);
struct ProfileDataForImportData : public sf::LargeData, public sf::PrefersMapAliasTransferMode { struct ProfilePayload : public sf::LargeData, public sf::PrefersMapAliasTransferMode {
struct { struct {
Identifier identifier_0; HashKey hash_key_0;
Identifier identifier_1; HashKey hash_key_1;
u8 unk_0E[2]; u8 unk_0E[2];
u32 version; u32 version;
u8 unk_14[0x1C]; u8 unk_14[0x1C];
@@ -86,25 +86,25 @@ namespace ams::sprofile::srv {
ProfileData data; ProfileData data;
u8 unk_4040[0x4400 - 0x4040]; u8 unk_4040[0x4400 - 0x4040];
}; };
static_assert(util::is_pod<ProfileDataForImportData>::value); static_assert(util::is_pod<ProfilePayload>::value);
static_assert(sizeof(ProfileDataForImportData) == 0x4400); static_assert(sizeof(ProfilePayload) == 0x4400);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, header) == 0x00); static_assert(AMS_OFFSETOF(ProfilePayload, header) == 0x00);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, hash) == 0x30); static_assert(AMS_OFFSETOF(ProfilePayload, hash) == 0x30);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, data) == 0x40); static_assert(AMS_OFFSETOF(ProfilePayload, data) == 0x40);
static_assert(AMS_OFFSETOF(ProfileDataForImportData, unk_4040) == 0x4040); static_assert(AMS_OFFSETOF(ProfilePayload, unk_4040) == 0x4040);
struct ProfileMetadataEntry { struct ProfileMetadataEntry {
Identifier identifier_0; HashKey hash_key_0;
Identifier identifier_1; HashKey hash_key_1;
u8 unk_0E[0x32]; u8 unk_0E[0x32];
}; };
static_assert(util::is_pod<ProfileMetadataEntry>::value); static_assert(util::is_pod<ProfileMetadataEntry>::value);
static_assert(sizeof(ProfileMetadataEntry) == 0x40); static_assert(sizeof(ProfileMetadataEntry) == 0x40);
static_assert(AMS_OFFSETOF(ProfileMetadataEntry, identifier_0) == 0x00); static_assert(AMS_OFFSETOF(ProfileMetadataEntry, hash_key_0) == 0x00);
static_assert(AMS_OFFSETOF(ProfileMetadataEntry, identifier_1) == 0x07); static_assert(AMS_OFFSETOF(ProfileMetadataEntry, hash_key_1) == 0x07);
static_assert(AMS_OFFSETOF(ProfileMetadataEntry, unk_0E) == 0x0E); static_assert(AMS_OFFSETOF(ProfileMetadataEntry, unk_0E) == 0x0E);
struct ProfileUrl : public sf::PrefersMapAliasTransferMode { struct ProfileUrl : public sf::PrefersMapAliasTransferMode {
char url[0x100]; char url[0x100];
@@ -115,7 +115,7 @@ namespace ams::sprofile::srv {
struct ProfileMetadata { struct ProfileMetadata {
u32 num_entries; u32 num_entries;
u32 unk_04; u32 unk_04;
Identifier revision_key; HashKey revision_key;
u8 unk_0F[0x1]; u8 unk_0F[0x1];
u8 unk_10[0x30]; u8 unk_10[0x30];
ProfileMetadataEntry entries[50]; ProfileMetadataEntry entries[50];
@@ -130,7 +130,7 @@ namespace ams::sprofile::srv {
static_assert(AMS_OFFSETOF(ProfileMetadata, unk_10) == 0x10); static_assert(AMS_OFFSETOF(ProfileMetadata, unk_10) == 0x10);
static_assert(AMS_OFFSETOF(ProfileMetadata, entries) == 0x40); static_assert(AMS_OFFSETOF(ProfileMetadata, entries) == 0x40);
struct ProfileMetadataForImportMetadata : public sf::LargeData, public sf::PrefersMapAliasTransferMode { struct MetadataPayload : public sf::LargeData, public sf::PrefersMapAliasTransferMode {
struct { struct {
u32 version; u32 version;
u8 unk_04[0x1C]; u8 unk_04[0x1C];
@@ -140,13 +140,13 @@ namespace ams::sprofile::srv {
ProfileUrl profile_urls[50]; ProfileUrl profile_urls[50];
u8 unk_3EF0[0x8000 - 0x3EF0]; u8 unk_3EF0[0x8000 - 0x3EF0];
}; };
static_assert(util::is_pod<ProfileMetadataForImportMetadata>::value); static_assert(util::is_pod<MetadataPayload>::value);
static_assert(sizeof(ProfileMetadataForImportMetadata) == 0x8000); static_assert(sizeof(MetadataPayload) == 0x8000);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, header) == 0x00); static_assert(AMS_OFFSETOF(MetadataPayload, header) == 0x00);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, hash) == 0x20); static_assert(AMS_OFFSETOF(MetadataPayload, hash) == 0x20);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, metadata) == 0x30); static_assert(AMS_OFFSETOF(MetadataPayload, metadata) == 0x30);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, profile_urls) == 0xCF0); static_assert(AMS_OFFSETOF(MetadataPayload, profile_urls) == 0xCF0);
static_assert(AMS_OFFSETOF(ProfileMetadataForImportMetadata, unk_3EF0) == 0x3EF0); static_assert(AMS_OFFSETOF(MetadataPayload, unk_3EF0) == 0x3EF0);
} }

View File

@@ -21,20 +21,23 @@ R_DEFINE_NAMESPACE_RESULT_MODULE(ams::sprofile, 246);
namespace ams::sprofile { namespace ams::sprofile {
R_DEFINE_ERROR_RESULT(InvalidArgument, 100); R_DEFINE_ERROR_RESULT(InvalidArgument, 100);
R_DEFINE_ERROR_RESULT(InvalidState, 101); R_DEFINE_ERROR_RESULT(InvalidState, 101);
R_DEFINE_ERROR_RESULT(NotPermitted, 303); R_DEFINE_ERROR_RESULT(NotImplemented, 300);
R_DEFINE_ERROR_RESULT(NotSupported, 301);
R_DEFINE_ERROR_RESULT(Delayed, 302);
R_DEFINE_ERROR_RESULT(NotPermitted, 303);
R_DEFINE_ERROR_RESULT(AllocationFailed, 401); R_DEFINE_ERROR_RESULT(AllocationFailed, 401);
R_DEFINE_ERROR_RESULT(KeyNotFound, 600); R_DEFINE_ERROR_RESULT(KeyNotFound, 600);
R_DEFINE_ERROR_RESULT(InvalidDataType, 601); R_DEFINE_ERROR_RESULT(InvalidDataType, 601);
R_DEFINE_ERROR_RESULT(MaxListeners, 620); R_DEFINE_ERROR_RESULT(MaxListeners, 620);
R_DEFINE_ERROR_RESULT(AlreadyListening, 621); R_DEFINE_ERROR_RESULT(AlreadyListening, 621);
R_DEFINE_ERROR_RESULT(NotListening, 622); R_DEFINE_ERROR_RESULT(NotListening, 622);
R_DEFINE_ERROR_RESULT(MaxObservers, 623); R_DEFINE_ERROR_RESULT(MaxObservers, 623);
R_DEFINE_ERROR_RESULT(InvalidMetadataVersion, 3210); R_DEFINE_ERROR_RESULT(InvalidMetadataVersion, 3210);
R_DEFINE_ERROR_RESULT(InvalidMetadataHash, 3211); R_DEFINE_ERROR_RESULT(InvalidMetadataHash, 3211);