From 6b35b0d6ad5a653c6bd96a7f3a75c80e6c8a5e67 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Sat, 27 Jul 2019 22:19:04 +1000 Subject: [PATCH] Make dispatch tables great again --- .../ncm/source/lr_contentlocationresolver.hpp | 23 ------- .../ncm/source/lr_ilocationresolver.hpp | 47 +++++++++++++- .../lr_redirectonlylocationresolver.hpp | 23 ------- .../ncm/source/ncm_contentmetadatabase.hpp | 24 ------- .../ncm/source/ncm_contentstorage.hpp | 31 --------- .../ncm/source/ncm_icontentmetadatabase.hpp | 48 +++++++++++++- .../ncm/source/ncm_icontentstorage.hpp | 63 ++++++++++++++++++- .../ncm/source/ncm_readonlycontentstorage.hpp | 31 --------- 8 files changed, 154 insertions(+), 136 deletions(-) diff --git a/stratosphere/ncm/source/lr_contentlocationresolver.hpp b/stratosphere/ncm/source/lr_contentlocationresolver.hpp index ea3841053..e5a59370c 100644 --- a/stratosphere/ncm/source/lr_contentlocationresolver.hpp +++ b/stratosphere/ncm/source/lr_contentlocationresolver.hpp @@ -26,29 +26,6 @@ namespace sts::lr { class ContentLocationResolverInterface : public ILocationResolver { - private: - enum class CommandId { - ResolveProgramPath = 0, - RedirectProgramPath = 1, - ResolveApplicationControlPath = 2, - ResolveApplicationHtmlDocumentPath = 3, - ResolveDataPath = 4, - RedirectApplicationControlPath = 5, - RedirectApplicationHtmlDocumentPath = 6, - ResolveApplicationLegalInformationPath = 7, - RedirectApplicationLegalInformationPath = 8, - Refresh = 9, - RedirectApplicationProgramPath = 10, - ClearApplicationRedirection = 11, - EraseProgramRedirection = 12, - EraseApplicationControlRedirection = 13, - EraseApplicationHtmlDocumentRedirection = 14, - EraseApplicationLegalInformationRedirection = 15, - ResolveProgramPathForDebug = 16, - RedirectProgramPathForDebug = 17, - RedirectApplicationProgramPathForDebug = 18, - EraseProgramRedirectionForDebug = 19, - }; private: ncm::StorageId storage_id; std::shared_ptr content_meta_database; diff --git a/stratosphere/ncm/source/lr_ilocationresolver.hpp b/stratosphere/ncm/source/lr_ilocationresolver.hpp index b7d6149d6..2b4a7bef8 100644 --- a/stratosphere/ncm/source/lr_ilocationresolver.hpp +++ b/stratosphere/ncm/source/lr_ilocationresolver.hpp @@ -23,6 +23,29 @@ namespace sts::lr { class ILocationResolver : public IServiceObject { + protected: + enum class CommandId { + ResolveProgramPath = 0, + RedirectProgramPath = 1, + ResolveApplicationControlPath = 2, + ResolveApplicationHtmlDocumentPath = 3, + ResolveDataPath = 4, + RedirectApplicationControlPath = 5, + RedirectApplicationHtmlDocumentPath = 6, + ResolveApplicationLegalInformationPath = 7, + RedirectApplicationLegalInformationPath = 8, + Refresh = 9, + RedirectApplicationProgramPath = 10, + ClearApplicationRedirection = 11, + EraseProgramRedirection = 12, + EraseApplicationControlRedirection = 13, + EraseApplicationHtmlDocumentRedirection = 14, + EraseApplicationLegalInformationRedirection = 15, + ResolveProgramPathForDebug = 16, + RedirectProgramPathForDebug = 17, + RedirectApplicationProgramPathForDebug = 18, + EraseProgramRedirectionForDebug = 19, + }; protected: impl::LocationRedirector program_redirector; impl::LocationRedirector debug_program_redirector; @@ -50,9 +73,29 @@ namespace sts::lr { virtual Result RedirectProgramPathForDebug(InPointer path, ncm::TitleId tid); virtual Result RedirectApplicationProgramPathForDebug(InPointer path, ncm::TitleId tid); virtual Result EraseProgramRedirectionForDebug(ncm::TitleId tid); - public: - DEFINE_SERVICE_DISPATCH_TABLE {}; + DEFINE_SERVICE_DISPATCH_TABLE { + MAKE_SERVICE_COMMAND_META(ILocationResolver, ResolveProgramPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, RedirectProgramPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, ResolveApplicationControlPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, ResolveApplicationHtmlDocumentPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, ResolveDataPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, RedirectApplicationControlPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, RedirectApplicationHtmlDocumentPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, ResolveApplicationLegalInformationPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, RedirectApplicationLegalInformationPath), + MAKE_SERVICE_COMMAND_META(ILocationResolver, Refresh), + MAKE_SERVICE_COMMAND_META(ILocationResolver, RedirectApplicationProgramPath, FirmwareVersion_500), + MAKE_SERVICE_COMMAND_META(ILocationResolver, ClearApplicationRedirection, FirmwareVersion_500), + MAKE_SERVICE_COMMAND_META(ILocationResolver, EraseProgramRedirection, FirmwareVersion_500), + MAKE_SERVICE_COMMAND_META(ILocationResolver, EraseApplicationControlRedirection, FirmwareVersion_500), + MAKE_SERVICE_COMMAND_META(ILocationResolver, EraseApplicationHtmlDocumentRedirection, FirmwareVersion_500), + MAKE_SERVICE_COMMAND_META(ILocationResolver, EraseApplicationLegalInformationRedirection, FirmwareVersion_500), + MAKE_SERVICE_COMMAND_META(ILocationResolver, ResolveProgramPathForDebug, FirmwareVersion_700), + MAKE_SERVICE_COMMAND_META(ILocationResolver, RedirectProgramPathForDebug, FirmwareVersion_700), + MAKE_SERVICE_COMMAND_META(ILocationResolver, RedirectApplicationProgramPathForDebug, FirmwareVersion_700), + MAKE_SERVICE_COMMAND_META(ILocationResolver, EraseProgramRedirectionForDebug, FirmwareVersion_700), + }; }; } \ No newline at end of file diff --git a/stratosphere/ncm/source/lr_redirectonlylocationresolver.hpp b/stratosphere/ncm/source/lr_redirectonlylocationresolver.hpp index dbfdaac57..e69696d18 100644 --- a/stratosphere/ncm/source/lr_redirectonlylocationresolver.hpp +++ b/stratosphere/ncm/source/lr_redirectonlylocationresolver.hpp @@ -23,29 +23,6 @@ namespace sts::lr { class RedirectOnlyLocationResolverInterface : public ILocationResolver { - private: - enum class CommandId { - ResolveProgramPath = 0, - RedirectProgramPath = 1, - ResolveApplicationControlPath = 2, - ResolveApplicationHtmlDocumentPath = 3, - ResolveDataPath = 4, - RedirectApplicationControlPath = 5, - RedirectApplicationHtmlDocumentPath = 6, - ResolveApplicationLegalInformationPath = 7, - RedirectApplicationLegalInformationPath = 8, - Refresh = 9, - RedirectApplicationProgramPath = 10, - ClearApplicationRedirection = 11, - EraseProgramRedirection = 12, - EraseApplicationControlRedirection = 13, - EraseApplicationHtmlDocumentRedirection = 14, - EraseApplicationLegalInformationRedirection = 15, - ResolveProgramPathForDebug = 16, - RedirectProgramPathForDebug = 17, - RedirectApplicationProgramPathForDebug = 18, - EraseProgramRedirectionForDebug = 19, - }; public: ~RedirectOnlyLocationResolverInterface(); public: diff --git a/stratosphere/ncm/source/ncm_contentmetadatabase.hpp b/stratosphere/ncm/source/ncm_contentmetadatabase.hpp index 64c3a8492..b306631e3 100644 --- a/stratosphere/ncm/source/ncm_contentmetadatabase.hpp +++ b/stratosphere/ncm/source/ncm_contentmetadatabase.hpp @@ -23,30 +23,6 @@ namespace sts::ncm { class ContentMetaDatabaseInterface : public IContentMetaDatabase { - private: - enum class CommandId { - Set = 0, - Get = 1, - Remove = 2, - GetContentIdByType = 3, - ListContentInfo = 4, - List = 5, - GetLatestContentMetaKey = 6, - ListApplication = 7, - Has = 8, - HasAll = 9, - GetSize = 10, - GetRequiredSystemVersion = 11, - GetPatchId = 12, - DisableForcibly = 13, - LookupOrphanContent = 14, - Commit = 15, - HasContent = 16, - ListContentMetaInfo = 17, - GetAttributes = 18, - GetRequiredApplicationVersion = 19, - GetContentIdByTypeAndIdOffset = 20, - }; public: ContentMetaDatabaseInterface(sts::kvdb::MemoryKeyValueStore* kvs, const char* mount_name) : IContentMetaDatabase(kvs, mount_name) { } diff --git a/stratosphere/ncm/source/ncm_contentstorage.hpp b/stratosphere/ncm/source/ncm_contentstorage.hpp index d69b115f7..df124f9bd 100644 --- a/stratosphere/ncm/source/ncm_contentstorage.hpp +++ b/stratosphere/ncm/source/ncm_contentstorage.hpp @@ -25,37 +25,6 @@ namespace sts::ncm { class ContentStorageInterface : public IContentStorage { - private: - enum class CommandId { - GeneratePlaceHolderId = 0, - CreatePlaceHolder = 1, - DeletePlaceHolder = 2, - HasPlaceHolder = 3, - WritePlaceHolder = 4, - Register = 5, - Delete = 6, - Has = 7, - GetPath = 8, - GetPlaceHolderPath = 9, - CleanupAllPlaceHolder = 10, - ListPlaceHolder = 11, - GetContentCount = 12, - ListContentId = 13, - GetSizeFromContentId = 14, - DisableForcibly = 15, - RevertToPlaceHolder = 16, - SetPlaceHolderSize = 17, - ReadContentIdFile = 18, - GetRightsIdFromPlaceHolderId = 19, - GetRightsIdFromContentId = 20, - WriteContentForDebug = 21, - GetFreeSpaceSize = 22, - GetTotalSpaceSize = 23, - FlushPlaceHolder = 24, - GetSizeFromPlaceHolderId = 25, - RepairInvalidFileAttribute = 26, - GetRightsIdFromPlaceHolderIdWithCache = 27, - }; protected: impl::PlaceHolderAccessor placeholder_accessor; ContentId cached_content_id; diff --git a/stratosphere/ncm/source/ncm_icontentmetadatabase.hpp b/stratosphere/ncm/source/ncm_icontentmetadatabase.hpp index 2fec2aa92..4a9855f91 100644 --- a/stratosphere/ncm/source/ncm_icontentmetadatabase.hpp +++ b/stratosphere/ncm/source/ncm_icontentmetadatabase.hpp @@ -24,6 +24,30 @@ namespace sts::ncm { class IContentMetaDatabase : public IServiceObject { + protected: + enum class CommandId { + Set = 0, + Get = 1, + Remove = 2, + GetContentIdByType = 3, + ListContentInfo = 4, + List = 5, + GetLatestContentMetaKey = 6, + ListApplication = 7, + Has = 8, + HasAll = 9, + GetSize = 10, + GetRequiredSystemVersion = 11, + GetPatchId = 12, + DisableForcibly = 13, + LookupOrphanContent = 14, + Commit = 15, + HasContent = 16, + ListContentMetaInfo = 17, + GetAttributes = 18, + GetRequiredApplicationVersion = 19, + GetContentIdByTypeAndIdOffset = 20, + }; protected: sts::kvdb::MemoryKeyValueStore* kvs; char mount_name[16]; @@ -67,7 +91,29 @@ namespace sts::ncm { virtual Result GetLatestProgram(ContentId* out_content_id, TitleId title_id); virtual Result GetLatestData(ContentId* out_content_id, TitleId title_id); public: - DEFINE_SERVICE_DISPATCH_TABLE {}; + DEFINE_SERVICE_DISPATCH_TABLE { + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, Set), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, Get), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, Remove), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetContentIdByType), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, ListContentInfo), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, List), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetLatestContentMetaKey), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, ListApplication), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, Has), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, HasAll), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetSize), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetRequiredSystemVersion), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetPatchId), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, DisableForcibly), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, LookupOrphanContent), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, Commit), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, HasContent), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, ListContentMetaInfo), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetAttributes), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetRequiredApplicationVersion, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentMetaDatabase, GetContentIdByTypeAndIdOffset, FirmwareVersion_500), + }; }; } \ No newline at end of file diff --git a/stratosphere/ncm/source/ncm_icontentstorage.hpp b/stratosphere/ncm/source/ncm_icontentstorage.hpp index 7ac4b6c78..6e58ea6c6 100644 --- a/stratosphere/ncm/source/ncm_icontentstorage.hpp +++ b/stratosphere/ncm/source/ncm_icontentstorage.hpp @@ -24,6 +24,37 @@ namespace sts::ncm { class IContentStorage : public IServiceObject { + protected: + enum class CommandId { + GeneratePlaceHolderId = 0, + CreatePlaceHolder = 1, + DeletePlaceHolder = 2, + HasPlaceHolder = 3, + WritePlaceHolder = 4, + Register = 5, + Delete = 6, + Has = 7, + GetPath = 8, + GetPlaceHolderPath = 9, + CleanupAllPlaceHolder = 10, + ListPlaceHolder = 11, + GetContentCount = 12, + ListContentId = 13, + GetSizeFromContentId = 14, + DisableForcibly = 15, + RevertToPlaceHolder = 16, + SetPlaceHolderSize = 17, + ReadContentIdFile = 18, + GetRightsIdFromPlaceHolderId = 19, + GetRightsIdFromContentId = 20, + WriteContentForDebug = 21, + GetFreeSpaceSize = 22, + GetTotalSpaceSize = 23, + FlushPlaceHolder = 24, + GetSizeFromPlaceHolderId = 25, + RepairInvalidFileAttribute = 26, + GetRightsIdFromPlaceHolderIdWithCache = 27, + }; protected: char root_path[FS_MAX_PATH-1]; MakeContentPathFunc make_content_path_func; @@ -58,7 +89,37 @@ namespace sts::ncm { virtual Result RepairInvalidFileAttribute(); virtual Result GetRightsIdFromPlaceHolderIdWithCache(Out out_rights_id, Out out_key_generation, PlaceHolderId placeholder_id, ContentId cache_content_id); public: - DEFINE_SERVICE_DISPATCH_TABLE {}; + DEFINE_SERVICE_DISPATCH_TABLE { + MAKE_SERVICE_COMMAND_META(IContentStorage, GeneratePlaceHolderId), + MAKE_SERVICE_COMMAND_META(IContentStorage, CreatePlaceHolder), + MAKE_SERVICE_COMMAND_META(IContentStorage, DeletePlaceHolder), + MAKE_SERVICE_COMMAND_META(IContentStorage, HasPlaceHolder), + MAKE_SERVICE_COMMAND_META(IContentStorage, WritePlaceHolder), + MAKE_SERVICE_COMMAND_META(IContentStorage, Register), + MAKE_SERVICE_COMMAND_META(IContentStorage, Delete), + MAKE_SERVICE_COMMAND_META(IContentStorage, Has), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetPath), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetPlaceHolderPath), + MAKE_SERVICE_COMMAND_META(IContentStorage, CleanupAllPlaceHolder), + MAKE_SERVICE_COMMAND_META(IContentStorage, ListPlaceHolder), + MAKE_SERVICE_COMMAND_META(IContentStorage, GeneratePlaceHolderId), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetContentCount), + MAKE_SERVICE_COMMAND_META(IContentStorage, ListContentId), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetSizeFromContentId), + MAKE_SERVICE_COMMAND_META(IContentStorage, DisableForcibly), + MAKE_SERVICE_COMMAND_META(IContentStorage, RevertToPlaceHolder, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, SetPlaceHolderSize, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, ReadContentIdFile, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetRightsIdFromPlaceHolderId, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetRightsIdFromContentId, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, WriteContentForDebug, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetFreeSpaceSize, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetTotalSpaceSize, FirmwareVersion_200), + MAKE_SERVICE_COMMAND_META(IContentStorage, FlushPlaceHolder, FirmwareVersion_300), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetSizeFromPlaceHolderId, FirmwareVersion_400), + MAKE_SERVICE_COMMAND_META(IContentStorage, RepairInvalidFileAttribute, FirmwareVersion_400), + MAKE_SERVICE_COMMAND_META(IContentStorage, GetRightsIdFromPlaceHolderIdWithCache, FirmwareVersion_800), + }; }; } \ No newline at end of file diff --git a/stratosphere/ncm/source/ncm_readonlycontentstorage.hpp b/stratosphere/ncm/source/ncm_readonlycontentstorage.hpp index 169d814b8..135690230 100644 --- a/stratosphere/ncm/source/ncm_readonlycontentstorage.hpp +++ b/stratosphere/ncm/source/ncm_readonlycontentstorage.hpp @@ -23,37 +23,6 @@ namespace sts::ncm { class ReadOnlyContentStorageInterface : public IContentStorage { - private: - enum class CommandId { - GeneratePlaceHolderId = 0, - CreatePlaceHolder = 1, - DeletePlaceHolder = 2, - HasPlaceHolder = 3, - WritePlaceHolder = 4, - Register = 5, - Delete = 6, - Has = 7, - GetPath = 8, - GetPlaceHolderPath = 9, - CleanupAllPlaceHolder = 10, - ListPlaceHolder = 11, - GetContentCount = 12, - ListContentId = 13, - GetSizeFromContentId = 14, - DisableForcibly = 15, - RevertToPlaceHolder = 16, - SetPlaceHolderSize = 17, - ReadContentIdFile = 18, - GetRightsIdFromPlaceHolderId = 19, - GetRightsIdFromContentId = 20, - WriteContentForDebug = 21, - GetFreeSpaceSize = 22, - GetTotalSpaceSize = 23, - FlushPlaceHolder = 24, - GetSizeFromPlaceHolderId = 25, - RepairInvalidFileAttribute = 26, - GetRightsIdFromPlaceHolderIdWithCache = 27, - }; public: Result Initialize(const char* root_path, MakeContentPathFunc content_path_func); public: