Make dispatch tables great again

This commit is contained in:
Adubbz 2019-07-27 22:19:04 +10:00
parent e1023a59ba
commit 6b35b0d6ad
8 changed files with 154 additions and 136 deletions

View file

@ -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<ncm::IContentMetaDatabase> content_meta_database;

View file

@ -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<const Path> path, ncm::TitleId tid);
virtual Result RedirectApplicationProgramPathForDebug(InPointer<const Path> 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),
};
};
}

View file

@ -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:

View file

@ -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<ContentMetaKey>* kvs, const char* mount_name) : IContentMetaDatabase(kvs, mount_name) {
}

View file

@ -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;

View file

@ -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<ContentMetaKey>* 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),
};
};
}

View file

@ -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<FsRightsId> out_rights_id, Out<u64> 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),
};
};
}

View file

@ -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: