spl: refactor into sts namespace

This commit is contained in:
Michael Scire 2019-06-21 01:36:00 -07:00
parent 1671c04e24
commit f9b48f06a3
30 changed files with 2230 additions and 2152 deletions

View file

@ -19,38 +19,76 @@
#include <stratosphere.hpp>
#include "spl_types.hpp"
#include "spl_secmon_wrapper.hpp"
class GeneralService : public IServiceObject {
private:
SecureMonitorWrapper *secmon_wrapper;
public:
GeneralService(SecureMonitorWrapper *sw) : secmon_wrapper(sw) {
/* ... */
}
namespace sts::spl {
virtual ~GeneralService() { /* ... */ }
protected:
SecureMonitorWrapper *GetSecureMonitorWrapper() const {
return this->secmon_wrapper;
}
protected:
/* Actual commands. */
virtual Result GetConfig(Out<u64> out, u32 which);
virtual Result ExpMod(OutPointerWithClientSize<u8> out, InPointer<u8> base, InPointer<u8> exp, InPointer<u8> mod);
virtual Result SetConfig(u32 which, u64 value);
virtual Result GenerateRandomBytes(OutPointerWithClientSize<u8> out);
virtual Result IsDevelopment(Out<bool> is_dev);
virtual Result SetBootReason(BootReasonValue boot_reason);
virtual Result GetBootReason(Out<BootReasonValue> out);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MakeServiceCommandMeta<Spl_Cmd_GetConfig, &GeneralService::GetConfig>(),
MakeServiceCommandMeta<Spl_Cmd_ExpMod, &GeneralService::ExpMod>(),
MakeServiceCommandMeta<Spl_Cmd_SetConfig, &GeneralService::SetConfig>(),
MakeServiceCommandMeta<Spl_Cmd_GenerateRandomBytes, &GeneralService::GenerateRandomBytes>(),
MakeServiceCommandMeta<Spl_Cmd_IsDevelopment, &GeneralService::IsDevelopment>(),
MakeServiceCommandMeta<Spl_Cmd_SetBootReason, &GeneralService::SetBootReason, FirmwareVersion_300>(),
MakeServiceCommandMeta<Spl_Cmd_GetBootReason, &GeneralService::GetBootReason, FirmwareVersion_300>(),
};
};
class GeneralService : public IServiceObject {
protected:
enum class CommandId {
/* 1.0.0+ */
GetConfig = 0,
ExpMod = 1,
GenerateAesKek = 2,
LoadAesKey = 3,
GenerateAesKey = 4,
SetConfig = 5,
GenerateRandomBytes = 7,
ImportLotusKey = 9,
DecryptLotusMessage = 10,
IsDevelopment = 11,
GenerateSpecificAesKey = 12,
DecryptRsaPrivateKey = 13,
DecryptAesKey = 14,
CryptAesCtr = 15,
ComputeCmac = 16,
ImportEsKey = 17,
UnwrapTitleKey = 18,
LoadTitleKey = 19,
/* 2.0.0+ */
UnwrapCommonTitleKey = 20,
AllocateAesKeyslot = 21,
FreeAesKeyslot = 22,
GetAesKeyslotAvailableEvent = 23,
/* 3.0.0+ */
SetBootReason = 24,
GetBootReason = 25,
/* 5.0.0+ */
ImportSslKey = 26,
SslExpMod = 27,
ImportDrmKey = 28,
DrmExpMod = 29,
ReEncryptRsaPrivateKey = 30,
GetPackage2Hash = 31,
/* 6.0.0+ */
UnwrapElicenseKey = 31, /* re-used command id :( */
LoadElicenseKey = 32,
};
public:
GeneralService() { /* ... */ }
virtual ~GeneralService() { /* ... */ }
protected:
/* Actual commands. */
virtual Result GetConfig(Out<u64> out, u32 which);
virtual Result ExpMod(OutPointerWithClientSize<u8> out, InPointer<u8> base, InPointer<u8> exp, InPointer<u8> mod);
virtual Result SetConfig(u32 which, u64 value);
virtual Result GenerateRandomBytes(OutPointerWithClientSize<u8> out);
virtual Result IsDevelopment(Out<bool> is_dev);
virtual Result SetBootReason(BootReasonValue boot_reason);
virtual Result GetBootReason(Out<BootReasonValue> out);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MakeServiceCommandMeta<CommandId::GetConfig, &GeneralService::GetConfig>(),
MakeServiceCommandMeta<CommandId::ExpMod, &GeneralService::ExpMod>(),
MakeServiceCommandMeta<CommandId::SetConfig, &GeneralService::SetConfig>(),
MakeServiceCommandMeta<CommandId::GenerateRandomBytes, &GeneralService::GenerateRandomBytes>(),
MakeServiceCommandMeta<CommandId::IsDevelopment, &GeneralService::IsDevelopment>(),
MakeServiceCommandMeta<CommandId::SetBootReason, &GeneralService::SetBootReason, FirmwareVersion_300>(),
MakeServiceCommandMeta<CommandId::GetBootReason, &GeneralService::GetBootReason, FirmwareVersion_300>(),
};
};
}