NPDM: Difference between revisions

No edit summary
 
(23 intermediate revisions by 6 users not shown)
Line 9: Line 9:
| 0x0
| 0x0
| 0x80
| 0x80
| [[#META|META]]
| [[#Meta|Meta]]
|-
|-
| 0x80
| 0x80
| <Varies>
| Variable
| [[#ACID|ACID]]
| [[#Acid|Acid]]
|-
|-
| <See META>
| Variable
| <See META>
| Variable
| [[#ACI0|ACI0]]
| [[#Aci|Aci]]
|}
|}


= META =
= Meta =
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 29: Line 29:
| 0x0
| 0x0
| 0x4
| 0x4
| Magicnum "META"
| Magic ("META")
|-
|-
| 0x4
| 0x4
| 0x4
| 0x4
| [9.0.0+] [[#AcidSignatureKeyGeneration|AcidSignatureKeyGeneration]]
| [9.0.0+] SignatureKeyGeneration
|-
|-
| 0x8
| 0x8
Line 85: Line 85:
| 0x70
| 0x70
| 0x4
| 0x4
| [[#ACI0|AciOffset]]
| [[#Aci|AciOffset]]
|-
|-
| 0x74
| 0x74
| 0x4
| 0x4
| [[#ACI0|AciSize]]
| [[#Aci|AciSize]]
|-
|-
| 0x78
| 0x78
| 0x4
| 0x4
| [[#ACID|AcidOffset]]
| [[#Acid|AcidOffset]]
|-
|-
| 0x7C
| 0x7C
| 0x4
| 0x4
| [[#ACID|AcidSize]]
| [[#Acid|AcidSize]]
|}
|}
== AcidSignatureKeyGeneration ==
0 and 1 are valid.


== Flags ==
== Flags ==
Line 113: Line 110:
|-
|-
| 1-3
| 1-3
| ProcessAddressSpace (0x00 = AddressSpace32Bit, 0x01 = AddressSpace64BitOld, 0x02 = AddressSpace32BitNoReserved, 0x03 = AddressSpace64Bit)
| [[#ProcessAddressSpace|ProcessAddressSpace]]
|-
|-
| 4
| 4
| OptimizeMemoryAllocation
| [7.0.0+] OptimizeMemoryAllocation
|-
| 5
| [11.0.0+] DisableDeviceAddressSpaceMerge
|-
| 6
| [18.0.0+] EnableAliasRegionExtraSize
|-
| 7
| [19.0.0-19.0.1] PreventCodeReads
|}
 
=== ProcessAddressSpace ===
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0
| AddressSpace32Bit
|-
| 1
| AddressSpace64BitOld
|-
| 2
| AddressSpace32BitNoReserved
|-
| 3
| AddressSpace64Bit
|}
|}


Line 123: Line 148:


== SystemResourceSize ==
== SystemResourceSize ==
This is the size of PersonalMmHeap. Maximum size as of 5.0.0 is 0x1FE00000.
When this is non-zero, the kernel reserves this amount of memory and dynamically uses it as needed for page table pages, KMemoryBlocks, and KBlockInfos. When this is zero, the process uses global shared heaps for these.
 
This enables a process to sacrifice some of the memory available to it in order to have higher limits on these resources, thus enabling the use of SvcMapPhysicalMemory.
 
Maximum size as is 0x1FE00000.


== Version ==
== Version ==
Line 133: Line 162:


== MainThreadStackSize ==
== MainThreadStackSize ==
Must be aligned to 0x1000.
Must be aligned to 0x1000. If zero, kernel will start the process's initial thread with sp=0.


In non-nspwn scenarios, values of 0 can also rarely break in Horizon. This might be something auto-adapting or a security feature of some sort?
= Acid =
 
= ACID =
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 154: Line 181:
| 0x200
| 0x200
| 0x4
| 0x4
| Magicnum "ACID"
| Magic ("ACID")
|-
|-
| 0x204
| 0x204
Line 161: Line 188:
|-
|-
| 0x208
| 0x208
| 0x4
| 0x1
| [9.0.0+] Version
|-
| 0x209
| 0x1
| [14.0.0+]
|-
| 0x20A
| 0x2
| Reserved
| Reserved
|-
|-
Line 178: Line 213:
| 0x220
| 0x220
| 0x4
| 0x4
| [[#FsAccessControl|FsAccessControlOffset]]
| [[#FsAccessControl|FacOffset]]
|-
|-
| 0x224
| 0x224
| 0x4
| 0x4
| [[#FsAccessControl|FsAccessControlSize]]
| [[#FsAccessControl|FacSize]]
|-
|-
| 0x228
| 0x228
| 0x4
| 0x4
| [[#SrvAccessControl|SrvAccessControlOffset]]
| [[#SrvAccessControl|SacOffset]]
|-
|-
| 0x22C
| 0x22C
| 0x4
| 0x4
| [[#SrvAccessControl|SrvAccessControlSize]]
| [[#SrvAccessControl|SacSize]]
|-
|-
| 0x230
| 0x230
| 0x4
| 0x4
| [[#KernelCapability|KernelCapabilityOffset]]
| [[#KernelCapability|KcOffset]]
|-
|-
| 0x234
| 0x234
| 0x4
| 0x4
| [[#KernelCapability|KernelCapabilitySize]]
| [[#KernelCapability|KcSize]]
|-
|-
| 0x238
| 0x238
Line 217: Line 252:
| UnqualifiedApproval
| UnqualifiedApproval
|-
|-
| 2-3
| 2-5
| [5.0.0+ ] MemoryRegion (0 = Application, 1 = Applet, 2 = SecureSystem, 3 = NonSecureSystem)
| [5.0.0+] [[#MemoryRegion|MemoryRegion]]
|-
| 6
| Unused?
|-
| 7
| [21.0.0+] LoadBrowserCoreDll
|}
|}


MemoryRegion is set to Application for "starter" and NonSecureSystem for "nvservices".
MemoryRegion is set to Application for "starter" and NonSecureSystem for "nvservices".


= ACI0 =
When LoadBrowserCoreDll flag is set, an additional NPDM + NSOs (wkc0-wkc9) will be loaded from program id 010000000000085D (not present on retail).
 
=== MemoryRegion ===
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0
| Application
|-
| 1
| Applet
|-
| 2
| SecureSystem
|-
| 3
| NonSecureSystem
|}
 
= Aci =
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 232: Line 294:
| 0x0
| 0x0
| 0x4
| 0x4
| Magicnum "ACI0"
| Magic ("ACI0")
|-
|-
| 0x4
| 0x4
Line 248: Line 310:
| 0x20
| 0x20
| 0x4
| 0x4
| [[#FsAccessControl|FsAccessControlOffset]]
| [[#FsAccessControl|FacOffset]]
|-
|-
| 0x24
| 0x24
| 0x4
| 0x4
| [[#FsAccessControl|FsAccessControlSize]]
| [[#FsAccessControl|FacSize]]
|-
|-
| 0x28
| 0x28
| 0x4
| 0x4
| [[#SrvAccessControl|SrvAccessControlOffset]]
| [[#SrvAccessControl|SacOffset]]
|-
|-
| 0x2C
| 0x2C
| 0x4
| 0x4
| [[#SrvAccessControl|SrvAccessControlSize]]
| [[#SrvAccessControl|SacSize]]
|-
|-
| 0x30
| 0x30
| 0x4
| 0x4
| [[#KernelCapability|KernelCapabilityOffset]]
| [[#KernelCapability|KcOffset]]
|-
|-
| 0x34
| 0x34
| 0x4
| 0x4
| [[#KernelCapability|KernelCapabilitySize]]
| [[#KernelCapability|KcSize]]
|-
|-
| 0x38
| 0x38
Line 276: Line 338:


= FsAccessControl =
= FsAccessControl =
For [[#ACID|ACID]] this is a simple descriptor as follows:
For [[#Acid|Acid]] this is a simple descriptor as follows:
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 288: Line 350:
|-
|-
| 0x1
| 0x1
| 0x1
| [5.0.0+] ContentOwnerIdCount
|-
| 0x2
| 0x1
| [5.0.0+] SaveDataOwnerIdCount
|-
| 0x3
| 0x3
| 0x1
| Padding
| Padding
|-
|-
Line 296: Line 366:
|-
|-
| 0xC
| 0xC
| 0x20
| 0x8
| Reserved
| ContentOwnerIdMin
|-
| 0x14
| 0x8
| ContentOwnerIdMax
|-
| 0x1C
| 0x8
| SaveDataOwnerIdMin
|-
| 0x24
| 0x8
| SaveDataOwnerIdMax
|-
| 0x2C
| 0x8 * ContentOwnerIdCount
| [5.0.0+] ContentOwnerIds
|-
| Variable
| 0x8 * SaveDataOwnerIdCount
| [5.0.0+] SaveDataOwnerIds
|}
|}


For [[#ACI0|ACI0]] this embeds data as follows:
For [[#Aci|Aci]] this embeds data as follows:
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 337: Line 427:
| 0x1C
| 0x1C
| 0x4
| 0x4
| (Optional) Amount of content owner id's
| (Optional) ContentOwnerIdCount
|-
|-
| 0x1C
| 0x1C
| 0x8 * Content Owner ID's
| 0x8 * ContentOwnerIdCount
| Content owner ID's as uint64's.
| ContentOwnerIds
|-
|-
| Variable
| Variable
| 0x4
| 0x4
| Amount of save owner id's
| SaveDataOwnerIdCount
|-
|-
| Variable
| Variable
| 0x1 * Save data owner accessibilities (?)
| 0x1 * SaveDataOwnerIdCount
| Sets flags for what save data owners can do with other applications save data (?)
| Accessibilities (1=Read, 2=Write, 3=ReadWrite)
|-
|-
| Variable (padded to nearest 4 bytes)
| Variable (padded to nearest 4 bytes)
| 0x8 * Amount of save owner ID's
| 0x8 * SaveDataOwnerIdCount
| Save data owner ID's
| SaveDataOwnerIds
|}
|}


Line 360: Line 450:
|-
|-
! Bits
! Bits
! Name
! Description
! Description
|-
|-
| 0
| 0
| ApplicationInfo
| ApplicationInfo (MountContent* is accessible when set)
| MountContent* is accessible when set.
|-
|-
| 1
| 1
| BootModeControl
| BootModeControl
|
|-
|-
| 2
| 2
| Calibration
| Calibration
|
|-
|-
| 3
| 3
| SystemSaveData
| SystemSaveData
|
|-
|-
| 4
| 4
| GameCard
| GameCard
|
|-
|-
| 5
| 5
| SaveDataBackUp
| SaveDataBackUp
|
|-
|-
| 6
| 6
| SaveDataManagement
| SaveDataManagement
|
|-
|-
| 7
| 7
| BisAllRaw
| BisAllRaw
|
|-
|-
| 8
| 8
| GameCardRaw
| GameCardRaw
|
|-
|-
| 9
| 9
| GameCardPrivate
| GameCardPrivate
|
|-
|-
| 10
| 10
| SetTime
| SetTime
|
|-
|-
| 11
| 11
| ContentManager
| ContentManager
|
|-
|-
| 12
| 12
| ImageManager
| ImageManager
|
|-
|-
| 13
| 13
| CreateSaveData
| CreateSaveData
|
|-
|-
| 14
| 14
| SystemSaveDataManagement
| SystemSaveDataManagement
|
|-
|-
| 15
| 15
| BisFileSystem
| BisFileSystem
|
|-
|-
| 16
| 16
| SystemUpdate
| SystemUpdate
|
|-
|-
| 17
| 17
| SaveDataMeta
| SaveDataMeta
|
|-
|-
| 18
| 18
| DeviceSaveData
| DeviceSaveData
|
|-
|-
| 19
| 19
| SettingsControl
| SettingsControl
|
|-
|-
| 20
| 20
| SystemData
| SystemData
|
|-
|-
| 21
| 21
| SdCard
| SdCard
|
|-
|-
| 22
| 22
| Host
| Host
|
|-
|-
| 23
| 23
| FillBis
| FillBis
|
|-
|-
| 24
| 24
| CorruptSaveData
| CorruptSaveData
|
|-
|-
| 25
| 25
| SaveDataForDebug
| SaveDataForDebug
|
|-
|-
| 26
| 26
| FormatSdCard
| FormatSdCard
|
|-
|-
| 27
| 27
| GetRightsId
| GetRightsId
|
|-
|-
| 28
| 28
| RegisterExternalKey
| RegisterExternalKey
|
|-
|-
| 29
| 29
| RegisterUpdatePartition
| RegisterUpdatePartition
|
|-
|-
| 30
| 30
| SaveDataTransfer
| SaveDataTransfer
|
|-
|-
| 31
| 31
| DeviceDetection
| DeviceDetection
|
|-
|-
| 32
| 32
| AccessFailureResolution
| AccessFailureResolution
|
|-
|-
| 33
| 33
| SaveDataTransferVersion2
| SaveDataTransferVersion2
|
|-
|-
| 34
| 34
| RegisterProgramIndexMapInfo
| RegisterProgramIndexMapInfo
|
|-
|-
| 35
| 35
| CreateOwnSaveData
| CreateOwnSaveData
|
|-
|-
| 36-61
| 36
| MoveCacheStorage
|-
| 37
| DeviceTreeBlob
|-
| 38
| NotifyErrorContextServiceReady
|-
| 39
| CalibrationSystemData
|-
| 40
| CalibrationLog
|-
| 41
| StorageSecure
|-
| 42
| StorageControl
|-
| 43
| GameCardReport
|-
| 44
| MarkBeforeEraseBis
|-
| 45
| HtmlViewer
|-
| 46
| ApplicationSaveDataBackUp
|-
| 47-61
| Reserved
| Reserved
|
|-
|-
| 62
| 62
| Debug
| Debug (ignored on non-DebugMode, see [[SPL_services#GetConfig|here]])
| See [[SPL_services#GetConfig|here]].
|-
|-
| 63
| 63
| FullPermission
| FullPermission (ignored on non-DebugMode, all [[Filesystem_services#Permissions|permission types]] which check a bitmask have this bit set)
| Enables access to everything: all [[Filesystem_services#Permissions|permission types]] which check a bitmask have this bit set.
|}
|}


Line 595: Line 678:
| All ones
| All ones
|  
|  
| Ignored
| Invalid
|}
|}


Line 633: Line 716:


== MemoryMap ==
== MemoryMap ==
MemoryMap entries are stored in pairs. The first pair will contain BeginAddress and PermissionType, while the second pair will contain Size and MappingType.
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 639: Line 723:
|-
|-
| 7-30
| 7-30
| BeginAddress or Size
| BeginAddress
|-
|-
| 31
| 31
| IsRw or IsIo
| PermissionType (0=RW, 1=RO)
|}
|}


MemoryMap entries are stored alternating between BeginAddress + IsRw and Size + IsIo.
{| class="wikitable" border="1"
|-
! Bits
! Description
|-
| 7-26
| Size
|-
| 27-30
| Reserved
|-
| 31
| MappingType (0=Io, 1=Static)
|}


=== Restrictions ===
=== Restrictions ===
Line 698: Line 795:
| RegionIsReadOnly2
| RegionIsReadOnly2
|}
|}
MemoryRegionMap is supported by the kernel but not by [[Loader_services|Loader]]. Thus, only initial processes may possess this capability.


== EnableInterrupts ==
== EnableInterrupts ==
Line 741: Line 836:
|}
|}


This is compared with 0x80000, when less than an error is returned. This is equivalent to comparing the bits starting at bit15 with 0x10. This enforces a minimum required version, not a maximum.
This encodes the intended kernel version for the program.
 
The kernel requires that the intended version is >= the minimum supported version (3.0 for all released kernels), and <= the current version.
 
Kernel version is derived from/equivalent to SDK version:
* Kernel Major = SDK Major + 4
* Kernel Minor = SDK Minor


=== Versions ===
=== Versions ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Firmware || Kernel Version || Minimum Allowed
! Firmware || Kernel Version || Corresponding SDK Version
|-
| 1.0.0 || 5.0 || 1.0.0.0
|-
| 2.0.0 || 6.1 || 2.1.0.0
|-
| 3.0.0 || 7.4 || 3.4.0.0
|-
|-
| 1.0.0 || 5.0.0 || 3.0.0
| 3.0.2 || 7.4 || 3.4.0.0
|-
|-
| 2.0.0 || 6.1.0 || 3.0.0
| 5.0.0 || 9.3 || 5.3.0.0
|-
|-
| 3.0.0 || 7.4.0 || 3.0.0
| 10.0.0 || 14.4 || 10.4.0.0
|-
|-
| 3.0.2 || 7.4.0 || 3.0.0
| 11.0.0 || 15.4 || 11.4.0.0
|-
|-
| 5.0.0 || 9.3.0 || 3.0.0
| 11.0.1 || 15.4 || 11.4.0.0
|}
|}


Line 779: Line 886:
|-
|-
| 18
| 18
| ForceDebug
| [19.0.0+] ForceDebugProd ([1.0.0-18.1.0] ForceDebug)
|-
| 19
| [19.0.0+] ForceDebug
|}
|}