diff options
| author | 2021-06-15 02:35:06 -0400 | |
|---|---|---|
| committer | 2021-06-16 01:46:45 -0400 | |
| commit | faf11fe46d1568da0b60a9bfb0b0452dc32c45a6 (patch) | |
| tree | 30fcd37d704b9bc1d9c4dd445b368fac13714aa7 /src/core/hle/service/spl | |
| parent | spl: Add SPL result codes (diff) | |
| download | yuzu-faf11fe46d1568da0b60a9bfb0b0452dc32c45a6.tar.gz yuzu-faf11fe46d1568da0b60a9bfb0b0452dc32c45a6.tar.xz yuzu-faf11fe46d1568da0b60a9bfb0b0452dc32c45a6.zip | |
spl: Add SPL types
Diffstat (limited to 'src/core/hle/service/spl')
| -rw-r--r-- | src/core/hle/service/spl/spl_types.h | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/src/core/hle/service/spl/spl_types.h b/src/core/hle/service/spl/spl_types.h new file mode 100644 index 000000000..23c39f7ed --- /dev/null +++ b/src/core/hle/service/spl/spl_types.h | |||
| @@ -0,0 +1,230 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <span> | ||
| 6 | |||
| 7 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | namespace Service::SPL { | ||
| 11 | |||
| 12 | constexpr size_t AES_128_KEY_SIZE = 0x10; | ||
| 13 | |||
| 14 | namespace Smc { | ||
| 15 | |||
| 16 | enum class FunctionId : u32 { | ||
| 17 | SetConfig = 0xC3000401, | ||
| 18 | GetConfig = 0xC3000002, | ||
| 19 | GetResult = 0xC3000003, | ||
| 20 | GetResultData = 0xC3000404, | ||
| 21 | ModularExponentiate = 0xC3000E05, | ||
| 22 | GenerateRandomBytes = 0xC3000006, | ||
| 23 | GenerateAesKek = 0xC3000007, | ||
| 24 | LoadAesKey = 0xC3000008, | ||
| 25 | ComputeAes = 0xC3000009, | ||
| 26 | GenerateSpecificAesKey = 0xC300000A, | ||
| 27 | ComputeCmac = 0xC300040B, | ||
| 28 | ReencryptDeviceUniqueData = 0xC300D60C, | ||
| 29 | DecryptDeviceUniqueData = 0xC300100D, | ||
| 30 | |||
| 31 | ModularExponentiateWithStorageKey = 0xC300060F, | ||
| 32 | PrepareEsDeviceUniqueKey = 0xC3000610, | ||
| 33 | LoadPreparedAesKey = 0xC3000011, | ||
| 34 | PrepareCommonEsTitleKey = 0xC3000012, | ||
| 35 | |||
| 36 | // Deprecated functions. | ||
| 37 | LoadEsDeviceKey = 0xC300100C, | ||
| 38 | DecryptAndStoreGcKey = 0xC300100E, | ||
| 39 | |||
| 40 | // Atmosphere functions. | ||
| 41 | AtmosphereIramCopy = 0xF0000201, | ||
| 42 | AtmosphereReadWriteRegister = 0xF0000002, | ||
| 43 | |||
| 44 | AtmosphereGetEmummcConfig = 0xF0000404, | ||
| 45 | }; | ||
| 46 | |||
| 47 | enum class CipherMode { | ||
| 48 | CbcEncrypt = 0, | ||
| 49 | CbcDecrypt = 1, | ||
| 50 | Ctr = 2, | ||
| 51 | }; | ||
| 52 | |||
| 53 | enum class DeviceUniqueDataMode { | ||
| 54 | DecryptDeviceUniqueData = 0, | ||
| 55 | DecryptAndStoreGcKey = 1, | ||
| 56 | DecryptAndStoreEsDeviceKey = 2, | ||
| 57 | DecryptAndStoreSslKey = 3, | ||
| 58 | DecryptAndStoreDrmDeviceCertKey = 4, | ||
| 59 | }; | ||
| 60 | |||
| 61 | enum class ModularExponentiateWithStorageKeyMode { | ||
| 62 | Gc = 0, | ||
| 63 | Ssl = 1, | ||
| 64 | DrmDeviceCert = 2, | ||
| 65 | }; | ||
| 66 | |||
| 67 | enum class EsCommonKeyType { | ||
| 68 | TitleKey = 0, | ||
| 69 | ArchiveKey = 1, | ||
| 70 | }; | ||
| 71 | |||
| 72 | struct AsyncOperationKey { | ||
| 73 | u64 value; | ||
| 74 | }; | ||
| 75 | |||
| 76 | } // namespace Smc | ||
| 77 | |||
| 78 | enum class HardwareType { | ||
| 79 | Icosa = 0, | ||
| 80 | Copper = 1, | ||
| 81 | Hoag = 2, | ||
| 82 | Iowa = 3, | ||
| 83 | Calcio = 4, | ||
| 84 | Aula = 5, | ||
| 85 | }; | ||
| 86 | |||
| 87 | enum class SocType { | ||
| 88 | Erista = 0, | ||
| 89 | Mariko = 1, | ||
| 90 | }; | ||
| 91 | |||
| 92 | enum class HardwareState { | ||
| 93 | Development = 0, | ||
| 94 | Production = 1, | ||
| 95 | }; | ||
| 96 | |||
| 97 | enum class MemoryArrangement { | ||
| 98 | Standard = 0, | ||
| 99 | StandardForAppletDev = 1, | ||
| 100 | StandardForSystemDev = 2, | ||
| 101 | Expanded = 3, | ||
| 102 | ExpandedForAppletDev = 4, | ||
| 103 | |||
| 104 | // Note: Dynamic is not official. | ||
| 105 | // Atmosphere uses it to maintain compatibility with firmwares prior to 6.0.0, | ||
| 106 | // which removed the explicit retrieval of memory arrangement from PM. | ||
| 107 | Dynamic = 5, | ||
| 108 | Count, | ||
| 109 | }; | ||
| 110 | |||
| 111 | enum class BootReason { | ||
| 112 | Unknown = 0, | ||
| 113 | AcOk = 1, | ||
| 114 | OnKey = 2, | ||
| 115 | RtcAlarm1 = 3, | ||
| 116 | RtcAlarm2 = 4, | ||
| 117 | }; | ||
| 118 | |||
| 119 | struct BootReasonValue { | ||
| 120 | union { | ||
| 121 | u32 value{}; | ||
| 122 | |||
| 123 | BitField<0, 8, u32> power_intr; | ||
| 124 | BitField<8, 8, u32> rtc_intr; | ||
| 125 | BitField<16, 8, u32> nv_erc; | ||
| 126 | BitField<24, 8, u32> boot_reason; | ||
| 127 | }; | ||
| 128 | }; | ||
| 129 | static_assert(sizeof(BootReasonValue) == sizeof(u32), "BootReasonValue definition!"); | ||
| 130 | |||
| 131 | struct AesKey { | ||
| 132 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 133 | |||
| 134 | std::span<u8> AsBytes() { | ||
| 135 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 136 | } | ||
| 137 | |||
| 138 | std::span<const u8> AsBytes() const { | ||
| 139 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 140 | } | ||
| 141 | }; | ||
| 142 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "AesKey definition!"); | ||
| 143 | |||
| 144 | struct IvCtr { | ||
| 145 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 146 | |||
| 147 | std::span<u8> AsBytes() { | ||
| 148 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 149 | } | ||
| 150 | |||
| 151 | std::span<const u8> AsBytes() const { | ||
| 152 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 153 | } | ||
| 154 | }; | ||
| 155 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "IvCtr definition!"); | ||
| 156 | |||
| 157 | struct Cmac { | ||
| 158 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 159 | |||
| 160 | std::span<u8> AsBytes() { | ||
| 161 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 162 | } | ||
| 163 | |||
| 164 | std::span<const u8> AsBytes() const { | ||
| 165 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 166 | } | ||
| 167 | }; | ||
| 168 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "Cmac definition!"); | ||
| 169 | |||
| 170 | struct AccessKey { | ||
| 171 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 172 | |||
| 173 | std::span<u8> AsBytes() { | ||
| 174 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 175 | } | ||
| 176 | |||
| 177 | std::span<const u8> AsBytes() const { | ||
| 178 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 179 | } | ||
| 180 | }; | ||
| 181 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "AccessKey definition!"); | ||
| 182 | |||
| 183 | struct KeySource { | ||
| 184 | std::array<u64, AES_128_KEY_SIZE / sizeof(u64)> data64{}; | ||
| 185 | |||
| 186 | std::span<u8> AsBytes() { | ||
| 187 | return std::span{reinterpret_cast<u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 188 | } | ||
| 189 | |||
| 190 | std::span<const u8> AsBytes() const { | ||
| 191 | return std::span{reinterpret_cast<const u8*>(data64.data()), AES_128_KEY_SIZE}; | ||
| 192 | } | ||
| 193 | }; | ||
| 194 | static_assert(sizeof(AesKey) == AES_128_KEY_SIZE, "KeySource definition!"); | ||
| 195 | |||
| 196 | enum class ConfigItem : u32 { | ||
| 197 | // Standard config items. | ||
| 198 | DisableProgramVerification = 1, | ||
| 199 | DramId = 2, | ||
| 200 | SecurityEngineInterruptNumber = 3, | ||
| 201 | FuseVersion = 4, | ||
| 202 | HardwareType = 5, | ||
| 203 | HardwareState = 6, | ||
| 204 | IsRecoveryBoot = 7, | ||
| 205 | DeviceId = 8, | ||
| 206 | BootReason = 9, | ||
| 207 | MemoryMode = 10, | ||
| 208 | IsDevelopmentFunctionEnabled = 11, | ||
| 209 | KernelConfiguration = 12, | ||
| 210 | IsChargerHiZModeEnabled = 13, | ||
| 211 | QuestState = 14, | ||
| 212 | RegulatorType = 15, | ||
| 213 | DeviceUniqueKeyGeneration = 16, | ||
| 214 | Package2Hash = 17, | ||
| 215 | |||
| 216 | // Extension config items for exosphere. | ||
| 217 | ExosphereApiVersion = 65000, | ||
| 218 | ExosphereNeedsReboot = 65001, | ||
| 219 | ExosphereNeedsShutdown = 65002, | ||
| 220 | ExosphereGitCommitHash = 65003, | ||
| 221 | ExosphereHasRcmBugPatch = 65004, | ||
| 222 | ExosphereBlankProdInfo = 65005, | ||
| 223 | ExosphereAllowCalWrites = 65006, | ||
| 224 | ExosphereEmummcType = 65007, | ||
| 225 | ExospherePayloadAddress = 65008, | ||
| 226 | ExosphereLogConfiguration = 65009, | ||
| 227 | ExosphereForceEnableUsb30 = 65010, | ||
| 228 | }; | ||
| 229 | |||
| 230 | } // namespace Service::SPL | ||