Changes

Jump to navigation Jump to search
5,172 bytes added ,  24 February
no edit summary
= Secure Monitor Calls calls
The secure monitor provides two top level handlers of which each provides a range of sub handlers.
Secure Monitor Calls calls follow the ARM SMC calling convention up to a small change:
{| class=wikitable
! Bit number || Bit mask || Description
SMC arguments are passed using registers X0-X7 with X0 always sending the call sub-id and returning the result of the call.
== ID 0 FunctionId0 ==
Functions exposed to user-mode processes using [[SVC|svcCallSecureMonitor]]. SMCs should be called from CPUID 3 (where SPL runs).
{| class=wikitable
! Sub-ID Value || Name || In || Out
|-
| 0xC3000401 || SetConfig || ||
|-
| 0xC3000002 || [[#GetConfig ]] (Same same as ID 1, Sub-ID 4in [[#FunctionId1]]) || ||
|-
| 0xC3000003 || CheckStatus || ||GetResult
|-
| 0xC3000404 || GetResult || ||GetResultData
|-
| 0xC3000E05 || ExpMod || ||
|-
| 0xC3000006 || GetRandomBytes [[#GenerateRandomBytes]] (Same same as ID 1, Sub-ID 5in [[#FunctionId1]]) || ||
|-
| 0xC3000007 || [[#GenerateAesKek]] || ||
|-
| 0xC3000008 || [[#LoadAesKey]] || ||
|-
| 0xC3000009 || [[#CryptAesComputeAes]] || ||
|-
| 0xC300000A || [[#GenerateSpecificAesKey]] || ||
|-
| 0xC300040B || [[#ComputeCmac]] || ||
|-
| [1.0.0-4.1.0] 0xC300100C || [[#LoadRsaOaepKeyImportEsKey]] || ||
|-
| [5.0.0+] 0xC300D60C || [[#EncryptRsaKeyForImportReEncryptRsaPrivateKey]] || ||
|-
| [1.0.0-4.1.0] 0xC300100D || [[#DecryptRsaPrivateKey]] || ||
|-
| [5.0.0+] 0xC300100D || [[#DecryptOrImportRsaKeyDecryptOrImportRsaPrivateKey]] || ||
|-
| [1.0.0-4.1.0] 0xC300100E || [[#LoadSecureExpModKeyImportLotusKey]] || ||
|-
| 0xC300060F || [[#SecureExpModStorageExpMod]] || ||
|-
| 0xC3000610 || [[#UnwrapRsaOaepWrappedTitleKeyUnwrapTitleKey]] || ||
|-
| 0xC3000011 || [[#LoadTitleKey]] || ||
|-
| 0xC3000012 || [2.0.0+] UnwrapAesWrappedTitleKey || ||[[#UnwrapCommonTitleKey]]
|}
** This means: Plaintext kek keys never leave TrustZone.
** Further, this means: Actual AES/RSA keys never leave TrustZone.
 
Note:
The [[#enum_CryptoUsecase|CryptoUsecase_TitleKey]] represents a RSA wrapped AES key.
=== GenerateAesKek ===
Takes an "access key" as input, an [[#enum_CryptoUsecaseCryptoUsecase]].
Returns a session-unique kek for said usecase.
Takes a session kek created with [[#GenerateAesKek]], and a wrapped AES key.
The session kek must have been created with [[#enum_CryptoUsecaseCryptoUsecase|CryptoUsecase_AesCryptoUsecase Aes]].
=== CryptAes ComputeAes ===Encrypts/decrypts using Aes AES (CTR and CBC). Takes an [[#CipherMode]].
Key must be set prior using one of the [[#LoadAesKey]], or [[#GenerateSpecificAesKey]] or [[#LoadRsaWrappedAesKey]] commands.
=== GenerateSpecificAesKey ===
Todo: This one seems unrelated to [[#enum_CryptoUsecase]]Takes a wrapped AES key and decrypts it using static data.
=== LoadRsaOaepKey ComputeCmac ===Calculates CMAC over input data. === ImportEsKey ===
Takes a session kek created with [[#GenerateAesKek]], a wrapped AES key, and a wrapped RSA private key.
The session kek must have been created with [[#enum_CryptoUsecaseCryptoUsecase|CryptoUsecase_RsaOaepCryptoUsecase TitleKey]].
This function was removed in [[5.0.0]], This function was removed and replaced with [[#EncryptRsaKeyForImportReEncryptRsaPrivateKey]].
=== EncryptRsaKeyForImport ReEncryptRsaPrivateKey ===
Takes in two session keks created with [[#GenerateAesKek]], two wrapped AES keys, an enum member, and a wrapped RSA private key.
Decrypts and validates the wrapped RSA private key with the first kek/wrapped key, and re-encrypts it with the second if valid.
The re-encrypted key is then passed to the user, for use with [[#DecryptOrImportRsaKeyDecryptOrImportRsaPrivateKey]].
=== DecryptRsaPrivateKey ===
Takes a session kek created with [[#GenerateAesKek]], a wrapped AES key, an enum member, and a wrapped RSA private key.
The session kek must have been created with [[#enum_CryptoUsecaseCryptoUsecase|CryptoUsecase_RsaPrivateCryptoUsecase RsaPrivate]].
[4.0.0+] The SMC handler when certain conditions pass and SMC_IDFunctionId0==0xC300100D now returns error 0x6 instead of calling the handler funcptr.
=== DecryptOrImportRsaKey ===[5.0.0+] This function was replaced by [[#DecryptOrImportRsaPrivateKey]].
=== DecryptOrImportRsaPrivateKey ===This function replaced [[#DecryptRsaPrivateKey]] in [[5.0.0]], adding an additional enum member argument[[#DecryptOrImportMode]].
This SMC extends DecryptRsaPrivateKey's original functionality to enable importing private keys into the security engine instead of decrypting them, when certain enum members are passed.
=== LoadSecureExpModKey ImportLotusKey ===
Takes a session kek created with [[#GenerateAesKek]], and a wrapped RSA key.
The session kek must have been created with [[#enum_CryptoUsecaseCryptoUsecase|CryptoUsecase_RsaSecureExpModCryptoUsecase RsaSecureExpMod]].
This function was removed in [[5.0.0]], and replaced with [[#EncryptRsaKeyForImport]]This function was removed.
=== SecureExpMod ===
Performs an Exp Mod ExpMod operation using an exponent previously loaded with the [[#LoadSecureExpModKeyImportLotusKey]] command. [5.0.0+] This now uses any exponent previously loaded with [[#DecryptOrImportRsaPrivateKey]] and takes an [[#SecureExpModMode]].
=== UnwrapRsaOaepWrappedTitleKey UnwrapTitleKey ===
Takes an Rsa-Oaep-wrapped TitleKey, an RSA Public Key, and a label hash.
Performs an Exp Mod ExpMod operation using an exponent previously loaded with the [[#LoadRsaOaepKeyImportEsKey]] command, and then validates/extracts a Titlekey from the resulting message.
Returns a session-unique AES key especially for use in [[#LoadTitleKey]].
 
[5.0.0+] This now uses any exponent previously loaded with [[#DecryptOrImportRsaPrivateKey]].
=== LoadTitleKey ===
Takes a session-unique AES key from [[#UnwrapAesWrappedTitleKeyUnwrapCommonTitleKey]] or [[#UnwrapRsaOaepWrappedTitleKeyUnwrapTitleKey]].
=== enum CryptoUsecase UnwrapCommonTitleKey ==={| class=wikitable! Value || Name|-| 0 || CryptoUsecase_Aes|-| 1 || CryptoUsecase_RsaPrivate|Takes an AES-| 2 || CryptoUsecase_RsaSecureExpMod|-| 3 || CryptoUsecase_RsaOaep|}wrapped TitleKey and returns a sealed AES key.
== ID 1 FunctionId1 ==
Functions exposed to the kernel internally.
{| class=wikitable
! Sub-ID Value || Name || In || Out
|-
| 0xC4000001 || [[#CpuSuspend]] || X1=power_state, X2=entrypoint_addr, X3=context_id || None
|-
| 0x84000002 || [[#CpuOff]] || None || None
|-
| 0xC4000003 || [[#CpuOn]] || X1=target_cpu, X2=entrypoint_addr, X3=context_id, X4,X5,X6,X7=0 || X0=result
|-
| 0xC3000004 || [[#GetConfig]] (Same same as ID 0, Sub-ID 2in [[#FunctionId0]]) || W1=config_item, X2,X3,X4,X5,X6,X7=0 || X0=result, X1,X2,X3,X4=config_val
|-
| 0xC3000005 || [[#GetRandomBytesGenerateRandomBytes]] (Same same as ID 0, Sub-ID 6in [[#FunctionId0]]) || X1=size, X2,X3,X4,X5,X6,X7=0 || X0=result, X1,X2,X3,X4,X5,X6,X7=rand_bytes
|-
| 0xC3000006 || [[#Panic]] || W1=panic_color, X2,X3,X4,X5,X6,X7=0 || X0=result
|-
| 0xC3000007 || [2.0.0+] [[#ConfigureCarveout]] || X1=carveout_index, X2=region_phys_addr, X3=region_size, X4,X5,X6,X7=0 || X0=result
|-
| 0xC3000008 || [2.0.0+] [[#ReadWriteRegister]] || X1=reg_addr, W2=rw_mask, W3=in_val, X4,X5,X6,X7=0 || X0=result, W1=out_val
|}
=== CpuSuspend ===
Standard ARM PCSI SMCTakes an u64 '''PowerState''', an u64 '''EntrypointAddr''' and an u64 '''ContextId'''. Suspends the CPU (CPU0)No output.
Suspends the CPU (CPU0). The kernel calls this SMC on shutdown with '''power_statePowerState''' set to 0x0201001B (power level: 0x02==system; power type: 0x01==powerdown; ID: 0x1B).
=== CpuOff ===
Standard ARM PCSI SMCNo input/output.  Turns off the CPU (CPU1, CPU2 or CPU3).
=== CpuOn ===
Standard ARM PCSI SMCTakes an u64 '''TargetCpu''', an u64 '''EntrypointAddr''' and an u64 '''ContextId'''. Returns [[#Result]]. Turns on the CPU (CPU1, CPU2 or CPU3).
=== GetConfig ===
Takes a '''config_item''' [[#ConfigItem]]. Returns [[#Result]] and returns an associated a '''config_valConfigVal'''.
==== ConfigItem ====
{| class="wikitable" border="1"
|-
! ConfigItem Value || Name
|-
| 1 || [[#DisableProgramVerification]]
| 2 || [[#DramId]]
|-
| 3 || [[#SecurityEngineIrqNumberSecurityEngineInterruptNumber]]
|-
| 4 || [[#VersionFuseVersion]]
|-
| 5 || [[#HardwareType]]
| 9 || [1.0.0-4.0.0] [[#BootReason]]
|-
| 10 || [[#MemoryArrangeMemoryMode]]
|-
| 11 || [[#IsDebugMode]]
| 13 || [[#IsChargerHiZModeEnabled]]
|-
| 14 || [4.0.0+] [[#IsKioskIsQuest]]
|-
| 15 || [5.0.0+] [[#NewHardwareTypeRegulatorType]]
|-
| 16 || [5.0.0+] [[#NewKeyGenerationDeviceUniqueKeyGeneration]]
|-
| 17 || [5.0.0+] [[#Package2Hash]]
|}
===== DisableProgramVerification =====
[[Process Manager services|PM]] checks this item and if non-zero, calls fsp-pr SetEnabledProgramVerification(false).
===== DramId ====This is extracted directly from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]].=
{| class="wikitable" border="1"
|-
! Value! Description|-| 0| EristaIcosaSamsung4gb|-| 1| EristaIcosaHynix4gb|-| 2| EristaIcosaMicron4gb|-| 3| Reserved|-| 4| EristaIcosaSamsung6gb
|-
| 05| DramId_EristaIcosaSamsung4gb[4.0.0+] Reserved
|-
| 16| DramId_EristaIcosaHynix4gb[4.0.0+] Reserved
|-
| 27| DramId_EristaIcosaMicron4gb[5.0.0+] MarikoIowax1x2Samsung4gb ([4.0.0-4.1.0] Reserved)
|-
| 38| Reserved[5.0.0+] MarikoIowaSamsung4gb
|-
| 49| DramId_EristaIcosaSamsung6gb[5.0.0+] MarikoIowaSamsung8gb
|-
| 510| [46.0.0+] MarikoIowaHynix4gb ([5.0.0-5.1.0] Reserved (DramId_EristaIcosaHynix6gb)
|-
| 611| [47.0.0+] MarikoIowaMicron4gb ([5.0.0-6.2.0] Reserved (DramId_EristaIcosaMicron6gb)
|-
| 712| [5.0.0+] DramId_MarikoIowax1x2Samsung4gb ([4.0.0-4.1.0] Reserved)MarikoHoagSamsung4gb
|-
| 813| [5.0.0+] DramId_MarikoIowaSamsung4gbMarikoHoagSamsung8gb
|-
| 914| [7.0.0+] MarikoHoagHynix4gb ([5.0.0+-6.2.0] DramId_MarikoIowaSamsung8gbReserved)
|-
| 1015| [67.0.0+] DramId_MarikoIowaHynix4gb MarikoHoagMicron4gb ([5.0.0-56.12.0] Reserved)
|-
| 1116| [78.0.0+] DramId_MarikoIowaMicron4gb ([5.0.0-6.2.0] Reserved)MarikoIowaSamsung4gbY
|-
| 1217| [59.0.0+] DramId_MarikoHoagSamsung4gbMarikoIowaSamsung1y4gbX
|-
| 1318| [59.0.0+] DramId_MarikoHoagSamsung8gbMarikoIowaSamsung1y8gbX
|-
| 1419| [79.0.0+] DramId_MarikoHoagHynix4gb ([5.0.0-6.2.0] Reserved)MarikoHoagSamsung1y4gbX
|-
| 1520| [79.0.0+] DramId_MarikoHoagMicron4gb (MarikoIowaSamsung1y4gbY|-| 21| [59.0.0+] MarikoIowaSamsung1y8gbY|-6| 22| [9.20.0+] Reserved)MarikoIowaSamsung1y4gbA
|}
 
This is extracted directly from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]].
[[PCV_services|PCV]] selects memory training tables based on DramId.
{| class="wikitable" border="1"
|-
! SoC! Platform! DramId! Revision! DVFS version
|-
| T210| jetson-tx1| N/A| 0x07
|
11_40800_01_V9.8.3_V1.6
11_1600000_02_V9.8.3_V1.6
|-
| T210| nx-abcb| EristaIcosaSamsung4gb| 0x07
|
10_40800_NoCfgVersion_V9.8.7_V1.6
10_1600000_NoCfgVersion_V9.8.7_V1.6
|-
| T210| nx-abcb| EristaIcosaMicron4gb| 0x07
|
10_40800_NoCfgVersion_V9.8.4_V1.6
10_1600000_NoCfgVersion_V9.8.4_V1.6
|-
| T210| nx-abcb| EristaIcosaHynix4gb| 0x07
|
10_40800_NoCfgVersion_V9.8.4_V1.6
10_1600000_NoCfgVersion_V9.8.4_V1.6
|-
| T210| nx-abca2| EristaIcosaSamsung4gb or , EristaIcosaMicron4gb| 0x07
|
10_40800_NoCfgVersion_V9.8.7_V1.6
10_1600000_NoCfgVersion_V9.8.7_V1.6
|-
| T210| nx-abca2| EristaIcosaHynix4gb| 0x07
|
10_40800_NoCfgVersion_V9.8.7_V1.6
10_1600000_NoCfgVersion_V9.8.7_V1.6
|-
| T210| nx-abca2| EristaIcosaSamsung6gb| 0x07
|
10_40800_NoCfgVersion_V9.8.7_V1.6
10_1600000_NoCfgVersion_V9.8.7_V1.6
|-
| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowax1x2Samsung4gb| 0x03
|
01_204000_NoCfgVersion_V0.3.1_V2.0
01_1600000_NoCfgVersion_V0.3.1_V2.0
|-
| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaSamsung4gb or , MarikoHoagSamsung4gb| 0x03
|
01_204000_NoCfgVersion_V0.3.1_V2.0
01_1600000_NoCfgVersion_V0.3.1_V2.0
|-
| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaSamsung8gb or , MarikoHoagSamsung8gb| 0x03
|
01_204000_NoCfgVersion_V0.4.2_V2.0
01_1600000_NoCfgVersion_V0.4.2_V2.0
|-
| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaHynix4gb or , MarikoHoagHynix4gb| 0x03
|
01_204000_NoCfgVersion_V0.3.1_V2.0
01_1600000_NoCfgVersion_V0.3.1_V2.0
|-
| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaMicron4gb, MarikoHoagMicron4gb| 0x03| 01_204000_NoCfgVersion_V0.4.2_V2.0 01_1331200.0_NoCfgVersion_V0.4.2_V2.0 01_1600000_NoCfgVersion_V0.4.2_V2.0|-| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaSamsung4gbY| 0x03| MarikoIowaMicron4gb or MarikoHoagMicron4gb 01_204000_NoCfgVersion_V0.4.2_V2.0 01_1331200.0_NoCfgVersion_V0.4.2_V2.0 01_1600000_NoCfgVersion_V0.4.2_V2.0|-| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaSamsung1y4gbX| 0x03| 01_204000_NoCfgVersion_V0.4.2_V2.0 01_1331200.0_NoCfgVersion_V0.4.2_V2.0 01_1600000_NoCfgVersion_V0.4.2_V2.0|-| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaSamsung1y8gbX| 0x03| 01_204000_NoCfgVersion_V0.4.2_V2.0 01_1331200.0_NoCfgVersion_V0.4.2_V2.0 01_1600000_NoCfgVersion_V0.4.2_V2.0|-| T214| nx-abca2, nx-abcb, nx-abcc| MarikoHoagSamsung1y4gbX| 0x03| 01_204000_NoCfgVersion_V0.4.2_V2.0 01_1331200.0_NoCfgVersion_V0.4.2_V2.0 01_1600000_NoCfgVersion_V0.4.2_V2.0|-| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaSamsung1y4gbY| 0x03| 01_204000_NoCfgVersion_V0.4.2_V2.0 01_1331200.0_NoCfgVersion_V0.4.2_V2.0 01_1600000_NoCfgVersion_V0.4.2_V2.0|-| T214| nx-abca2, nx-abcb, nx-abcc| MarikoIowaSamsung1y8gbY| 0x03
|
01_204000_NoCfgVersion_V0.4.2_V2.0
01_1331200.0_NoCfgVersion_V0.4.2_V2.0
01_1600000_NoCfgVersion_V0.4.2_V2.0
|-
| T214
| nx-abca2, nx-abcb, nx-abcc
| MarikoIowaSamsung1y4gbA
| 0x03
|
01_204000_NoCfgVersion_V0.4.5_V2.0
01_1331200.0_NoCfgVersion_V0.4.5_V2.0
01_1600000_NoCfgVersion_V0.4.5_V2.0
|}
'''nx-abca2''' ('''Icosa''' in '''Erista''', '''Iowa''' in '''Mariko''') hardware types are variations of the retail, EDEV and SDEV form factors. '''nx-abcb ''' ('''Copper''' in '''Erista''', '''Calcio''' in '''Mariko''') is the SDEV a prototype unit. Among other differences, this has extra hardware to support HDMI output.
[8.0.0+] '''nx-abca2 abcc''' (Icosa'''Hoag''') hardware types are variations of was added for the Lite retail and HDEV form factorfactors.
'''Erista ''' memory is LPDDR4, while '''Mariko ''' memory is LPDDR4X.
==== SecurityEngineIrqNumber = SecurityEngineInterruptNumber =====
SPL uses this for setting up the security engine IRQ.
==== Version = FuseVersion =====
The current [[Package2#Versions|Package1 Maxver Constant]] - 1.
===== HardwareType =====[1.0.0+] This item is obtained by checking bits 8 and 2 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]]. It can be :* 0 ('''Icosa'''; Erista retail, EDEV and SDEV), if development flag (bit 8) is '''Retail''' and production flag (bit 2) is '''Production'''.* 1 ('''Copper'''; Erista prototype), if development flag (bit 8) or is '''Development''' and production flag (bit 2) is '''Prototype'''.* 3 (Invalid). Value 2 is reserved and considered invalid.
[4.0.0+] This item is obtained by checking bits 8, 2 and 16-19 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]]. It can be :* 0 ('''Icosa'''; Erista retail, EDEV and SDEV), if development flag (bit 8) is '''Retail''' and production flag (bit 2) is '''Production'''.* 1 ('''Copper'''; Erista prototype), if development flag (bit 8) is '''Development''' and production flag (bit 2) is '''Prototype'''.* 3 ('''Iowa'''; Marikoretail, EDEV and SDEV), if new hardware type (bits 16-19) or is '''Iowa'''.* 4 (Invalid).
A value of Value 2 (Hoag) is always mapped to 4 (Invalid)reserved and considered invalid.
[7.0.0+] This item can be obtained by checking bits 8, 2 and 16-19 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]], but is now only 0 (Icosa) or 0xF (Invalid) in retail units. [8.0.0+] This item can be obtained by checking bits 8, 2 and 16-19 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]]. It can be:* 0 ('''Icosa'''; Erista retail, EDEV and SDEV), if development flag (bit 8) is '''Retail''' and production flag (bit 2) is '''Production'''.* 1 ('''Copper'''; Erista prototype), if development flag (bit 8) is '''Development''' and production flag (bit 2) is '''Prototype'''.* 2 ('''Hoag'''; Mariko Lite retail and HDEV), if new hardware type (bits 16-19) is '''Hoag'''.* 3 ('''Iowa'''; Mariko retail, EDEV and SDEV), if new hardware type (bits 16-19) is '''Iowa'''.* 4 ('''Calcio'''; Mariko prototype), if development flag (bit 8) is '''Development''' and production flag (bit 2) is '''Prototype'''.* 5 (Invalid). It is still only 0 (Icosa) or 0xF (Invalid) in retail units. ===== IsRetail =====
This item is obtained by checking bits 9 and 0-1 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]]. It can be 0 (Debug), 1 (Retail) or 2 (Invalid).
===== IsRecoveryBoot =====
Used to determine if the system is booting from SafeMode firmware.
Under normal circumstances, this just returns bit 0 of the active [[BCT#bootloader0_info|bootloader info]]'s attribute field.
===== DeviceId =====
[[NIM_services|NIM]] checks if this item matches the [[Settings_services|set:cal]] DeviceId with byte7 cleared. If they don't match, a panic is thrown.
===== BootReason ====={| class=wikitable! Value || Description|-| 0 || Invalid|-| 1 || AcOk|-| 2 || OnKey|-| 3 || RtcAlarm1|-| 4 || RtcAlarm2|} 
Used to determine how the system booted.
==== MemoryArrange =MemoryMode ====={| class="wikitable" border="1"|-! Bits! Description|-| 0-3| Purpose (0 = None, 1 = ForStandard, 2 = ForAppletDev, 3 = ForSystemDev)|-| 4-7[[Process Manager services|PM]] uses this item for selecting the appropriate size for each [[SVC#LimitableResourceSize (0 = 4GB, 1 = 6GB, 2 = 8GB)|LimitableResource_Memory]].}
[[Process Manager services|PM]] and the kernel decide memory arrangement based on MemoryMode.{| class="wikitable" border="1"|-! MemoryArrange! MemoryMode! Description|-| 0| 0x01| Standard |-| 1| 0x02| StandardForAppletDev|-| 2| 0x03| StandardForSystemDev|-| 3| 0x11| Expanded|-| 4| 0x12| ExpandedForAppletDev|-| 5| 0x21| ExpandedForMarikoDev|} ===== IsDebugMode =====
Kernel uses this to determine behavior of svcBreak positive arguments. It will break instead of just force-exiting the process which is what happens on retail.
[3.0.0+] [[Loader services|RO]] checks this and if set then skipping NRR rsa signatures is allowed.
The value of this field is loaded from ===== KernelConfiguration ====={| class="wikitable" border="1"|-! Bits! Description|-| 0| EnableNonZeroFillMemory|-| 1| EnableUserExceptionHandler|-| 2| PerformanceMonitoringUnit|-| 3| [[BootConfig8.0.0+]] unsignedEnableApplicationExtraThread|-| 8| CallShowErrorOnPanic|-| 16-17| MemorySize|} Kernel reads this when setting up memory-config+0x10 u8 bit1related code.
==== KernelConfiguration ====Kernel reads this when setting up EnableNonZeroFillMemory is a boolean determining whether kernel should it will memset various allocated memory-related coderegions with 0x58, 0x59, 0x5A ('X', 'Y', 'Z') instead of zero. This allows Nintendo devs to find uninitialized memory bugs.
Bit 0 EnableUserExceptionHandler is a boolean determining whether kernel should it will memset various allocated memory-regions with 0x58forcefully enable usermode exception handlers (when false, 0x59, 0x5A only certain aborts (((1LL << ('X'esr >> 26)) & 0x1115804400224001) == 0, 'Y', 'Z'typically data/prefetch aborts) that occur when the faulting address is in a readable region with MemoryType_CodeStatic will trigger usermode exception handlers) instead of zero. This allows Nintendo devs to find uninitialized memory bugs.
Bit 1 PerformanceMonitoringUnit is a boolean determining whether kernel should forcefully enable usermode exception handlers access to the Performance Monitors (when false, only certain aborts (((1LL << (esr >> 26)) & 0x1115804400224001) == whether PMUSERENR_EL0 should be 1 or 0, typically data/prefetch aborts) that occur when the faulting address is in a readable region with MemoryType_CodeStatic will trigger usermode exception handlers).
Bit 2 EnableApplicationExtraThread is a boolean determining whether the kernel should enable usermode access to increase the Performance Monitors (whether PMUSERENR_EL0 should be 1 or 0)KThread slabheap capacity by 160. This also increases object capacities that are calculated based on number of threads.
Bits 8-15 are CallShowErrorOnPanic is a boolean determining whether kernel should call smcPanic on error instead of infinite-looping.
Bits 16-17 determine MemorySize determines how much memory is available. 00/03 = 4 GB, 01 = 6 GB, 02 = 8 GB.
===== IsChargerHiZModeEnabled =====
This tells if the TI Charger (bq24192) is active.
==== NewKeyGeneration =IsQuest ===This item is obtained from [[Fuse_registers#FUSE_RESERVED_ODM2|FUSE_RESERVED_ODM2]] if bit 11 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]] is set, [[Fuse_registers#FUSE_RESERVED_ODM0|FUSE_RESERVED_ODM0]] matches 0x8E61ECAE and [[Fuse_registers#FUSE_RESERVED_ODM1|FUSE_RESERVED_ODM1]] matches 0xF2BA3BB2. [5.0.0+] [[Filesystem services|FS]] can now use this value for the '''KeyGeneration''' parameter when calling [[#GenerateAesKek|GenerateAesKek]] during "GetBisEncryptionKey". ==== IsKiosk ====
This item is bit 10 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]].
[4.0.0+] [[Settings_services|Settings]] uses this value to overwrite the quest flag from [[Settings_services#set:sys|GetQuestFlag]]. This is used to detect if a Switch is a kiosk unit for display at retail stores.
==== NewHardwareType = RegulatorType =====This item is currently hardcoded to 0. [5.0.0+] [[PCV_services|PCV]] overrides the value from [[#HardwareType|HardwareType]] and configures PMIC devices with this item.
{| class="wikitable" border="1"
|-
! Value! DevicesSoC! GPU! Power Blocks
|-
| 0| T210| GM20B (0x12B)| max77620_sd0, max77621_cpu and max77621_gpu
|-
| 1| T214| GM20B_B (0x12E)| max77620_sd0, max77812_cpu and max77812_gpu
|-
| 2| T214| GM20B_B (0x12E)| max77620_sd0, max77812_cpu and max77812_gpu
|}
This item is currently hardcoded to 0. [5.0.0+] [[PCV_services|PCV]] uses this value in combination with [[#HardwareType|HardwareType]] to configure power blocks and memory tables for different hardware. ===== DeviceUniqueKeyGeneration =====This item is obtained from [[Fuse_registers#FUSE_RESERVED_ODM2|FUSE_RESERVED_ODM2]] if bit 11 from [[Fuse_registers#FUSE_RESERVED_ODM4|FUSE_RESERVED_ODM4]] is set, [[Fuse_registers#FUSE_RESERVED_ODM0|FUSE_RESERVED_ODM0]] matches 0x8E61ECAE and [[Fuse_registers#FUSE_RESERVED_ODM1|FUSE_RESERVED_ODM1]] matches 0xF2BA3BB2. [5.0.0+] [[Filesystem services|FS]] can now use this value for the '''KeyGeneration''' parameter when calling [[#GenerateAesKek|GenerateAesKek]] during "GetBisEncryptionKey". ===== Package2Hash =====
This is a SHA-256 hash calculated over the [[Package2|package2]] image. Since the hash calculation is an optional step in pkg2ldr, this item is only valid in recovery mode. Otherwise, an error is returned instead.
=== GetRandomBytes GenerateRandomBytes ===Takes a an u64 '''sizeRndSize''' . Returns [[#Result]] and returns '''rand_bytesRndData'''.
The kernel limits '''sizeRndSize''' to 0x38 (for fitting in return registers).
=== Panic ===
Issues Takes an u32 '''PanicColor''' and issues a system panic.
The kernel always calls this with '''panic_colorPanicColor''' set to 0xF00.
=== ConfigureCarveout ===
Configures memory controller carveout regionsTakes an u64 '''CarveoutIdx''', an u64 '''CarveoutAddr''' and an u64 '''CarveoutSize'''. Returns [[#Result]].
If '''carveout_indexCarveoutIdx''' is 0, '''region_phys_addrCarveoutAddr''' and '''region_sizeCarveoutSize''' are used to configure '''MC_SECURITY_CARVEOUT4'''.If '''carveout_indexCarveoutIdx''' is 1, '''region_phys_addrCarveoutAddr''' and '''region_sizeCarveoutSize''' are used to configure '''MC_SECURITY_CARVEOUT5'''.Any other '''carveout_indexCarveoutIdx''' values are invalid.
The kernel calls this with '''carveout_indexCarveoutIdx''' set to 0, '''region_phys_addrCarveoutAddr''' set to 0x80060000 and '''region_sizeCarveoutSize''' set to a dynamically calculated size which covers all the kernel and built-in sysmodules' DRAM regions.
=== ReadWriteRegister ===
Takes an u64 '''RegAddr''', an u32 '''RwMask''' and an u32 '''InValue'''. Returns [[#Result]] and an u32 '''OutValue'''.
 
Relays [[SVC#svcReadWriteRegister|svcReadWriteRegister]] to the Secure Monitor.
= Errors CryptoUsecase ={| class=wikitable! Value || Name|-| 0 || Aes|-| 1 || RsaPrivate|-| 2 || RsaSecureExpMod|-| 3 || TitleKey|} TitleKey represents a RSA wrapped AES key. = CipherMode ={| class=wikitable! Value || Name|-| 0 || CbcEncrypt|-| 1 || CbcDecrypt|-| 2 || Ctr|} = DecryptOrImportMode ={| class=wikitable! Value || Name|-| 0 || DecryptRsaPrivateKey|-| 1 || ImportLotusKey|-| 2 || ImportEsKey|-| 3 || ImportSslKey|-| 4 || ImportDrmKey|} = SecureExpModMode ={| class=wikitable! Value || Name|-| 0 || Lotus|-| 1 || Ssl|-| 2 || Drm|} = Result =
{| class=wikitable
! Value || Description
|-
| 0 || Success|-| 1 || Not implemented|-| 2 || Invalid inputargument|-| 3 || In progress|-| 4 || No async operation|-| 5 || Invalid async operation
|-
| 3 [8.0.0+] 6 || BusyNot permitted
|}

Navigation menu