<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://switchbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DCNick3</id>
	<title>Nintendo Switch Brew - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://switchbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DCNick3"/>
	<link rel="alternate" type="text/html" href="https://switchbrew.org/wiki/Special:Contributions/DCNick3"/>
	<updated>2026-05-14T18:21:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=Rtld&amp;diff=13760</id>
		<title>Rtld</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=Rtld&amp;diff=13760"/>
		<updated>2025-08-14T06:52:50Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: Fix link to MOD page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;rtld, short for “runtime link-editor”, is the first executable code belonging to the program that the system launches. This serves as the program entry point and crt0. rtld&#039;s entry point is defined to be the start of its .text section.&lt;br /&gt;
&lt;br /&gt;
rtld is tasked with relocating the [[NSO|NSOs]] that were loaded in to memory by the system loader, at a random base address. To do this, it requires that binaries include a [[MOD|module header]], and a pointer to it at offset +0x04 in the .text section.&lt;br /&gt;
&lt;br /&gt;
rtld receives two parameters from the system, in X0 and X1. The first parameter should be null. The second parameter is the handle of the main thread. See the [[Homebrew_ABI#Entrypoint_Arguments|entrypoint arguments]] section.&lt;br /&gt;
&lt;br /&gt;
rtld initially derives absolute pointers by using the BL instruction to skip over an offset value, and then accessing and adding X30.&lt;br /&gt;
&lt;br /&gt;
== Functionality ==&lt;br /&gt;
&lt;br /&gt;
An outline of rtld&#039;s functions is below.&lt;br /&gt;
&lt;br /&gt;
* Check the first parameter. Hangs if set.&lt;br /&gt;
* Clear rtld .bss.&lt;br /&gt;
&lt;br /&gt;
The main function for loading all of the modules now executes.&lt;br /&gt;
&lt;br /&gt;
* Iterate over the rtld .dynamic section to establish REL, RELA, RELENT, RELAENT, RELCOUNT and RELACOUNT.&lt;br /&gt;
* With the above information, process relative relocations (R_AARCH64_RELATIVE) on rtld.&lt;br /&gt;
* rtld initializes load lists and a module object for itself, which formalizes loading of the rtld .dynamic section.&lt;br /&gt;
* Prepare to iterate over all modules. rtld does this by scanning memory using [[SVC#svcQueryMemory|svcQueryMemory]]. The memory must be R-X and STATIC. If the address matches the rtld base address, the module is skipped here.&lt;br /&gt;
* Each valid memory region is read, and must contain &#039;MOD0&#039; magic at offset +0x04. If this check fails, rtld hangs.&lt;br /&gt;
* Read the .dynamic and .bss pointers from the module header. If the .bss pointers are unequal, rtld clears the .bss for this module.&lt;br /&gt;
* Initialize a module object for this module, using the same function that was used to initialize an object for rtld itself. This object is typically stored in the module&#039;s .bss, via another pointer in the module header.&lt;br /&gt;
* Process relative relocations for this module.&lt;br /&gt;
* Update list pointers for the rtld lists and the module object.&lt;br /&gt;
* Prepare for next iteration - the next memory query address is calculated by adding the size of the current memory region to the current address.&lt;br /&gt;
* Once all modules are loaded, rtld resolves symbols. The full list of supported relocation types is available below. This uses the .dynsym, .dynstr and .hash sections.&lt;br /&gt;
&lt;br /&gt;
Once the above function returns, rtld serves as a general initialization routine for the program.&lt;br /&gt;
&lt;br /&gt;
* Initializes the standard library “musl”.&lt;br /&gt;
* Initializes the SDK. The second parameter (thread handle) passed to rtld is passed to this function.&lt;br /&gt;
* Calls program-defined initialization routine.&lt;br /&gt;
* Calls each module&#039;s initialization function.&lt;br /&gt;
* Calls program main().&lt;br /&gt;
* Finalizes the SDK.&lt;br /&gt;
* Jumps to [[SVC#svcExitProcess|svcExitProcess]].&lt;br /&gt;
&lt;br /&gt;
== Relocation types ==&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 257   || R_AARCH64_ABS64&lt;br /&gt;
|-&lt;br /&gt;
| 258   || R_AARCH64_ABS32&lt;br /&gt;
|-&lt;br /&gt;
| 1025  || R_AARCH64_GLOB_DAT&lt;br /&gt;
|-&lt;br /&gt;
| 1026  || R_AARCH64_JUMP_SLOT&lt;br /&gt;
|-&lt;br /&gt;
| 1027  || R_AARCH64_RELATIVE &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11794</id>
		<title>HIPC</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11794"/>
		<updated>2022-07-15T09:26:49Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: /* Raw data section */ 0xA is also known as OutPointer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== IPC Command Structure ==&lt;br /&gt;
This is an array of u32&#039;s, usually located in [[Thread Local Storage]].&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-0 || [[#Type|Type]].&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 19-16 || Number of buf X (InPointer) descriptors (each: 2 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 23-20 || Number of buf A (InMapAlias) descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 27-24 || Number of buf B (OutMapAlias) descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-28 || Number of buf W (InOutMapAlias) desciptors (each: 3 words), not observed&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 9-0 || Size of [[#Raw data section|raw data]] in u32s.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 13-10 || Flags for buf C (OutPointer) descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 30-20 || Empty.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31 || Enable handle descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Handle descriptor|Handle descriptor]], if enabled.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor X &amp;quot;Pointer&amp;quot;|Buf X (InPointer) descriptors]], each one 2 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf A (InMapAlias) descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf B (OutMapAlias) descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf W (InOutMapAlias) descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Raw_data_section|Raw data section]] (including padding before and after aligned data section).&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor C &amp;quot;ReceiveList&amp;quot;|Buf C (OutPointer) descriptors]], each one 2 words.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
First two header u32&#039;s and handle descriptor (if enabled) are copied as-is from one process to the other.&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
IPC commands can have different types which influence how the IPC server processes requests in &amp;quot;nn::sf::hipc::server::HipcServerSessionManagerBase::ProcessRequest&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Invalid&lt;br /&gt;
|-&lt;br /&gt;
| 1 || [[#LegacyRequest, LegacyControl|LegacyRequest]]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[#Close|Close]]&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [[#LegacyRequest, LegacyControl|LegacyControl]]&lt;br /&gt;
|-&lt;br /&gt;
| 4 || [[#Request, Control|Request]]&lt;br /&gt;
|-&lt;br /&gt;
| 5 || [[#Request, Control|Control]]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || [5.0.0+] [[#RequestWithContext, ControlWithContext|RequestWithContext]]&lt;br /&gt;
|-&lt;br /&gt;
| 7 || [5.0.0+] [[#RequestWithContext, ControlWithContext|ControlWithContext]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Close ====&lt;br /&gt;
When processing a request of this type, the IPC server calls:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::DestroyServerSession&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::CloseServerSessionHandle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This ensures that the server session is destroyed internally and properly closed.&lt;br /&gt;
&lt;br /&gt;
==== LegacyRequest, LegacyControl ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::detail::HipcMessageBufferAccessor::ParseHeader&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::Reply&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It is speculated that these are part of an older message processing system where headers were further partitioned.&lt;br /&gt;
&lt;br /&gt;
==== Request, Control ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage2&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This represents a more modern message handling system where contents follow the general marshalling structure.&lt;br /&gt;
&lt;br /&gt;
==== RequestWithContext, ControlWithContext ====&lt;br /&gt;
These are identical to normal Request and Control types, but with the additional requirement of suppling a token in their [[#Data payload|data payload]].&lt;br /&gt;
&lt;br /&gt;
This token is used by &amp;quot;nn::sf::cmif::SetInlineContext&amp;quot; which has the sole purpose of saving it into the TLS in order for it to be distributed to any IPC commands that are made while processing the current command. It&#039;s unknown if this token serves any purpose or if it&#039;s just a debug-tool to figure out what IPC command caused a particular chain of commands.&lt;br /&gt;
&lt;br /&gt;
=== Handle descriptor ===&lt;br /&gt;
There can only be one of this descriptor type. It is enabled by bit31 of the second word.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Send current PID.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 4-1 || Number of handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-5 || Number of handles to move&lt;br /&gt;
|-&lt;br /&gt;
| ... || || 8-byte PID if enabled&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to move&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Sysmodules load the last u64 of rawdata when handling the PID. This is not written by kernel. For sysmodule handling:&lt;br /&gt;
* In some cases: these commands require a placeholder u64 value passed in the input parameters, as mentioned above. In these cases the OverwriteClientProcessId method is called to replace the value before it is used.&lt;br /&gt;
* In other cases: The rawdata_u64 is compared with the PID from the descriptor. On mismatch and when rawdata_u64!=0, error 0x60A is returned. The PID value passed to the cmdhandler vtable funcptr is the rawdata_u64.&lt;br /&gt;
&lt;br /&gt;
Handle 0 is allowed, and just means no handle was sent.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor X &amp;quot;Pointer&amp;quot; ===&lt;br /&gt;
This one is packed even worse than A, they inserted the bit38-36 of the address &#039;&#039;on top&#039;&#039; of the counter field.&lt;br /&gt;
&lt;br /&gt;
Officially, the counter is known as &amp;quot;receive index&amp;quot;. This one writes to the buffer described in the ReceiveList.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 5-0 || Bits 5-0 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-6 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 11-9 || Bits 11-9 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-12 || Bit 35-32 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Size&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot; ===&lt;br /&gt;
This packing is so unnecessarily complex.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of size.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1-0 || Flags. Always set to 0, 1 or 3.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-2 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 27-24 || Bit 35-32 of size.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 31-28 || Bit 35-32 of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A reply must not use A/B/W, svcReplyAndReceive will return 0xE801.&lt;br /&gt;
&lt;br /&gt;
[[SVC|MemoryAttribute]] IsBorrowed and IsUncached are never allowed for the source address.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Send&amp;quot; means buffer is sent from source process into service process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Receive&amp;quot; means that data is copied from service process into user process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Exchange&amp;quot; means both &amp;quot;Send&amp;quot; and &amp;quot;Receive&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
Determines what [[SVC|MemoryState]] to use with the mapped memory in the sysmodule.&lt;br /&gt;
&lt;br /&gt;
Used to enforce whether or not device mapping is allowed for src and dst buffers respectively.&lt;br /&gt;
 &lt;br /&gt;
* Ipc (flag=0): Device mapping *not* allowed for src or dst.&lt;br /&gt;
* NonSecureIpc (flag=1): Device mapping allowed for src and dst.&lt;br /&gt;
* NonDeviceIpc (flag=3): Device mapping allowed for src but not for dst.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor C &amp;quot;ReceiveList&amp;quot; ===&lt;br /&gt;
There&#039;s a 4-bit flag in the main header controlling the behavior of C descriptors.&lt;br /&gt;
&lt;br /&gt;
If it has value 0, the C descriptor functionality is disabled.&lt;br /&gt;
&lt;br /&gt;
If it has value 1, there is an &amp;quot;inlined&amp;quot; C buffer after the raw data. Received data is copied to ROUND_UP(cmdbuf+raw_size+index, 16)&lt;br /&gt;
&lt;br /&gt;
If it has value 2, there is a single C descriptor.&lt;br /&gt;
&lt;br /&gt;
Otherwise it has (flag-2) C descriptors. In this case, index picks which C descriptor to copy received data to [instead of picking the offset into the buffer].&lt;br /&gt;
&lt;br /&gt;
Data sent with this method must have MemoryState 0x4000000 mask set.&lt;br /&gt;
&lt;br /&gt;
After reply, X descriptors are written to the sender containing the address, size and index that were copied to.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 15-0 || Rest of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31-16 || Size&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== IPC buffers ===&lt;br /&gt;
Buffer descriptor A/B/... map memory into the sysmodule process. For the mapped memory in the sysmodule the permissions are: desc-A = R--, desc-B = RW-. The buffer is automatically unmapped while the kernel handles the cmdreply, the sysmodule doesn&#039;t need to specify anything in the cmdreply to trigger this.&lt;br /&gt;
&lt;br /&gt;
This memory is mapped in the sysmodule to the same vaddr from the original user-process cmd-request, except with with bits &amp;gt;=(~28(?)) changed to a different ASLR&#039;d region.&lt;br /&gt;
&lt;br /&gt;
No user-process-&amp;gt;sysmodule memcpy is done for outbufs, only sysmodule-&amp;gt;user-process.&lt;br /&gt;
&lt;br /&gt;
Buffer descriptors C/X are somewhat different. Rather than mapping new memory into the server process, C/X descriptors copy data between existing buffers in different processes. Each X descriptor in a message has its data copied into a C descriptor on the other side. Each C descriptor in a message is used to reserve space for the other side&#039;s X descriptors to copy into.&lt;br /&gt;
&lt;br /&gt;
When the kernel processes X descriptors, it must determine where to copy the data to. If the destination used C descriptors with flags &amp;gt;= 3, each X descriptor from the source is matched to a C descriptor in the destination by the X descriptor&#039;s index field. If the destination used a &amp;quot;single&amp;quot; C descriptor, the data from all the X descriptors is copied into the same buffer specified by the destination&#039;s C descriptor (causing error 0xce01 if there is not enough space) and the X descriptor index is ignored. The kernel then modifies the addresses in the X descriptors to indicate where the data was copied to in the destination.&lt;br /&gt;
&lt;br /&gt;
Before receiving a request, if the IPC server is expecting X descriptors, it prepares a message with a &amp;quot;single&amp;quot; C descriptor (flags=2) in its message buffer before calling svcReplyAndReceive so that X descriptors from the client have a place to copy their data to.  The usage of the flag-2 C descriptor allows the server to receive an arbitrary number of X descriptors, since they&#039;re all packed into the same buffer. If the server had used flag-3+ C descriptors, it would be limited in how many X descriptors it could receive since the X descriptors would have to be matched to distinct C descriptors. The buffer that the server&#039;s C descriptor points to is called the &#039;&#039;&#039;pointer buffer&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When the client sends X descriptors, data is copied into the server&#039;s pointer buffer. When the client sends C descriptors, no data is copied automatically. The server needs to use X descriptors to copy the data back to the client&#039;s C descriptors (using the index field to match X descriptors in the response back to the correct C descriptors).&lt;br /&gt;
&lt;br /&gt;
== Raw data section ==&lt;br /&gt;
[[File:Ipc msg buffer type a example.png|thumb|An example of an IPC message with a type 0xA (OutPointer) buffer in it. Red is headers/descriptors, yellow is padding, and blue is data/buffer lengths. Note that the size of the u16 array for type A lengths is padded to fill up a whole word.]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding to align to 16 bytes.&lt;br /&gt;
|-&lt;br /&gt;
| ... || If sent to an object domain, a [[#Domain_message|domain message]], otherwise a [[#Data payload|data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding&lt;br /&gt;
|-&lt;br /&gt;
| ... || Buffer type 0xA (OutPointer) lengths (u16 array)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The total amount of padding within the raw data section is always 0x10 bytes. This means that if no padding is required before the message, there will be 0x10 bytes of padding after the message (before the buffer type 0xA (OutPointer) - lengths).&lt;br /&gt;
&lt;br /&gt;
=== Domains ===&lt;br /&gt;
Because the switch has relatively low limits on the total number of sessions available to the system (Kernel slabheap limits, sysmodule handle table size limits), HIPC supports a &amp;quot;Domains&amp;quot; feature that allows multiplexing multiple service sessions through a single handle. Domains store (effectively) a mapping from u32 object id to a SharedPointer&amp;lt;IServiceObject&amp;gt; -- When messages are sent to a domain, an extra header is sent in the raw data section (before anything else) with information about what object in the domain is being acted on; responses similarly contain an additional header. Official session code implements this by just using the dispatch table for the object in the map with the appropriate ID, instead of the dispatch table the session was initialized with.&lt;br /&gt;
&lt;br /&gt;
Format for the extra request header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 7-0 || Command. 1=send message, 2=close virtual handle&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-15 || Input object count&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Length of [[IPC_Marshalling#Data_payload|data payload]] in bytes.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Object ID (from cmd 0 in [[IPC_Marshalling#Control|Control]]).&lt;br /&gt;
|-&lt;br /&gt;
| 2 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
| 3 || || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only)&lt;br /&gt;
|-&lt;br /&gt;
| 4... || || [[#Data payload|Data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Input object IDs (u32s, not aligned)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Format for the extra response header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-0 || Output object count&lt;br /&gt;
|-&lt;br /&gt;
| 1-3 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Data payload ===&lt;br /&gt;
This is an array of u32&#039;s, but individual parameters are generally stored as u64&#039;s.&lt;br /&gt;
&lt;br /&gt;
Input Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCI) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. 1 for NewRequest, 0 for Request.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Command id as u32&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only, non-domain messages).&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Input parameters&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[5.0.0+] Version was incremented from 0 to 1, and a token value was introduced into raw_data+12 (regardless of domain or not, in either case it overlaps with padding).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Output Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCO&amp;quot;) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. Always 0.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[Error_codes|Result]].&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-13.2.1] Padding [14.0.0+] Interface ID&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Return values&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[14.0.0+] Padding field at +12 is now interface ID, generated as little endian first four bytes of sha256(&amp;lt;fully qualified interface name&amp;gt;). The version field was not incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The rawdata struct for input parameters/return values is generated by stable-sorting function parameters by alignment, from low to high. It is likely this is a mistake, as it generates structs with suboptimal possible padding -- Nintendo probably meant to sort from high to low (which would give minimized padding), but couldn&#039;t/can&#039;t change this without breaking backwards compatibility.&lt;br /&gt;
&lt;br /&gt;
== Official marshalling code ==&lt;br /&gt;
The official marshalling function is called &amp;quot;nn::sf::hipc::client::Hipc2ClientCoreProcessorImpl::WriteBufferDataImpl&amp;quot; and takes:&lt;br /&gt;
* A pointer to a &amp;quot;nn::sf::hipc::detail::HipcMessageWriter&amp;quot; context;&lt;br /&gt;
* The number of (buf_ptr, size) pairs;&lt;br /&gt;
* An array of (buf_ptr, size) pairs (called &amp;quot;nn::sf::detail::PointerAndSize&amp;quot;);&lt;br /&gt;
* A pointer to a type bitfield for each such pair;&lt;br /&gt;
* The offset of the main IPC command structure;&lt;br /&gt;
* The size of the IPC command&#039;s [[IPC_Marshalling#Raw_data_section|raw data]].&lt;br /&gt;
&lt;br /&gt;
The type of an IPC command is described by a bitfield as below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Bits || Mask || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0x01 || In || Direction is input.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x02 || Out || Direction is output.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x04 || HipcMapAlias || Use buffer descriptors A (&amp;quot;Send&amp;quot;), B (&amp;quot;Receive&amp;quot;) or W (&amp;quot;Exchange&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x08 || HipcPointer || Use buffer descriptors X (&amp;quot;Pointer&amp;quot;) or C (&amp;quot;ReceiveList&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0x10 || FixedSize || Skip saving the pointer buffer size in raw data.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 0x20 || HipcAutoSelect || Select which buffer descriptor to use automatically.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 0x40 || HipcMapTransferAllowsNonSecure || Use [[#Flags|NonSecureIpc flag]].&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 0x80 || HipcMapTransferAllowsNonDevice || Use [[#Flags|NonDeviceIpc flag]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
X and C (Pointer and ReceiveList) descriptors are backed by the &amp;quot;pointer buffer&amp;quot;, a buffer in the service process. Its size is a u16, which is retrieved using the &amp;quot;QueryPointerBufferSize&amp;quot; control message. If the client code determines all buffers with flag HipcPointer do not fit in the pointer buffer, it returns error 0x11A0B.&lt;br /&gt;
&lt;br /&gt;
For buffers with flag HipcAutoSelect it creates two descriptors (A+X or B+C), but one descriptor is NULL (zero size and pointer), while the other holds the expected values. X/C descriptors are used as the non-NULL descriptor where possible, but if they don&#039;t fit in the pointer buffer, A/B descriptors are used instead. The code defers processing of HipcAutoSelect buffers with sizes that fit in a u16 (and may therefore fit in the pointer buffer), which ensures all HipcPointer buffers get pointer-buffer space before any HipcAutoSelect. The order in which the deferred HipcAutoSelect buffers are processed is determined by a convoluted loop.&lt;br /&gt;
&lt;br /&gt;
== Official IPC Cmd Structure ==&lt;br /&gt;
Official struct that is stored for each IPC command. It contains precalculated offsets for different portions of the command structure.&lt;br /&gt;
&lt;br /&gt;
All offsets are given is in number of u32 words.&lt;br /&gt;
&lt;br /&gt;
 struct IpcCmdStruct {&lt;br /&gt;
   u8  unk0;&lt;br /&gt;
   u8  has_handle_descriptor;&lt;br /&gt;
   u8  pad0[2];&lt;br /&gt;
   u32 cmd0;&lt;br /&gt;
   u32 cmd1;&lt;br /&gt;
   u32 offset_handle_descriptor;&lt;br /&gt;
   u32 pad1;&lt;br /&gt;
   u32 offset_handles;          &lt;br /&gt;
   u32 pad2;&lt;br /&gt;
   u32 offset_x_descriptors;&lt;br /&gt;
   u32 offset_a_descriptors;&lt;br /&gt;
   u32 offset_b_descriptors;&lt;br /&gt;
   u32 offset_w_descriptors; /* this is a guess */&lt;br /&gt;
   u32 offset_raw_data;&lt;br /&gt;
   u32 offset_c_descriptors;&lt;br /&gt;
   u32 unk2;&lt;br /&gt;
   u32 unk3;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Control ==&lt;br /&gt;
When type is [[IPC_Marshalling#Request.2C_Control|Control]], you are talking to the IPC manager. These are processed by the sysmodule.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Cmd || Name || Arguments || Output&lt;br /&gt;
|-&lt;br /&gt;
| 0 || ConvertCurrentObjectToDomain || None || u32 CmifDomainObjectId&lt;br /&gt;
|-&lt;br /&gt;
| 1 || CopyFromCurrentDomain || u32 CmifDomainObjectId || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CloneCurrentObject || None || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 3 || QueryPointerBufferSize || None || u16 size&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CloneCurrentObjectEx || u32 unknown || u32 NativeHandle&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11793</id>
		<title>HIPC</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11793"/>
		<updated>2022-07-15T04:00:49Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: /* IPC Command Structure */ Annotate X/A/B/W descriptors with alternative and more meaningful names ({In,Out}{Pointer,MapAlias})&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== IPC Command Structure ==&lt;br /&gt;
This is an array of u32&#039;s, usually located in [[Thread Local Storage]].&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-0 || [[#Type|Type]].&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 19-16 || Number of buf X (InPointer) descriptors (each: 2 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 23-20 || Number of buf A (InMapAlias) descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 27-24 || Number of buf B (OutMapAlias) descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-28 || Number of buf W (InOutMapAlias) desciptors (each: 3 words), not observed&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 9-0 || Size of [[#Raw data section|raw data]] in u32s.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 13-10 || Flags for buf C (OutPointer) descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 30-20 || Empty.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31 || Enable handle descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Handle descriptor|Handle descriptor]], if enabled.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor X &amp;quot;Pointer&amp;quot;|Buf X (InPointer) descriptors]], each one 2 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf A (InMapAlias) descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf B (OutMapAlias) descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf W (InOutMapAlias) descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Raw_data_section|Raw data section]] (including padding before and after aligned data section).&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor C &amp;quot;ReceiveList&amp;quot;|Buf C (OutPointer) descriptors]], each one 2 words.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
First two header u32&#039;s and handle descriptor (if enabled) are copied as-is from one process to the other.&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
IPC commands can have different types which influence how the IPC server processes requests in &amp;quot;nn::sf::hipc::server::HipcServerSessionManagerBase::ProcessRequest&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Invalid&lt;br /&gt;
|-&lt;br /&gt;
| 1 || [[#LegacyRequest, LegacyControl|LegacyRequest]]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[#Close|Close]]&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [[#LegacyRequest, LegacyControl|LegacyControl]]&lt;br /&gt;
|-&lt;br /&gt;
| 4 || [[#Request, Control|Request]]&lt;br /&gt;
|-&lt;br /&gt;
| 5 || [[#Request, Control|Control]]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || [5.0.0+] [[#RequestWithContext, ControlWithContext|RequestWithContext]]&lt;br /&gt;
|-&lt;br /&gt;
| 7 || [5.0.0+] [[#RequestWithContext, ControlWithContext|ControlWithContext]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Close ====&lt;br /&gt;
When processing a request of this type, the IPC server calls:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::DestroyServerSession&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::CloseServerSessionHandle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This ensures that the server session is destroyed internally and properly closed.&lt;br /&gt;
&lt;br /&gt;
==== LegacyRequest, LegacyControl ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::detail::HipcMessageBufferAccessor::ParseHeader&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::Reply&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It is speculated that these are part of an older message processing system where headers were further partitioned.&lt;br /&gt;
&lt;br /&gt;
==== Request, Control ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage2&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This represents a more modern message handling system where contents follow the general marshalling structure.&lt;br /&gt;
&lt;br /&gt;
==== RequestWithContext, ControlWithContext ====&lt;br /&gt;
These are identical to normal Request and Control types, but with the additional requirement of suppling a token in their [[#Data payload|data payload]].&lt;br /&gt;
&lt;br /&gt;
This token is used by &amp;quot;nn::sf::cmif::SetInlineContext&amp;quot; which has the sole purpose of saving it into the TLS in order for it to be distributed to any IPC commands that are made while processing the current command. It&#039;s unknown if this token serves any purpose or if it&#039;s just a debug-tool to figure out what IPC command caused a particular chain of commands.&lt;br /&gt;
&lt;br /&gt;
=== Handle descriptor ===&lt;br /&gt;
There can only be one of this descriptor type. It is enabled by bit31 of the second word.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Send current PID.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 4-1 || Number of handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-5 || Number of handles to move&lt;br /&gt;
|-&lt;br /&gt;
| ... || || 8-byte PID if enabled&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to move&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Sysmodules load the last u64 of rawdata when handling the PID. This is not written by kernel. For sysmodule handling:&lt;br /&gt;
* In some cases: these commands require a placeholder u64 value passed in the input parameters, as mentioned above. In these cases the OverwriteClientProcessId method is called to replace the value before it is used.&lt;br /&gt;
* In other cases: The rawdata_u64 is compared with the PID from the descriptor. On mismatch and when rawdata_u64!=0, error 0x60A is returned. The PID value passed to the cmdhandler vtable funcptr is the rawdata_u64.&lt;br /&gt;
&lt;br /&gt;
Handle 0 is allowed, and just means no handle was sent.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor X &amp;quot;Pointer&amp;quot; ===&lt;br /&gt;
This one is packed even worse than A, they inserted the bit38-36 of the address &#039;&#039;on top&#039;&#039; of the counter field.&lt;br /&gt;
&lt;br /&gt;
Officially, the counter is known as &amp;quot;receive index&amp;quot;. This one writes to the buffer described in the ReceiveList.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 5-0 || Bits 5-0 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-6 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 11-9 || Bits 11-9 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-12 || Bit 35-32 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Size&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot; ===&lt;br /&gt;
This packing is so unnecessarily complex.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of size.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1-0 || Flags. Always set to 0, 1 or 3.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-2 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 27-24 || Bit 35-32 of size.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 31-28 || Bit 35-32 of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A reply must not use A/B/W, svcReplyAndReceive will return 0xE801.&lt;br /&gt;
&lt;br /&gt;
[[SVC|MemoryAttribute]] IsBorrowed and IsUncached are never allowed for the source address.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Send&amp;quot; means buffer is sent from source process into service process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Receive&amp;quot; means that data is copied from service process into user process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Exchange&amp;quot; means both &amp;quot;Send&amp;quot; and &amp;quot;Receive&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
Determines what [[SVC|MemoryState]] to use with the mapped memory in the sysmodule.&lt;br /&gt;
&lt;br /&gt;
Used to enforce whether or not device mapping is allowed for src and dst buffers respectively.&lt;br /&gt;
 &lt;br /&gt;
* Ipc (flag=0): Device mapping *not* allowed for src or dst.&lt;br /&gt;
* NonSecureIpc (flag=1): Device mapping allowed for src and dst.&lt;br /&gt;
* NonDeviceIpc (flag=3): Device mapping allowed for src but not for dst.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor C &amp;quot;ReceiveList&amp;quot; ===&lt;br /&gt;
There&#039;s a 4-bit flag in the main header controlling the behavior of C descriptors.&lt;br /&gt;
&lt;br /&gt;
If it has value 0, the C descriptor functionality is disabled.&lt;br /&gt;
&lt;br /&gt;
If it has value 1, there is an &amp;quot;inlined&amp;quot; C buffer after the raw data. Received data is copied to ROUND_UP(cmdbuf+raw_size+index, 16)&lt;br /&gt;
&lt;br /&gt;
If it has value 2, there is a single C descriptor.&lt;br /&gt;
&lt;br /&gt;
Otherwise it has (flag-2) C descriptors. In this case, index picks which C descriptor to copy received data to [instead of picking the offset into the buffer].&lt;br /&gt;
&lt;br /&gt;
Data sent with this method must have MemoryState 0x4000000 mask set.&lt;br /&gt;
&lt;br /&gt;
After reply, X descriptors are written to the sender containing the address, size and index that were copied to.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 15-0 || Rest of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31-16 || Size&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== IPC buffers ===&lt;br /&gt;
Buffer descriptor A/B/... map memory into the sysmodule process. For the mapped memory in the sysmodule the permissions are: desc-A = R--, desc-B = RW-. The buffer is automatically unmapped while the kernel handles the cmdreply, the sysmodule doesn&#039;t need to specify anything in the cmdreply to trigger this.&lt;br /&gt;
&lt;br /&gt;
This memory is mapped in the sysmodule to the same vaddr from the original user-process cmd-request, except with with bits &amp;gt;=(~28(?)) changed to a different ASLR&#039;d region.&lt;br /&gt;
&lt;br /&gt;
No user-process-&amp;gt;sysmodule memcpy is done for outbufs, only sysmodule-&amp;gt;user-process.&lt;br /&gt;
&lt;br /&gt;
Buffer descriptors C/X are somewhat different. Rather than mapping new memory into the server process, C/X descriptors copy data between existing buffers in different processes. Each X descriptor in a message has its data copied into a C descriptor on the other side. Each C descriptor in a message is used to reserve space for the other side&#039;s X descriptors to copy into.&lt;br /&gt;
&lt;br /&gt;
When the kernel processes X descriptors, it must determine where to copy the data to. If the destination used C descriptors with flags &amp;gt;= 3, each X descriptor from the source is matched to a C descriptor in the destination by the X descriptor&#039;s index field. If the destination used a &amp;quot;single&amp;quot; C descriptor, the data from all the X descriptors is copied into the same buffer specified by the destination&#039;s C descriptor (causing error 0xce01 if there is not enough space) and the X descriptor index is ignored. The kernel then modifies the addresses in the X descriptors to indicate where the data was copied to in the destination.&lt;br /&gt;
&lt;br /&gt;
Before receiving a request, if the IPC server is expecting X descriptors, it prepares a message with a &amp;quot;single&amp;quot; C descriptor (flags=2) in its message buffer before calling svcReplyAndReceive so that X descriptors from the client have a place to copy their data to.  The usage of the flag-2 C descriptor allows the server to receive an arbitrary number of X descriptors, since they&#039;re all packed into the same buffer. If the server had used flag-3+ C descriptors, it would be limited in how many X descriptors it could receive since the X descriptors would have to be matched to distinct C descriptors. The buffer that the server&#039;s C descriptor points to is called the &#039;&#039;&#039;pointer buffer&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When the client sends X descriptors, data is copied into the server&#039;s pointer buffer. When the client sends C descriptors, no data is copied automatically. The server needs to use X descriptors to copy the data back to the client&#039;s C descriptors (using the index field to match X descriptors in the response back to the correct C descriptors).&lt;br /&gt;
&lt;br /&gt;
== Raw data section ==&lt;br /&gt;
[[File:Ipc msg buffer type a example.png|thumb|An example of an IPC message with a type 0xA buffer in it. Red is headers/descriptors, yellow is padding, and blue is data/buffer lengths. Note that the size of the u16 array for type A lengths is padded to fill up a whole word.]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding to align to 16 bytes.&lt;br /&gt;
|-&lt;br /&gt;
| ... || If sent to an object domain, a [[#Domain_message|domain message]], otherwise a [[#Data payload|data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding&lt;br /&gt;
|-&lt;br /&gt;
| ... || Buffer type 0xA lengths (u16 array)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The total amount of padding within the raw data section is always 0x10 bytes. This means that if no padding is required before the message, there will be 0x10 bytes of padding after the message (before the buffer type 0xA lengths).&lt;br /&gt;
&lt;br /&gt;
=== Domains ===&lt;br /&gt;
Because the switch has relatively low limits on the total number of sessions available to the system (Kernel slabheap limits, sysmodule handle table size limits), HIPC supports a &amp;quot;Domains&amp;quot; feature that allows multiplexing multiple service sessions through a single handle. Domains store (effectively) a mapping from u32 object id to a SharedPointer&amp;lt;IServiceObject&amp;gt; -- When messages are sent to a domain, an extra header is sent in the raw data section (before anything else) with information about what object in the domain is being acted on; responses similarly contain an additional header. Official session code implements this by just using the dispatch table for the object in the map with the appropriate ID, instead of the dispatch table the session was initialized with.&lt;br /&gt;
&lt;br /&gt;
Format for the extra request header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 7-0 || Command. 1=send message, 2=close virtual handle&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-15 || Input object count&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Length of [[IPC_Marshalling#Data_payload|data payload]] in bytes.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Object ID (from cmd 0 in [[IPC_Marshalling#Control|Control]]).&lt;br /&gt;
|-&lt;br /&gt;
| 2 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
| 3 || || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only)&lt;br /&gt;
|-&lt;br /&gt;
| 4... || || [[#Data payload|Data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Input object IDs (u32s, not aligned)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Format for the extra response header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-0 || Output object count&lt;br /&gt;
|-&lt;br /&gt;
| 1-3 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Data payload ===&lt;br /&gt;
This is an array of u32&#039;s, but individual parameters are generally stored as u64&#039;s.&lt;br /&gt;
&lt;br /&gt;
Input Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCI) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. 1 for NewRequest, 0 for Request.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Command id as u32&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only, non-domain messages).&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Input parameters&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[5.0.0+] Version was incremented from 0 to 1, and a token value was introduced into raw_data+12 (regardless of domain or not, in either case it overlaps with padding).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Output Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCO&amp;quot;) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. Always 0.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[Error_codes|Result]].&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-13.2.1] Padding [14.0.0+] Interface ID&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Return values&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[14.0.0+] Padding field at +12 is now interface ID, generated as little endian first four bytes of sha256(&amp;lt;fully qualified interface name&amp;gt;). The version field was not incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The rawdata struct for input parameters/return values is generated by stable-sorting function parameters by alignment, from low to high. It is likely this is a mistake, as it generates structs with suboptimal possible padding -- Nintendo probably meant to sort from high to low (which would give minimized padding), but couldn&#039;t/can&#039;t change this without breaking backwards compatibility.&lt;br /&gt;
&lt;br /&gt;
== Official marshalling code ==&lt;br /&gt;
The official marshalling function is called &amp;quot;nn::sf::hipc::client::Hipc2ClientCoreProcessorImpl::WriteBufferDataImpl&amp;quot; and takes:&lt;br /&gt;
* A pointer to a &amp;quot;nn::sf::hipc::detail::HipcMessageWriter&amp;quot; context;&lt;br /&gt;
* The number of (buf_ptr, size) pairs;&lt;br /&gt;
* An array of (buf_ptr, size) pairs (called &amp;quot;nn::sf::detail::PointerAndSize&amp;quot;);&lt;br /&gt;
* A pointer to a type bitfield for each such pair;&lt;br /&gt;
* The offset of the main IPC command structure;&lt;br /&gt;
* The size of the IPC command&#039;s [[IPC_Marshalling#Raw_data_section|raw data]].&lt;br /&gt;
&lt;br /&gt;
The type of an IPC command is described by a bitfield as below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Bits || Mask || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0x01 || In || Direction is input.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x02 || Out || Direction is output.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x04 || HipcMapAlias || Use buffer descriptors A (&amp;quot;Send&amp;quot;), B (&amp;quot;Receive&amp;quot;) or W (&amp;quot;Exchange&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x08 || HipcPointer || Use buffer descriptors X (&amp;quot;Pointer&amp;quot;) or C (&amp;quot;ReceiveList&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0x10 || FixedSize || Skip saving the pointer buffer size in raw data.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 0x20 || HipcAutoSelect || Select which buffer descriptor to use automatically.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 0x40 || HipcMapTransferAllowsNonSecure || Use [[#Flags|NonSecureIpc flag]].&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 0x80 || HipcMapTransferAllowsNonDevice || Use [[#Flags|NonDeviceIpc flag]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
X and C (Pointer and ReceiveList) descriptors are backed by the &amp;quot;pointer buffer&amp;quot;, a buffer in the service process. Its size is a u16, which is retrieved using the &amp;quot;QueryPointerBufferSize&amp;quot; control message. If the client code determines all buffers with flag HipcPointer do not fit in the pointer buffer, it returns error 0x11A0B.&lt;br /&gt;
&lt;br /&gt;
For buffers with flag HipcAutoSelect it creates two descriptors (A+X or B+C), but one descriptor is NULL (zero size and pointer), while the other holds the expected values. X/C descriptors are used as the non-NULL descriptor where possible, but if they don&#039;t fit in the pointer buffer, A/B descriptors are used instead. The code defers processing of HipcAutoSelect buffers with sizes that fit in a u16 (and may therefore fit in the pointer buffer), which ensures all HipcPointer buffers get pointer-buffer space before any HipcAutoSelect. The order in which the deferred HipcAutoSelect buffers are processed is determined by a convoluted loop.&lt;br /&gt;
&lt;br /&gt;
== Official IPC Cmd Structure ==&lt;br /&gt;
Official struct that is stored for each IPC command. It contains precalculated offsets for different portions of the command structure.&lt;br /&gt;
&lt;br /&gt;
All offsets are given is in number of u32 words.&lt;br /&gt;
&lt;br /&gt;
 struct IpcCmdStruct {&lt;br /&gt;
   u8  unk0;&lt;br /&gt;
   u8  has_handle_descriptor;&lt;br /&gt;
   u8  pad0[2];&lt;br /&gt;
   u32 cmd0;&lt;br /&gt;
   u32 cmd1;&lt;br /&gt;
   u32 offset_handle_descriptor;&lt;br /&gt;
   u32 pad1;&lt;br /&gt;
   u32 offset_handles;          &lt;br /&gt;
   u32 pad2;&lt;br /&gt;
   u32 offset_x_descriptors;&lt;br /&gt;
   u32 offset_a_descriptors;&lt;br /&gt;
   u32 offset_b_descriptors;&lt;br /&gt;
   u32 offset_w_descriptors; /* this is a guess */&lt;br /&gt;
   u32 offset_raw_data;&lt;br /&gt;
   u32 offset_c_descriptors;&lt;br /&gt;
   u32 unk2;&lt;br /&gt;
   u32 unk3;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Control ==&lt;br /&gt;
When type is [[IPC_Marshalling#Request.2C_Control|Control]], you are talking to the IPC manager. These are processed by the sysmodule.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Cmd || Name || Arguments || Output&lt;br /&gt;
|-&lt;br /&gt;
| 0 || ConvertCurrentObjectToDomain || None || u32 CmifDomainObjectId&lt;br /&gt;
|-&lt;br /&gt;
| 1 || CopyFromCurrentDomain || u32 CmifDomainObjectId || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CloneCurrentObject || None || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 3 || QueryPointerBufferSize || None || u16 size&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CloneCurrentObjectEx || u32 unknown || u32 NativeHandle&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11785</id>
		<title>HIPC</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11785"/>
		<updated>2022-07-07T10:48:31Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: /* Official marshalling code */ Add mask values&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== IPC Command Structure ==&lt;br /&gt;
This is an array of u32&#039;s, usually located in [[Thread Local Storage]].&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-0 || [[#Type|Type]].&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 19-16 || Number of buf X descriptors (each: 2 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 23-20 || Number of buf A descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 27-24 || Number of buf B descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-28 || Number of buf W desciptors (each: 3 words), not observed&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 9-0 || Size of [[#Raw data section|raw data]] in u32s.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 13-10 || Flags for buf C descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 30-20 || Empty.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31 || Enable handle descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Handle descriptor|Handle descriptor]], if enabled.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor X &amp;quot;Pointer&amp;quot;|Buf X descriptors]], each one 2 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf A descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf B descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf W descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Raw_data_section|Raw data section]] (including padding before and after aligned data section).&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor C &amp;quot;ReceiveList&amp;quot;|Buf C descriptors]], each one 2 words.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
First two header u32&#039;s and handle descriptor (if enabled) are copied as-is from one process to the other.&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
IPC commands can have different types which influence how the IPC server processes requests in &amp;quot;nn::sf::hipc::server::HipcServerSessionManagerBase::ProcessRequest&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Invalid&lt;br /&gt;
|-&lt;br /&gt;
| 1 || [[#LegacyRequest, LegacyControl|LegacyRequest]]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[#Close|Close]]&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [[#LegacyRequest, LegacyControl|LegacyControl]]&lt;br /&gt;
|-&lt;br /&gt;
| 4 || [[#Request, Control|Request]]&lt;br /&gt;
|-&lt;br /&gt;
| 5 || [[#Request, Control|Control]]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || [5.0.0+] [[#RequestWithContext, ControlWithContext|RequestWithContext]]&lt;br /&gt;
|-&lt;br /&gt;
| 7 || [5.0.0+] [[#RequestWithContext, ControlWithContext|ControlWithContext]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Close ====&lt;br /&gt;
When processing a request of this type, the IPC server calls:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::DestroyServerSession&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::CloseServerSessionHandle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This ensures that the server session is destroyed internally and properly closed.&lt;br /&gt;
&lt;br /&gt;
==== LegacyRequest, LegacyControl ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::detail::HipcMessageBufferAccessor::ParseHeader&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::Reply&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It is speculated that these are part of an older message processing system where headers were further partitioned.&lt;br /&gt;
&lt;br /&gt;
==== Request, Control ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage2&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This represents a more modern message handling system where contents follow the general marshalling structure.&lt;br /&gt;
&lt;br /&gt;
==== RequestWithContext, ControlWithContext ====&lt;br /&gt;
These are identical to normal Request and Control types, but with the additional requirement of suppling a token in their [[#Data payload|data payload]].&lt;br /&gt;
&lt;br /&gt;
This token is used by &amp;quot;nn::sf::cmif::SetInlineContext&amp;quot; which has the sole purpose of saving it into the TLS in order for it to be distributed to any IPC commands that are made while processing the current command. It&#039;s unknown if this token serves any purpose or if it&#039;s just a debug-tool to figure out what IPC command caused a particular chain of commands.&lt;br /&gt;
&lt;br /&gt;
=== Handle descriptor ===&lt;br /&gt;
There can only be one of this descriptor type. It is enabled by bit31 of the second word.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Send current PID.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 4-1 || Number of handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-5 || Number of handles to move&lt;br /&gt;
|-&lt;br /&gt;
| ... || || 8-byte PID if enabled&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to move&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Sysmodules load the last u64 of rawdata when handling the PID. This is not written by kernel. For sysmodule handling:&lt;br /&gt;
* In some cases: these commands require a placeholder u64 value passed in the input parameters, as mentioned above. In these cases the OverwriteClientProcessId method is called to replace the value before it is used.&lt;br /&gt;
* In other cases: The rawdata_u64 is compared with the PID from the descriptor. On mismatch and when rawdata_u64!=0, error 0x60A is returned. The PID value passed to the cmdhandler vtable funcptr is the rawdata_u64.&lt;br /&gt;
&lt;br /&gt;
Handle 0 is allowed, and just means no handle was sent.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor X &amp;quot;Pointer&amp;quot; ===&lt;br /&gt;
This one is packed even worse than A, they inserted the bit38-36 of the address &#039;&#039;on top&#039;&#039; of the counter field.&lt;br /&gt;
&lt;br /&gt;
Officially, the counter is known as &amp;quot;receive index&amp;quot;. This one writes to the buffer described in the ReceiveList.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 5-0 || Bits 5-0 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-6 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 11-9 || Bits 11-9 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-12 || Bit 35-32 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Size&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot; ===&lt;br /&gt;
This packing is so unnecessarily complex.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of size.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1-0 || Flags. Always set to 0, 1 or 3.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-2 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 27-24 || Bit 35-32 of size.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 31-28 || Bit 35-32 of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A reply must not use A/B/W, svcReplyAndReceive will return 0xE801.&lt;br /&gt;
&lt;br /&gt;
[[SVC|MemoryAttribute]] IsBorrowed and IsUncached are never allowed for the source address.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Send&amp;quot; means buffer is sent from source process into service process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Receive&amp;quot; means that data is copied from service process into user process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Exchange&amp;quot; means both &amp;quot;Send&amp;quot; and &amp;quot;Receive&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
Determines what [[SVC|MemoryState]] to use with the mapped memory in the sysmodule.&lt;br /&gt;
&lt;br /&gt;
Used to enforce whether or not device mapping is allowed for src and dst buffers respectively.&lt;br /&gt;
 &lt;br /&gt;
* Ipc (flag=0): Device mapping *not* allowed for src or dst.&lt;br /&gt;
* NonSecureIpc (flag=1): Device mapping allowed for src and dst.&lt;br /&gt;
* NonDeviceIpc (flag=3): Device mapping allowed for src but not for dst.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor C &amp;quot;ReceiveList&amp;quot; ===&lt;br /&gt;
There&#039;s a 4-bit flag in the main header controlling the behavior of C descriptors.&lt;br /&gt;
&lt;br /&gt;
If it has value 0, the C descriptor functionality is disabled.&lt;br /&gt;
&lt;br /&gt;
If it has value 1, there is an &amp;quot;inlined&amp;quot; C buffer after the raw data. Received data is copied to ROUND_UP(cmdbuf+raw_size+index, 16)&lt;br /&gt;
&lt;br /&gt;
If it has value 2, there is a single C descriptor.&lt;br /&gt;
&lt;br /&gt;
Otherwise it has (flag-2) C descriptors. In this case, index picks which C descriptor to copy received data to [instead of picking the offset into the buffer].&lt;br /&gt;
&lt;br /&gt;
Data sent with this method must have MemoryState 0x4000000 mask set.&lt;br /&gt;
&lt;br /&gt;
After reply, X descriptors are written to the sender containing the address, size and index that were copied to.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 15-0 || Rest of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31-16 || Size&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== IPC buffers ===&lt;br /&gt;
Buffer descriptor A/B/... map memory into the sysmodule process. For the mapped memory in the sysmodule the permissions are: desc-A = R--, desc-B = RW-. The buffer is automatically unmapped while the kernel handles the cmdreply, the sysmodule doesn&#039;t need to specify anything in the cmdreply to trigger this.&lt;br /&gt;
&lt;br /&gt;
This memory is mapped in the sysmodule to the same vaddr from the original user-process cmd-request, except with with bits &amp;gt;=(~28(?)) changed to a different ASLR&#039;d region.&lt;br /&gt;
&lt;br /&gt;
No user-process-&amp;gt;sysmodule memcpy is done for outbufs, only sysmodule-&amp;gt;user-process.&lt;br /&gt;
&lt;br /&gt;
Buffer descriptors C/X are somewhat different. Rather than mapping new memory into the server process, C/X descriptors copy data between existing buffers in different processes. Each X descriptor in a message has its data copied into a C descriptor on the other side. Each C descriptor in a message is used to reserve space for the other side&#039;s X descriptors to copy into.&lt;br /&gt;
&lt;br /&gt;
When the kernel processes X descriptors, it must determine where to copy the data to. If the destination used C descriptors with flags &amp;gt;= 3, each X descriptor from the source is matched to a C descriptor in the destination by the X descriptor&#039;s index field. If the destination used a &amp;quot;single&amp;quot; C descriptor, the data from all the X descriptors is copied into the same buffer specified by the destination&#039;s C descriptor (causing error 0xce01 if there is not enough space) and the X descriptor index is ignored. The kernel then modifies the addresses in the X descriptors to indicate where the data was copied to in the destination.&lt;br /&gt;
&lt;br /&gt;
Before receiving a request, if the IPC server is expecting X descriptors, it prepares a message with a &amp;quot;single&amp;quot; C descriptor (flags=2) in its message buffer before calling svcReplyAndReceive so that X descriptors from the client have a place to copy their data to.  The usage of the flag-2 C descriptor allows the server to receive an arbitrary number of X descriptors, since they&#039;re all packed into the same buffer. If the server had used flag-3+ C descriptors, it would be limited in how many X descriptors it could receive since the X descriptors would have to be matched to distinct C descriptors. The buffer that the server&#039;s C descriptor points to is called the &#039;&#039;&#039;pointer buffer&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When the client sends X descriptors, data is copied into the server&#039;s pointer buffer. When the client sends C descriptors, no data is copied automatically. The server needs to use X descriptors to copy the data back to the client&#039;s C descriptors (using the index field to match X descriptors in the response back to the correct C descriptors).&lt;br /&gt;
&lt;br /&gt;
== Raw data section ==&lt;br /&gt;
[[File:Ipc msg buffer type a example.png|thumb|An example of an IPC message with a type 0xA buffer in it. Red is headers/descriptors, yellow is padding, and blue is data/buffer lengths. Note that the size of the u16 array for type A lengths is padded to fill up a whole word.]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding to align to 16 bytes.&lt;br /&gt;
|-&lt;br /&gt;
| ... || If sent to an object domain, a [[#Domain_message|domain message]], otherwise a [[#Data payload|data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding&lt;br /&gt;
|-&lt;br /&gt;
| ... || Buffer type 0xA lengths (u16 array)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The total amount of padding within the raw data section is always 0x10 bytes. This means that if no padding is required before the message, there will be 0x10 bytes of padding after the message (before the buffer type 0xA lengths).&lt;br /&gt;
&lt;br /&gt;
=== Domains ===&lt;br /&gt;
Because the switch has relatively low limits on the total number of sessions available to the system (Kernel slabheap limits, sysmodule handle table size limits), HIPC supports a &amp;quot;Domains&amp;quot; feature that allows multiplexing multiple service sessions through a single handle. Domains store (effectively) a mapping from u32 object id to a SharedPointer&amp;lt;IServiceObject&amp;gt; -- When messages are sent to a domain, an extra header is sent in the raw data section (before anything else) with information about what object in the domain is being acted on; responses similarly contain an additional header. Official session code implements this by just using the dispatch table for the object in the map with the appropriate ID, instead of the dispatch table the session was initialized with.&lt;br /&gt;
&lt;br /&gt;
Format for the extra request header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 7-0 || Command. 1=send message, 2=close virtual handle&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-15 || Input object count&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Length of [[IPC_Marshalling#Data_payload|data payload]] in bytes.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Object ID (from cmd 0 in [[IPC_Marshalling#Control|Control]]).&lt;br /&gt;
|-&lt;br /&gt;
| 2 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
| 3 || || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only)&lt;br /&gt;
|-&lt;br /&gt;
| 4... || || [[#Data payload|Data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Input object IDs (u32s, not aligned)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Format for the extra response header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-0 || Output object count&lt;br /&gt;
|-&lt;br /&gt;
| 1-3 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Data payload ===&lt;br /&gt;
This is an array of u32&#039;s, but individual parameters are generally stored as u64&#039;s.&lt;br /&gt;
&lt;br /&gt;
Input Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCI) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. 1 for NewRequest, 0 for Request.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Command id as u32&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only, non-domain messages).&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Input parameters&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[5.0.0+] Version was incremented from 0 to 1, and a token value was introduced into raw_data+12 (regardless of domain or not, in either case it overlaps with padding).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Output Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCO&amp;quot;) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. Always 0.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[Error_codes|Result]].&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-13.2.1] Padding [14.0.0+] Interface ID&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Return values&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[14.0.0+] Padding field at +12 is now interface ID, generated as little endian first four bytes of sha256(&amp;lt;fully qualified interface name&amp;gt;). The version field was not incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The rawdata struct for input parameters/return values is generated by stable-sorting function parameters by alignment, from low to high. It is likely this is a mistake, as it generates structs with suboptimal possible padding -- Nintendo probably meant to sort from high to low (which would give minimized padding), but couldn&#039;t/can&#039;t change this without breaking backwards compatibility.&lt;br /&gt;
&lt;br /&gt;
== Official marshalling code ==&lt;br /&gt;
The official marshalling function is called &amp;quot;nn::sf::hipc::client::Hipc2ClientCoreProcessorImpl::WriteBufferDataImpl&amp;quot; and takes:&lt;br /&gt;
* A pointer to a &amp;quot;nn::sf::hipc::detail::HipcMessageWriter&amp;quot; context;&lt;br /&gt;
* The number of (buf_ptr, size) pairs;&lt;br /&gt;
* An array of (buf_ptr, size) pairs (called &amp;quot;nn::sf::detail::PointerAndSize&amp;quot;);&lt;br /&gt;
* A pointer to a type bitfield for each such pair;&lt;br /&gt;
* The offset of the main IPC command structure;&lt;br /&gt;
* The size of the IPC command&#039;s [[IPC_Marshalling#Raw_data_section|raw data]].&lt;br /&gt;
&lt;br /&gt;
The type of an IPC command is described by a bitfield as below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Bits || Mask || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0x01 || In || Direction is input.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 0x02 || Out || Direction is output.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 0x04 || HipcMapAlias || Use buffer descriptors A (&amp;quot;Send&amp;quot;), B (&amp;quot;Receive&amp;quot;) or W (&amp;quot;Exchange&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 0x08 || HipcPointer || Use buffer descriptors X (&amp;quot;Pointer&amp;quot;) or C (&amp;quot;ReceiveList&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 0x10 || FixedSize || Skip saving the pointer buffer size in raw data.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 0x20 || HipcAutoSelect || Select which buffer descriptor to use automatically.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 0x40 || HipcMapTransferAllowsNonSecure || Use [[#Flags|NonSecureIpc flag]].&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 0x80 || HipcMapTransferAllowsNonDevice || Use [[#Flags|NonDeviceIpc flag]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
X and C (Pointer and ReceiveList) descriptors are backed by the &amp;quot;pointer buffer&amp;quot;, a buffer in the service process. Its size is a u16, which is retrieved using the &amp;quot;QueryPointerBufferSize&amp;quot; control message. If the client code determines all buffers with flag HipcPointer do not fit in the pointer buffer, it returns error 0x11A0B.&lt;br /&gt;
&lt;br /&gt;
For buffers with flag HipcAutoSelect it creates two descriptors (A+X or B+C), but one descriptor is NULL (zero size and pointer), while the other holds the expected values. X/C descriptors are used as the non-NULL descriptor where possible, but if they don&#039;t fit in the pointer buffer, A/B descriptors are used instead. The code defers processing of HipcAutoSelect buffers with sizes that fit in a u16 (and may therefore fit in the pointer buffer), which ensures all HipcPointer buffers get pointer-buffer space before any HipcAutoSelect. The order in which the deferred HipcAutoSelect buffers are processed is determined by a convoluted loop.&lt;br /&gt;
&lt;br /&gt;
== Official IPC Cmd Structure ==&lt;br /&gt;
Official struct that is stored for each IPC command. It contains precalculated offsets for different portions of the command structure.&lt;br /&gt;
&lt;br /&gt;
All offsets are given is in number of u32 words.&lt;br /&gt;
&lt;br /&gt;
 struct IpcCmdStruct {&lt;br /&gt;
   u8  unk0;&lt;br /&gt;
   u8  has_handle_descriptor;&lt;br /&gt;
   u8  pad0[2];&lt;br /&gt;
   u32 cmd0;&lt;br /&gt;
   u32 cmd1;&lt;br /&gt;
   u32 offset_handle_descriptor;&lt;br /&gt;
   u32 pad1;&lt;br /&gt;
   u32 offset_handles;          &lt;br /&gt;
   u32 pad2;&lt;br /&gt;
   u32 offset_x_descriptors;&lt;br /&gt;
   u32 offset_a_descriptors;&lt;br /&gt;
   u32 offset_b_descriptors;&lt;br /&gt;
   u32 offset_w_descriptors; /* this is a guess */&lt;br /&gt;
   u32 offset_raw_data;&lt;br /&gt;
   u32 offset_c_descriptors;&lt;br /&gt;
   u32 unk2;&lt;br /&gt;
   u32 unk3;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Control ==&lt;br /&gt;
When type is [[IPC_Marshalling#Request.2C_Control|Control]], you are talking to the IPC manager. These are processed by the sysmodule.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Cmd || Name || Arguments || Output&lt;br /&gt;
|-&lt;br /&gt;
| 0 || ConvertCurrentObjectToDomain || None || u32 CmifDomainObjectId&lt;br /&gt;
|-&lt;br /&gt;
| 1 || CopyFromCurrentDomain || u32 CmifDomainObjectId || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CloneCurrentObject || None || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 3 || QueryPointerBufferSize || None || u16 size&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CloneCurrentObjectEx || u32 unknown || u32 NativeHandle&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11772</id>
		<title>HIPC</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=HIPC&amp;diff=11772"/>
		<updated>2022-06-21T22:03:23Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: /* Official marshalling code */ type 0x20 -&amp;gt; HipcAutoSelect, type 8 -&amp;gt; HipcPointer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== IPC Command Structure ==&lt;br /&gt;
This is an array of u32&#039;s, usually located in [[Thread Local Storage]].&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-0 || [[#Type|Type]].&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 19-16 || Number of buf X descriptors (each: 2 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 23-20 || Number of buf A descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 27-24 || Number of buf B descriptors (each: 3 words).&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-28 || Number of buf W desciptors (each: 3 words), not observed&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 9-0 || Size of [[#Raw data section|raw data]] in u32s.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 13-10 || Flags for buf C descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 30-20 || Empty.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31 || Enable handle descriptor.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Handle descriptor|Handle descriptor]], if enabled.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor X &amp;quot;Pointer&amp;quot;|Buf X descriptors]], each one 2 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf A descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf B descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot;|Buf W descriptors]], each one 3 words.&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Raw_data_section|Raw data section]] (including padding before and after aligned data section).&lt;br /&gt;
|-&lt;br /&gt;
| ... || || [[#Buffer descriptor C &amp;quot;ReceiveList&amp;quot;|Buf C descriptors]], each one 2 words.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
First two header u32&#039;s and handle descriptor (if enabled) are copied as-is from one process to the other.&lt;br /&gt;
&lt;br /&gt;
=== Type ===&lt;br /&gt;
IPC commands can have different types which influence how the IPC server processes requests in &amp;quot;nn::sf::hipc::server::HipcServerSessionManagerBase::ProcessRequest&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Invalid&lt;br /&gt;
|-&lt;br /&gt;
| 1 || [[#LegacyRequest, LegacyControl|LegacyRequest]]&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[#Close|Close]]&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [[#LegacyRequest, LegacyControl|LegacyControl]]&lt;br /&gt;
|-&lt;br /&gt;
| 4 || [[#Request, Control|Request]]&lt;br /&gt;
|-&lt;br /&gt;
| 5 || [[#Request, Control|Control]]&lt;br /&gt;
|-&lt;br /&gt;
| 6 || [5.0.0+] [[#RequestWithContext, ControlWithContext|RequestWithContext]]&lt;br /&gt;
|-&lt;br /&gt;
| 7 || [5.0.0+] [[#RequestWithContext, ControlWithContext|ControlWithContext]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Close ====&lt;br /&gt;
When processing a request of this type, the IPC server calls:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::DestroyServerSession&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::CloseServerSessionHandle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This ensures that the server session is destroyed internally and properly closed.&lt;br /&gt;
&lt;br /&gt;
==== LegacyRequest, LegacyControl ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::detail::HipcMessageBufferAccessor::ParseHeader&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::Reply&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It is speculated that these are part of an older message processing system where headers were further partitioned.&lt;br /&gt;
&lt;br /&gt;
==== Request, Control ====&lt;br /&gt;
These types are handled by calling:&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::ProcessMessage2&amp;quot;&lt;br /&gt;
* &amp;quot;nn::sf::hipc::server::HipcServerSessionManager::RegisterServerSessionToWaitBase&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This represents a more modern message handling system where contents follow the general marshalling structure.&lt;br /&gt;
&lt;br /&gt;
==== RequestWithContext, ControlWithContext ====&lt;br /&gt;
These are identical to normal Request and Control types, but with the additional requirement of suppling a token in their [[#Data payload|data payload]].&lt;br /&gt;
&lt;br /&gt;
This token is used by &amp;quot;nn::sf::cmif::SetInlineContext&amp;quot; which has the sole purpose of saving it into the TLS in order for it to be distributed to any IPC commands that are made while processing the current command. It&#039;s unknown if this token serves any purpose or if it&#039;s just a debug-tool to figure out what IPC command caused a particular chain of commands.&lt;br /&gt;
&lt;br /&gt;
=== Handle descriptor ===&lt;br /&gt;
There can only be one of this descriptor type. It is enabled by bit31 of the second word.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 0 || Send current PID.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 4-1 || Number of handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-5 || Number of handles to move&lt;br /&gt;
|-&lt;br /&gt;
| ... || || 8-byte PID if enabled&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to copy&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Handles to move&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Sysmodules load the last u64 of rawdata when handling the PID. This is not written by kernel. For sysmodule handling:&lt;br /&gt;
* In some cases: these commands require a placeholder u64 value passed in the input parameters, as mentioned above. In these cases the OverwriteClientProcessId method is called to replace the value before it is used.&lt;br /&gt;
* In other cases: The rawdata_u64 is compared with the PID from the descriptor. On mismatch and when rawdata_u64!=0, error 0x60A is returned. The PID value passed to the cmdhandler vtable funcptr is the rawdata_u64.&lt;br /&gt;
&lt;br /&gt;
Handle 0 is allowed, and just means no handle was sent.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor X &amp;quot;Pointer&amp;quot; ===&lt;br /&gt;
This one is packed even worse than A, they inserted the bit38-36 of the address &#039;&#039;on top&#039;&#039; of the counter field.&lt;br /&gt;
&lt;br /&gt;
Officially, the counter is known as &amp;quot;receive index&amp;quot;. This one writes to the buffer described in the ReceiveList.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 5-0 || Bits 5-0 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-6 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 11-9 || Bits 11-9 of counter.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 15-12 || Bit 35-32 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Size&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor A/B/W &amp;quot;Send&amp;quot;/&amp;quot;Receive&amp;quot;/&amp;quot;Exchange&amp;quot; ===&lt;br /&gt;
This packing is so unnecessarily complex.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of size.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1-0 || Flags. Always set to 0, 1 or 3.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4-2 || Bit 38-36 of address.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 27-24 || Bit 35-32 of size.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 31-28 || Bit 35-32 of address.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A reply must not use A/B/W, svcReplyAndReceive will return 0xE801.&lt;br /&gt;
&lt;br /&gt;
[[SVC|MemoryAttribute]] IsBorrowed and IsUncached are never allowed for the source address.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Send&amp;quot; means buffer is sent from source process into service process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Receive&amp;quot; means that data is copied from service process into user process.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Exchange&amp;quot; means both &amp;quot;Send&amp;quot; and &amp;quot;Receive&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Flags ====&lt;br /&gt;
Determines what [[SVC|MemoryState]] to use with the mapped memory in the sysmodule.&lt;br /&gt;
&lt;br /&gt;
Used to enforce whether or not device mapping is allowed for src and dst buffers respectively.&lt;br /&gt;
 &lt;br /&gt;
* Ipc (flag=0): Device mapping *not* allowed for src or dst.&lt;br /&gt;
* NonSecureIpc (flag=1): Device mapping allowed for src and dst.&lt;br /&gt;
* NonDeviceIpc (flag=3): Device mapping allowed for src but not for dst.&lt;br /&gt;
&lt;br /&gt;
=== Buffer descriptor C &amp;quot;ReceiveList&amp;quot; ===&lt;br /&gt;
There&#039;s a 4-bit flag in the main header controlling the behavior of C descriptors.&lt;br /&gt;
&lt;br /&gt;
If it has value 0, the C descriptor functionality is disabled.&lt;br /&gt;
&lt;br /&gt;
If it has value 1, there is an &amp;quot;inlined&amp;quot; C buffer after the raw data. Received data is copied to ROUND_UP(cmdbuf+raw_size+index, 16)&lt;br /&gt;
&lt;br /&gt;
If it has value 2, there is a single C descriptor.&lt;br /&gt;
&lt;br /&gt;
Otherwise it has (flag-2) C descriptors. In this case, index picks which C descriptor to copy received data to [instead of picking the offset into the buffer].&lt;br /&gt;
&lt;br /&gt;
Data sent with this method must have MemoryState 0x4000000 mask set.&lt;br /&gt;
&lt;br /&gt;
After reply, X descriptors are written to the sender containing the address, size and index that were copied to.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || || Lower 32-bits of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 15-0 || Rest of address.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 31-16 || Size&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== IPC buffers ===&lt;br /&gt;
Buffer descriptor A/B/... map memory into the sysmodule process. For the mapped memory in the sysmodule the permissions are: desc-A = R--, desc-B = RW-. The buffer is automatically unmapped while the kernel handles the cmdreply, the sysmodule doesn&#039;t need to specify anything in the cmdreply to trigger this.&lt;br /&gt;
&lt;br /&gt;
This memory is mapped in the sysmodule to the same vaddr from the original user-process cmd-request, except with with bits &amp;gt;=(~28(?)) changed to a different ASLR&#039;d region.&lt;br /&gt;
&lt;br /&gt;
No user-process-&amp;gt;sysmodule memcpy is done for outbufs, only sysmodule-&amp;gt;user-process.&lt;br /&gt;
&lt;br /&gt;
Buffer descriptors C/X are somewhat different. Rather than mapping new memory into the server process, C/X descriptors copy data between existing buffers in different processes. Each X descriptor in a message has its data copied into a C descriptor on the other side. Each C descriptor in a message is used to reserve space for the other side&#039;s X descriptors to copy into.&lt;br /&gt;
&lt;br /&gt;
When the kernel processes X descriptors, it must determine where to copy the data to. If the destination used C descriptors with flags &amp;gt;= 3, each X descriptor from the source is matched to a C descriptor in the destination by the X descriptor&#039;s index field. If the destination used a &amp;quot;single&amp;quot; C descriptor, the data from all the X descriptors is copied into the same buffer specified by the destination&#039;s C descriptor (causing error 0xce01 if there is not enough space) and the X descriptor index is ignored. The kernel then modifies the addresses in the X descriptors to indicate where the data was copied to in the destination.&lt;br /&gt;
&lt;br /&gt;
Before receiving a request, if the IPC server is expecting X descriptors, it prepares a message with a &amp;quot;single&amp;quot; C descriptor (flags=2) in its message buffer before calling svcReplyAndReceive so that X descriptors from the client have a place to copy their data to.  The usage of the flag-2 C descriptor allows the server to receive an arbitrary number of X descriptors, since they&#039;re all packed into the same buffer. If the server had used flag-3+ C descriptors, it would be limited in how many X descriptors it could receive since the X descriptors would have to be matched to distinct C descriptors. The buffer that the server&#039;s C descriptor points to is called the &#039;&#039;&#039;pointer buffer&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When the client sends X descriptors, data is copied into the server&#039;s pointer buffer. When the client sends C descriptors, no data is copied automatically. The server needs to use X descriptors to copy the data back to the client&#039;s C descriptors (using the index field to match X descriptors in the response back to the correct C descriptors).&lt;br /&gt;
&lt;br /&gt;
== Raw data section ==&lt;br /&gt;
[[File:Ipc msg buffer type a example.png|thumb|An example of an IPC message with a type 0xA buffer in it. Red is headers/descriptors, yellow is padding, and blue is data/buffer lengths. Note that the size of the u16 array for type A lengths is padded to fill up a whole word.]]&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding to align to 16 bytes.&lt;br /&gt;
|-&lt;br /&gt;
| ... || If sent to an object domain, a [[#Domain_message|domain message]], otherwise a [[#Data payload|data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || Padding&lt;br /&gt;
|-&lt;br /&gt;
| ... || Buffer type 0xA lengths (u16 array)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The total amount of padding within the raw data section is always 0x10 bytes. This means that if no padding is required before the message, there will be 0x10 bytes of padding after the message (before the buffer type 0xA lengths).&lt;br /&gt;
&lt;br /&gt;
=== Domains ===&lt;br /&gt;
Because the switch has relatively low limits on the total number of sessions available to the system (Kernel slabheap limits, sysmodule handle table size limits), HIPC supports a &amp;quot;Domains&amp;quot; feature that allows multiplexing multiple service sessions through a single handle. Domains store (effectively) a mapping from u32 object id to a SharedPointer&amp;lt;IServiceObject&amp;gt; -- When messages are sent to a domain, an extra header is sent in the raw data section (before anything else) with information about what object in the domain is being acted on; responses similarly contain an additional header. Official session code implements this by just using the dispatch table for the object in the map with the appropriate ID, instead of the dispatch table the session was initialized with.&lt;br /&gt;
&lt;br /&gt;
Format for the extra request header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 7-0 || Command. 1=send message, 2=close virtual handle&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8-15 || Input object count&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-16 || Length of [[IPC_Marshalling#Data_payload|data payload]] in bytes.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Object ID (from cmd 0 in [[IPC_Marshalling#Control|Control]]).&lt;br /&gt;
|-&lt;br /&gt;
| 2 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
| 3 || || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only)&lt;br /&gt;
|-&lt;br /&gt;
| 4... || || [[#Data payload|Data payload]]&lt;br /&gt;
|-&lt;br /&gt;
| ... || || Input object IDs (u32s, not aligned)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Format for the extra response header for domain message:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 31-0 || Output object count&lt;br /&gt;
|-&lt;br /&gt;
| 1-3 || || Padding&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Data payload ===&lt;br /&gt;
This is an array of u32&#039;s, but individual parameters are generally stored as u64&#039;s.&lt;br /&gt;
&lt;br /&gt;
Input Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCI) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. 1 for NewRequest, 0 for Request.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Command id as u32&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-4.1.0] Padding [5.0.0+] Token (for NewRequest only, non-domain messages).&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Input parameters&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[5.0.0+] Version was incremented from 0 to 1, and a token value was introduced into raw_data+12 (regardless of domain or not, in either case it overlaps with padding).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Output Header:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Word || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Magic (&amp;quot;SFCO&amp;quot;) as u32.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Version as u32. Always 0.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[Error_codes|Result]].&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [1.0.0-13.2.1] Padding [14.0.0+] Interface ID&lt;br /&gt;
|-&lt;br /&gt;
| 4... || Return values&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[14.0.0+] Padding field at +12 is now interface ID, generated as little endian first four bytes of sha256(&amp;lt;fully qualified interface name&amp;gt;). The version field was not incremented.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The rawdata struct for input parameters/return values is generated by stable-sorting function parameters by alignment, from low to high. It is likely this is a mistake, as it generates structs with suboptimal possible padding -- Nintendo probably meant to sort from high to low (which would give minimized padding), but couldn&#039;t/can&#039;t change this without breaking backwards compatibility.&lt;br /&gt;
&lt;br /&gt;
== Official marshalling code ==&lt;br /&gt;
The official marshalling function is called &amp;quot;nn::sf::hipc::client::Hipc2ClientCoreProcessorImpl::WriteBufferDataImpl&amp;quot; and takes:&lt;br /&gt;
* A pointer to a &amp;quot;nn::sf::hipc::detail::HipcMessageWriter&amp;quot; context;&lt;br /&gt;
* The number of (buf_ptr, size) pairs;&lt;br /&gt;
* An array of (buf_ptr, size) pairs (called &amp;quot;nn::sf::detail::PointerAndSize&amp;quot;);&lt;br /&gt;
* A pointer to a type bitfield for each such pair;&lt;br /&gt;
* The offset of the main IPC command structure;&lt;br /&gt;
* The size of the IPC command&#039;s [[IPC_Marshalling#Raw_data_section|raw data]].&lt;br /&gt;
&lt;br /&gt;
The type of an IPC command is described by a bitfield as below:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Bits || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || In || Direction is input.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Out || Direction is output.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || HipcMapAlias || Use buffer descriptors A (&amp;quot;Send&amp;quot;), B (&amp;quot;Receive&amp;quot;) or W (&amp;quot;Exchange&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 3 || HipcPointer || Use buffer descriptors X (&amp;quot;Pointer&amp;quot;) or C (&amp;quot;ReceiveList&amp;quot;).&lt;br /&gt;
|-&lt;br /&gt;
| 4 || FixedSize || Skip saving the pointer buffer size in raw data.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || HipcAutoSelect || Select which buffer descriptor to use automatically.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || HipcMapTransferAllowsNonSecure || Use [[#Flags|NonSecureIpc flag]].&lt;br /&gt;
|-&lt;br /&gt;
| 7 || HipcMapTransferAllowsNonDevice || Use [[#Flags|NonDeviceIpc flag]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
X and C (Pointer and ReceiveList) descriptors are backed by the &amp;quot;pointer buffer&amp;quot;, a buffer in the service process. Its size is a u16, which is retrieved using the &amp;quot;QueryPointerBufferSize&amp;quot; control message. If the client code determines all buffers with flag HipcPointer do not fit in the pointer buffer, it returns error 0x11A0B.&lt;br /&gt;
&lt;br /&gt;
For buffers with flag HipcAutoSelect it creates two descriptors (A+X or B+C), but one descriptor is NULL (zero size and pointer), while the other holds the expected values. X/C descriptors are used as the non-NULL descriptor where possible, but if they don&#039;t fit in the pointer buffer, A/B descriptors are used instead. The code defers processing of HipcAutoSelect buffers with sizes that fit in a u16 (and may therefore fit in the pointer buffer), which ensures all HipcPointer buffers get pointer-buffer space before any HipcAutoSelect. The order in which the deferred HipcAutoSelect buffers are processed is determined by a convoluted loop.&lt;br /&gt;
&lt;br /&gt;
== Official IPC Cmd Structure ==&lt;br /&gt;
Official struct that is stored for each IPC command. It contains precalculated offsets for different portions of the command structure.&lt;br /&gt;
&lt;br /&gt;
All offsets are given is in number of u32 words.&lt;br /&gt;
&lt;br /&gt;
 struct IpcCmdStruct {&lt;br /&gt;
   u8  unk0;&lt;br /&gt;
   u8  has_handle_descriptor;&lt;br /&gt;
   u8  pad0[2];&lt;br /&gt;
   u32 cmd0;&lt;br /&gt;
   u32 cmd1;&lt;br /&gt;
   u32 offset_handle_descriptor;&lt;br /&gt;
   u32 pad1;&lt;br /&gt;
   u32 offset_handles;          &lt;br /&gt;
   u32 pad2;&lt;br /&gt;
   u32 offset_x_descriptors;&lt;br /&gt;
   u32 offset_a_descriptors;&lt;br /&gt;
   u32 offset_b_descriptors;&lt;br /&gt;
   u32 offset_w_descriptors; /* this is a guess */&lt;br /&gt;
   u32 offset_raw_data;&lt;br /&gt;
   u32 offset_c_descriptors;&lt;br /&gt;
   u32 unk2;&lt;br /&gt;
   u32 unk3;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Control ==&lt;br /&gt;
When type is [[IPC_Marshalling#Request.2C_Control|Control]], you are talking to the IPC manager. These are processed by the sysmodule.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Cmd || Name || Arguments || Output&lt;br /&gt;
|-&lt;br /&gt;
| 0 || ConvertCurrentObjectToDomain || None || u32 CmifDomainObjectId&lt;br /&gt;
|-&lt;br /&gt;
| 1 || CopyFromCurrentDomain || u32 CmifDomainObjectId || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 2 || CloneCurrentObject || None || u32 NativeHandle&lt;br /&gt;
|-&lt;br /&gt;
| 3 || QueryPointerBufferSize || None || u16 size&lt;br /&gt;
|-&lt;br /&gt;
| 4 || CloneCurrentObjectEx || u32 unknown || u32 NativeHandle&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=SVC&amp;diff=11749</id>
		<title>SVC</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=SVC&amp;diff=11749"/>
		<updated>2022-06-08T20:45:51Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: /* SetHeapSize */ Fix register size W1 -&amp;gt; X1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
= System calls =&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! ID || Return Type || Name || Arguments&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Result || [[#SetHeapSize|SetHeapSize]] || uintptr_t *out_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Result || [[#SetMemoryPermission|SetMemoryPermission]] || uintptr_t address, size_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Result || [[#SetMemoryAttribute|SetMemoryAttribute]] || uintptr_t address, size_t size, uint32_t mask, uint32_t attr&lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Result || [[#MapMemory|MapMemory]] || uintptr_t dst_address, uintptr_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Result || [[#UnmapMemory|UnmapMemory]] || uintptr_t dst_address, uintptr_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Result || [[#QueryMemory|QueryMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || void || [[#ExitProcess|ExitProcess]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Result || [[#CreateThread|CreateThread]] || Handle *out_handle, ThreadFunc func, uintptr_t arg, uintptr_t stack_bottom, int32_t priority, int32_t core_id&lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Result || [[#StartThread|StartThread]] || Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || void || [[#ExitThread|ExitThread]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || void || [[#SleepThread|SleepThread]] || int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Result || [[#GetThreadPriority|GetThreadPriority]] || int32_t *out_priority, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Result || [[#SetThreadPriority|SetThreadPriority]] || Handle thread_handle, int32_t priority&lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Result || [[#GetThreadCoreMask|GetThreadCoreMask]] || int32_t *out_core_id, uint64_t *out_affinity_mask, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0F || Result || [[#SetThreadCoreMask|SetThreadCoreMask]] || Handle thread_handle, int32_t core_id, uint64_t affinity_mask&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || int32_t || [[#GetCurrentProcessorNumber|GetCurrentProcessorNumber]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x11 || Result || [[#SignalEvent|SignalEvent]] || Handle event_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x12 || Result || [[#ClearEvent|ClearEvent]] || Handle event_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x13 || Result || [[#MapSharedMemory|MapSharedMemory]] || Handle shmem_handle, uintptr_t address, size_t size, MemoryPermission map_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x14 || Result || [[#UnmapSharedMemory|UnmapSharedMemory]] || Handle shmem_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x15 || Result || [[#CreateTransferMemory|CreateTransferMemory]] || Handle *out_handle, uintptr_t address, size_t size, MemoryPermission map_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x16 || Result || [[#CloseHandle|CloseHandle]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x17 || Result || [[#ResetSignal|ResetSignal]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || Result || [[#WaitSynchronization|WaitSynchronization]] || int32_t *out_index, const Handle *handles, int32_t numHandles, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x19 || Result || [[#CancelSynchronization|CancelSynchronization]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x1A || Result || [[#ArbitrateLock|ArbitrateLock]] || Handle thread_handle, uintptr_t address, uint32_t tag&lt;br /&gt;
|-&lt;br /&gt;
| 0x1B || Result || [[#ArbitrateUnlock|ArbitrateUnlock]] || uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C || Result || [[#WaitProcessWideKeyAtomic|WaitProcessWideKeyAtomic]] || uintptr_t address, uintptr_t cv_key, uint32_t tag, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x1D || void || [[#SignalProcessWideKey|SignalProcessWideKey]] || uintptr_t cv_key, int32_t count&lt;br /&gt;
|-&lt;br /&gt;
| 0x1E || int64_t || [[#GetSystemTick|GetSystemTick]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x1F || Result || [[#ConnectToNamedPort|ConnectToNamedPort]] || Handle *out_handle, const char *name&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || Result || [[#SendSyncRequestLight|SendSyncRequestLight]] || Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Result || [[#SendSyncRequest|SendSyncRequest]] || Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x22 || Result || [[#SendSyncRequestWithUserBuffer|SendSyncRequestWithUserBuffer]] || uintptr_t message_buffer, size_t message_buffer_size, Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x23 || Result || [[#SendAsyncRequestWithUserBuffer|SendAsyncRequestWithUserBuffer]] || Handle *out_event_handle, uintptr_t message_buffer, size_t message_buffer_size, Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || Result || [[#GetProcessId|GetProcessId]] || uint64_t *out_process_id, Handle process_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x25 || Result || [[#GetThreadId|GetThreadId]] || uint64_t *out_thread_id, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x26 || void || [[#Break|Break]] || BreakReason break_reason, uintptr_t arg, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x27 || Result || [[#OutputDebugString|OutputDebugString]] || const char *debug_str, size_t len&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || void || [[#ReturnFromException|ReturnFromException]] || Result result&lt;br /&gt;
|-&lt;br /&gt;
| 0x29 || Result || [[#GetInfo|GetInfo]] || uint64_t *out, InfoType info_type, Handle handle, uint64_t info_subtype&lt;br /&gt;
|-&lt;br /&gt;
| 0x2A || void || [[#FlushEntireDataCache|FlushEntireDataCache]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x2B || Result || [[#FlushDataCache|FlushDataCache]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [3.0.0+] 0x2C  || Result || [[#MapPhysicalMemory|MapPhysicalMemory]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [3.0.0+] 0x2D  || Result || [[#UnmapPhysicalMemory|UnmapPhysicalMemory]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0-5.1.0] 0x2E  || Result || GetFutureThreadInfo || arch::LastThreadContext *out_context, uintptr_t *out_tls_address, uint32_t *out_flags, int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| [6.0.0+] 0x2E  || Result || [[#GetDebugFutureThreadInfo|GetDebugFutureThreadInfo]] || arch::LastThreadContext *out_context, uint64_t *thread_id, Handle debug_handle, int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x2F || Result || [[#GetLastThreadInfo|GetLastThreadInfo]] || arch::LastThreadContext *out_context, uintptr_t *out_tls_address, uint32_t *out_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || Result || [[#GetResourceLimitLimitValue|GetResourceLimitLimitValue]] || int64_t *out_limit_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|-&lt;br /&gt;
| 0x31 || Result || [[#GetResourceLimitCurrentValue|GetResourceLimitCurrentValue]] || int64_t *out_current_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|-&lt;br /&gt;
| 0x32 || Result || [[#SetThreadActivity|SetThreadActivity]] || Handle thread_handle, ThreadActivity thread_activity&lt;br /&gt;
|-&lt;br /&gt;
| 0x33  || Result || [[#GetThreadContext3|GetThreadContext3]] || ThreadContext *out_context, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x34 || Result || [[#WaitForAddress|WaitForAddress]] || uintptr_t address, ArbitrationType arb_type, int32_t value, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x35 || Result || [[#SignalToAddress|SignalToAddress]] || uintptr_t address, SignalType signal_type, int32_t value, int32_t count&lt;br /&gt;
|-&lt;br /&gt;
| [8.0.0+] 0x36 || void || [[#SynchronizePreemptionState|SynchronizePreemptionState]] || &lt;br /&gt;
|-&lt;br /&gt;
| [11.0.0+] 0x37 || Result || [[#GetResourceLimitPeakValue|GetResourceLimitPeakValue]] || int64_t *out_peak_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [13.0.0+] 0x39 || Result || CreateIoPool || Handle *out_handle, IoPoolType which_pool&lt;br /&gt;
|-&lt;br /&gt;
| [13.0.0+] 0x3A || Result || CreateIoRegion || Handle *out_handle, Handle io_pool, PhysicalAddress physical_address, size_t size, MemoryMapping mapping, MemoryPermission perm&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [1.0.0-3.0.2] 0x3C || void || [[#DumpInfo|DumpInfo]] || DumpInfoType dump_info_type, uint64_t arg&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x3C || void || [[#KernelDebug|KernelDebug]] || KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x3D || void || [[#ChangeKernelTraceState|ChangeKernelTraceState]] || KernelTraceState kern_trace_state&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| 0x40 || Result || [[#CreateSession|CreateSession]] || Handle *out_server_session_handle, Handle *out_client_session_handle, bool is_light, uintptr_t name&lt;br /&gt;
|-&lt;br /&gt;
| 0x41 || Result || [[#AcceptSession|AcceptSession]] || Handle *out_handle, Handle port&lt;br /&gt;
|-&lt;br /&gt;
| 0x42 || Result || [[#ReplyAndReceiveLight|ReplyAndReceiveLight]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x43 || Result || [[#ReplyAndReceive|ReplyAndReceive]] || int32_t *out_index, const Handle *handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x44 || Result || [[#ReplyAndReceiveWithUserBuffer|ReplyAndReceiveWithUserBuffer]] || int32_t *out_index, uintptr_t message_buffer, size_t message_buffer_size, const Handle *handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x45 || Result || [[#CreateEvent|CreateEvent]] || Handle *out_write_handle, Handle *out_read_handle&lt;br /&gt;
|-&lt;br /&gt;
| [13.0.0+] 0x46 || Result || MapIoRegion || Handle io_region, uintptr_t address, size_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| [13.0.0+] 0x47 || Result || UnmapIoRegion || Handle io_region, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x48 || Result || [[#MapPhysicalMemoryUnsafe|MapPhysicalMemoryUnsafe]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x49 || Result || [[#UnmapPhysicalMemoryUnsafe|UnmapPhysicalMemoryUnsafe]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x4A || Result || [[#SetUnsafeLimit|SetUnsafeLimit]] || size_t limit&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x4B || Result || [[#CreateCodeMemory|CreateCodeMemory]] || Handle *out_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x4C || Result || [[#ControlCodeMemory|ControlCodeMemory]] || Handle code_memory_handle, CodeMemoryOperation operation, uint64_t address, uint64_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x4D || void || [[#SleepSystem|SleepSystem]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x4E || Result || [[#ReadWriteRegister|ReadWriteRegister]] || uint32_t *out_value, PhysicalAddress address, uint32_t mask, uint32_t value&lt;br /&gt;
|-&lt;br /&gt;
| 0x4F || Result || [[#SetProcessActivity|SetProcessActivity]] || Handle process_handle, ProcessActivity process_activity&lt;br /&gt;
|-&lt;br /&gt;
| 0x50 || Result || [[#CreateSharedMemory|CreateSharedMemory]] || Handle *out_handle, size_t size, MemoryPermission owner_perm, MemoryPermission remote_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x51 || Result || [[#MapTransferMemory|MapTransferMemory]] || Handle trmem_handle, uintptr_t address, size_t size, MemoryPermission owner_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x52 || Result || [[#UnmapTransferMemory|UnmapTransferMemory]] || Handle trmem_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x53 || Result || [[#CreateInterruptEvent|CreateInterruptEvent]] || Handle *out_read_handle, int32_t interrupt_id, InterruptType interrupt_type&lt;br /&gt;
|-&lt;br /&gt;
| 0x54 || Result || [[#QueryPhysicalAddress|QueryPhysicalAddress]] || arch::PhysicalMemoryInfo *out_info, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x55 || Result || [[#QueryIoMapping|QueryIoMapping]] || uintptr_t *out_address, [10.0.0+] size_t *out_size, PhysicalAddress physical_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x56 || Result || [[#CreateDeviceAddressSpace|CreateDeviceAddressSpace]] || Handle *out_handle, uint64_t das_address, uint64_t das_size&lt;br /&gt;
|-&lt;br /&gt;
| 0x57 || Result || [[#AttachDeviceAddressSpace|AttachDeviceAddressSpace]] || DeviceName device_name, Handle das_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x58 || Result || [[#DetachDeviceAddressSpace|DetachDeviceAddressSpace]] || DeviceName device_name, Handle das_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x59 || Result || [[#MapDeviceAddressSpaceByForce|MapDeviceAddressSpaceByForce]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x5A || Result || [[#MapDeviceAddressSpaceAligned|MapDeviceAddressSpaceAligned]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0-12.1.0] 0x5B || Result || [[#MapDeviceAddressSpace|MapDeviceAddressSpace]] || size_t *out_mapped_size, Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x5C || Result || [[#UnmapDeviceAddressSpace|UnmapDeviceAddressSpace]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address&lt;br /&gt;
|-&lt;br /&gt;
| 0x5D || Result || [[#InvalidateProcessDataCache|InvalidateProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x5E || Result || [[#StoreProcessDataCache|StoreProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x5F || Result || [[#FlushProcessDataCache|FlushProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x60 || Result || [[#DebugActiveProcess|DebugActiveProcess]] || Handle *out_handle, uint64_t process_id&lt;br /&gt;
|-&lt;br /&gt;
| 0x61 || Result || [[#BreakDebugProcess|BreakDebugProcess]] || Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x62 || Result || [[#TerminateDebugProcess|TerminateDebugProcess]] || Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x63 || Result || [[#GetDebugEvent|GetDebugEvent]] || arch::DebugEventInfo *out_info, Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x64 || Result || [[#ContinueDebugEvent|ContinueDebugEvent]] || Handle debug_handle, uint32_t flags, const uint64_t *thread_ids, int32_t num_thread_ids&lt;br /&gt;
|-&lt;br /&gt;
| 0x65 || Result || [[#GetProcessList|GetProcessList]] || int32_t *out_num_processes, uint64_t *out_process_ids, int32_t max_out_count&lt;br /&gt;
|-&lt;br /&gt;
| 0x66 || Result || [[#GetThreadList|GetThreadList]] || int32_t *out_num_threads, uint64_t *out_thread_ids, int32_t max_out_count, Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x67 || Result || [[#GetDebugThreadContext|GetDebugThreadContext]] || ThreadContext *out_context, Handle debug_handle, uint64_t thread_id, uint32_t context_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x68 || Result || [[#SetDebugThreadContext|SetDebugThreadContext]] || Handle debug_handle, uint64_t thread_id, const ThreadContext *context, uint32_t context_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x69 || Result || [[#QueryDebugProcessMemory|QueryDebugProcessMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, Handle process_handle, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x6A || Result || [[#ReadDebugProcessMemory|ReadDebugProcessMemory]] || uintptr_t buffer, Handle debug_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x6B || Result || [[#WriteDebugProcessMemory|WriteDebugProcessMemory]] || Handle debug_handle, uintptr_t buffer, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C || Result || [[#SetHardwareBreakPoint|SetHardwareBreakPoint]] || HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value&lt;br /&gt;
|-&lt;br /&gt;
| 0x6D || Result || [[#GetDebugThreadParam|GetDebugThreadParam]] || uint64_t *out_64, uint32_t *out_32, Handle debug_handle, uint64_t thread_id, DebugThreadParam param&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [5.0.0+] 0x6F || Result || [[#GetSystemInfo|GetSystemInfo]] || uint64_t *out, SystemInfoType info_type, Handle handle, uint64_t info_subtype&lt;br /&gt;
|-&lt;br /&gt;
| 0x70 || Result || [[#CreatePort|CreatePort]] || Handle *out_server_handle, Handle *out_client_handle, int32_t max_sessions, bool is_light, uintptr_t name&lt;br /&gt;
|-&lt;br /&gt;
| 0x71 || Result || [[#ManageNamedPort|ManageNamedPort]] || Handle *out_server_handle, const char *name, int32_t max_sessions&lt;br /&gt;
|-&lt;br /&gt;
| 0x72 || Result || [[#ConnectToPort|ConnectToPort]] || Handle *out_handle, Handle port&lt;br /&gt;
|-&lt;br /&gt;
| 0x73 || Result || [[#SetProcessMemoryPermission|SetProcessMemoryPermission]] || Handle process_handle, uint64_t address, uint64_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x74 || Result || [[#MapProcessMemory|MapProcessMemory]] || uintptr_t dst_address, Handle process_handle, uint64_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x75 || Result || [[#UnmapProcessMemory|UnmapProcessMemory]] || uintptr_t dst_address, Handle process_handle, uint64_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x76 || Result || [[#QueryProcessMemory|QueryProcessMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, Handle process_handle, uint64_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x77 || Result || [[#MapProcessCodeMemory|MapProcessCodeMemory]] || Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x78 || Result || [[#UnmapProcessCodeMemory|UnmapProcessCodeMemory]] || Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x79 || Result || [[#CreateProcess|CreateProcess]] || Handle *out_handle, const arch::CreateProcessParameter *parameters, const uint32_t *caps, int32_t num_caps&lt;br /&gt;
|-&lt;br /&gt;
| 0x7A || Result || [[#StartProcess|StartProcess]] || Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size&lt;br /&gt;
|-&lt;br /&gt;
| 0x7B || Result || [[#TerminateProcess|TerminateProcess]] || Handle process_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x7C || Result || [[#GetProcessInfo|GetProcessInfo]] || int64_t *out_info, Handle process_handle, ProcessInfoType info_type&lt;br /&gt;
|-&lt;br /&gt;
| 0x7D || Result || [[#CreateResourceLimit|CreateResourceLimit]] || Handle *out_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x7E || Result || [[#SetResourceLimitLimitValue|SetResourceLimitLimitValue]] || Handle resource_limit_handle, LimitableResource which, int64_t limit_value&lt;br /&gt;
|-&lt;br /&gt;
| 0x7F || void || [[#CallSecureMonitor|CallSecureMonitor]] || SecureMonitorArguments *args&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SetHeapSize ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || void* || HeapAddress&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the process heap to a given Size. It can both extend and shrink the heap.&lt;br /&gt;
&lt;br /&gt;
Size must be a multiple of 0x200000 (2MB).&lt;br /&gt;
&lt;br /&gt;
On success, the heap base-address (which is fixed by kernel, aslr&#039;d, and always in the Heap memory region) is written to HeapAddress.&lt;br /&gt;
&lt;br /&gt;
Uses current process pool partition. The memory allocated counts towards the caller&#039;s process Memory ResourceLimit.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] Size must be less than or equal to 4GB.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Invalid size passed. It&#039;s either bigger than 4GB, or misaligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD001:&#039;&#039;&#039; Size is bigger than the Heap Region size.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; KMemoryBlockAllocator slab allocator exhausted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The memory region is in an invalid state. Likely because a mapping was made in the heap region.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0x10801:&#039;&#039;&#039; Memory resource limit reached.&lt;br /&gt;
&lt;br /&gt;
== SetMemoryPermission ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes permission of page-aligned memory region.&lt;br /&gt;
&lt;br /&gt;
Bit2 of permission (exec) is not allowed. Setting write-only is not allowed either (bit1).&lt;br /&gt;
&lt;br /&gt;
This can be used to move back and forth between ---, r-- and rw-.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The memory region was reprotected.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Unaligned address specified.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Unaligned or zero size specified.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The provided memory region does not fall within the userland address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD801:&#039;&#039;&#039; Invalid permission specified. Valid permissions are ---, r-- and rw-.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The provided memory region was in an invalid state. The region must have the [[#MemoryState|FlagCanReprotect]] state, and must not have the [[#MemoryAttribute|Locked]] or [[#MemoryAttribute|Uncached]] attributes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; Kernel resource exhausted.&lt;br /&gt;
&lt;br /&gt;
== SetMemoryAttribute ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || uint32_t || Mask&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes attribute of page-aligned memory region. The only allowed combination of Value and Mask is 0x8, which means only bit3 in [[#MemoryAttribute]] can be set or cleared.&lt;br /&gt;
&lt;br /&gt;
This is used to turn on/off caching for a given memory area. Useful when talking to devices such as the GPU.&lt;br /&gt;
&lt;br /&gt;
What happens &amp;quot;under the hood&amp;quot; is the &amp;quot;Memory Attribute Indirection Register&amp;quot; index is changed from 2 to 3 in the MMU descriptor.&lt;br /&gt;
&lt;br /&gt;
== MapMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps a memory range into a different range.&lt;br /&gt;
&lt;br /&gt;
Mainly used for adding guard pages around stack.&lt;br /&gt;
&lt;br /&gt;
Source range gets reprotected to --- (it can no longer be accessed), and bit0 is set in the source [[#MemoryAttribute]].&lt;br /&gt;
&lt;br /&gt;
[1.0.0] This could be used to map into either the Alias Region or the Stack region.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] This can only be used to map into the Stack region.&lt;br /&gt;
&lt;br /&gt;
Code can get the range of the Alias region from [[#GetInfo]] id0=2,3, and on 2.0.0+ the range of the Stack region via [[#GetInfo]] id0=14, 15 (on 1.0.0, the Stack region had hardcoded limits).&lt;br /&gt;
&lt;br /&gt;
When mapped into the Alias region, the mapped memory will have state 0x482907.&lt;br /&gt;
&lt;br /&gt;
When mapped into the Stack region, the mapped memory will have state 0x5C3C0B.&lt;br /&gt;
&lt;br /&gt;
== UnmapMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps a region that was previously mapped with [[#MapMemory]].&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to unmap ranges partially, you don&#039;t need to unmap the entire range &amp;quot;in one go&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The srcaddr/dstaddr must match what was given when the pages were originally mapped.&lt;br /&gt;
&lt;br /&gt;
== QueryMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Queries information about an address. Will always fetch the lowest page-aligned mapping that contains the provided address.&lt;br /&gt;
&lt;br /&gt;
Outputs a [[#MemoryInfo]] struct.&lt;br /&gt;
&lt;br /&gt;
== ExitProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the current process.&lt;br /&gt;
&lt;br /&gt;
== CreateThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void(*)(void*) || Entry&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || void* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || void* || StackTop&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R0 || int32_t || Priority&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R4 || int32_t || ProcessorId&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a thread in the current process.&lt;br /&gt;
&lt;br /&gt;
ProcessorId must be 0,1,2,3 or -2, where -2 uses the default CpuId for process.&lt;br /&gt;
&lt;br /&gt;
== StartThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None ||  ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the thread for the provided handle.&lt;br /&gt;
&lt;br /&gt;
== ExitThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the current thread.&lt;br /&gt;
&lt;br /&gt;
== SleepThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0, R1 || uint64_t || Nanoseconds&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sleeps for a specified amount of time, or yields the thread.&lt;br /&gt;
&lt;br /&gt;
Setting nanoseconds to 0, -1, or -2 indicates a yielding type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Yielding without core migration&lt;br /&gt;
|-&lt;br /&gt;
| -1 || Yielding with core migration&lt;br /&gt;
|-&lt;br /&gt;
| -2 || Yielding to any other thread&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadPriority ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1|| Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || int32_t || Priority&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets the priority of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== SetThreadPriority ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0|| Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1|| int32_t || Priority&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the priority of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
Priority is a number 0-0x3F. Lower value means higher priority.&lt;br /&gt;
&lt;br /&gt;
== GetThreadCoreMask ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || int32_t || CoreMask0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || R2, R3 || uint64_t || CoreMask1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets the affinity mask of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== SetThreadCoreMask ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || int32_t || CoreMask0&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || uint64_t || CoreMask1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the affinity mask of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== GetCurrentProcessorNumber ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || uint32_t || CpuId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets which cpu is executing the current thread.&lt;br /&gt;
&lt;br /&gt;
CpuId is an integer in the range 0-3.&lt;br /&gt;
&lt;br /&gt;
== SignalEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;WritableEvent&amp;gt; || EventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Puts the given event in the signaled state.&lt;br /&gt;
&lt;br /&gt;
Will wake up any thread currently waiting on this event. Can potentially trigger a reschedule.&lt;br /&gt;
&lt;br /&gt;
Any calls to [[#WaitSynchronization]] on this handle will return immediately, until the event&#039;s signaled state is reset.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. Event is now in signaled state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; Invalid handle. The handle either does not exist, or is not a WritableEvent.&lt;br /&gt;
&lt;br /&gt;
== ClearEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;WritableEvent&amp;gt; or Handle&amp;lt;ReadableEvent&amp;gt; || EventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes the given event out of the signaled state.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success, the event is now in the not-signaled state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; Invalid handle. The handle either does not exist, or is not a ReadableEvent nor a WritableEvent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; The handle was not in a signaled state.&lt;br /&gt;
&lt;br /&gt;
== MapSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the block supplied by the handle. The required permissions are different for the process that created the handle and all other processes.&lt;br /&gt;
&lt;br /&gt;
Increases reference count for the KSharedMemory object. Thus in order to release the memory associated with the object, all handles to it must be closed and all mappings must be unmapped.&lt;br /&gt;
&lt;br /&gt;
== UnmapSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one reprotects the src block with perms you give it. It also sets bit0 into [[#MemoryAttribute]].&lt;br /&gt;
&lt;br /&gt;
Executable bit perm not allowed.&lt;br /&gt;
&lt;br /&gt;
Closing all handles automatically causes the bit0 in [[#MemoryAttribute]] to clear, and the permission to reset.&lt;br /&gt;
&lt;br /&gt;
== CloseHandle ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ResetSignal ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;ReadableEvent&amp;gt; or Handle&amp;lt;Process&amp;gt; || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resets the signal on the given handle, ensuring future calls to [[#WaitSynchronization]] on this handle will sleep until the handle is signaled again. If the handle is a ReadableEvent, this is equivalent to calling ClearEvent() on the handle.&lt;br /&gt;
&lt;br /&gt;
If the handle is a Process, it will clear the signaled state (which is set when the process changes [[#ProcessState]]. Once the process enters the Exited state, calling ResetSignal on the process will no longer have an effect (the process is permanently signaled), and the syscall will return 0xFA01.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The signal was reset.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; The handle is invalid or of the wrong type.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; The handle was not signaled, or the process is in exited state, causing it to be permanently signaled.&lt;br /&gt;
&lt;br /&gt;
== WaitSynchronization ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle* || HandlesPtr&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || HandlesNum&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || int64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint64_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Works with HandlesNum &amp;lt;= 0x40.&lt;br /&gt;
&lt;br /&gt;
When zero handles are passed, this will wait forever until either timeout or cancellation occurs.&lt;br /&gt;
&lt;br /&gt;
Does not accept 0xFFFF8001 or 0xFFFF8000 as handles.&lt;br /&gt;
&lt;br /&gt;
=== Object types ===&lt;br /&gt;
&#039;&#039;&#039;KDebug:&#039;&#039;&#039; signals when there is a new [[#DebugEventInfo|DebugEvent]] (retrievable via [[#GetDebugEvent]]).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KClientPort:&#039;&#039;&#039; signals when the number of sessions is less than the maximum allowed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KProcess:&#039;&#039;&#039; signals when the process undergoes a state change (retrievable via [[#GetProcessInfo]]).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KReadableEvent:&#039;&#039;&#039; signals when the event&#039;s corresponding KWritableEvent has been signaled via [[#SignalEvent]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KServerPort:&#039;&#039;&#039; signals when there is an incoming connection waiting to be [[#AcceptSession|accepted]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KServerSession:&#039;&#039;&#039; signals when there is an incoming message waiting to be [[#ReplyAndReceive|received]] or the pipe is closed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KThread:&#039;&#039;&#039; signals when the thread has exited.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. One of the objects was signaled before the timeout expired, or one of the objects is a Session with a closed remote. Handle index is updated to indicate which object signaled.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0x7601:&#039;&#039;&#039; Thread termination requested. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid handle. Returned when one of the handles passed is invalid. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe601:&#039;&#039;&#039; Invalid address. Returned when the handles pointer is not a readable address. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xea01:&#039;&#039;&#039; Timeout. Returned when no objects have been signaled within the timeout. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xec01:&#039;&#039;&#039; Interrupted. Returned when another thread uses [[#CancelSynchronization]] to cancel this thread. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xee01:&#039;&#039;&#039; Too many handles. Returned when the number of handles passed is &amp;gt; 0x40.&lt;br /&gt;
&lt;br /&gt;
== CancelSynchronization ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the referenced thread is currently in a synchronization call ([[#WaitSynchronization]], [[#ReplyAndReceive]] or [[#ReplyAndReceiveLight]]), that call will be interrupted and return 0xec01.&lt;br /&gt;
If that thread is not currently executing such a synchronization call, the next call to a synchronization call will return 0xec01.&lt;br /&gt;
&lt;br /&gt;
This doesn&#039;t take force-pause (activity/debug pause) into account.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The thread was either interrupted or has had its flag set.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid handle. The handle given was either invalid or not a thread handle.&lt;br /&gt;
&lt;br /&gt;
== ArbitrateLock ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || uint32_t || Tag&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;                                  &lt;br /&gt;
&lt;br /&gt;
== ArbitrateUnlock ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WaitProcessWideKeyAtomic ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || KeyAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void* || TagAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Tag&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || int64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SignalProcessWideKey ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || int32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetSystemTick ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0, R1 || uint64_t || Ticks&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the value of cntpct_el0.&lt;br /&gt;
&lt;br /&gt;
The frequency is 19200000 Hz (constant from official sw).&lt;br /&gt;
&lt;br /&gt;
Official sw reads cntpct_el0 directly from usermode without using this SVC. [[ExeFS|sdk-nso]] has this SVC, but it&#039;s not known to be called anywhere.&lt;br /&gt;
&lt;br /&gt;
== ConnectToNamedPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || char* || PortName&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequestLight ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequest ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequestWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size and Address must be 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xcc01:&#039;&#039;&#039; Address is not 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xca01:&#039;&#039;&#039; Size is not 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xce01:&#039;&#039;&#039; KSessionRequest allocation failed (unlikely) or pointer buffer size exceeded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Handles does not exist, or handle is not an instance of KClientSession.&lt;br /&gt;
&lt;br /&gt;
== SendAsyncRequestWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ReadableEvent&amp;gt; || EventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size and Address must be 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
== GetProcessId ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || ProcessId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadId ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || ThreadId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Break ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#BreakReason]] || BreakReason&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Info&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the process is attached, report the Break event. Then, if [[#ContinueDebugEvent]] didn&#039;t apply IgnoreException on the thread: if TPIDR_EL0 is 0, adjust ELR_EL1 to retry to svc instruction (and set TPIDR_EL0 to 1).&lt;br /&gt;
&lt;br /&gt;
Otherwise, if bit31 in reason isn&#039;t set, perform crash reporting (see Exception Handling section below), if it doesn&#039;t terminate the process adjust ELR_EL1 as well.&lt;br /&gt;
&lt;br /&gt;
Otherwise just return 0.&lt;br /&gt;
&lt;br /&gt;
== OutputDebugString ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || char* || String&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReturnFromException ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#InfoType]] || InfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || uint64_t || InfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || Info&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushEntireDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MapPhysicalMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Acts like [[#SetHeapSize]] except you can allocate heap at any address you&#039;d like.&lt;br /&gt;
&lt;br /&gt;
Uses current process pool partition.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Invalid size passed. It&#039;s either zero or not 4k-aligned&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Invalid address. (not 4k-aligned)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xDC01:&#039;&#039;&#039; Invalid memory range. It&#039;s either causes overflow, or does not fall into &amp;quot;reserved&amp;quot; address range (aka Alias). See AliasRegionAddress at [[#InfoType]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; Invalid state. (not enough SystemResource (see [[NPDM#SystemResourceSize]]))&lt;br /&gt;
&lt;br /&gt;
== UnmapPhysicalMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugFutureThreadInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R1 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || LastThreadContextParam0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || LastThreadContextParam1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || LastThreadContextParam2&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X4 || uint64_t || LastThreadContextParam3&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X5 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W6 || uint32_t ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetLastThreadInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || LastThreadContextParam0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || LastThreadContextParam1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || LastThreadContextParam2&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X4 || uint64_t || LastThreadContextParam3&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X5 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W6 || uint32_t ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitLimitValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || LimitValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitCurrentValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || CurrentValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetThreadActivity ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || [[#ThreadActivity]] || ThreadActivity&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadContext3 ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WaitForAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#ArbitrationType]] || ArbitrationType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SignalToAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#SignalType]] || SignalType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || uint32_t || NumToSignal&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0  || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SynchronizePreemptionState ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None ||  || &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitPeakValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || PeakValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DumpInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#DumpInfoType]] || DumpInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || DumpInfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
[4.0.0+] This function was removed and replaced by [[#KernelDebug]].&lt;br /&gt;
&lt;br /&gt;
== KernelDebug ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#KernelDebugType]] || KernelDebugType&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
== ChangeKernelTraceState ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#KernelTraceState]] || KernelTraceState&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
== CreateSession ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || bool || IsLight&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ServerSession&amp;gt; || ServerSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || Handle&amp;lt;ClientSession&amp;gt; || ClientSessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== AcceptSession ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Port&amp;gt; || PortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ServerSession&amp;gt; || ServerSessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0xf201:&#039;&#039;&#039; No session waiting to be accepted&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceiveLight ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Port&amp;gt; or Handle&amp;lt;ServerSession&amp;gt; || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceive ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle&amp;lt;Port&amp;gt;* or Handle&amp;lt;ServerSession&amp;gt;* || Handles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || NumHandles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || Handle&amp;lt;ServerSession&amp;gt; || ReplyTargetSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R0, R4 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If ReplyTargetSessionHandle is not zero, a reply from the TLS will be sent to that session.&lt;br /&gt;
Then it will wait until either of the passed sessions has an incoming message, is closed, a passed port has an incoming connection, or the timeout expires.&lt;br /&gt;
If there is an incoming message, it is copied to the TLS.&lt;br /&gt;
&lt;br /&gt;
If ReplyTargetSessionHandle is zero, the TLS should contain a blank message. If this message has a C descriptor, the buffer it points to will be used as the pointer buffer. See [[IPC_Marshalling#IPC_buffers]]. Note that a pointer buffer cannot be specified if ReplyTargetSessionHandle is not zero.&lt;br /&gt;
&lt;br /&gt;
After being validated, passed handles will be enumerated in order; even if a session has been closed, if one that appears earlier in the list has an incoming message, it will take priority and a result code of 0x0 will be returned.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. Either a session has an incoming message or a port has an incoming connection. HandleIndex is set appropriately.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xea01:&#039;&#039;&#039; Timeout. No handles were signalled before the timeout expired. HandleIndex is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xf601:&#039;&#039;&#039; Port remote dead. One of the sessions has been closed. HandleIndex is set appropriately.&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceiveWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || Handle&amp;lt;Port&amp;gt;* or Handle&amp;lt;ServerSession&amp;gt;* || Handles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R0 || uint32_t || NumHandles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R4 || Handle&amp;lt;ServerSession&amp;gt; || ReplyTargetSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X6 || R5, R6 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;WritableEvent&amp;gt; || WritableEventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || Handle&amp;lt;ReadableEvent&amp;gt; || ReadableEventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MapPhysicalMemoryUnsafe ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Same as [[#MapPhysicalMemory]] except it always uses pool partition 0.&lt;br /&gt;
&lt;br /&gt;
== UnmapPhysicalMemoryUnsafe ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetUnsafeLimit ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || uint64_t || Limit&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;CodeMemory&amp;gt; || CodeMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes an address range with backing memory to create the code memory object.&lt;br /&gt;
&lt;br /&gt;
The memory is initially memset to 0xFF after being locked.&lt;br /&gt;
&lt;br /&gt;
== ControlCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;CodeMemory&amp;gt; || CodeMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#CodeMemoryOperation]] || CodeMemoryOperation&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4, R5 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R6 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the backing memory for a CodeMemory object into the current process.&lt;br /&gt;
&lt;br /&gt;
For [[#CodeMemoryOperation|MapOwner]], memory permission must be RW-.&lt;br /&gt;
&lt;br /&gt;
For [[#CodeMemoryOperation|MapSlave]], memory permission must be R-- or R-X.&lt;br /&gt;
&lt;br /&gt;
Operations [[#CodeMemoryOperation|UnmapOwner/UnmapSlave]] unmap memory that was previously mapped this way.&lt;br /&gt;
&lt;br /&gt;
This allows one &amp;quot;secure JIT&amp;quot; process to map the code memory as RW-, and the other &amp;quot;slave&amp;quot; process to map it R-X.&lt;br /&gt;
&lt;br /&gt;
[5.0.0+] Error 0xE401 is now returned when the process owner of the Code memory object is the same as the current process.&lt;br /&gt;
&lt;br /&gt;
== SleepSystem ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || || &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReadWriteRegister ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || RegisterAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R0 || uint32_t || RwMask&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R1 || uint32_t || InValue&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || OutValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Read/write IO registers with a hardcoded whitelist. Input address is physical-address and must be aligned to 4.&lt;br /&gt;
&lt;br /&gt;
rw_mask is 0 for reading and 0xffffffff for writing. You can also write individual bits by using a mask value.&lt;br /&gt;
&lt;br /&gt;
You can only write to registers inside physical pages 0x70019000 (MC), 0x7001C000 (MC0), 0x7001D000 (MC1), and they all share the same whitelist.&lt;br /&gt;
&lt;br /&gt;
The whitelist is same for writing as for reading.&lt;br /&gt;
&lt;br /&gt;
The whitelist is:&lt;br /&gt;
&lt;br /&gt;
0x054, 0x090, 0x094, 0x098, 0x09c, 0x0a0, 0x0a4, 0x0a8, 0x0ac, 0x0b0, 0x0b4, 0x0b8, 0x0bc, 0x0c0, 0x0c4, 0x0c8, 0x0d0, 0x0d4, 0x0d8, 0x0dc, 0x0e0, 0x100, 0x108, 0x10c, 0x118, 0x11c, 0x124, 0x128, 0x12c, 0x130, 0x134, 0x138, 0x13c, 0x158, 0x15c, 0x164, 0x168, 0x16c, 0x170, 0x174, 0x178, 0x17c, 0x200, 0x204, 0x2e4, 0x2e8, 0x2ec, 0x2f4, 0x2f8, 0x310, 0x314, 0x320, 0x328, 0x344, 0x348, 0x370, 0x374, 0x37c, 0x380, 0x390, 0x394, 0x398, 0x3ac, 0x3b8, 0x3bc, 0x3c0, 0x3c4, 0x3d8, 0x3e8, 0x41c, 0x420, 0x424, 0x428, 0x42c, 0x430, 0x44c, 0x47c, 0x480, 0x484, 0x50c, 0x554, 0x558, 0x55c, 0x670, 0x674, 0x690, 0x694, 0x698, 0x69c, 0x6a0, 0x6a4, 0x6c0, 0x6c4, 0x6f0, 0x6f4, 0x960, 0x970, 0x974, 0xa20, 0xa24, 0xb88, 0xb8c, 0xbc4, 0xbc8, 0xbcc, 0xbd0, 0xbd4, 0xbd8, 0xbdc, 0xbe0, 0xbe4, 0xbe8, 0xbec, 0xc00, 0xc5c, 0xcac&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] Whitelist was extended with 0x4c4, 0x4c8, 0x4cc, 0x584, 0x588, 0x58c.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] The IO registers in range 0x7000E400 (PMC) size 0xC00 skip the whitelist, and do a TrustZone call using [[SMC#ReadWriteRegister|ReadWriteRegister]].&lt;br /&gt;
&lt;br /&gt;
[4.0.0+] Access to the Memory Controller (0x70019000) also uses smcReadWriteRegister.&lt;br /&gt;
&lt;br /&gt;
Here is the whitelist imposed by that SMC, relative to the start of the PMC registers:&lt;br /&gt;
&lt;br /&gt;
0x000, 0x00c, 0x010, 0x014, 0x01c, 0x020, 0x02c, 0x030, 0x034, 0x038, 0x03c, 0x040, 0x044, 0x048, 0x0dc, 0x0e0, 0x0e4, 0x160, 0x164, 0x168, 0x170, 0x1a8, 0x1b8, 0x1bc, 0x1c0, 0x1c4, 0x1c8, 0x2b4, 0x2d4, 0x440, 0x4d8&lt;br /&gt;
&lt;br /&gt;
Here is the whitelist imposed by the SMC [[SMC#ReadWriteRegister|ReadWriteRegister]] (checked in addition to the whitelist in the ReadWriteRegister SVC), relative to the start of the MC registers:&lt;br /&gt;
&lt;br /&gt;
0x000, 0x004, 0x008, 0x00C, 0x010, 0x01C, 0x020, 0x030, 0x034, 0x050, 0x054, 0x090, 0x094, 0x098, 0x09C, 0x0A0, 0x0A4, 0x0A8, 0x0AC, 0x0B0, 0x0B4, 0x0B8, 0x0BC, 0x0C0, 0x0C4, 0x0C8, 0x0D0, 0x0D4, 0x0D8, 0x0DC, 0x0E0, 0x100, 0x108, 0x10C, 0x118, 0x11C, 0x124, 0x128, 0x12C, 0x130, 0x134, 0x138, 0x13C, 0x158, 0x15C, 0x164, 0x168, 0x16C, 0x170, 0x174, 0x178, 0x17C, 0x200, 0x204, 0x238, 0x240, 0x244, 0x250, 0x254, 0x258, 0x264, 0x268, 0x26C, 0x270, 0x274, 0x280, 0x284, 0x288, 0x28C, 0x294, 0x2E4, 0x2E8, 0x2EC, 0x2F4, 0x2F8, 0x310, 0x314, 0x320, 0x328, 0x344, 0x348, 0x370, 0x374, 0x37C, 0x380, 0x390, 0x394, 0x398, 0x3AC, 0x3B8, 0x3BC, 0x3C0, 0x3C4, 0x3D8, 0x3E8, 0x41C, 0x420, 0x424, 0x428, 0x42C, 0x430, 0x44C, 0x47C, 0x480, 0x484, 0x4C4, 0x4C8, 0x4CC, 0x50C, 0x554, 0x558, 0x55C, 0x584, 0x588, 0x58C, 0x670, 0x674, 0x690, 0x694, 0x698, 0x69C, 0x6A0, 0x6A4, 0x6C0, 0x6C4, 0x6F0, 0x6F4, 0x960, 0x970, 0x974, 0x9B8, 0xA20, 0xA24, 0xA88, 0xA94, 0xA98, 0xA9C, 0xAA0, 0xAA4, 0xAA8, 0xAAC, 0xAB0, 0xAB4, 0xAB8, 0xABC, 0xAC0, 0xAC4, 0xAC8, 0xACC, 0xAD0, 0xAD4, 0xAD8, 0xADC, 0xAE0, 0xB88, 0xB8C, 0xBC4, 0xBC8, 0xBCC, 0xBD0, 0xBD4, 0xBD8, 0xBDC, 0xBE0, 0xBE4, 0xBE8, 0xBEC, 0xC00, 0xC5C, 0xCAC&lt;br /&gt;
&lt;br /&gt;
== SetProcessActivity ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || [[#ProcessActivity]] || ProcessActivity&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#MemoryPermission]] || LocalMemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || RemoteMemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other perm can be used to enforce permission 1, 3, or 0x10000000 if don&#039;t care.&lt;br /&gt;
&lt;br /&gt;
Allocates memory from the current process&#039; pool partition.&lt;br /&gt;
&lt;br /&gt;
== MapTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You must pass same size and permissions as given in [[#CreateTransferMemory]], otherwise error.&lt;br /&gt;
&lt;br /&gt;
== UnmapTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size must match size given in map syscall, otherwise there&#039;s an invalid-size error.&lt;br /&gt;
&lt;br /&gt;
== CreateInterruptEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#Interrupt]] || Interrupt&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#InterruptType]] || InterruptType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ReadableEvent&amp;gt; || ReadableEventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an event handle for the given IRQ number. Waiting on this handle will wait until the IRQ is triggered. The InterruptType argument configures the triggering. If it is 0, the IRQ is active HIGH level sensitive, if it is 1 it is rising-edge sensitive.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF001:&#039;&#039;&#039; Flags was &amp;gt; 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF201:&#039;&#039;&#039; IRQ above 0x3FF or outside the [[NPDM#Kernel_Access_Control|IRQ access mask]] was given.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; A SlabHeap was exhausted (too many interrupts created).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF401:&#039;&#039;&#039; IRQ already has an event registered.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD201:&#039;&#039;&#039; The handle table is full. Try closing some handles.&lt;br /&gt;
&lt;br /&gt;
== QueryPhysicalAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || VirtualAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]]|| Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || PhysicalMemoryInfoAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || PhysicalMemoryInfoBaseAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || PhysicalMemoryInfoSize&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Queries the physical address of a virtual address. Will always fetch the lowest page-aligned mapping that contains the provided physical address.&lt;br /&gt;
&lt;br /&gt;
The returned PhysicalMemoryInfoBaseAddress is the virtual address of that page-aligned mapping, while PhysicalMemoryInfoAddress is the physical address of that page. PhysicalMemoryInfoSize is the amount of continuous physical memory in that mapping.&lt;br /&gt;
&lt;br /&gt;
== QueryIoMapping ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || IoAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R0 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1 || void* || VirtualAddress&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns a virtual address mapped to a given IO range.&lt;br /&gt;
&lt;br /&gt;
== CreateDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || DeviceAddressSpaceStartAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R0, R1 || uint64_t || DeviceAddressSpaceEndAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a virtual address space for binding device address spaces and returns a handle.&lt;br /&gt;
&lt;br /&gt;
StartAddr is normally set to 0 and EndAddr is normally set to 0xFFFFFFFF.&lt;br /&gt;
&lt;br /&gt;
== AttachDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#DeviceName]] || DeviceName&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a device address space to a [[#DeviceName|device]].&lt;br /&gt;
&lt;br /&gt;
== DetachDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#DeviceName]] || DeviceName&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches a device address space from a [[#DeviceName|device]].&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpaceByForce ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps an attached device address space to an userspace address.&lt;br /&gt;
&lt;br /&gt;
Address is the userspace destination address, while DeviceAddressSpaceAddress is the source address between DeviceAddressSpaceStartAddress and DeviceAddressSpaceEndAddress (passed to [[#CreateDeviceAddressSpace]]).&lt;br /&gt;
&lt;br /&gt;
The userspace destination address must have the [[SVC#MemoryState|FlagCanDeviceMap]] bit set. Bit [[SVC#MemoryAttribute|DeviceShared]] will be set after mapping.&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpaceAligned ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps an attached device address space to an userspace address.&lt;br /&gt;
&lt;br /&gt;
Same as [[#MapDeviceAddressSpaceByForce]], but the userspace destination address must have the [[SVC#MemoryState|FlagCanAlignedDeviceMap]] bit set instead.&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X5 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W6 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1 || uint64_t || Size&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== UnmapDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps an attached device address space from an userspace address.&lt;br /&gt;
&lt;br /&gt;
== InvalidateProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== StoreProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DebugActiveProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || ProcessId&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== BreakDebugProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== TerminateDebugProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#DebugEventInfo]]* || DebugEventInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || uint32_t || [[#ContinueDebugFlags]] ([1.0.0-2.3.0] [[#ContinueDebugFlagsOld]])&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 ([1.0.0-2.3.0] R2, R3) || uint64_t* ([1.0.0-2.3.0] uint64_t)|| ThreadIdList ([1.0.0-2.3.0] ThreadId)&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || uint64_t || [3.0.0+] NumThreadIds&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maximum NumThreadIds is 64. 0 means &amp;quot;all threads&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The process has been resumed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid debug handle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xf401:&#039;&#039;&#039; Process has debug events queued or is already running.&lt;br /&gt;
&lt;br /&gt;
== GetProcessList ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || uint64_t* || ProcessIdBuffer&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || ProcessIdBufferSize&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || NumProcesses&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fills the provided array with the pids of currently living processes. A process &amp;quot;lives&amp;quot; so long as it is currently running or a handle to it still exists.&lt;br /&gt;
&lt;br /&gt;
It returns the total number of processes currently alive. If this number is bigger than the size of ProcessIdBuffer, the user won&#039;t have all the pids.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xd401:&#039;&#039;&#039; The provided buffer is outside the process address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe601:&#039;&#039;&#039; copyToUser failed. The provided buffer is not user-accessible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xee01:&#039;&#039;&#039; The provided buffer size is too big. Max value is 0xFFFFFFF.&lt;br /&gt;
&lt;br /&gt;
== GetThreadList ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || uint64_t* || ThreadIdBuffer&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || ThreadIdBufferSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || NumThreads&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugThreadContext ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R4 || uint32_t || [[#ThreadContextFlags]]&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetDebugThreadContext ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R4 || uint32_t || [[#ThreadContextFlags]]&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== QueryDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReadDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || MemoryBufferAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WriteDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || MemoryBufferAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetHardwareBreakPoint ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || [[#HardwareBreakPointRegisterName]] || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || Flags&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets one of the AArch64 hardware breakpoints. The nintendo switch has 6 hardware breakpoints, and 4 hardware watchpoints. The syscall has two behaviors depending on the value of HardwareBreakPointRegisterName:&lt;br /&gt;
&lt;br /&gt;
If HardwareBreakPointRegisterName &amp;lt; 0x10, then it sets one of the AArch64 hardware breakpoints. Flags will go to DBGBCRn_EL1, and value to DBGBVRn_EL1. The only flags the user is allowed to set are those in the bitmask 0x7F01E1. Furthermore, the kernel will or it with 0x4004, in order to set various security flags to guarantee the watchpoints only triggers for code in EL0. If the user asks for a Breakpoint Type of ContextIDR match, the kernel shall use the given DebugHandle to set DBGBVRn_EL1 to the ContextID of the debugged process.&lt;br /&gt;
&lt;br /&gt;
If HardwareBreakPointRegisterName is between 0x10 and 0x20 (exclusive), then it sets one of the AArch64 hardware watchpoints. Flags will go to DBGWCRn_EL1, and the value to DBGWVRn_EL1. The only flags the user is allowed to set are those in the bitmask 0xFF0F1FF9. Furthermore, the kernel will or it with 0x104004. This will set various security flags, and set the watchpoint type to be a Linked Watchpoint. This means that you need to link it to a Linked ContextIDR breakpoint. Check the ARM documentation for more information.&lt;br /&gt;
&lt;br /&gt;
Note that HardwareBreakPointRegisterName 0 to 4 match only to Virtual Address, while HardwareBreakPointRegisterName 5 and 6 match against either Virtual Address, ContextID, or VMID. As such, if you are configuring a breakpoint to link for a watchpoint, make sure you use hardware_breakpoint_id 5 or 6.&lt;br /&gt;
&lt;br /&gt;
For more documentation for hardware breakpoints, check out the AArch64 documentation for the [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0488h/way1382455558968.html DBGBCRn_EL1 register] and the [http://infocenter.arm.com/help/topic/com.arm.doc.ddi0488h/way1382455560629.html DBGWCRn_EL1 register]&lt;br /&gt;
&lt;br /&gt;
== GetDebugThreadParam ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R1 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R3 || [[#DebugThreadParam]] || DebugThreadParam&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || Out0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || R3 || uint32_t || Out1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetSystemInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#SystemInfoType]] || SystemInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || SystemInfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || SystemInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreatePort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || MaxSessions&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || bool || IsLight&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R0 || uint64_t || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Port&amp;gt; || ServerPortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || R2 || Handle&amp;lt;Port&amp;gt; || ClientPortHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ManageNamedPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || char* || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || int32_t || MaxSessions&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Port&amp;gt; || ServerPortHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ConnectToPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Port&amp;gt; || ClientPortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetProcessMemoryPermission ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Addr&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R5 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sets the memory permissions for the specified memory with the supplied process handle.&lt;br /&gt;
&lt;br /&gt;
This throws an error(0xD801) when the input perm is &amp;gt;0x5, hence -WX and RWX are not allowed.&lt;br /&gt;
&lt;br /&gt;
== MapProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the src address from the supplied process handle into the current process.&lt;br /&gt;
&lt;br /&gt;
This allows mapping code and rodata with RW- permission.&lt;br /&gt;
&lt;br /&gt;
== UnmapProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps what was mapped by [[#MapProcessMemory]].&lt;br /&gt;
&lt;br /&gt;
== QueryProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R1, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equivalent to [[#QueryMemory]] except takes a process handle.&lt;br /&gt;
&lt;br /&gt;
== MapProcessCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R5, R6 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a process handle, and maps normal heap in that process as executable code in that process. Used when loading NROs. This does not support using the current-process handle alias.&lt;br /&gt;
&lt;br /&gt;
== UnmapProcessCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R5, R6 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps what was mapped by [[#MapProcessCodeMemory]].&lt;br /&gt;
&lt;br /&gt;
== CreateProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#CreateProcessParameter]]* || CreateProcessParameter&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint32_t* || Capabilities&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || int32_t || CapabilitiesNum&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a [[#CreateProcessParameter]] as input.&lt;br /&gt;
Capabilities points to an array of [[NPDM#Kernel_Access_Control|kernel capabilities]].&lt;br /&gt;
CapabilitiesNum is a number of capabilities in the Capabilities array (number of element, not number of bytes).&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Attempted to map more code pages than available in address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Provided CodeAddr is invalid (make sure it&#039;s in range?)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; The resource handle passed is invalid.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE601:&#039;&#039;&#039; Attempt to copy procinfo from user-supplied pointer failed. Attempt to copy capabilities_num from user-supplied pointer failed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE801:&#039;&#039;&#039; Attempted to create a 32-bit process with a 36-bit address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF001:&#039;&#039;&#039; Unused bits are set in mmuflags. Unknown address space type used.&lt;br /&gt;
&lt;br /&gt;
== StartProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || int32_t || MainThreadPriority&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || DefaultCpuId&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || uint64_t || MainThreadStackSize&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== TerminateProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetProcessInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R2 || [[#ProcessInfoType]] || ProcessInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || [[#ProcessState]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns an enum with value 0-7.&lt;br /&gt;
&lt;br /&gt;
== CreateResourceLimit ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetResourceLimitLimitValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || int64_t || LimitValue&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CallSecureMonitor ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || uint64_t || [[SMC#Secure_Monitor_calls|FunctionId]]&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1-X7 || R1-R7 || uint64_t || SMC arguments&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[SMC#Result|Result]] || SMC result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1-X7 || R1-R7 || uint64_t || SMC output&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes in a SMC function ID in X0, and arguments for that SMC function in X1-X7.&lt;br /&gt;
&lt;br /&gt;
Passing an invalid SMC function ID or calling from a core other than core 3 will result in a secure monitor panic.&lt;br /&gt;
&lt;br /&gt;
The kernel parses bits 9-15 in the passed SMC function ID (per the ARM SMC calling convention), and when set uses as an indicator to translate a pointer in the associated register (X1-X7) to a physical address. The kernel will translate any address mapped as R-W, other addresses (R--, R-X, or invalid pointers) will be translated as 0/NULL.&lt;br /&gt;
&lt;br /&gt;
Output is returned raw from the Secure Monitor; X0 will be the untranslated SMC result and X1-X7 will contain other SMC output (or be unchanged, depending on the SMC).&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
[2.0.0+] Exactly 6 debug SVCs require that [[SPL_services#GetConfig|IsDebugMode]] is non-zero. Error 0x4201 is returned otherwise.&lt;br /&gt;
* BreakDebugProcess&lt;br /&gt;
* ContinueDebugEvent&lt;br /&gt;
* WriteDebugProcessMemory&lt;br /&gt;
* SetDebugThreadContext&lt;br /&gt;
* TerminateDebugProcess&lt;br /&gt;
* SetHardwareBreakPoint&lt;br /&gt;
&lt;br /&gt;
DebugActiveProcess stops execution of the target process, the normal method for resuming it requires ContinueDebugEvent(see above). Closing the debug handle also results in execution being resumed.&lt;br /&gt;
&lt;br /&gt;
= Enum/Structures =&lt;br /&gt;
== InfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Handle type || InfoType || InfoSubType || Description&lt;br /&gt;
|-&lt;br /&gt;
| Process || 0 || 0 || CoreMask&lt;br /&gt;
|-&lt;br /&gt;
| Process || 1 || 0 || PriorityMask&lt;br /&gt;
|-&lt;br /&gt;
| Process || 2 || 0 || AliasRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 3 || 0 || AliasRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 4 || 0 || HeapRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 5 || 0 || HeapRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 6 || 0 || TotalMemorySize. Total memory available(free+used).&lt;br /&gt;
|-&lt;br /&gt;
| Process || 7 || 0 || UsedMemorySize. Total used size of codebin memory + main-thread stack + allocated heap.&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 8 || 0 || DebuggerAttached&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 9 || 0 || ResourceLimit&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 10 || -1, {current coreid} || IdleTickCount&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 11 || 0-3 || RandomEntropy. Used to seed usermode PRNGs.&lt;br /&gt;
|-&lt;br /&gt;
| Process || 12 || 0 || [2.0.0+] AslrRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 13 || 0 || [2.0.0+] AslrRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 14 || 0 || [2.0.0+] StackRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 15 || 0 || [2.0.0+] StackRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 16 || 0 || [3.0.0+] SystemResourceSizeTotal&lt;br /&gt;
|-&lt;br /&gt;
| Process || 17 || 0 || [3.0.0+] SystemResourceSizeUsed&lt;br /&gt;
|-&lt;br /&gt;
| Process || 18 || 0 || [3.0.0+] ProgramId&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 19 || 0 || [4.0.0-4.1.0] InitialProcessIdRange_LowerBound&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 19 || 1 || [4.0.0-4.1.0] InitialProcessIdRange_UpperBound&lt;br /&gt;
|-&lt;br /&gt;
| Process || 20 || 0 || [5.0.0+] UserExceptionContextAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 21 || 0 || [6.0.0+] TotalNonSystemMemorySize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 22 || 0 || [6.0.0+] UsedNonSystemMemorySize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 23 || 0 || [9.0.0+] IsApplication&lt;br /&gt;
|-&lt;br /&gt;
| Process || 24 || 0 || [11.0.0+] FreeThreadCount&lt;br /&gt;
|-&lt;br /&gt;
| Thread  || 25 ([1.0.0-12.1.0] 0xF0000002) || 0-3, -1 || ThreadTickCount. When 0-3 are passed, gets specific core CPU ticks spent on thread. When -1 is passed, gets total CPU ticks spent on thread.&lt;br /&gt;
|-&lt;br /&gt;
| Process || 26 || 0 || [14.0.0+] IsSvcPermitted&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SystemInfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Handle type || SystemInfoType || SystemInfoSubType || Description&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 0 || TotalPhysicalMemorySize_Application&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 1 || TotalPhysicalMemorySize_Applet&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 2 || TotalPhysicalMemorySize_System&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 3 || TotalPhysicalMemorySize_SystemUnsafe&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 0 || UsedPhysicalMemorySize_Application&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 1 || UsedPhysicalMemorySize_Applet&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 2 || UsedPhysicalMemorySize_System&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 3 || UsedPhysicalMemorySize_SystemUnsafe&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 2 || 0 || InitialProcessIdRange_LowerBound&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 2 || 1 || InitialProcessIdRange_UpperBound&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ThreadContextFlags ==&lt;br /&gt;
Bitfield of one of more of these:&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || General-purpose registers || If in 64-bit mode, GPRs 0–28 will be read/written. If in 32-bit mode, GPRs 0–12 will be read/written.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || Control registers || Reads/writes the FP, LR, PC, SP, PSTATE, and TPIDR registers.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || Floating-point registers || Reads/writes the floating-point vector registers.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 8 || Floating-point control registers || Reads/writes the FPCR and FPSR registers.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== DeviceName ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AFI&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AVPC&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DC&lt;br /&gt;
|-&lt;br /&gt;
| 3 || DCB&lt;br /&gt;
|-&lt;br /&gt;
| 4 || HC&lt;br /&gt;
|-&lt;br /&gt;
| 5 || HDA&lt;br /&gt;
|-&lt;br /&gt;
| 6 || ISP2&lt;br /&gt;
|-&lt;br /&gt;
| 7 || MSENCNVENC&lt;br /&gt;
|-&lt;br /&gt;
| 8 || NV&lt;br /&gt;
|-&lt;br /&gt;
| 9 || NV2&lt;br /&gt;
|-&lt;br /&gt;
| 10 || PPCS&lt;br /&gt;
|-&lt;br /&gt;
| 11 || SATA&lt;br /&gt;
|-&lt;br /&gt;
| 12 || VI&lt;br /&gt;
|-&lt;br /&gt;
| 13 || VIC&lt;br /&gt;
|-&lt;br /&gt;
| 14 || XUSB_HOST&lt;br /&gt;
|-&lt;br /&gt;
| 15 || XUSB_DEV&lt;br /&gt;
|-&lt;br /&gt;
| 16 || TSEC&lt;br /&gt;
|-&lt;br /&gt;
| 17 || PPCS1&lt;br /&gt;
|-&lt;br /&gt;
| 18 || DC1&lt;br /&gt;
|-&lt;br /&gt;
| 19 || SDMMC1A&lt;br /&gt;
|-&lt;br /&gt;
| 20 || SDMMC2A&lt;br /&gt;
|-&lt;br /&gt;
| 21 || SDMMC3A&lt;br /&gt;
|-&lt;br /&gt;
| 22 || SDMMC4A&lt;br /&gt;
|-&lt;br /&gt;
| 23 || ISP2B&lt;br /&gt;
|-&lt;br /&gt;
| 24 || GPU&lt;br /&gt;
|-&lt;br /&gt;
| 25 || GPUB&lt;br /&gt;
|-&lt;br /&gt;
| 26 || PPCS2&lt;br /&gt;
|-&lt;br /&gt;
| 27 || NVDEC&lt;br /&gt;
|-&lt;br /&gt;
| 28 || APE&lt;br /&gt;
|-&lt;br /&gt;
| 29 || SE&lt;br /&gt;
|-&lt;br /&gt;
| 30 || NVJPG&lt;br /&gt;
|-&lt;br /&gt;
| 31 || HC1&lt;br /&gt;
|-&lt;br /&gt;
| 32 || SE1&lt;br /&gt;
|-&lt;br /&gt;
| 33 || AXIAP&lt;br /&gt;
|-&lt;br /&gt;
| 34 || ETR&lt;br /&gt;
|-&lt;br /&gt;
| 35 || TSECB&lt;br /&gt;
|-&lt;br /&gt;
| 36 || TSEC1&lt;br /&gt;
|-&lt;br /&gt;
| 37 || TSECB1&lt;br /&gt;
|-&lt;br /&gt;
| 38 || NVDEC1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CodeMemoryOperation ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || MapOwner&lt;br /&gt;
|-&lt;br /&gt;
| 1 || MapSlave&lt;br /&gt;
|-&lt;br /&gt;
| 2 || UnmapOwner&lt;br /&gt;
|-&lt;br /&gt;
| 3 || UnmapSlave&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== LimitableResource ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || PhysicalMemoryMax || Bytes of memory a process may allocate.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ThreadCountMax || Amount of threads a process can create.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || EventCountMax || Amount of events a process can create through [[#CreateEvent]] or [[#SendAsyncRequestWithUserBuffer]].&lt;br /&gt;
|-&lt;br /&gt;
| 3 || TransferMemoryCountMax || Amount of TransferMemory a process can create through [[#CreateTransferMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 4 || SessionCountMax || Amount of session a process can create through [[#CreateSession]], [[#ConnectToPort]] or [[#ConnectToNamedPort]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= ThreadActivity =&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || None&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Runnable&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessActivity ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || None&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Runnable&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessInfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || [[#ProcessState|ProcessState]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessState ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name || Notes&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Created ||&lt;br /&gt;
|-&lt;br /&gt;
| 1 || CreatedAttached ||&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Started ||&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Crashed || Processes will not enter this state unless they were created with [[#CreateProcessParameter|EnableDebug]].&lt;br /&gt;
|-&lt;br /&gt;
| 4 || StartedAttached ||&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Exiting ||&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Exited ||&lt;br /&gt;
|-&lt;br /&gt;
| 7 || DebugSuspended ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== DebugThreadParam ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || DynamicPriority&lt;br /&gt;
|-&lt;br /&gt;
| 1 || SchedulingStatus&lt;br /&gt;
|-&lt;br /&gt;
| 2 || PreferredCpuCore&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCpuCore&lt;br /&gt;
|-&lt;br /&gt;
| 4 || AffinityMask&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Dynamic priority: output in out2&lt;br /&gt;
&lt;br /&gt;
Scheduling status: out1 contains bit0: is debug-suspended, bit1: is user-suspended ([[#SetThreadActivity]] 1 or [[#SetProcessActivity]] 1).&lt;br /&gt;
Out2 contains {suspended, idle, running, terminating} =&amp;gt; {5, 0, 1, 4}&lt;br /&gt;
&lt;br /&gt;
PreferredCpuCore: output in out2&lt;br /&gt;
&lt;br /&gt;
CurrentCpuCore: output in out2&lt;br /&gt;
&lt;br /&gt;
AffinityMask: output in out1&lt;br /&gt;
&lt;br /&gt;
== CreateProcessParameter ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 12 || || ProcessName (doesn&#039;t have to be null-terminated)&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || 4 || || ProcessCategory (0: regular title, 1: kernel built-in)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 8 || || TitleId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || 8 || || CodeAddr&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 4 || || CodeNumPages&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 4 || || Flags&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit0 || Is64BitInstruction&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit3-1 || [[#AddressSpaceType]]&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit4 || [2.0.0+] EnableDebug&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit5 || EnableAslr&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit6 || IsApplication&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit7 || [4.0.0] UseSecureMemory&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit10-7 || [5.0.0+] MemoryRegion (0 = Application, 1 = Applet, 2 = SecureSystem, 3 = NonSecureSystem)&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit11 || [7.0.0+] OptimizeMemoryAllocation (only allowed in combination with IsApplication)&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || 4 || || ResourceLimitHandle (can be zero)&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || 4 || || [3.0.0+] SystemResourceNumPages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On [1.0.0] there&#039;s only one MemoryRegion.&lt;br /&gt;
&lt;br /&gt;
On [2.0.0-4.0.0] MemoryRegion is 1 for built-ins and 0 for rest.&lt;br /&gt;
&lt;br /&gt;
On [5.0.0] MemoryRegion is specified in CreateProcessArgs. There are now 4 pool partitions.&lt;br /&gt;
&lt;br /&gt;
On [5.0.0] (maybe lower?) a zero ResourceLimitHandle defaults to sysmodule limits and 0x12300000 bytes of memory.&lt;br /&gt;
&lt;br /&gt;
The PersonalMmHeap are allocated as follows:&lt;br /&gt;
* For the application, normal insecure pool is used. Carveout 5 is used to provide protection.&lt;br /&gt;
* For the applet, a pre-allocated secure pool segment of size 0x400000 is used.&lt;br /&gt;
* For sysmodules, secure pool is allocated.&lt;br /&gt;
&lt;br /&gt;
=== AddressSpaceType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Type || Name || Width || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AddressSpace32Bit || 32 ||&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AddressSpace64BitOld || 36 ||&lt;br /&gt;
|-&lt;br /&gt;
| 2 || AddressSpace32BitNoReserved || 32 || Appears to be missing map region [?]&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [2.0.0+] AddressSpace64Bit || 39 ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryInfo ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8 || BaseAddress&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 8 || Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 4 || [[#MemoryType]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x14 || 4 || [[#MemoryAttribute]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || 4 || [[#MemoryPermission]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C || 4 || IpcRefCount&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 4 || DeviceRefCount&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 4 || Padding: always zero&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryPermission ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Read || Can be set by [[#SetMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Write || Can be set by [[#SetMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Execute || Can be set by [[#SetProcessMemoryPermission]] and [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 28 || DontCare ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryAttribute ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Locked || Used by MapMemory, as an async IPC user buffer.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || IpcLocked || True when IpcRefCount &amp;gt; 0.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DeviceShared || True when DeviceRefCount &amp;gt; 0.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Uncached || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryState ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Description || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 7-0 || [[#MemoryType]] || &lt;br /&gt;
|-&lt;br /&gt;
| 8 || [[#SetMemoryPermission|FlagCanReprotect]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 9 || FlagCanDebug || Allows using [[#WriteDebugProcessMemory]] on segments mapped read-only.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || FlagCanUseIpc || Allows sending this region as an IPC A/B/W buffer with flags=0.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || FlagCanUseNonDeviceIpc || Allows sending this region as an IPC A/B/W buffer with flags=1.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || FlagCanUseNonSecureIpc || Allows sending this region as an IPC A/B/W buffer with flags=3.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || FlagMapped ||&lt;br /&gt;
|-&lt;br /&gt;
| 14 || [[#SetProcessMemoryPermission|FlagCode]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 15 || [[#MapMemory|FlagCanAlias]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 16 || [[#MapProcessCodeMemory|FlagCanCodeAlias]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 17 || [[#CreateTransferMemory|FlagCanTransfer]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 18 || [[#QueryPhysicalAddress|FlagCanQueryPhysical]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 19 || [[#MapDeviceAddressSpace|FlagCanDeviceMap]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 20 || [[#MapDeviceAddressSpaceAligned|FlagCanAlignedDeviceMap]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 21 || [[#SendSyncRequestWithUserBuffer|FlagCanIpcUserBuffer]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 22 || FlagReferenceCounted || The physical memory blocks backing this region are refcounted.&lt;br /&gt;
|-&lt;br /&gt;
| 23 || [[#MapProcessMemory|FlagCanMapProcess]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 24 || [[#SetMemoryAttribute|FlagCanChangeAttribute]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 25 || [4.0.0+] [[#CreateCodeMemory|FlagCanCodeMemory]] ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== MemoryType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000000 || Free ||&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002001 || Io || Mapped by kernel capability parsing in [[#CreateProcess]]. &lt;br /&gt;
|-&lt;br /&gt;
| 0x00042002 || Static || Mapped by kernel capability parsing in [[#CreateProcess]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00DC7E03 || Code || Mapped during [[#CreateProcess]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x01FEBD04&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x03FEBD04&lt;br /&gt;
|| CodeData || Transition from 0xDC7E03 performed by [[#SetProcessMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
0x017EBD05&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x037EBD05&lt;br /&gt;
|| Normal || Mapped using [[#SetHeapSize]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402006 || Shared || Mapped using [[#MapSharedMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00482907 || [1.0.0] Alias || Mapped using [[#MapMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00DD7E08 || AliasCode || Mapped using [[#MapProcessCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x01FFBD09&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x03FFBD09&lt;br /&gt;
|| AliasCodeData || Transition from 0xDD7E08 performed by [[#SetProcessMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3C0A || [[IPC_Marshalling|Ipc]] || IPC buffers with descriptor flags=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3C0B || Stack || Mapped using [[#MapMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x0040200C || [[Thread Local Storage|ThreadLocal]] || Mapped during [[#CreateThread]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x015C3C0D || Transfered || Mapped using [[#MapTransferMemory]] when the owning process has perm=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C380E || SharedTransfered || Mapped using [[#MapTransferMemory]] when the owning process has perm!=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0040380F || SharedCode || Mapped using [[#MapProcessMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Inaccessible ||&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3811 || [[IPC_Marshalling|NonSecureIpc]] || IPC buffers with descriptor flags=1.&lt;br /&gt;
|-&lt;br /&gt;
| 0x004C2812 || [[IPC_Marshalling|NonDeviceIpc]] || IPC buffers with descriptor flags=3.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002013 || Kernel || Mapped in kernel during [[#CreateThread]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402214 || [4.0.0+] GeneratedCode || Mapped in kernel during [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402015 || [4.0.0+] CodeOut || Mapped in kernel during [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002016 || [13.0.0+] Coverage || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ArbitrationType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || WaitIfLessThan&lt;br /&gt;
|-&lt;br /&gt;
| 0x1 || DecrementAndWaitIfLessThan&lt;br /&gt;
|-&lt;br /&gt;
| 0x2 || WaitIfEqual&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SignalType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || Signal&lt;br /&gt;
|-&lt;br /&gt;
| 0x1 || SignalAndIncrementIfEqual&lt;br /&gt;
|-&lt;br /&gt;
| 0x2 || SignalAndModifyBasedOnWaitingThreadCountIfEqual&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugFlagsOld ==&lt;br /&gt;
[1.0.0-2.3.0]&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || IgnoreException (note: ResumeAllThreads or debug-suspended-thread-id needed)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || SwallowException&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || ResumeAllThreads&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugFlags ==&lt;br /&gt;
[3.0.0+]&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || IgnoreException (note: doesn&#039;t need to be set in the same call than Resume)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || DontCatchExceptions&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || Resume&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 8 || IgnoreOtherThreadsExceptions&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
IgnoreExceptionsOfOthers is like IgnoreException but acts on all threads that aren&#039;t in the input list. The affected threads are resumed.&lt;br /&gt;
&lt;br /&gt;
Only one of of Resume and IgnoreOtherThreadsExceptions can be set at a time.&lt;br /&gt;
&lt;br /&gt;
If the input number of threads is 0, this means &amp;quot;all threads&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== DebugEventInfo ==&lt;br /&gt;
The below table is for the Aarch64 version of the system call. For A32, all u64 fields but title/process/thread id are actually u32, making the structure 0x28-byte-big (0x40 for a64).&lt;br /&gt;
&lt;br /&gt;
Size: 0x40&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || u32 || EventType&lt;br /&gt;
|-&lt;br /&gt;
| 4 || u32 || Flags (bit0: NeedsContinue)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || u64 || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || || PerTypeSpecifics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AttachProcess specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u64 || TitleId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || ProcessId&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || char[12] || ProcessName&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || u32 || MmuFlags&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || u64 || [5.0.0+] UserExceptionContextAddr&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AttachThread specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u64 || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || TlsPtr&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u64 || Entrypoint&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Exit specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u32|| Type (0=PausedThread, 1=RunningThread, 2=ExitedProcess, 3=TerminatedProcess)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Exception specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u32 || ExceptionType&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || FaultRegister&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || || PerExceptionSpecifics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== DebugEventType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AttachProcess&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AttachThread&lt;br /&gt;
|-&lt;br /&gt;
| 2 || ExitProcess&lt;br /&gt;
|-&lt;br /&gt;
| 3 || ExitThread&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Exception&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== DebugExceptionType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Trap (*)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || InstructionAbort&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DataAbortMisc (**)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || PcSpAlignmentFault&lt;br /&gt;
|-&lt;br /&gt;
| 4 || DebuggerAttached&lt;br /&gt;
|-&lt;br /&gt;
| 5 || BreakPoint&lt;br /&gt;
|-&lt;br /&gt;
| 6 || UserBreak&lt;br /&gt;
|-&lt;br /&gt;
| 7 || DebuggerBreak&lt;br /&gt;
|-&lt;br /&gt;
| 8 || BadSvcId&lt;br /&gt;
|-&lt;br /&gt;
| 9 || [2.0.0+] SError&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; Undefined instructions, software breakpoints, some other traps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; Data aborts, FP traps, and everything else that doesn&#039;t belong to any of the above.&lt;br /&gt;
&lt;br /&gt;
Trap specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || Opcode&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
BreakPoint specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || IsWatchpoint&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
UserBreak specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || Info0&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || u64 || Info1&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || u64 || Info2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
BadSvcId specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || SvcId&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Exception handling =&lt;br /&gt;
First of all, a function that might be called by synchronous exception handler and that is called by the SError handler fetches the exception info, adjusts PC, panics on exceptions taken from EL1, then dispatches the exception.&lt;br /&gt;
&lt;br /&gt;
The dispatcher has two mutually exclusive exception reporting methods:&lt;br /&gt;
* by storing information at the start of the process&#039;s TLS memregion (TPIDRRO_EL0) and jumping back to the crt0&lt;br /&gt;
* by using KDebug&lt;br /&gt;
&lt;br /&gt;
KDebug dispatching is used when at least one of the following conditions are met:&lt;br /&gt;
* SMC ConfigItem KernelMemConfig bit 1 is NOT set (it isn&#039;t on retail), unless: this is a software or hardware breakpoint, or a watchpoint, or [4.0.0+?] the process is attached and this is a Google PNaCl trap instruction (see LLVM source)&lt;br /&gt;
* FAR doesn&#039;t point to a valid address in mapped-readable CodeStatic memory (i.e. this is the case for NRO and JIT memory) or this is one of the following exceptions (it particular, that doesn&#039;t include FP exceptions occurring in CodeStatic memory):&lt;br /&gt;
** Uncategorized&lt;br /&gt;
** IllegalState&lt;br /&gt;
** SupervisorCallA32&lt;br /&gt;
** SupervisorCallA64&lt;br /&gt;
** PCAlignment&lt;br /&gt;
** SPAlignment&lt;br /&gt;
** SError&lt;br /&gt;
** BreakpointLowerEl&lt;br /&gt;
** SoftwareStepLowerEl (note: no way set single-step flag; not parsed)&lt;br /&gt;
** WatchpointLowerEl&lt;br /&gt;
** SoftwareBreakpointA32 (note: not parsed)&lt;br /&gt;
** SoftwareBreakpointA64 (note: not parsed)&lt;br /&gt;
    &lt;br /&gt;
In all other cases the userland-handled exception path is taken.&lt;br /&gt;
&lt;br /&gt;
KDebug path:&lt;br /&gt;
&lt;br /&gt;
If the process is attached, the exception is reported to the KDebug. If the thread was continued using flag IgnoreExceptions, it returns from the exception as if nothing happened.&lt;br /&gt;
&lt;br /&gt;
If the latter is not the case, or if the process isn&#039;t attached, proceed to [2.0.0+] crash reporting (or in [1.0.0] just terminate the process): &lt;br /&gt;
if EnableDebug is set, and depending on the process state (more than one crash per process isn&#039;t permitted) it may signal itself with ProcessState_Crashed so that PM asks NS to start creport so that creport attaches to it and reports the crashes. Otherwise, just terminate.&lt;br /&gt;
&lt;br /&gt;
Userland reporting path and [[#ReturnFromException]]:&lt;br /&gt;
&lt;br /&gt;
TLS region start (A64):&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x148 || Exception stack&lt;br /&gt;
|-&lt;br /&gt;
| 0x148 || 0x78 || ExceptionFrameA64&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
ExceptionFrameA64:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x48 (8*9) || GPRs 0..8.&lt;br /&gt;
|-&lt;br /&gt;
| 0x48 || 0x8 || lr&lt;br /&gt;
|-&lt;br /&gt;
| 0x50 || 0x8 || sp&lt;br /&gt;
|-&lt;br /&gt;
| 0x58 || 0x8 || pc (elr_el1)&lt;br /&gt;
|-&lt;br /&gt;
| 0x60 || 0x4 || pstate &amp;amp; 0xFF0FFE20&lt;br /&gt;
|-&lt;br /&gt;
| 0x64 || 0x4 || afsr0&lt;br /&gt;
|-&lt;br /&gt;
| 0x68 || 0x4 || afsr1&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C || 0x4 || esr&lt;br /&gt;
|-&lt;br /&gt;
| 0x70 || 0x8 || far&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TLS region start (A32):&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x178 || Exception stack&lt;br /&gt;
|-&lt;br /&gt;
| 0x148 || 0x44 || ExceptionFrameA32&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
ExceptionFrameA32:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x20 (8*4) || GPRs 0..7.&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 0x4 || sp&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 0x4 || lr&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || 0x4 || pc (elr_el1)&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || 0x4 || tpidr_el0 = 1&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || 0x4 || cpsr &amp;amp; 0xFF0FFE20&lt;br /&gt;
|-&lt;br /&gt;
| 0x34 || 0x4 || afsr0&lt;br /&gt;
|-&lt;br /&gt;
| 0x38 || 0x4 || afsr1&lt;br /&gt;
|-&lt;br /&gt;
| 0x3C || 0x4 || esr&lt;br /&gt;
|-&lt;br /&gt;
| 0x40 || 0x4 || far&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In that case, after storing the regs in the TLS, the exception handler returns to the application&#039;s crt0 (entrypoint), with X0=&amp;lt;error description code&amp;gt; (see below) and X1=SP=frame=&amp;lt;stack top&amp;gt; (see above)&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Desc. code || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 0x100 || Instruction abort&lt;br /&gt;
|-&lt;br /&gt;
| 0x102 || Misaligned PC&lt;br /&gt;
|-&lt;br /&gt;
| 0x103 || Misaligned SP&lt;br /&gt;
|-&lt;br /&gt;
| 0x106 || [2.0.0+] SError&lt;br /&gt;
|-&lt;br /&gt;
| 0x301 || Bad SVC&lt;br /&gt;
|-&lt;br /&gt;
| 0x104 || Uncategorized, CP15RTTrap, CP15RRTTrap, CP14RTTrap, CP14RRTTrap, IllegalState, SystemRegisterTrap&lt;br /&gt;
|-&lt;br /&gt;
| 0x101 || None of the above, EC &amp;lt;= 0x34 and not a breakpoint&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(During normal app boot the process is invoked with X0=0 and X1=main_thread_handle. The crt0 of retail apps determines whether to boot normally or handle an exception if X0 is set to 0 or not)&lt;br /&gt;
&lt;br /&gt;
The application is supposed to promptly update the contents of elr_el1 to a user handler (and any other regs it sees fit) and call [[#ReturnFromException]] (error code) to call that handler. The latter is then expected to promptly abort the program.&lt;br /&gt;
&lt;br /&gt;
[[#ReturnFromException]] updates the contents of the kernel stack frame with what the user provided in the TLS structure, sets TPIDR_EL0 to 1, then:&lt;br /&gt;
* if the provided error code is 0, gracefully pivots and returns from exception&lt;br /&gt;
* if it is not, replays the exception and pass it to the KDebug (see above). One can pass 0x10001 to prevent process termination. If the process is attached, this also prevents crash-collection/termination (different from the exception handler behavior)&lt;br /&gt;
&lt;br /&gt;
If an exception occurs from the above user handler, the entire exception handling process will repeat with the new exception.&lt;br /&gt;
&lt;br /&gt;
Note that if a thread that wasn&#039;t faulting calls [[#ReturnFromException]], it signals an &amp;quot;invalid syscall&amp;quot; exception&lt;br /&gt;
&lt;br /&gt;
Note that [[SMC|IsDebugMode]] is not used during exception-handling, except for enabling printing a message to UART-A. This UART code causes a system-hang on retail (likely due to a loop that doesn&#039;t exit). This printing doesn&#039;t seem to run when the process is attached for debugging?&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=SVC&amp;diff=11748</id>
		<title>SVC</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=SVC&amp;diff=11748"/>
		<updated>2022-06-08T18:41:05Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: Fix a typo: a 32-bit register can&amp;#039;t be used to pass a pointer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
= System calls =&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! ID || Return Type || Name || Arguments&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Result || [[#SetHeapSize|SetHeapSize]] || uintptr_t *out_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Result || [[#SetMemoryPermission|SetMemoryPermission]] || uintptr_t address, size_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Result || [[#SetMemoryAttribute|SetMemoryAttribute]] || uintptr_t address, size_t size, uint32_t mask, uint32_t attr&lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Result || [[#MapMemory|MapMemory]] || uintptr_t dst_address, uintptr_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Result || [[#UnmapMemory|UnmapMemory]] || uintptr_t dst_address, uintptr_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Result || [[#QueryMemory|QueryMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || void || [[#ExitProcess|ExitProcess]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Result || [[#CreateThread|CreateThread]] || Handle *out_handle, ThreadFunc func, uintptr_t arg, uintptr_t stack_bottom, int32_t priority, int32_t core_id&lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Result || [[#StartThread|StartThread]] || Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || void || [[#ExitThread|ExitThread]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || void || [[#SleepThread|SleepThread]] || int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Result || [[#GetThreadPriority|GetThreadPriority]] || int32_t *out_priority, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Result || [[#SetThreadPriority|SetThreadPriority]] || Handle thread_handle, int32_t priority&lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Result || [[#GetThreadCoreMask|GetThreadCoreMask]] || int32_t *out_core_id, uint64_t *out_affinity_mask, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0F || Result || [[#SetThreadCoreMask|SetThreadCoreMask]] || Handle thread_handle, int32_t core_id, uint64_t affinity_mask&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || int32_t || [[#GetCurrentProcessorNumber|GetCurrentProcessorNumber]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x11 || Result || [[#SignalEvent|SignalEvent]] || Handle event_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x12 || Result || [[#ClearEvent|ClearEvent]] || Handle event_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x13 || Result || [[#MapSharedMemory|MapSharedMemory]] || Handle shmem_handle, uintptr_t address, size_t size, MemoryPermission map_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x14 || Result || [[#UnmapSharedMemory|UnmapSharedMemory]] || Handle shmem_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x15 || Result || [[#CreateTransferMemory|CreateTransferMemory]] || Handle *out_handle, uintptr_t address, size_t size, MemoryPermission map_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x16 || Result || [[#CloseHandle|CloseHandle]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x17 || Result || [[#ResetSignal|ResetSignal]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || Result || [[#WaitSynchronization|WaitSynchronization]] || int32_t *out_index, const Handle *handles, int32_t numHandles, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x19 || Result || [[#CancelSynchronization|CancelSynchronization]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x1A || Result || [[#ArbitrateLock|ArbitrateLock]] || Handle thread_handle, uintptr_t address, uint32_t tag&lt;br /&gt;
|-&lt;br /&gt;
| 0x1B || Result || [[#ArbitrateUnlock|ArbitrateUnlock]] || uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C || Result || [[#WaitProcessWideKeyAtomic|WaitProcessWideKeyAtomic]] || uintptr_t address, uintptr_t cv_key, uint32_t tag, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x1D || void || [[#SignalProcessWideKey|SignalProcessWideKey]] || uintptr_t cv_key, int32_t count&lt;br /&gt;
|-&lt;br /&gt;
| 0x1E || int64_t || [[#GetSystemTick|GetSystemTick]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x1F || Result || [[#ConnectToNamedPort|ConnectToNamedPort]] || Handle *out_handle, const char *name&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || Result || [[#SendSyncRequestLight|SendSyncRequestLight]] || Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Result || [[#SendSyncRequest|SendSyncRequest]] || Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x22 || Result || [[#SendSyncRequestWithUserBuffer|SendSyncRequestWithUserBuffer]] || uintptr_t message_buffer, size_t message_buffer_size, Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x23 || Result || [[#SendAsyncRequestWithUserBuffer|SendAsyncRequestWithUserBuffer]] || Handle *out_event_handle, uintptr_t message_buffer, size_t message_buffer_size, Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || Result || [[#GetProcessId|GetProcessId]] || uint64_t *out_process_id, Handle process_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x25 || Result || [[#GetThreadId|GetThreadId]] || uint64_t *out_thread_id, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x26 || void || [[#Break|Break]] || BreakReason break_reason, uintptr_t arg, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x27 || Result || [[#OutputDebugString|OutputDebugString]] || const char *debug_str, size_t len&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || void || [[#ReturnFromException|ReturnFromException]] || Result result&lt;br /&gt;
|-&lt;br /&gt;
| 0x29 || Result || [[#GetInfo|GetInfo]] || uint64_t *out, InfoType info_type, Handle handle, uint64_t info_subtype&lt;br /&gt;
|-&lt;br /&gt;
| 0x2A || void || [[#FlushEntireDataCache|FlushEntireDataCache]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x2B || Result || [[#FlushDataCache|FlushDataCache]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [3.0.0+] 0x2C  || Result || [[#MapPhysicalMemory|MapPhysicalMemory]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [3.0.0+] 0x2D  || Result || [[#UnmapPhysicalMemory|UnmapPhysicalMemory]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0-5.1.0] 0x2E  || Result || GetFutureThreadInfo || arch::LastThreadContext *out_context, uintptr_t *out_tls_address, uint32_t *out_flags, int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| [6.0.0+] 0x2E  || Result || [[#GetDebugFutureThreadInfo|GetDebugFutureThreadInfo]] || arch::LastThreadContext *out_context, uint64_t *thread_id, Handle debug_handle, int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x2F || Result || [[#GetLastThreadInfo|GetLastThreadInfo]] || arch::LastThreadContext *out_context, uintptr_t *out_tls_address, uint32_t *out_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || Result || [[#GetResourceLimitLimitValue|GetResourceLimitLimitValue]] || int64_t *out_limit_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|-&lt;br /&gt;
| 0x31 || Result || [[#GetResourceLimitCurrentValue|GetResourceLimitCurrentValue]] || int64_t *out_current_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|-&lt;br /&gt;
| 0x32 || Result || [[#SetThreadActivity|SetThreadActivity]] || Handle thread_handle, ThreadActivity thread_activity&lt;br /&gt;
|-&lt;br /&gt;
| 0x33  || Result || [[#GetThreadContext3|GetThreadContext3]] || ThreadContext *out_context, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x34 || Result || [[#WaitForAddress|WaitForAddress]] || uintptr_t address, ArbitrationType arb_type, int32_t value, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x35 || Result || [[#SignalToAddress|SignalToAddress]] || uintptr_t address, SignalType signal_type, int32_t value, int32_t count&lt;br /&gt;
|-&lt;br /&gt;
| [8.0.0+] 0x36 || void || [[#SynchronizePreemptionState|SynchronizePreemptionState]] || &lt;br /&gt;
|-&lt;br /&gt;
| [11.0.0+] 0x37 || Result || [[#GetResourceLimitPeakValue|GetResourceLimitPeakValue]] || int64_t *out_peak_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [13.0.0+] 0x39 || Result || CreateIoPool || Handle *out_handle, IoPoolType which_pool&lt;br /&gt;
|-&lt;br /&gt;
| [13.0.0+] 0x3A || Result || CreateIoRegion || Handle *out_handle, Handle io_pool, PhysicalAddress physical_address, size_t size, MemoryMapping mapping, MemoryPermission perm&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [1.0.0-3.0.2] 0x3C || void || [[#DumpInfo|DumpInfo]] || DumpInfoType dump_info_type, uint64_t arg&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x3C || void || [[#KernelDebug|KernelDebug]] || KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x3D || void || [[#ChangeKernelTraceState|ChangeKernelTraceState]] || KernelTraceState kern_trace_state&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| 0x40 || Result || [[#CreateSession|CreateSession]] || Handle *out_server_session_handle, Handle *out_client_session_handle, bool is_light, uintptr_t name&lt;br /&gt;
|-&lt;br /&gt;
| 0x41 || Result || [[#AcceptSession|AcceptSession]] || Handle *out_handle, Handle port&lt;br /&gt;
|-&lt;br /&gt;
| 0x42 || Result || [[#ReplyAndReceiveLight|ReplyAndReceiveLight]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x43 || Result || [[#ReplyAndReceive|ReplyAndReceive]] || int32_t *out_index, const Handle *handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x44 || Result || [[#ReplyAndReceiveWithUserBuffer|ReplyAndReceiveWithUserBuffer]] || int32_t *out_index, uintptr_t message_buffer, size_t message_buffer_size, const Handle *handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x45 || Result || [[#CreateEvent|CreateEvent]] || Handle *out_write_handle, Handle *out_read_handle&lt;br /&gt;
|-&lt;br /&gt;
| [13.0.0+] 0x46 || Result || MapIoRegion || Handle io_region, uintptr_t address, size_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| [13.0.0+] 0x47 || Result || UnmapIoRegion || Handle io_region, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x48 || Result || [[#MapPhysicalMemoryUnsafe|MapPhysicalMemoryUnsafe]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x49 || Result || [[#UnmapPhysicalMemoryUnsafe|UnmapPhysicalMemoryUnsafe]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x4A || Result || [[#SetUnsafeLimit|SetUnsafeLimit]] || size_t limit&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x4B || Result || [[#CreateCodeMemory|CreateCodeMemory]] || Handle *out_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x4C || Result || [[#ControlCodeMemory|ControlCodeMemory]] || Handle code_memory_handle, CodeMemoryOperation operation, uint64_t address, uint64_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x4D || void || [[#SleepSystem|SleepSystem]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x4E || Result || [[#ReadWriteRegister|ReadWriteRegister]] || uint32_t *out_value, PhysicalAddress address, uint32_t mask, uint32_t value&lt;br /&gt;
|-&lt;br /&gt;
| 0x4F || Result || [[#SetProcessActivity|SetProcessActivity]] || Handle process_handle, ProcessActivity process_activity&lt;br /&gt;
|-&lt;br /&gt;
| 0x50 || Result || [[#CreateSharedMemory|CreateSharedMemory]] || Handle *out_handle, size_t size, MemoryPermission owner_perm, MemoryPermission remote_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x51 || Result || [[#MapTransferMemory|MapTransferMemory]] || Handle trmem_handle, uintptr_t address, size_t size, MemoryPermission owner_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x52 || Result || [[#UnmapTransferMemory|UnmapTransferMemory]] || Handle trmem_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x53 || Result || [[#CreateInterruptEvent|CreateInterruptEvent]] || Handle *out_read_handle, int32_t interrupt_id, InterruptType interrupt_type&lt;br /&gt;
|-&lt;br /&gt;
| 0x54 || Result || [[#QueryPhysicalAddress|QueryPhysicalAddress]] || arch::PhysicalMemoryInfo *out_info, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x55 || Result || [[#QueryIoMapping|QueryIoMapping]] || uintptr_t *out_address, [10.0.0+] size_t *out_size, PhysicalAddress physical_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x56 || Result || [[#CreateDeviceAddressSpace|CreateDeviceAddressSpace]] || Handle *out_handle, uint64_t das_address, uint64_t das_size&lt;br /&gt;
|-&lt;br /&gt;
| 0x57 || Result || [[#AttachDeviceAddressSpace|AttachDeviceAddressSpace]] || DeviceName device_name, Handle das_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x58 || Result || [[#DetachDeviceAddressSpace|DetachDeviceAddressSpace]] || DeviceName device_name, Handle das_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x59 || Result || [[#MapDeviceAddressSpaceByForce|MapDeviceAddressSpaceByForce]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x5A || Result || [[#MapDeviceAddressSpaceAligned|MapDeviceAddressSpaceAligned]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0-12.1.0] 0x5B || Result || [[#MapDeviceAddressSpace|MapDeviceAddressSpace]] || size_t *out_mapped_size, Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x5C || Result || [[#UnmapDeviceAddressSpace|UnmapDeviceAddressSpace]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address&lt;br /&gt;
|-&lt;br /&gt;
| 0x5D || Result || [[#InvalidateProcessDataCache|InvalidateProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x5E || Result || [[#StoreProcessDataCache|StoreProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x5F || Result || [[#FlushProcessDataCache|FlushProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x60 || Result || [[#DebugActiveProcess|DebugActiveProcess]] || Handle *out_handle, uint64_t process_id&lt;br /&gt;
|-&lt;br /&gt;
| 0x61 || Result || [[#BreakDebugProcess|BreakDebugProcess]] || Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x62 || Result || [[#TerminateDebugProcess|TerminateDebugProcess]] || Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x63 || Result || [[#GetDebugEvent|GetDebugEvent]] || arch::DebugEventInfo *out_info, Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x64 || Result || [[#ContinueDebugEvent|ContinueDebugEvent]] || Handle debug_handle, uint32_t flags, const uint64_t *thread_ids, int32_t num_thread_ids&lt;br /&gt;
|-&lt;br /&gt;
| 0x65 || Result || [[#GetProcessList|GetProcessList]] || int32_t *out_num_processes, uint64_t *out_process_ids, int32_t max_out_count&lt;br /&gt;
|-&lt;br /&gt;
| 0x66 || Result || [[#GetThreadList|GetThreadList]] || int32_t *out_num_threads, uint64_t *out_thread_ids, int32_t max_out_count, Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x67 || Result || [[#GetDebugThreadContext|GetDebugThreadContext]] || ThreadContext *out_context, Handle debug_handle, uint64_t thread_id, uint32_t context_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x68 || Result || [[#SetDebugThreadContext|SetDebugThreadContext]] || Handle debug_handle, uint64_t thread_id, const ThreadContext *context, uint32_t context_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x69 || Result || [[#QueryDebugProcessMemory|QueryDebugProcessMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, Handle process_handle, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x6A || Result || [[#ReadDebugProcessMemory|ReadDebugProcessMemory]] || uintptr_t buffer, Handle debug_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x6B || Result || [[#WriteDebugProcessMemory|WriteDebugProcessMemory]] || Handle debug_handle, uintptr_t buffer, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C || Result || [[#SetHardwareBreakPoint|SetHardwareBreakPoint]] || HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value&lt;br /&gt;
|-&lt;br /&gt;
| 0x6D || Result || [[#GetDebugThreadParam|GetDebugThreadParam]] || uint64_t *out_64, uint32_t *out_32, Handle debug_handle, uint64_t thread_id, DebugThreadParam param&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [5.0.0+] 0x6F || Result || [[#GetSystemInfo|GetSystemInfo]] || uint64_t *out, SystemInfoType info_type, Handle handle, uint64_t info_subtype&lt;br /&gt;
|-&lt;br /&gt;
| 0x70 || Result || [[#CreatePort|CreatePort]] || Handle *out_server_handle, Handle *out_client_handle, int32_t max_sessions, bool is_light, uintptr_t name&lt;br /&gt;
|-&lt;br /&gt;
| 0x71 || Result || [[#ManageNamedPort|ManageNamedPort]] || Handle *out_server_handle, const char *name, int32_t max_sessions&lt;br /&gt;
|-&lt;br /&gt;
| 0x72 || Result || [[#ConnectToPort|ConnectToPort]] || Handle *out_handle, Handle port&lt;br /&gt;
|-&lt;br /&gt;
| 0x73 || Result || [[#SetProcessMemoryPermission|SetProcessMemoryPermission]] || Handle process_handle, uint64_t address, uint64_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x74 || Result || [[#MapProcessMemory|MapProcessMemory]] || uintptr_t dst_address, Handle process_handle, uint64_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x75 || Result || [[#UnmapProcessMemory|UnmapProcessMemory]] || uintptr_t dst_address, Handle process_handle, uint64_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x76 || Result || [[#QueryProcessMemory|QueryProcessMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, Handle process_handle, uint64_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x77 || Result || [[#MapProcessCodeMemory|MapProcessCodeMemory]] || Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x78 || Result || [[#UnmapProcessCodeMemory|UnmapProcessCodeMemory]] || Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x79 || Result || [[#CreateProcess|CreateProcess]] || Handle *out_handle, const arch::CreateProcessParameter *parameters, const uint32_t *caps, int32_t num_caps&lt;br /&gt;
|-&lt;br /&gt;
| 0x7A || Result || [[#StartProcess|StartProcess]] || Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size&lt;br /&gt;
|-&lt;br /&gt;
| 0x7B || Result || [[#TerminateProcess|TerminateProcess]] || Handle process_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x7C || Result || [[#GetProcessInfo|GetProcessInfo]] || int64_t *out_info, Handle process_handle, ProcessInfoType info_type&lt;br /&gt;
|-&lt;br /&gt;
| 0x7D || Result || [[#CreateResourceLimit|CreateResourceLimit]] || Handle *out_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x7E || Result || [[#SetResourceLimitLimitValue|SetResourceLimitLimitValue]] || Handle resource_limit_handle, LimitableResource which, int64_t limit_value&lt;br /&gt;
|-&lt;br /&gt;
| 0x7F || void || [[#CallSecureMonitor|CallSecureMonitor]] || SecureMonitorArguments *args&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SetHeapSize ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || uint32_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || void* || HeapAddress&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the process heap to a given Size. It can both extend and shrink the heap.&lt;br /&gt;
&lt;br /&gt;
Size must be a multiple of 0x200000 (2MB).&lt;br /&gt;
&lt;br /&gt;
On success, the heap base-address (which is fixed by kernel, aslr&#039;d, and always in the Heap memory region) is written to HeapAddress.&lt;br /&gt;
&lt;br /&gt;
Uses current process pool partition. The memory allocated counts towards the caller&#039;s process Memory ResourceLimit.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] Size must be less than or equal to 4GB.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Invalid size passed. It&#039;s either bigger than 4GB, or misaligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD001:&#039;&#039;&#039; Size is bigger than the Heap Region size.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; KMemoryBlockAllocator slab allocator exhausted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The memory region is in an invalid state. Likely because a mapping was made in the heap region.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0x10801:&#039;&#039;&#039; Memory resource limit reached.&lt;br /&gt;
&lt;br /&gt;
== SetMemoryPermission ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes permission of page-aligned memory region.&lt;br /&gt;
&lt;br /&gt;
Bit2 of permission (exec) is not allowed. Setting write-only is not allowed either (bit1).&lt;br /&gt;
&lt;br /&gt;
This can be used to move back and forth between ---, r-- and rw-.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The memory region was reprotected.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Unaligned address specified.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Unaligned or zero size specified.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The provided memory region does not fall within the userland address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD801:&#039;&#039;&#039; Invalid permission specified. Valid permissions are ---, r-- and rw-.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The provided memory region was in an invalid state. The region must have the [[#MemoryState|FlagCanReprotect]] state, and must not have the [[#MemoryAttribute|Locked]] or [[#MemoryAttribute|Uncached]] attributes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; Kernel resource exhausted.&lt;br /&gt;
&lt;br /&gt;
== SetMemoryAttribute ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || uint32_t || Mask&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes attribute of page-aligned memory region. The only allowed combination of Value and Mask is 0x8, which means only bit3 in [[#MemoryAttribute]] can be set or cleared.&lt;br /&gt;
&lt;br /&gt;
This is used to turn on/off caching for a given memory area. Useful when talking to devices such as the GPU.&lt;br /&gt;
&lt;br /&gt;
What happens &amp;quot;under the hood&amp;quot; is the &amp;quot;Memory Attribute Indirection Register&amp;quot; index is changed from 2 to 3 in the MMU descriptor.&lt;br /&gt;
&lt;br /&gt;
== MapMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps a memory range into a different range.&lt;br /&gt;
&lt;br /&gt;
Mainly used for adding guard pages around stack.&lt;br /&gt;
&lt;br /&gt;
Source range gets reprotected to --- (it can no longer be accessed), and bit0 is set in the source [[#MemoryAttribute]].&lt;br /&gt;
&lt;br /&gt;
[1.0.0] This could be used to map into either the Alias Region or the Stack region.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] This can only be used to map into the Stack region.&lt;br /&gt;
&lt;br /&gt;
Code can get the range of the Alias region from [[#GetInfo]] id0=2,3, and on 2.0.0+ the range of the Stack region via [[#GetInfo]] id0=14, 15 (on 1.0.0, the Stack region had hardcoded limits).&lt;br /&gt;
&lt;br /&gt;
When mapped into the Alias region, the mapped memory will have state 0x482907.&lt;br /&gt;
&lt;br /&gt;
When mapped into the Stack region, the mapped memory will have state 0x5C3C0B.&lt;br /&gt;
&lt;br /&gt;
== UnmapMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps a region that was previously mapped with [[#MapMemory]].&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to unmap ranges partially, you don&#039;t need to unmap the entire range &amp;quot;in one go&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The srcaddr/dstaddr must match what was given when the pages were originally mapped.&lt;br /&gt;
&lt;br /&gt;
== QueryMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Queries information about an address. Will always fetch the lowest page-aligned mapping that contains the provided address.&lt;br /&gt;
&lt;br /&gt;
Outputs a [[#MemoryInfo]] struct.&lt;br /&gt;
&lt;br /&gt;
== ExitProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the current process.&lt;br /&gt;
&lt;br /&gt;
== CreateThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void(*)(void*) || Entry&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || void* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || void* || StackTop&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R0 || int32_t || Priority&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R4 || int32_t || ProcessorId&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a thread in the current process.&lt;br /&gt;
&lt;br /&gt;
ProcessorId must be 0,1,2,3 or -2, where -2 uses the default CpuId for process.&lt;br /&gt;
&lt;br /&gt;
== StartThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None ||  ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the thread for the provided handle.&lt;br /&gt;
&lt;br /&gt;
== ExitThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the current thread.&lt;br /&gt;
&lt;br /&gt;
== SleepThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0, R1 || uint64_t || Nanoseconds&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sleeps for a specified amount of time, or yields the thread.&lt;br /&gt;
&lt;br /&gt;
Setting nanoseconds to 0, -1, or -2 indicates a yielding type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Yielding without core migration&lt;br /&gt;
|-&lt;br /&gt;
| -1 || Yielding with core migration&lt;br /&gt;
|-&lt;br /&gt;
| -2 || Yielding to any other thread&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadPriority ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1|| Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || int32_t || Priority&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets the priority of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== SetThreadPriority ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0|| Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1|| int32_t || Priority&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the priority of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
Priority is a number 0-0x3F. Lower value means higher priority.&lt;br /&gt;
&lt;br /&gt;
== GetThreadCoreMask ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || int32_t || CoreMask0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || R2, R3 || uint64_t || CoreMask1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets the affinity mask of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== SetThreadCoreMask ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || int32_t || CoreMask0&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || uint64_t || CoreMask1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the affinity mask of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== GetCurrentProcessorNumber ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || uint32_t || CpuId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets which cpu is executing the current thread.&lt;br /&gt;
&lt;br /&gt;
CpuId is an integer in the range 0-3.&lt;br /&gt;
&lt;br /&gt;
== SignalEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;WritableEvent&amp;gt; || EventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Puts the given event in the signaled state.&lt;br /&gt;
&lt;br /&gt;
Will wake up any thread currently waiting on this event. Can potentially trigger a reschedule.&lt;br /&gt;
&lt;br /&gt;
Any calls to [[#WaitSynchronization]] on this handle will return immediately, until the event&#039;s signaled state is reset.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. Event is now in signaled state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; Invalid handle. The handle either does not exist, or is not a WritableEvent.&lt;br /&gt;
&lt;br /&gt;
== ClearEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;WritableEvent&amp;gt; or Handle&amp;lt;ReadableEvent&amp;gt; || EventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes the given event out of the signaled state.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success, the event is now in the not-signaled state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; Invalid handle. The handle either does not exist, or is not a ReadableEvent nor a WritableEvent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; The handle was not in a signaled state.&lt;br /&gt;
&lt;br /&gt;
== MapSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the block supplied by the handle. The required permissions are different for the process that created the handle and all other processes.&lt;br /&gt;
&lt;br /&gt;
Increases reference count for the KSharedMemory object. Thus in order to release the memory associated with the object, all handles to it must be closed and all mappings must be unmapped.&lt;br /&gt;
&lt;br /&gt;
== UnmapSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one reprotects the src block with perms you give it. It also sets bit0 into [[#MemoryAttribute]].&lt;br /&gt;
&lt;br /&gt;
Executable bit perm not allowed.&lt;br /&gt;
&lt;br /&gt;
Closing all handles automatically causes the bit0 in [[#MemoryAttribute]] to clear, and the permission to reset.&lt;br /&gt;
&lt;br /&gt;
== CloseHandle ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ResetSignal ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;ReadableEvent&amp;gt; or Handle&amp;lt;Process&amp;gt; || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resets the signal on the given handle, ensuring future calls to [[#WaitSynchronization]] on this handle will sleep until the handle is signaled again. If the handle is a ReadableEvent, this is equivalent to calling ClearEvent() on the handle.&lt;br /&gt;
&lt;br /&gt;
If the handle is a Process, it will clear the signaled state (which is set when the process changes [[#ProcessState]]. Once the process enters the Exited state, calling ResetSignal on the process will no longer have an effect (the process is permanently signaled), and the syscall will return 0xFA01.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The signal was reset.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; The handle is invalid or of the wrong type.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; The handle was not signaled, or the process is in exited state, causing it to be permanently signaled.&lt;br /&gt;
&lt;br /&gt;
== WaitSynchronization ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle* || HandlesPtr&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || HandlesNum&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || int64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint64_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Works with HandlesNum &amp;lt;= 0x40.&lt;br /&gt;
&lt;br /&gt;
When zero handles are passed, this will wait forever until either timeout or cancellation occurs.&lt;br /&gt;
&lt;br /&gt;
Does not accept 0xFFFF8001 or 0xFFFF8000 as handles.&lt;br /&gt;
&lt;br /&gt;
=== Object types ===&lt;br /&gt;
&#039;&#039;&#039;KDebug:&#039;&#039;&#039; signals when there is a new [[#DebugEventInfo|DebugEvent]] (retrievable via [[#GetDebugEvent]]).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KClientPort:&#039;&#039;&#039; signals when the number of sessions is less than the maximum allowed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KProcess:&#039;&#039;&#039; signals when the process undergoes a state change (retrievable via [[#GetProcessInfo]]).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KReadableEvent:&#039;&#039;&#039; signals when the event&#039;s corresponding KWritableEvent has been signaled via [[#SignalEvent]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KServerPort:&#039;&#039;&#039; signals when there is an incoming connection waiting to be [[#AcceptSession|accepted]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KServerSession:&#039;&#039;&#039; signals when there is an incoming message waiting to be [[#ReplyAndReceive|received]] or the pipe is closed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KThread:&#039;&#039;&#039; signals when the thread has exited.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. One of the objects was signaled before the timeout expired, or one of the objects is a Session with a closed remote. Handle index is updated to indicate which object signaled.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0x7601:&#039;&#039;&#039; Thread termination requested. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid handle. Returned when one of the handles passed is invalid. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe601:&#039;&#039;&#039; Invalid address. Returned when the handles pointer is not a readable address. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xea01:&#039;&#039;&#039; Timeout. Returned when no objects have been signaled within the timeout. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xec01:&#039;&#039;&#039; Interrupted. Returned when another thread uses [[#CancelSynchronization]] to cancel this thread. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xee01:&#039;&#039;&#039; Too many handles. Returned when the number of handles passed is &amp;gt; 0x40.&lt;br /&gt;
&lt;br /&gt;
== CancelSynchronization ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the referenced thread is currently in a synchronization call ([[#WaitSynchronization]], [[#ReplyAndReceive]] or [[#ReplyAndReceiveLight]]), that call will be interrupted and return 0xec01.&lt;br /&gt;
If that thread is not currently executing such a synchronization call, the next call to a synchronization call will return 0xec01.&lt;br /&gt;
&lt;br /&gt;
This doesn&#039;t take force-pause (activity/debug pause) into account.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The thread was either interrupted or has had its flag set.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid handle. The handle given was either invalid or not a thread handle.&lt;br /&gt;
&lt;br /&gt;
== ArbitrateLock ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || uint32_t || Tag&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;                                  &lt;br /&gt;
&lt;br /&gt;
== ArbitrateUnlock ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WaitProcessWideKeyAtomic ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || KeyAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void* || TagAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Tag&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || int64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SignalProcessWideKey ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || int32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetSystemTick ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0, R1 || uint64_t || Ticks&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the value of cntpct_el0.&lt;br /&gt;
&lt;br /&gt;
The frequency is 19200000 Hz (constant from official sw).&lt;br /&gt;
&lt;br /&gt;
Official sw reads cntpct_el0 directly from usermode without using this SVC. [[ExeFS|sdk-nso]] has this SVC, but it&#039;s not known to be called anywhere.&lt;br /&gt;
&lt;br /&gt;
== ConnectToNamedPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || char* || PortName&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequestLight ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequest ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequestWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size and Address must be 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xcc01:&#039;&#039;&#039; Address is not 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xca01:&#039;&#039;&#039; Size is not 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xce01:&#039;&#039;&#039; KSessionRequest allocation failed (unlikely) or pointer buffer size exceeded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Handles does not exist, or handle is not an instance of KClientSession.&lt;br /&gt;
&lt;br /&gt;
== SendAsyncRequestWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ReadableEvent&amp;gt; || EventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size and Address must be 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
== GetProcessId ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || ProcessId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadId ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || ThreadId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Break ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#BreakReason]] || BreakReason&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Info&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the process is attached, report the Break event. Then, if [[#ContinueDebugEvent]] didn&#039;t apply IgnoreException on the thread: if TPIDR_EL0 is 0, adjust ELR_EL1 to retry to svc instruction (and set TPIDR_EL0 to 1).&lt;br /&gt;
&lt;br /&gt;
Otherwise, if bit31 in reason isn&#039;t set, perform crash reporting (see Exception Handling section below), if it doesn&#039;t terminate the process adjust ELR_EL1 as well.&lt;br /&gt;
&lt;br /&gt;
Otherwise just return 0.&lt;br /&gt;
&lt;br /&gt;
== OutputDebugString ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || char* || String&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReturnFromException ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#InfoType]] || InfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || uint64_t || InfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || Info&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushEntireDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MapPhysicalMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Acts like [[#SetHeapSize]] except you can allocate heap at any address you&#039;d like.&lt;br /&gt;
&lt;br /&gt;
Uses current process pool partition.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Invalid size passed. It&#039;s either zero or not 4k-aligned&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Invalid address. (not 4k-aligned)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xDC01:&#039;&#039;&#039; Invalid memory range. It&#039;s either causes overflow, or does not fall into &amp;quot;reserved&amp;quot; address range (aka Alias). See AliasRegionAddress at [[#InfoType]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; Invalid state. (not enough SystemResource (see [[NPDM#SystemResourceSize]]))&lt;br /&gt;
&lt;br /&gt;
== UnmapPhysicalMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugFutureThreadInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R1 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || LastThreadContextParam0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || LastThreadContextParam1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || LastThreadContextParam2&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X4 || uint64_t || LastThreadContextParam3&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X5 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W6 || uint32_t ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetLastThreadInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || LastThreadContextParam0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || LastThreadContextParam1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || LastThreadContextParam2&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X4 || uint64_t || LastThreadContextParam3&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X5 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W6 || uint32_t ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitLimitValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || LimitValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitCurrentValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || CurrentValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetThreadActivity ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || [[#ThreadActivity]] || ThreadActivity&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadContext3 ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WaitForAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#ArbitrationType]] || ArbitrationType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SignalToAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#SignalType]] || SignalType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || uint32_t || NumToSignal&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0  || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SynchronizePreemptionState ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None ||  || &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitPeakValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || PeakValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DumpInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#DumpInfoType]] || DumpInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || DumpInfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
[4.0.0+] This function was removed and replaced by [[#KernelDebug]].&lt;br /&gt;
&lt;br /&gt;
== KernelDebug ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#KernelDebugType]] || KernelDebugType&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
== ChangeKernelTraceState ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#KernelTraceState]] || KernelTraceState&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
== CreateSession ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || bool || IsLight&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ServerSession&amp;gt; || ServerSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || Handle&amp;lt;ClientSession&amp;gt; || ClientSessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== AcceptSession ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Port&amp;gt; || PortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ServerSession&amp;gt; || ServerSessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0xf201:&#039;&#039;&#039; No session waiting to be accepted&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceiveLight ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Port&amp;gt; or Handle&amp;lt;ServerSession&amp;gt; || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceive ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle&amp;lt;Port&amp;gt;* or Handle&amp;lt;ServerSession&amp;gt;* || Handles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || NumHandles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || Handle&amp;lt;ServerSession&amp;gt; || ReplyTargetSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R0, R4 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If ReplyTargetSessionHandle is not zero, a reply from the TLS will be sent to that session.&lt;br /&gt;
Then it will wait until either of the passed sessions has an incoming message, is closed, a passed port has an incoming connection, or the timeout expires.&lt;br /&gt;
If there is an incoming message, it is copied to the TLS.&lt;br /&gt;
&lt;br /&gt;
If ReplyTargetSessionHandle is zero, the TLS should contain a blank message. If this message has a C descriptor, the buffer it points to will be used as the pointer buffer. See [[IPC_Marshalling#IPC_buffers]]. Note that a pointer buffer cannot be specified if ReplyTargetSessionHandle is not zero.&lt;br /&gt;
&lt;br /&gt;
After being validated, passed handles will be enumerated in order; even if a session has been closed, if one that appears earlier in the list has an incoming message, it will take priority and a result code of 0x0 will be returned.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. Either a session has an incoming message or a port has an incoming connection. HandleIndex is set appropriately.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xea01:&#039;&#039;&#039; Timeout. No handles were signalled before the timeout expired. HandleIndex is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xf601:&#039;&#039;&#039; Port remote dead. One of the sessions has been closed. HandleIndex is set appropriately.&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceiveWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || Handle&amp;lt;Port&amp;gt;* or Handle&amp;lt;ServerSession&amp;gt;* || Handles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R0 || uint32_t || NumHandles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R4 || Handle&amp;lt;ServerSession&amp;gt; || ReplyTargetSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X6 || R5, R6 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;WritableEvent&amp;gt; || WritableEventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || Handle&amp;lt;ReadableEvent&amp;gt; || ReadableEventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MapPhysicalMemoryUnsafe ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Same as [[#MapPhysicalMemory]] except it always uses pool partition 0.&lt;br /&gt;
&lt;br /&gt;
== UnmapPhysicalMemoryUnsafe ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetUnsafeLimit ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || uint64_t || Limit&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;CodeMemory&amp;gt; || CodeMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes an address range with backing memory to create the code memory object.&lt;br /&gt;
&lt;br /&gt;
The memory is initially memset to 0xFF after being locked.&lt;br /&gt;
&lt;br /&gt;
== ControlCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;CodeMemory&amp;gt; || CodeMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#CodeMemoryOperation]] || CodeMemoryOperation&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4, R5 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R6 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the backing memory for a CodeMemory object into the current process.&lt;br /&gt;
&lt;br /&gt;
For [[#CodeMemoryOperation|MapOwner]], memory permission must be RW-.&lt;br /&gt;
&lt;br /&gt;
For [[#CodeMemoryOperation|MapSlave]], memory permission must be R-- or R-X.&lt;br /&gt;
&lt;br /&gt;
Operations [[#CodeMemoryOperation|UnmapOwner/UnmapSlave]] unmap memory that was previously mapped this way.&lt;br /&gt;
&lt;br /&gt;
This allows one &amp;quot;secure JIT&amp;quot; process to map the code memory as RW-, and the other &amp;quot;slave&amp;quot; process to map it R-X.&lt;br /&gt;
&lt;br /&gt;
[5.0.0+] Error 0xE401 is now returned when the process owner of the Code memory object is the same as the current process.&lt;br /&gt;
&lt;br /&gt;
== SleepSystem ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || || &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReadWriteRegister ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || RegisterAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R0 || uint32_t || RwMask&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R1 || uint32_t || InValue&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || OutValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Read/write IO registers with a hardcoded whitelist. Input address is physical-address and must be aligned to 4.&lt;br /&gt;
&lt;br /&gt;
rw_mask is 0 for reading and 0xffffffff for writing. You can also write individual bits by using a mask value.&lt;br /&gt;
&lt;br /&gt;
You can only write to registers inside physical pages 0x70019000 (MC), 0x7001C000 (MC0), 0x7001D000 (MC1), and they all share the same whitelist.&lt;br /&gt;
&lt;br /&gt;
The whitelist is same for writing as for reading.&lt;br /&gt;
&lt;br /&gt;
The whitelist is:&lt;br /&gt;
&lt;br /&gt;
0x054, 0x090, 0x094, 0x098, 0x09c, 0x0a0, 0x0a4, 0x0a8, 0x0ac, 0x0b0, 0x0b4, 0x0b8, 0x0bc, 0x0c0, 0x0c4, 0x0c8, 0x0d0, 0x0d4, 0x0d8, 0x0dc, 0x0e0, 0x100, 0x108, 0x10c, 0x118, 0x11c, 0x124, 0x128, 0x12c, 0x130, 0x134, 0x138, 0x13c, 0x158, 0x15c, 0x164, 0x168, 0x16c, 0x170, 0x174, 0x178, 0x17c, 0x200, 0x204, 0x2e4, 0x2e8, 0x2ec, 0x2f4, 0x2f8, 0x310, 0x314, 0x320, 0x328, 0x344, 0x348, 0x370, 0x374, 0x37c, 0x380, 0x390, 0x394, 0x398, 0x3ac, 0x3b8, 0x3bc, 0x3c0, 0x3c4, 0x3d8, 0x3e8, 0x41c, 0x420, 0x424, 0x428, 0x42c, 0x430, 0x44c, 0x47c, 0x480, 0x484, 0x50c, 0x554, 0x558, 0x55c, 0x670, 0x674, 0x690, 0x694, 0x698, 0x69c, 0x6a0, 0x6a4, 0x6c0, 0x6c4, 0x6f0, 0x6f4, 0x960, 0x970, 0x974, 0xa20, 0xa24, 0xb88, 0xb8c, 0xbc4, 0xbc8, 0xbcc, 0xbd0, 0xbd4, 0xbd8, 0xbdc, 0xbe0, 0xbe4, 0xbe8, 0xbec, 0xc00, 0xc5c, 0xcac&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] Whitelist was extended with 0x4c4, 0x4c8, 0x4cc, 0x584, 0x588, 0x58c.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] The IO registers in range 0x7000E400 (PMC) size 0xC00 skip the whitelist, and do a TrustZone call using [[SMC#ReadWriteRegister|ReadWriteRegister]].&lt;br /&gt;
&lt;br /&gt;
[4.0.0+] Access to the Memory Controller (0x70019000) also uses smcReadWriteRegister.&lt;br /&gt;
&lt;br /&gt;
Here is the whitelist imposed by that SMC, relative to the start of the PMC registers:&lt;br /&gt;
&lt;br /&gt;
0x000, 0x00c, 0x010, 0x014, 0x01c, 0x020, 0x02c, 0x030, 0x034, 0x038, 0x03c, 0x040, 0x044, 0x048, 0x0dc, 0x0e0, 0x0e4, 0x160, 0x164, 0x168, 0x170, 0x1a8, 0x1b8, 0x1bc, 0x1c0, 0x1c4, 0x1c8, 0x2b4, 0x2d4, 0x440, 0x4d8&lt;br /&gt;
&lt;br /&gt;
Here is the whitelist imposed by the SMC [[SMC#ReadWriteRegister|ReadWriteRegister]] (checked in addition to the whitelist in the ReadWriteRegister SVC), relative to the start of the MC registers:&lt;br /&gt;
&lt;br /&gt;
0x000, 0x004, 0x008, 0x00C, 0x010, 0x01C, 0x020, 0x030, 0x034, 0x050, 0x054, 0x090, 0x094, 0x098, 0x09C, 0x0A0, 0x0A4, 0x0A8, 0x0AC, 0x0B0, 0x0B4, 0x0B8, 0x0BC, 0x0C0, 0x0C4, 0x0C8, 0x0D0, 0x0D4, 0x0D8, 0x0DC, 0x0E0, 0x100, 0x108, 0x10C, 0x118, 0x11C, 0x124, 0x128, 0x12C, 0x130, 0x134, 0x138, 0x13C, 0x158, 0x15C, 0x164, 0x168, 0x16C, 0x170, 0x174, 0x178, 0x17C, 0x200, 0x204, 0x238, 0x240, 0x244, 0x250, 0x254, 0x258, 0x264, 0x268, 0x26C, 0x270, 0x274, 0x280, 0x284, 0x288, 0x28C, 0x294, 0x2E4, 0x2E8, 0x2EC, 0x2F4, 0x2F8, 0x310, 0x314, 0x320, 0x328, 0x344, 0x348, 0x370, 0x374, 0x37C, 0x380, 0x390, 0x394, 0x398, 0x3AC, 0x3B8, 0x3BC, 0x3C0, 0x3C4, 0x3D8, 0x3E8, 0x41C, 0x420, 0x424, 0x428, 0x42C, 0x430, 0x44C, 0x47C, 0x480, 0x484, 0x4C4, 0x4C8, 0x4CC, 0x50C, 0x554, 0x558, 0x55C, 0x584, 0x588, 0x58C, 0x670, 0x674, 0x690, 0x694, 0x698, 0x69C, 0x6A0, 0x6A4, 0x6C0, 0x6C4, 0x6F0, 0x6F4, 0x960, 0x970, 0x974, 0x9B8, 0xA20, 0xA24, 0xA88, 0xA94, 0xA98, 0xA9C, 0xAA0, 0xAA4, 0xAA8, 0xAAC, 0xAB0, 0xAB4, 0xAB8, 0xABC, 0xAC0, 0xAC4, 0xAC8, 0xACC, 0xAD0, 0xAD4, 0xAD8, 0xADC, 0xAE0, 0xB88, 0xB8C, 0xBC4, 0xBC8, 0xBCC, 0xBD0, 0xBD4, 0xBD8, 0xBDC, 0xBE0, 0xBE4, 0xBE8, 0xBEC, 0xC00, 0xC5C, 0xCAC&lt;br /&gt;
&lt;br /&gt;
== SetProcessActivity ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || [[#ProcessActivity]] || ProcessActivity&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#MemoryPermission]] || LocalMemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || RemoteMemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other perm can be used to enforce permission 1, 3, or 0x10000000 if don&#039;t care.&lt;br /&gt;
&lt;br /&gt;
Allocates memory from the current process&#039; pool partition.&lt;br /&gt;
&lt;br /&gt;
== MapTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You must pass same size and permissions as given in [[#CreateTransferMemory]], otherwise error.&lt;br /&gt;
&lt;br /&gt;
== UnmapTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size must match size given in map syscall, otherwise there&#039;s an invalid-size error.&lt;br /&gt;
&lt;br /&gt;
== CreateInterruptEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#Interrupt]] || Interrupt&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#InterruptType]] || InterruptType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ReadableEvent&amp;gt; || ReadableEventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an event handle for the given IRQ number. Waiting on this handle will wait until the IRQ is triggered. The InterruptType argument configures the triggering. If it is 0, the IRQ is active HIGH level sensitive, if it is 1 it is rising-edge sensitive.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF001:&#039;&#039;&#039; Flags was &amp;gt; 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF201:&#039;&#039;&#039; IRQ above 0x3FF or outside the [[NPDM#Kernel_Access_Control|IRQ access mask]] was given.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; A SlabHeap was exhausted (too many interrupts created).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF401:&#039;&#039;&#039; IRQ already has an event registered.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD201:&#039;&#039;&#039; The handle table is full. Try closing some handles.&lt;br /&gt;
&lt;br /&gt;
== QueryPhysicalAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || VirtualAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]]|| Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || PhysicalMemoryInfoAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || PhysicalMemoryInfoBaseAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || PhysicalMemoryInfoSize&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Queries the physical address of a virtual address. Will always fetch the lowest page-aligned mapping that contains the provided physical address.&lt;br /&gt;
&lt;br /&gt;
The returned PhysicalMemoryInfoBaseAddress is the virtual address of that page-aligned mapping, while PhysicalMemoryInfoAddress is the physical address of that page. PhysicalMemoryInfoSize is the amount of continuous physical memory in that mapping.&lt;br /&gt;
&lt;br /&gt;
== QueryIoMapping ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || IoAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R0 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1 || void* || VirtualAddress&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns a virtual address mapped to a given IO range.&lt;br /&gt;
&lt;br /&gt;
== CreateDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || DeviceAddressSpaceStartAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R0, R1 || uint64_t || DeviceAddressSpaceEndAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a virtual address space for binding device address spaces and returns a handle.&lt;br /&gt;
&lt;br /&gt;
StartAddr is normally set to 0 and EndAddr is normally set to 0xFFFFFFFF.&lt;br /&gt;
&lt;br /&gt;
== AttachDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#DeviceName]] || DeviceName&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a device address space to a [[#DeviceName|device]].&lt;br /&gt;
&lt;br /&gt;
== DetachDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#DeviceName]] || DeviceName&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches a device address space from a [[#DeviceName|device]].&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpaceByForce ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps an attached device address space to an userspace address.&lt;br /&gt;
&lt;br /&gt;
Address is the userspace destination address, while DeviceAddressSpaceAddress is the source address between DeviceAddressSpaceStartAddress and DeviceAddressSpaceEndAddress (passed to [[#CreateDeviceAddressSpace]]).&lt;br /&gt;
&lt;br /&gt;
The userspace destination address must have the [[SVC#MemoryState|FlagCanDeviceMap]] bit set. Bit [[SVC#MemoryAttribute|DeviceShared]] will be set after mapping.&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpaceAligned ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps an attached device address space to an userspace address.&lt;br /&gt;
&lt;br /&gt;
Same as [[#MapDeviceAddressSpaceByForce]], but the userspace destination address must have the [[SVC#MemoryState|FlagCanAlignedDeviceMap]] bit set instead.&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X5 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W6 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1 || uint64_t || Size&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== UnmapDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps an attached device address space from an userspace address.&lt;br /&gt;
&lt;br /&gt;
== InvalidateProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== StoreProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DebugActiveProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || ProcessId&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== BreakDebugProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== TerminateDebugProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#DebugEventInfo]]* || DebugEventInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || uint32_t || [[#ContinueDebugFlags]] ([1.0.0-2.3.0] [[#ContinueDebugFlagsOld]])&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 ([1.0.0-2.3.0] R2, R3) || uint64_t* ([1.0.0-2.3.0] uint64_t)|| ThreadIdList ([1.0.0-2.3.0] ThreadId)&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || uint64_t || [3.0.0+] NumThreadIds&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maximum NumThreadIds is 64. 0 means &amp;quot;all threads&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The process has been resumed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid debug handle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xf401:&#039;&#039;&#039; Process has debug events queued or is already running.&lt;br /&gt;
&lt;br /&gt;
== GetProcessList ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || uint64_t* || ProcessIdBuffer&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || ProcessIdBufferSize&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || NumProcesses&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fills the provided array with the pids of currently living processes. A process &amp;quot;lives&amp;quot; so long as it is currently running or a handle to it still exists.&lt;br /&gt;
&lt;br /&gt;
It returns the total number of processes currently alive. If this number is bigger than the size of ProcessIdBuffer, the user won&#039;t have all the pids.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xd401:&#039;&#039;&#039; The provided buffer is outside the process address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe601:&#039;&#039;&#039; copyToUser failed. The provided buffer is not user-accessible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xee01:&#039;&#039;&#039; The provided buffer size is too big. Max value is 0xFFFFFFF.&lt;br /&gt;
&lt;br /&gt;
== GetThreadList ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || uint64_t* || ThreadIdBuffer&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || ThreadIdBufferSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || NumThreads&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugThreadContext ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R4 || uint32_t || [[#ThreadContextFlags]]&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetDebugThreadContext ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R4 || uint32_t || [[#ThreadContextFlags]]&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== QueryDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReadDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || MemoryBufferAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WriteDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || MemoryBufferAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetHardwareBreakPoint ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || [[#HardwareBreakPointRegisterName]] || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || Flags&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets one of the AArch64 hardware breakpoints. The nintendo switch has 6 hardware breakpoints, and 4 hardware watchpoints. The syscall has two behaviors depending on the value of HardwareBreakPointRegisterName:&lt;br /&gt;
&lt;br /&gt;
If HardwareBreakPointRegisterName &amp;lt; 0x10, then it sets one of the AArch64 hardware breakpoints. Flags will go to DBGBCRn_EL1, and value to DBGBVRn_EL1. The only flags the user is allowed to set are those in the bitmask 0x7F01E1. Furthermore, the kernel will or it with 0x4004, in order to set various security flags to guarantee the watchpoints only triggers for code in EL0. If the user asks for a Breakpoint Type of ContextIDR match, the kernel shall use the given DebugHandle to set DBGBVRn_EL1 to the ContextID of the debugged process.&lt;br /&gt;
&lt;br /&gt;
If HardwareBreakPointRegisterName is between 0x10 and 0x20 (exclusive), then it sets one of the AArch64 hardware watchpoints. Flags will go to DBGWCRn_EL1, and the value to DBGWVRn_EL1. The only flags the user is allowed to set are those in the bitmask 0xFF0F1FF9. Furthermore, the kernel will or it with 0x104004. This will set various security flags, and set the watchpoint type to be a Linked Watchpoint. This means that you need to link it to a Linked ContextIDR breakpoint. Check the ARM documentation for more information.&lt;br /&gt;
&lt;br /&gt;
Note that HardwareBreakPointRegisterName 0 to 4 match only to Virtual Address, while HardwareBreakPointRegisterName 5 and 6 match against either Virtual Address, ContextID, or VMID. As such, if you are configuring a breakpoint to link for a watchpoint, make sure you use hardware_breakpoint_id 5 or 6.&lt;br /&gt;
&lt;br /&gt;
For more documentation for hardware breakpoints, check out the AArch64 documentation for the [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0488h/way1382455558968.html DBGBCRn_EL1 register] and the [http://infocenter.arm.com/help/topic/com.arm.doc.ddi0488h/way1382455560629.html DBGWCRn_EL1 register]&lt;br /&gt;
&lt;br /&gt;
== GetDebugThreadParam ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R1 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R3 || [[#DebugThreadParam]] || DebugThreadParam&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || Out0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || R3 || uint32_t || Out1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetSystemInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#SystemInfoType]] || SystemInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || SystemInfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || SystemInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreatePort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || MaxSessions&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || bool || IsLight&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R0 || uint64_t || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Port&amp;gt; || ServerPortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || R2 || Handle&amp;lt;Port&amp;gt; || ClientPortHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ManageNamedPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || char* || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || int32_t || MaxSessions&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Port&amp;gt; || ServerPortHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ConnectToPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Port&amp;gt; || ClientPortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetProcessMemoryPermission ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Addr&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R5 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sets the memory permissions for the specified memory with the supplied process handle.&lt;br /&gt;
&lt;br /&gt;
This throws an error(0xD801) when the input perm is &amp;gt;0x5, hence -WX and RWX are not allowed.&lt;br /&gt;
&lt;br /&gt;
== MapProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the src address from the supplied process handle into the current process.&lt;br /&gt;
&lt;br /&gt;
This allows mapping code and rodata with RW- permission.&lt;br /&gt;
&lt;br /&gt;
== UnmapProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps what was mapped by [[#MapProcessMemory]].&lt;br /&gt;
&lt;br /&gt;
== QueryProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R1, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equivalent to [[#QueryMemory]] except takes a process handle.&lt;br /&gt;
&lt;br /&gt;
== MapProcessCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R5, R6 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a process handle, and maps normal heap in that process as executable code in that process. Used when loading NROs. This does not support using the current-process handle alias.&lt;br /&gt;
&lt;br /&gt;
== UnmapProcessCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R5, R6 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps what was mapped by [[#MapProcessCodeMemory]].&lt;br /&gt;
&lt;br /&gt;
== CreateProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#CreateProcessParameter]]* || CreateProcessParameter&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint32_t* || Capabilities&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || int32_t || CapabilitiesNum&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a [[#CreateProcessParameter]] as input.&lt;br /&gt;
Capabilities points to an array of [[NPDM#Kernel_Access_Control|kernel capabilities]].&lt;br /&gt;
CapabilitiesNum is a number of capabilities in the Capabilities array (number of element, not number of bytes).&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Attempted to map more code pages than available in address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Provided CodeAddr is invalid (make sure it&#039;s in range?)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; The resource handle passed is invalid.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE601:&#039;&#039;&#039; Attempt to copy procinfo from user-supplied pointer failed. Attempt to copy capabilities_num from user-supplied pointer failed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE801:&#039;&#039;&#039; Attempted to create a 32-bit process with a 36-bit address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF001:&#039;&#039;&#039; Unused bits are set in mmuflags. Unknown address space type used.&lt;br /&gt;
&lt;br /&gt;
== StartProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || int32_t || MainThreadPriority&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || DefaultCpuId&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || uint64_t || MainThreadStackSize&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== TerminateProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetProcessInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R2 || [[#ProcessInfoType]] || ProcessInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || [[#ProcessState]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns an enum with value 0-7.&lt;br /&gt;
&lt;br /&gt;
== CreateResourceLimit ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetResourceLimitLimitValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || int64_t || LimitValue&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CallSecureMonitor ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || uint64_t || [[SMC#Secure_Monitor_calls|FunctionId]]&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1-X7 || R1-R7 || uint64_t || SMC arguments&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[SMC#Result|Result]] || SMC result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1-X7 || R1-R7 || uint64_t || SMC output&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes in a SMC function ID in X0, and arguments for that SMC function in X1-X7.&lt;br /&gt;
&lt;br /&gt;
Passing an invalid SMC function ID or calling from a core other than core 3 will result in a secure monitor panic.&lt;br /&gt;
&lt;br /&gt;
The kernel parses bits 9-15 in the passed SMC function ID (per the ARM SMC calling convention), and when set uses as an indicator to translate a pointer in the associated register (X1-X7) to a physical address. The kernel will translate any address mapped as R-W, other addresses (R--, R-X, or invalid pointers) will be translated as 0/NULL.&lt;br /&gt;
&lt;br /&gt;
Output is returned raw from the Secure Monitor; X0 will be the untranslated SMC result and X1-X7 will contain other SMC output (or be unchanged, depending on the SMC).&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
[2.0.0+] Exactly 6 debug SVCs require that [[SPL_services#GetConfig|IsDebugMode]] is non-zero. Error 0x4201 is returned otherwise.&lt;br /&gt;
* BreakDebugProcess&lt;br /&gt;
* ContinueDebugEvent&lt;br /&gt;
* WriteDebugProcessMemory&lt;br /&gt;
* SetDebugThreadContext&lt;br /&gt;
* TerminateDebugProcess&lt;br /&gt;
* SetHardwareBreakPoint&lt;br /&gt;
&lt;br /&gt;
DebugActiveProcess stops execution of the target process, the normal method for resuming it requires ContinueDebugEvent(see above). Closing the debug handle also results in execution being resumed.&lt;br /&gt;
&lt;br /&gt;
= Enum/Structures =&lt;br /&gt;
== InfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Handle type || InfoType || InfoSubType || Description&lt;br /&gt;
|-&lt;br /&gt;
| Process || 0 || 0 || CoreMask&lt;br /&gt;
|-&lt;br /&gt;
| Process || 1 || 0 || PriorityMask&lt;br /&gt;
|-&lt;br /&gt;
| Process || 2 || 0 || AliasRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 3 || 0 || AliasRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 4 || 0 || HeapRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 5 || 0 || HeapRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 6 || 0 || TotalMemorySize. Total memory available(free+used).&lt;br /&gt;
|-&lt;br /&gt;
| Process || 7 || 0 || UsedMemorySize. Total used size of codebin memory + main-thread stack + allocated heap.&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 8 || 0 || DebuggerAttached&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 9 || 0 || ResourceLimit&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 10 || -1, {current coreid} || IdleTickCount&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 11 || 0-3 || RandomEntropy. Used to seed usermode PRNGs.&lt;br /&gt;
|-&lt;br /&gt;
| Process || 12 || 0 || [2.0.0+] AslrRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 13 || 0 || [2.0.0+] AslrRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 14 || 0 || [2.0.0+] StackRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 15 || 0 || [2.0.0+] StackRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 16 || 0 || [3.0.0+] SystemResourceSizeTotal&lt;br /&gt;
|-&lt;br /&gt;
| Process || 17 || 0 || [3.0.0+] SystemResourceSizeUsed&lt;br /&gt;
|-&lt;br /&gt;
| Process || 18 || 0 || [3.0.0+] ProgramId&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 19 || 0 || [4.0.0-4.1.0] InitialProcessIdRange_LowerBound&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 19 || 1 || [4.0.0-4.1.0] InitialProcessIdRange_UpperBound&lt;br /&gt;
|-&lt;br /&gt;
| Process || 20 || 0 || [5.0.0+] UserExceptionContextAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 21 || 0 || [6.0.0+] TotalNonSystemMemorySize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 22 || 0 || [6.0.0+] UsedNonSystemMemorySize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 23 || 0 || [9.0.0+] IsApplication&lt;br /&gt;
|-&lt;br /&gt;
| Process || 24 || 0 || [11.0.0+] FreeThreadCount&lt;br /&gt;
|-&lt;br /&gt;
| Thread  || 25 ([1.0.0-12.1.0] 0xF0000002) || 0-3, -1 || ThreadTickCount. When 0-3 are passed, gets specific core CPU ticks spent on thread. When -1 is passed, gets total CPU ticks spent on thread.&lt;br /&gt;
|-&lt;br /&gt;
| Process || 26 || 0 || [14.0.0+] IsSvcPermitted&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SystemInfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Handle type || SystemInfoType || SystemInfoSubType || Description&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 0 || TotalPhysicalMemorySize_Application&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 1 || TotalPhysicalMemorySize_Applet&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 2 || TotalPhysicalMemorySize_System&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 3 || TotalPhysicalMemorySize_SystemUnsafe&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 0 || UsedPhysicalMemorySize_Application&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 1 || UsedPhysicalMemorySize_Applet&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 2 || UsedPhysicalMemorySize_System&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 3 || UsedPhysicalMemorySize_SystemUnsafe&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 2 || 0 || InitialProcessIdRange_LowerBound&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 2 || 1 || InitialProcessIdRange_UpperBound&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ThreadContextFlags ==&lt;br /&gt;
Bitfield of one of more of these:&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || General-purpose registers || If in 64-bit mode, GPRs 0–28 will be read/written. If in 32-bit mode, GPRs 0–12 will be read/written.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || Control registers || Reads/writes the FP, LR, PC, SP, PSTATE, and TPIDR registers.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || Floating-point registers || Reads/writes the floating-point vector registers.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 8 || Floating-point control registers || Reads/writes the FPCR and FPSR registers.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== DeviceName ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AFI&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AVPC&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DC&lt;br /&gt;
|-&lt;br /&gt;
| 3 || DCB&lt;br /&gt;
|-&lt;br /&gt;
| 4 || HC&lt;br /&gt;
|-&lt;br /&gt;
| 5 || HDA&lt;br /&gt;
|-&lt;br /&gt;
| 6 || ISP2&lt;br /&gt;
|-&lt;br /&gt;
| 7 || MSENCNVENC&lt;br /&gt;
|-&lt;br /&gt;
| 8 || NV&lt;br /&gt;
|-&lt;br /&gt;
| 9 || NV2&lt;br /&gt;
|-&lt;br /&gt;
| 10 || PPCS&lt;br /&gt;
|-&lt;br /&gt;
| 11 || SATA&lt;br /&gt;
|-&lt;br /&gt;
| 12 || VI&lt;br /&gt;
|-&lt;br /&gt;
| 13 || VIC&lt;br /&gt;
|-&lt;br /&gt;
| 14 || XUSB_HOST&lt;br /&gt;
|-&lt;br /&gt;
| 15 || XUSB_DEV&lt;br /&gt;
|-&lt;br /&gt;
| 16 || TSEC&lt;br /&gt;
|-&lt;br /&gt;
| 17 || PPCS1&lt;br /&gt;
|-&lt;br /&gt;
| 18 || DC1&lt;br /&gt;
|-&lt;br /&gt;
| 19 || SDMMC1A&lt;br /&gt;
|-&lt;br /&gt;
| 20 || SDMMC2A&lt;br /&gt;
|-&lt;br /&gt;
| 21 || SDMMC3A&lt;br /&gt;
|-&lt;br /&gt;
| 22 || SDMMC4A&lt;br /&gt;
|-&lt;br /&gt;
| 23 || ISP2B&lt;br /&gt;
|-&lt;br /&gt;
| 24 || GPU&lt;br /&gt;
|-&lt;br /&gt;
| 25 || GPUB&lt;br /&gt;
|-&lt;br /&gt;
| 26 || PPCS2&lt;br /&gt;
|-&lt;br /&gt;
| 27 || NVDEC&lt;br /&gt;
|-&lt;br /&gt;
| 28 || APE&lt;br /&gt;
|-&lt;br /&gt;
| 29 || SE&lt;br /&gt;
|-&lt;br /&gt;
| 30 || NVJPG&lt;br /&gt;
|-&lt;br /&gt;
| 31 || HC1&lt;br /&gt;
|-&lt;br /&gt;
| 32 || SE1&lt;br /&gt;
|-&lt;br /&gt;
| 33 || AXIAP&lt;br /&gt;
|-&lt;br /&gt;
| 34 || ETR&lt;br /&gt;
|-&lt;br /&gt;
| 35 || TSECB&lt;br /&gt;
|-&lt;br /&gt;
| 36 || TSEC1&lt;br /&gt;
|-&lt;br /&gt;
| 37 || TSECB1&lt;br /&gt;
|-&lt;br /&gt;
| 38 || NVDEC1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CodeMemoryOperation ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || MapOwner&lt;br /&gt;
|-&lt;br /&gt;
| 1 || MapSlave&lt;br /&gt;
|-&lt;br /&gt;
| 2 || UnmapOwner&lt;br /&gt;
|-&lt;br /&gt;
| 3 || UnmapSlave&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== LimitableResource ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || PhysicalMemoryMax || Bytes of memory a process may allocate.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ThreadCountMax || Amount of threads a process can create.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || EventCountMax || Amount of events a process can create through [[#CreateEvent]] or [[#SendAsyncRequestWithUserBuffer]].&lt;br /&gt;
|-&lt;br /&gt;
| 3 || TransferMemoryCountMax || Amount of TransferMemory a process can create through [[#CreateTransferMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 4 || SessionCountMax || Amount of session a process can create through [[#CreateSession]], [[#ConnectToPort]] or [[#ConnectToNamedPort]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= ThreadActivity =&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || None&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Runnable&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessActivity ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || None&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Runnable&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessInfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || [[#ProcessState|ProcessState]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessState ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name || Notes&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Created ||&lt;br /&gt;
|-&lt;br /&gt;
| 1 || CreatedAttached ||&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Started ||&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Crashed || Processes will not enter this state unless they were created with [[#CreateProcessParameter|EnableDebug]].&lt;br /&gt;
|-&lt;br /&gt;
| 4 || StartedAttached ||&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Exiting ||&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Exited ||&lt;br /&gt;
|-&lt;br /&gt;
| 7 || DebugSuspended ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== DebugThreadParam ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || DynamicPriority&lt;br /&gt;
|-&lt;br /&gt;
| 1 || SchedulingStatus&lt;br /&gt;
|-&lt;br /&gt;
| 2 || PreferredCpuCore&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCpuCore&lt;br /&gt;
|-&lt;br /&gt;
| 4 || AffinityMask&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Dynamic priority: output in out2&lt;br /&gt;
&lt;br /&gt;
Scheduling status: out1 contains bit0: is debug-suspended, bit1: is user-suspended ([[#SetThreadActivity]] 1 or [[#SetProcessActivity]] 1).&lt;br /&gt;
Out2 contains {suspended, idle, running, terminating} =&amp;gt; {5, 0, 1, 4}&lt;br /&gt;
&lt;br /&gt;
PreferredCpuCore: output in out2&lt;br /&gt;
&lt;br /&gt;
CurrentCpuCore: output in out2&lt;br /&gt;
&lt;br /&gt;
AffinityMask: output in out1&lt;br /&gt;
&lt;br /&gt;
== CreateProcessParameter ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 12 || || ProcessName (doesn&#039;t have to be null-terminated)&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || 4 || || ProcessCategory (0: regular title, 1: kernel built-in)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 8 || || TitleId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || 8 || || CodeAddr&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 4 || || CodeNumPages&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 4 || || Flags&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit0 || Is64BitInstruction&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit3-1 || [[#AddressSpaceType]]&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit4 || [2.0.0+] EnableDebug&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit5 || EnableAslr&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit6 || IsApplication&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit7 || [4.0.0] UseSecureMemory&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit10-7 || [5.0.0+] MemoryRegion (0 = Application, 1 = Applet, 2 = SecureSystem, 3 = NonSecureSystem)&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit11 || [7.0.0+] OptimizeMemoryAllocation (only allowed in combination with IsApplication)&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || 4 || || ResourceLimitHandle (can be zero)&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || 4 || || [3.0.0+] SystemResourceNumPages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On [1.0.0] there&#039;s only one MemoryRegion.&lt;br /&gt;
&lt;br /&gt;
On [2.0.0-4.0.0] MemoryRegion is 1 for built-ins and 0 for rest.&lt;br /&gt;
&lt;br /&gt;
On [5.0.0] MemoryRegion is specified in CreateProcessArgs. There are now 4 pool partitions.&lt;br /&gt;
&lt;br /&gt;
On [5.0.0] (maybe lower?) a zero ResourceLimitHandle defaults to sysmodule limits and 0x12300000 bytes of memory.&lt;br /&gt;
&lt;br /&gt;
The PersonalMmHeap are allocated as follows:&lt;br /&gt;
* For the application, normal insecure pool is used. Carveout 5 is used to provide protection.&lt;br /&gt;
* For the applet, a pre-allocated secure pool segment of size 0x400000 is used.&lt;br /&gt;
* For sysmodules, secure pool is allocated.&lt;br /&gt;
&lt;br /&gt;
=== AddressSpaceType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Type || Name || Width || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AddressSpace32Bit || 32 ||&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AddressSpace64BitOld || 36 ||&lt;br /&gt;
|-&lt;br /&gt;
| 2 || AddressSpace32BitNoReserved || 32 || Appears to be missing map region [?]&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [2.0.0+] AddressSpace64Bit || 39 ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryInfo ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8 || BaseAddress&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 8 || Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 4 || [[#MemoryType]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x14 || 4 || [[#MemoryAttribute]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || 4 || [[#MemoryPermission]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C || 4 || IpcRefCount&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 4 || DeviceRefCount&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 4 || Padding: always zero&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryPermission ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Read || Can be set by [[#SetMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Write || Can be set by [[#SetMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Execute || Can be set by [[#SetProcessMemoryPermission]] and [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 28 || DontCare ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryAttribute ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Locked || Used by MapMemory, as an async IPC user buffer.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || IpcLocked || True when IpcRefCount &amp;gt; 0.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DeviceShared || True when DeviceRefCount &amp;gt; 0.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Uncached || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryState ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Description || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 7-0 || [[#MemoryType]] || &lt;br /&gt;
|-&lt;br /&gt;
| 8 || [[#SetMemoryPermission|FlagCanReprotect]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 9 || FlagCanDebug || Allows using [[#WriteDebugProcessMemory]] on segments mapped read-only.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || FlagCanUseIpc || Allows sending this region as an IPC A/B/W buffer with flags=0.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || FlagCanUseNonDeviceIpc || Allows sending this region as an IPC A/B/W buffer with flags=1.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || FlagCanUseNonSecureIpc || Allows sending this region as an IPC A/B/W buffer with flags=3.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || FlagMapped ||&lt;br /&gt;
|-&lt;br /&gt;
| 14 || [[#SetProcessMemoryPermission|FlagCode]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 15 || [[#MapMemory|FlagCanAlias]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 16 || [[#MapProcessCodeMemory|FlagCanCodeAlias]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 17 || [[#CreateTransferMemory|FlagCanTransfer]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 18 || [[#QueryPhysicalAddress|FlagCanQueryPhysical]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 19 || [[#MapDeviceAddressSpace|FlagCanDeviceMap]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 20 || [[#MapDeviceAddressSpaceAligned|FlagCanAlignedDeviceMap]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 21 || [[#SendSyncRequestWithUserBuffer|FlagCanIpcUserBuffer]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 22 || FlagReferenceCounted || The physical memory blocks backing this region are refcounted.&lt;br /&gt;
|-&lt;br /&gt;
| 23 || [[#MapProcessMemory|FlagCanMapProcess]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 24 || [[#SetMemoryAttribute|FlagCanChangeAttribute]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 25 || [4.0.0+] [[#CreateCodeMemory|FlagCanCodeMemory]] ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== MemoryType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000000 || Free ||&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002001 || Io || Mapped by kernel capability parsing in [[#CreateProcess]]. &lt;br /&gt;
|-&lt;br /&gt;
| 0x00042002 || Static || Mapped by kernel capability parsing in [[#CreateProcess]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00DC7E03 || Code || Mapped during [[#CreateProcess]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x01FEBD04&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x03FEBD04&lt;br /&gt;
|| CodeData || Transition from 0xDC7E03 performed by [[#SetProcessMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
0x017EBD05&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x037EBD05&lt;br /&gt;
|| Normal || Mapped using [[#SetHeapSize]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402006 || Shared || Mapped using [[#MapSharedMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00482907 || [1.0.0] Alias || Mapped using [[#MapMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00DD7E08 || AliasCode || Mapped using [[#MapProcessCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x01FFBD09&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x03FFBD09&lt;br /&gt;
|| AliasCodeData || Transition from 0xDD7E08 performed by [[#SetProcessMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3C0A || [[IPC_Marshalling|Ipc]] || IPC buffers with descriptor flags=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3C0B || Stack || Mapped using [[#MapMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x0040200C || [[Thread Local Storage|ThreadLocal]] || Mapped during [[#CreateThread]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x015C3C0D || Transfered || Mapped using [[#MapTransferMemory]] when the owning process has perm=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C380E || SharedTransfered || Mapped using [[#MapTransferMemory]] when the owning process has perm!=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0040380F || SharedCode || Mapped using [[#MapProcessMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Inaccessible ||&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3811 || [[IPC_Marshalling|NonSecureIpc]] || IPC buffers with descriptor flags=1.&lt;br /&gt;
|-&lt;br /&gt;
| 0x004C2812 || [[IPC_Marshalling|NonDeviceIpc]] || IPC buffers with descriptor flags=3.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002013 || Kernel || Mapped in kernel during [[#CreateThread]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402214 || [4.0.0+] GeneratedCode || Mapped in kernel during [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402015 || [4.0.0+] CodeOut || Mapped in kernel during [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002016 || [13.0.0+] Coverage || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ArbitrationType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || WaitIfLessThan&lt;br /&gt;
|-&lt;br /&gt;
| 0x1 || DecrementAndWaitIfLessThan&lt;br /&gt;
|-&lt;br /&gt;
| 0x2 || WaitIfEqual&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SignalType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || Signal&lt;br /&gt;
|-&lt;br /&gt;
| 0x1 || SignalAndIncrementIfEqual&lt;br /&gt;
|-&lt;br /&gt;
| 0x2 || SignalAndModifyBasedOnWaitingThreadCountIfEqual&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugFlagsOld ==&lt;br /&gt;
[1.0.0-2.3.0]&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || IgnoreException (note: ResumeAllThreads or debug-suspended-thread-id needed)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || SwallowException&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || ResumeAllThreads&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugFlags ==&lt;br /&gt;
[3.0.0+]&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || IgnoreException (note: doesn&#039;t need to be set in the same call than Resume)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || DontCatchExceptions&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || Resume&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 8 || IgnoreOtherThreadsExceptions&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
IgnoreExceptionsOfOthers is like IgnoreException but acts on all threads that aren&#039;t in the input list. The affected threads are resumed.&lt;br /&gt;
&lt;br /&gt;
Only one of of Resume and IgnoreOtherThreadsExceptions can be set at a time.&lt;br /&gt;
&lt;br /&gt;
If the input number of threads is 0, this means &amp;quot;all threads&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== DebugEventInfo ==&lt;br /&gt;
The below table is for the Aarch64 version of the system call. For A32, all u64 fields but title/process/thread id are actually u32, making the structure 0x28-byte-big (0x40 for a64).&lt;br /&gt;
&lt;br /&gt;
Size: 0x40&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || u32 || EventType&lt;br /&gt;
|-&lt;br /&gt;
| 4 || u32 || Flags (bit0: NeedsContinue)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || u64 || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || || PerTypeSpecifics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AttachProcess specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u64 || TitleId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || ProcessId&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || char[12] || ProcessName&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || u32 || MmuFlags&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || u64 || [5.0.0+] UserExceptionContextAddr&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AttachThread specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u64 || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || TlsPtr&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u64 || Entrypoint&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Exit specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u32|| Type (0=PausedThread, 1=RunningThread, 2=ExitedProcess, 3=TerminatedProcess)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Exception specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u32 || ExceptionType&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || FaultRegister&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || || PerExceptionSpecifics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== DebugEventType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AttachProcess&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AttachThread&lt;br /&gt;
|-&lt;br /&gt;
| 2 || ExitProcess&lt;br /&gt;
|-&lt;br /&gt;
| 3 || ExitThread&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Exception&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== DebugExceptionType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Trap (*)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || InstructionAbort&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DataAbortMisc (**)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || PcSpAlignmentFault&lt;br /&gt;
|-&lt;br /&gt;
| 4 || DebuggerAttached&lt;br /&gt;
|-&lt;br /&gt;
| 5 || BreakPoint&lt;br /&gt;
|-&lt;br /&gt;
| 6 || UserBreak&lt;br /&gt;
|-&lt;br /&gt;
| 7 || DebuggerBreak&lt;br /&gt;
|-&lt;br /&gt;
| 8 || BadSvcId&lt;br /&gt;
|-&lt;br /&gt;
| 9 || [2.0.0+] SError&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; Undefined instructions, software breakpoints, some other traps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; Data aborts, FP traps, and everything else that doesn&#039;t belong to any of the above.&lt;br /&gt;
&lt;br /&gt;
Trap specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || Opcode&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
BreakPoint specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || IsWatchpoint&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
UserBreak specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || Info0&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || u64 || Info1&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || u64 || Info2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
BadSvcId specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || SvcId&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Exception handling =&lt;br /&gt;
First of all, a function that might be called by synchronous exception handler and that is called by the SError handler fetches the exception info, adjusts PC, panics on exceptions taken from EL1, then dispatches the exception.&lt;br /&gt;
&lt;br /&gt;
The dispatcher has two mutually exclusive exception reporting methods:&lt;br /&gt;
* by storing information at the start of the process&#039;s TLS memregion (TPIDRRO_EL0) and jumping back to the crt0&lt;br /&gt;
* by using KDebug&lt;br /&gt;
&lt;br /&gt;
KDebug dispatching is used when at least one of the following conditions are met:&lt;br /&gt;
* SMC ConfigItem KernelMemConfig bit 1 is NOT set (it isn&#039;t on retail), unless: this is a software or hardware breakpoint, or a watchpoint, or [4.0.0+?] the process is attached and this is a Google PNaCl trap instruction (see LLVM source)&lt;br /&gt;
* FAR doesn&#039;t point to a valid address in mapped-readable CodeStatic memory (i.e. this is the case for NRO and JIT memory) or this is one of the following exceptions (it particular, that doesn&#039;t include FP exceptions occurring in CodeStatic memory):&lt;br /&gt;
** Uncategorized&lt;br /&gt;
** IllegalState&lt;br /&gt;
** SupervisorCallA32&lt;br /&gt;
** SupervisorCallA64&lt;br /&gt;
** PCAlignment&lt;br /&gt;
** SPAlignment&lt;br /&gt;
** SError&lt;br /&gt;
** BreakpointLowerEl&lt;br /&gt;
** SoftwareStepLowerEl (note: no way set single-step flag; not parsed)&lt;br /&gt;
** WatchpointLowerEl&lt;br /&gt;
** SoftwareBreakpointA32 (note: not parsed)&lt;br /&gt;
** SoftwareBreakpointA64 (note: not parsed)&lt;br /&gt;
    &lt;br /&gt;
In all other cases the userland-handled exception path is taken.&lt;br /&gt;
&lt;br /&gt;
KDebug path:&lt;br /&gt;
&lt;br /&gt;
If the process is attached, the exception is reported to the KDebug. If the thread was continued using flag IgnoreExceptions, it returns from the exception as if nothing happened.&lt;br /&gt;
&lt;br /&gt;
If the latter is not the case, or if the process isn&#039;t attached, proceed to [2.0.0+] crash reporting (or in [1.0.0] just terminate the process): &lt;br /&gt;
if EnableDebug is set, and depending on the process state (more than one crash per process isn&#039;t permitted) it may signal itself with ProcessState_Crashed so that PM asks NS to start creport so that creport attaches to it and reports the crashes. Otherwise, just terminate.&lt;br /&gt;
&lt;br /&gt;
Userland reporting path and [[#ReturnFromException]]:&lt;br /&gt;
&lt;br /&gt;
TLS region start (A64):&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x148 || Exception stack&lt;br /&gt;
|-&lt;br /&gt;
| 0x148 || 0x78 || ExceptionFrameA64&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
ExceptionFrameA64:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x48 (8*9) || GPRs 0..8.&lt;br /&gt;
|-&lt;br /&gt;
| 0x48 || 0x8 || lr&lt;br /&gt;
|-&lt;br /&gt;
| 0x50 || 0x8 || sp&lt;br /&gt;
|-&lt;br /&gt;
| 0x58 || 0x8 || pc (elr_el1)&lt;br /&gt;
|-&lt;br /&gt;
| 0x60 || 0x4 || pstate &amp;amp; 0xFF0FFE20&lt;br /&gt;
|-&lt;br /&gt;
| 0x64 || 0x4 || afsr0&lt;br /&gt;
|-&lt;br /&gt;
| 0x68 || 0x4 || afsr1&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C || 0x4 || esr&lt;br /&gt;
|-&lt;br /&gt;
| 0x70 || 0x8 || far&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TLS region start (A32):&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x178 || Exception stack&lt;br /&gt;
|-&lt;br /&gt;
| 0x148 || 0x44 || ExceptionFrameA32&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
ExceptionFrameA32:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x20 (8*4) || GPRs 0..7.&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 0x4 || sp&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 0x4 || lr&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || 0x4 || pc (elr_el1)&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || 0x4 || tpidr_el0 = 1&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || 0x4 || cpsr &amp;amp; 0xFF0FFE20&lt;br /&gt;
|-&lt;br /&gt;
| 0x34 || 0x4 || afsr0&lt;br /&gt;
|-&lt;br /&gt;
| 0x38 || 0x4 || afsr1&lt;br /&gt;
|-&lt;br /&gt;
| 0x3C || 0x4 || esr&lt;br /&gt;
|-&lt;br /&gt;
| 0x40 || 0x4 || far&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In that case, after storing the regs in the TLS, the exception handler returns to the application&#039;s crt0 (entrypoint), with X0=&amp;lt;error description code&amp;gt; (see below) and X1=SP=frame=&amp;lt;stack top&amp;gt; (see above)&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Desc. code || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 0x100 || Instruction abort&lt;br /&gt;
|-&lt;br /&gt;
| 0x102 || Misaligned PC&lt;br /&gt;
|-&lt;br /&gt;
| 0x103 || Misaligned SP&lt;br /&gt;
|-&lt;br /&gt;
| 0x106 || [2.0.0+] SError&lt;br /&gt;
|-&lt;br /&gt;
| 0x301 || Bad SVC&lt;br /&gt;
|-&lt;br /&gt;
| 0x104 || Uncategorized, CP15RTTrap, CP15RRTTrap, CP14RTTrap, CP14RRTTrap, IllegalState, SystemRegisterTrap&lt;br /&gt;
|-&lt;br /&gt;
| 0x101 || None of the above, EC &amp;lt;= 0x34 and not a breakpoint&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(During normal app boot the process is invoked with X0=0 and X1=main_thread_handle. The crt0 of retail apps determines whether to boot normally or handle an exception if X0 is set to 0 or not)&lt;br /&gt;
&lt;br /&gt;
The application is supposed to promptly update the contents of elr_el1 to a user handler (and any other regs it sees fit) and call [[#ReturnFromException]] (error code) to call that handler. The latter is then expected to promptly abort the program.&lt;br /&gt;
&lt;br /&gt;
[[#ReturnFromException]] updates the contents of the kernel stack frame with what the user provided in the TLS structure, sets TPIDR_EL0 to 1, then:&lt;br /&gt;
* if the provided error code is 0, gracefully pivots and returns from exception&lt;br /&gt;
* if it is not, replays the exception and pass it to the KDebug (see above). One can pass 0x10001 to prevent process termination. If the process is attached, this also prevents crash-collection/termination (different from the exception handler behavior)&lt;br /&gt;
&lt;br /&gt;
If an exception occurs from the above user handler, the entire exception handling process will repeat with the new exception.&lt;br /&gt;
&lt;br /&gt;
Note that if a thread that wasn&#039;t faulting calls [[#ReturnFromException]], it signals an &amp;quot;invalid syscall&amp;quot; exception&lt;br /&gt;
&lt;br /&gt;
Note that [[SMC|IsDebugMode]] is not used during exception-handling, except for enabling printing a message to UART-A. This UART code causes a system-hang on retail (likely due to a loop that doesn&#039;t exit). This printing doesn&#039;t seem to run when the process is attached for debugging?&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
	<entry>
		<id>https://switchbrew.org/w/index.php?title=SVC&amp;diff=9616</id>
		<title>SVC</title>
		<link rel="alternate" type="text/html" href="https://switchbrew.org/w/index.php?title=SVC&amp;diff=9616"/>
		<updated>2020-05-31T15:13:13Z</updated>

		<summary type="html">&lt;p&gt;DCNick3: Add information about MapPhysicalMemory errors&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
= System calls =&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! ID || Return Type || Name || Arguments&lt;br /&gt;
|-&lt;br /&gt;
| 0x01 || Result || [[#SetHeapSize|SetHeapSize]] || uintptr_t *out_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x02 || Result || [[#SetMemoryPermission|SetMemoryPermission]] || uintptr_t address, size_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x03 || Result || [[#SetMemoryAttribute|SetMemoryAttribute]] || uintptr_t address, size_t size, uint32_t mask, uint32_t attr&lt;br /&gt;
|-&lt;br /&gt;
| 0x04 || Result || [[#MapMemory|MapMemory]] || uintptr_t dst_address, uintptr_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x05 || Result || [[#UnmapMemory|UnmapMemory]] || uintptr_t dst_address, uintptr_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x06 || Result || [[#QueryMemory|QueryMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x07 || void || [[#ExitProcess|ExitProcess]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x08 || Result || [[#CreateThread|CreateThread]] || Handle *out_handle, ThreadFunc func, uintptr_t arg, uintptr_t stack_bottom, int32_t priority, int32_t core_id&lt;br /&gt;
|-&lt;br /&gt;
| 0x09 || Result || [[#StartThread|StartThread]] || Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0A || void || [[#ExitThread|ExitThread]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x0B || void || [[#SleepThread|SleepThread]] || int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || Result || [[#GetThreadPriority|GetThreadPriority]] || int32_t *out_priority, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0D || Result || [[#SetThreadPriority|SetThreadPriority]] || Handle thread_handle, int32_t priority&lt;br /&gt;
|-&lt;br /&gt;
| 0x0E || Result || [[#GetThreadCoreMask|GetThreadCoreMask]] || int32_t *out_core_id, uint64_t *out_affinity_mask, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x0F || Result || [[#SetThreadCoreMask|SetThreadCoreMask]] || Handle thread_handle, int32_t core_id, uint64_t affinity_mask&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || int32_t || [[#GetCurrentProcessorNumber|GetCurrentProcessorNumber]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x11 || Result || [[#SignalEvent|SignalEvent]] || Handle event_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x12 || Result || [[#ClearEvent|ClearEvent]] || Handle event_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x13 || Result || [[#MapSharedMemory|MapSharedMemory]] || Handle shmem_handle, uintptr_t address, size_t size, MemoryPermission map_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x14 || Result || [[#UnmapSharedMemory|UnmapSharedMemory]] || Handle shmem_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x15 || Result || [[#CreateTransferMemory|CreateTransferMemory]] || Handle *out_handle, uintptr_t address, size_t size, MemoryPermission map_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x16 || Result || [[#CloseHandle|CloseHandle]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x17 || Result || [[#ResetSignal|ResetSignal]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || Result || [[#WaitSynchronization|WaitSynchronization]] || int32_t *out_index, const Handle *handles, int32_t numHandles, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x19 || Result || [[#CancelSynchronization|CancelSynchronization]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x1A || Result || [[#ArbitrateLock|ArbitrateLock]] || Handle thread_handle, uintptr_t address, uint32_t tag&lt;br /&gt;
|-&lt;br /&gt;
| 0x1B || Result || [[#ArbitrateUnlock|ArbitrateUnlock]] || uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C || Result || [[#WaitProcessWideKeyAtomic|WaitProcessWideKeyAtomic]] || uintptr_t address, uintptr_t cv_key, uint32_t tag, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x1D || void || [[#SignalProcessWideKey|SignalProcessWideKey]] || uintptr_t cv_key, int32_t count&lt;br /&gt;
|-&lt;br /&gt;
| 0x1E || int64_t || [[#GetSystemTick|GetSystemTick]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x1F || Result || [[#ConnectToNamedPort|ConnectToNamedPort]] || Handle *out_handle, const char *name&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || Result || [[#SendSyncRequestLight|SendSyncRequestLight]] || Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x21 || Result || [[#SendSyncRequest|SendSyncRequest]] || Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x22 || Result || [[#SendSyncRequestWithUserBuffer|SendSyncRequestWithUserBuffer]] || uintptr_t message_buffer, size_t message_buffer_size, Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x23 || Result || [[#SendAsyncRequestWithUserBuffer|SendAsyncRequestWithUserBuffer]] || Handle *out_event_handle, uintptr_t message_buffer, size_t message_buffer_size, Handle session_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || Result || [[#GetProcessId|GetProcessId]] || uint64_t *out_process_id, Handle process_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x25 || Result || [[#GetThreadId|GetThreadId]] || uint64_t *out_thread_id, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x26 || void || [[#Break|Break]] || BreakReason break_reason, uintptr_t arg, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x27 || Result || [[#OutputDebugString|OutputDebugString]] || const char *debug_str, size_t len&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || void || [[#ReturnFromException|ReturnFromException]] || Result result&lt;br /&gt;
|-&lt;br /&gt;
| 0x29 || Result || [[#GetInfo|GetInfo]] || uint64_t *out, InfoType info_type, Handle handle, uint64_t info_subtype&lt;br /&gt;
|-&lt;br /&gt;
| 0x2A || void || [[#FlushEntireDataCache|FlushEntireDataCache]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x2B || Result || [[#FlushDataCache|FlushDataCache]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [3.0.0+] 0x2C  || Result || [[#MapPhysicalMemory|MapPhysicalMemory]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [3.0.0+] 0x2D  || Result || [[#UnmapPhysicalMemory|UnmapPhysicalMemory]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x2E  || Result || [[#GetDebugFutureThreadInfo|GetDebugFutureThreadInfo]] || arch::LastThreadContext *out_context, uint64_t *thread_id, Handle debug_handle, int64_t ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x2F || Result || [[#GetLastThreadInfo|GetLastThreadInfo]] || arch::LastThreadContext *out_context, uintptr_t *out_tls_address, uint32_t *out_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || Result || [[#GetResourceLimitLimitValue|GetResourceLimitLimitValue]] || int64_t *out_limit_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|-&lt;br /&gt;
| 0x31 || Result || [[#GetResourceLimitCurrentValue|GetResourceLimitCurrentValue]] || int64_t *out_current_value, Handle resource_limit_handle, LimitableResource which&lt;br /&gt;
|-&lt;br /&gt;
| 0x32 || Result || [[#SetThreadActivity|SetThreadActivity]] || Handle thread_handle, ThreadActivity thread_activity&lt;br /&gt;
|-&lt;br /&gt;
| 0x33  || Result || [[#GetThreadContext3|GetThreadContext3]] || ThreadContext *out_context, Handle thread_handle&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x34 || Result || [[#WaitForAddress|WaitForAddress]] || uintptr_t address, ArbitrationType arb_type, int32_t value, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x35 || Result || [[#SignalToAddress|SignalToAddress]] || uintptr_t address, SignalType signal_type, int32_t value, int32_t count&lt;br /&gt;
|-&lt;br /&gt;
| [8.0.0+] 0x36 || void || [[#SynchronizePreemptionState|SynchronizePreemptionState]] || &lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [1.0.0-3.0.2] 0x3C || void || [[#DumpInfo|DumpInfo]] || DumpInfoType dump_info_type, uint64_t arg&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x3C || void || [[#KernelDebug|KernelDebug]] || KernelDebugType kern_debug_type, uint64_t arg0, uint64_t arg1, uint64_t arg2&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x3D || void || [[#ChangeKernelTraceState|ChangeKernelTraceState]] || KernelTraceState kern_trace_state&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| 0x40 || Result || [[#CreateSession|CreateSession]] || Handle *out_server_session_handle, Handle *out_client_session_handle, bool is_light, uintptr_t name&lt;br /&gt;
|-&lt;br /&gt;
| 0x41 || Result || [[#AcceptSession|AcceptSession]] || Handle *out_handle, Handle port&lt;br /&gt;
|-&lt;br /&gt;
| 0x42 || Result || [[#ReplyAndReceiveLight|ReplyAndReceiveLight]] || Handle handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x43 || Result || [[#ReplyAndReceive|ReplyAndReceive]] || int32_t *out_index, const Handle *handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x44 || Result || [[#ReplyAndReceiveWithUserBuffer|ReplyAndReceiveWithUserBuffer]] || int32_t *out_index, uintptr_t message_buffer, size_t message_buffer_size, const Handle *handles, int32_t num_handles, Handle reply_target, int64_t timeout_ns&lt;br /&gt;
|-&lt;br /&gt;
| 0x45 || Result || [[#CreateEvent|CreateEvent]] || Handle *out_write_handle, Handle *out_read_handle&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [5.0.0+] 0x48 || Result || [[#MapPhysicalMemoryUnsafe|MapPhysicalMemoryUnsafe]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x49 || Result || [[#UnmapPhysicalMemoryUnsafe|UnmapPhysicalMemoryUnsafe]] || uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [5.0.0+] 0x4A || Result || [[#SetUnsafeLimit|SetUnsafeLimit]] || size_t limit&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x4B || Result || [[#CreateCodeMemory|CreateCodeMemory]] || Handle *out_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| [4.0.0+] 0x4C || Result || [[#ControlCodeMemory|ControlCodeMemory]] || Handle code_memory_handle, CodeMemoryOperation operation, uint64_t address, uint64_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x4D || void || [[#SleepSystem|SleepSystem]] || &lt;br /&gt;
|-&lt;br /&gt;
| 0x4E || Result || [[#ReadWriteRegister|ReadWriteRegister]] || uint32_t *out_value, PhysicalAddress address, uint32_t mask, uint32_t value&lt;br /&gt;
|-&lt;br /&gt;
| 0x4F || Result || [[#SetProcessActivity|SetProcessActivity]] || Handle process_handle, ProcessActivity process_activity&lt;br /&gt;
|-&lt;br /&gt;
| 0x50 || Result || [[#CreateSharedMemory|CreateSharedMemory]] || Handle *out_handle, size_t size, MemoryPermission owner_perm, MemoryPermission remote_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x51 || Result || [[#MapTransferMemory|MapTransferMemory]] || Handle trmem_handle, uintptr_t address, size_t size, MemoryPermission owner_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x52 || Result || [[#UnmapTransferMemory|UnmapTransferMemory]] || Handle trmem_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x53 || Result || [[#CreateInterruptEvent|CreateInterruptEvent]] || Handle *out_read_handle, int32_t interrupt_id, InterruptType interrupt_type&lt;br /&gt;
|-&lt;br /&gt;
| 0x54 || Result || [[#QueryPhysicalAddress|QueryPhysicalAddress]] || arch::PhysicalMemoryInfo *out_info, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x55 || Result || [[#QueryIoMapping|QueryIoMapping]] || uintptr_t *out_address, [10.0.0+] size_t *out_size, PhysicalAddress physical_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x56 || Result || [[#CreateDeviceAddressSpace|CreateDeviceAddressSpace]] || Handle *out_handle, uint64_t das_address, uint64_t das_size&lt;br /&gt;
|-&lt;br /&gt;
| 0x57 || Result || [[#AttachDeviceAddressSpace|AttachDeviceAddressSpace]] || DeviceName device_name, Handle das_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x58 || Result || [[#DetachDeviceAddressSpace|DetachDeviceAddressSpace]] || DeviceName device_name, Handle das_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x59 || Result || [[#MapDeviceAddressSpaceByForce|MapDeviceAddressSpaceByForce]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x5A || Result || [[#MapDeviceAddressSpaceAligned|MapDeviceAddressSpaceAligned]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x5B || Result || [[#MapDeviceAddressSpace|MapDeviceAddressSpace]] || size_t *out_mapped_size, Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address, MemoryPermission device_perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x5C || Result || [[#UnmapDeviceAddressSpace|UnmapDeviceAddressSpace]] || Handle das_handle, Handle process_handle, uint64_t process_address, size_t size, uint64_t device_address&lt;br /&gt;
|-&lt;br /&gt;
| 0x5D || Result || [[#InvalidateProcessDataCache|InvalidateProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x5E || Result || [[#StoreProcessDataCache|StoreProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x5F || Result || [[#FlushProcessDataCache|FlushProcessDataCache]] || Handle process_handle, uint64_t address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x60 || Result || [[#DebugActiveProcess|DebugActiveProcess]] || Handle *out_handle, uint64_t process_id&lt;br /&gt;
|-&lt;br /&gt;
| 0x61 || Result || [[#BreakDebugProcess|BreakDebugProcess]] || Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x62 || Result || [[#TerminateDebugProcess|TerminateDebugProcess]] || Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x63 || Result || [[#GetDebugEvent|GetDebugEvent]] || arch::DebugEventInfo *out_info, Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x64 || Result || [[#ContinueDebugEvent|ContinueDebugEvent]] || Handle debug_handle, uint32_t flags, const uint64_t *thread_ids, int32_t num_thread_ids&lt;br /&gt;
|-&lt;br /&gt;
| 0x65 || Result || [[#GetProcessList|GetProcessList]] || int32_t *out_num_processes, uint64_t *out_process_ids, int32_t max_out_count&lt;br /&gt;
|-&lt;br /&gt;
| 0x66 || Result || [[#GetThreadList|GetThreadList]] || int32_t *out_num_threads, uint64_t *out_thread_ids, int32_t max_out_count, Handle debug_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x67 || Result || [[#GetDebugThreadContext|GetDebugThreadContext]] || ThreadContext *out_context, Handle debug_handle, uint64_t thread_id, uint32_t context_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x68 || Result || [[#SetDebugThreadContext|SetDebugThreadContext]] || Handle debug_handle, uint64_t thread_id, const ThreadContext *context, uint32_t context_flags&lt;br /&gt;
|-&lt;br /&gt;
| 0x69 || Result || [[#QueryDebugProcessMemory|QueryDebugProcessMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, Handle process_handle, uintptr_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x6A || Result || [[#ReadDebugProcessMemory|ReadDebugProcessMemory]] || uintptr_t buffer, Handle debug_handle, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x6B || Result || [[#WriteDebugProcessMemory|WriteDebugProcessMemory]] || Handle debug_handle, uintptr_t buffer, uintptr_t address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C || Result || [[#SetHardwareBreakPoint|SetHardwareBreakPoint]] || HardwareBreakPointRegisterName name, uint64_t flags, uint64_t value&lt;br /&gt;
|-&lt;br /&gt;
| 0x6D || Result || [[#GetDebugThreadParam|GetDebugThreadParam]] || uint64_t *out_64, uint32_t *out_32, Handle debug_handle, uint64_t thread_id, DebugThreadParam param&lt;br /&gt;
|- style=&amp;quot;border-top: double&amp;quot;&lt;br /&gt;
| [5.0.0+] 0x6F || Result || [[#GetSystemInfo|GetSystemInfo]] || uint64_t *out, SystemInfoType info_type, Handle handle, uint64_t info_subtype&lt;br /&gt;
|-&lt;br /&gt;
| 0x70 || Result || [[#CreatePort|CreatePort]] || Handle *out_server_handle, Handle *out_client_handle, int32_t max_sessions, bool is_light, uintptr_t name&lt;br /&gt;
|-&lt;br /&gt;
| 0x71 || Result || [[#ManageNamedPort|ManageNamedPort]] || Handle *out_server_handle, const char *name, int32_t max_sessions&lt;br /&gt;
|-&lt;br /&gt;
| 0x72 || Result || [[#ConnectToPort|ConnectToPort]] || Handle *out_handle, Handle port&lt;br /&gt;
|-&lt;br /&gt;
| 0x73 || Result || [[#SetProcessMemoryPermission|SetProcessMemoryPermission]] || Handle process_handle, uint64_t address, uint64_t size, MemoryPermission perm&lt;br /&gt;
|-&lt;br /&gt;
| 0x74 || Result || [[#MapProcessMemory|MapProcessMemory]] || uintptr_t dst_address, Handle process_handle, uint64_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x75 || Result || [[#UnmapProcessMemory|UnmapProcessMemory]] || uintptr_t dst_address, Handle process_handle, uint64_t src_address, size_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x76 || Result || [[#QueryProcessMemory|QueryProcessMemory]] || arch::MemoryInfo *out_memory_info, PageInfo *out_page_info, Handle process_handle, uint64_t address&lt;br /&gt;
|-&lt;br /&gt;
| 0x77 || Result || [[#MapProcessCodeMemory|MapProcessCodeMemory]] || Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x78 || Result || [[#UnmapProcessCodeMemory|UnmapProcessCodeMemory]] || Handle process_handle, uint64_t dst_address, uint64_t src_address, uint64_t size&lt;br /&gt;
|-&lt;br /&gt;
| 0x79 || Result || [[#CreateProcess|CreateProcess]] || Handle *out_handle, const arch::CreateProcessParameter *parameters, const uint32_t *caps, int32_t num_caps&lt;br /&gt;
|-&lt;br /&gt;
| 0x7A || Result || [[#StartProcess|StartProcess]] || Handle process_handle, int32_t priority, int32_t core_id, uint64_t main_thread_stack_size&lt;br /&gt;
|-&lt;br /&gt;
| 0x7B || Result || [[#TerminateProcess|TerminateProcess]] || Handle process_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x7C || Result || [[#GetProcessInfo|GetProcessInfo]] || int64_t *out_info, Handle process_handle, ProcessInfoType info_type&lt;br /&gt;
|-&lt;br /&gt;
| 0x7D || Result || [[#CreateResourceLimit|CreateResourceLimit]] || Handle *out_handle&lt;br /&gt;
|-&lt;br /&gt;
| 0x7E || Result || [[#SetResourceLimitLimitValue|SetResourceLimitLimitValue]] || Handle resource_limit_handle, LimitableResource which, int64_t limit_value&lt;br /&gt;
|-&lt;br /&gt;
| 0x7F || void || [[#CallSecureMonitor|CallSecureMonitor]] || SecureMonitorArguments *args&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SetHeapSize ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || uint32_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || void* || HeapAddress&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the process heap to a given Size. It can both extend and shrink the heap.&lt;br /&gt;
&lt;br /&gt;
Size must be a multiple of 0x200000 (2MB).&lt;br /&gt;
&lt;br /&gt;
On success, the heap base-address (which is fixed by kernel, aslr&#039;d, and always in the Heap memory region) is written to HeapAddress.&lt;br /&gt;
&lt;br /&gt;
Uses current process pool partition. The memory allocated counts towards the caller&#039;s process Memory ResourceLimit.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] Size must be less than or equal to 4GB.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Invalid size passed. It&#039;s either bigger than 4GB, or misaligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD001:&#039;&#039;&#039; Size is bigger than the Heap Region size.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; KMemoryBlockAllocator slab allocator exhausted.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The memory region is in an invalid state. Likely because a mapping was made in the heap region.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0x10801:&#039;&#039;&#039; Memory resource limit reached.&lt;br /&gt;
&lt;br /&gt;
== SetMemoryPermission ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes permission of page-aligned memory region.&lt;br /&gt;
&lt;br /&gt;
Bit2 of permission (exec) is not allowed. Setting write-only is not allowed either (bit1).&lt;br /&gt;
&lt;br /&gt;
This can be used to move back and forth between ---, r-- and rw-.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The memory region was reprotected.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Unaligned address specified.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Unaligned or zero size specified.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The provided memory region does not fall within the userland address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD801:&#039;&#039;&#039; Invalid permission specified. Valid permissions are ---, r-- and rw-.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD401:&#039;&#039;&#039; The provided memory region was in an invalid state. The region must have the [[#MemoryState|FlagCanReprotect]] state, and must not have the [[#MemoryAttribute|Locked]] or [[#MemoryAttribute|Uncached]] attributes.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; Kernel resource exhausted.&lt;br /&gt;
&lt;br /&gt;
== SetMemoryAttribute ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || uint32_t || Mask&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes attribute of page-aligned memory region. The only allowed combination of Value and Mask is 0x8, which means only bit3 in [[#MemoryAttribute]] can be set or cleared.&lt;br /&gt;
&lt;br /&gt;
This is used to turn on/off caching for a given memory area. Useful when talking to devices such as the GPU.&lt;br /&gt;
&lt;br /&gt;
What happens &amp;quot;under the hood&amp;quot; is the &amp;quot;Memory Attribute Indirection Register&amp;quot; index is changed from 2 to 3 in the MMU descriptor.&lt;br /&gt;
&lt;br /&gt;
== MapMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps a memory range into a different range.&lt;br /&gt;
&lt;br /&gt;
Mainly used for adding guard pages around stack.&lt;br /&gt;
&lt;br /&gt;
Source range gets reprotected to --- (it can no longer be accessed), and bit0 is set in the source [[#MemoryAttribute]].&lt;br /&gt;
&lt;br /&gt;
[1.0.0] This could be used to map into either the Alias Region or the Stack region.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] This can only be used to map into the Stack region.&lt;br /&gt;
&lt;br /&gt;
Code can get the range of the Alias region from [[#GetInfo]] id0=2,3, and on 2.0.0+ the range of the Stack region via [[#GetInfo]] id0=14, 15 (on 1.0.0, the Stack region had hardcoded limits).&lt;br /&gt;
&lt;br /&gt;
When mapped into the Alias region, the mapped memory will have state 0x482907.&lt;br /&gt;
&lt;br /&gt;
When mapped into the Stack region, the mapped memory will have state 0x5C3C0B.&lt;br /&gt;
&lt;br /&gt;
== UnmapMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps a region that was previously mapped with [[#MapMemory]].&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to unmap ranges partially, you don&#039;t need to unmap the entire range &amp;quot;in one go&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The srcaddr/dstaddr must match what was given when the pages were originally mapped.&lt;br /&gt;
&lt;br /&gt;
== QueryMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Queries information about an address. Will always fetch the lowest page-aligned mapping that contains the provided address.&lt;br /&gt;
&lt;br /&gt;
Outputs a [[#MemoryInfo]] struct.&lt;br /&gt;
&lt;br /&gt;
== ExitProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the current process.&lt;br /&gt;
&lt;br /&gt;
== CreateThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void(*)(void*) || Entry&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || void* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || void* || StackTop&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R0 || int32_t || Priority&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R4 || int32_t || ProcessorId&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a thread in the current process.&lt;br /&gt;
&lt;br /&gt;
ProcessorId must be 0,1,2,3 or -2, where -2 uses the default CpuId for process.&lt;br /&gt;
&lt;br /&gt;
== StartThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None ||  ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the thread for the provided handle.&lt;br /&gt;
&lt;br /&gt;
== ExitThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the current thread.&lt;br /&gt;
&lt;br /&gt;
== SleepThread ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0, R1 || uint64_t || Nanoseconds&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sleeps for a specified amount of time, or yields the thread.&lt;br /&gt;
&lt;br /&gt;
Setting nanoseconds to 0, -1, or -2 indicates a yielding type.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Yielding without core migration&lt;br /&gt;
|-&lt;br /&gt;
| -1 || Yielding with core migration&lt;br /&gt;
|-&lt;br /&gt;
| -2 || Yielding to any other thread&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadPriority ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1|| Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || int32_t || Priority&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets the priority of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== SetThreadPriority ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0|| Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1|| int32_t || Priority&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the priority of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
Priority is a number 0-0x3F. Lower value means higher priority.&lt;br /&gt;
&lt;br /&gt;
== GetThreadCoreMask ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || int32_t || CoreMask0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || R2, R3 || uint64_t || CoreMask1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets the affinity mask of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== SetThreadCoreMask ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || int32_t || CoreMask0&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || uint64_t || CoreMask1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the affinity mask of provided thread handle.&lt;br /&gt;
&lt;br /&gt;
== GetCurrentProcessorNumber ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || uint32_t || CpuId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets which cpu is executing the current thread.&lt;br /&gt;
&lt;br /&gt;
CpuId is an integer in the range 0-3.&lt;br /&gt;
&lt;br /&gt;
== SignalEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;WritableEvent&amp;gt; || EventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Puts the given event in the signaled state.&lt;br /&gt;
&lt;br /&gt;
Will wake up any thread currently waiting on this event. Can potentially trigger a reschedule.&lt;br /&gt;
&lt;br /&gt;
Any calls to [[#WaitSynchronization]] on this handle will return immediately, until the event&#039;s signaled state is reset.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. Event is now in signaled state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; Invalid handle. The handle either does not exist, or is not a WritableEvent.&lt;br /&gt;
&lt;br /&gt;
== ClearEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;WritableEvent&amp;gt; or Handle&amp;lt;ReadableEvent&amp;gt; || EventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes the given event out of the signaled state.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success, the event is now in the not-signaled state.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; Invalid handle. The handle either does not exist, or is not a ReadableEvent nor a WritableEvent.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; The handle was not in a signaled state.&lt;br /&gt;
&lt;br /&gt;
== MapSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the block supplied by the handle. The required permissions are different for the process that created the handle and all other processes.&lt;br /&gt;
&lt;br /&gt;
Increases reference count for the KSharedMemory object. Thus in order to release the memory associated with the object, all handles to it must be closed and all mappings must be unmapped.&lt;br /&gt;
&lt;br /&gt;
== UnmapSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one reprotects the src block with perms you give it. It also sets bit0 into [[#MemoryAttribute]].&lt;br /&gt;
&lt;br /&gt;
Executable bit perm not allowed.&lt;br /&gt;
&lt;br /&gt;
Closing all handles automatically causes the bit0 in [[#MemoryAttribute]] to clear, and the permission to reset.&lt;br /&gt;
&lt;br /&gt;
== CloseHandle ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ResetSignal ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;ReadableEvent&amp;gt; or Handle&amp;lt;Process&amp;gt; || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resets the signal on the given handle, ensuring future calls to [[#WaitSynchronization]] on this handle will sleep until the handle is signaled again. If the handle is a ReadableEvent, this is equivalent to calling ClearEvent() on the handle.&lt;br /&gt;
&lt;br /&gt;
If the handle is a Process, it will clear the signaled state (which is set when the process changes [[#ProcessState]]. Once the process enters the Exited state, calling ResetSignal on the process will no longer have an effect (the process is permanently signaled), and the syscall will return 0xFA01.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The signal was reset.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; The handle is invalid or of the wrong type.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; The handle was not signaled, or the process is in exited state, causing it to be permanently signaled.&lt;br /&gt;
&lt;br /&gt;
== WaitSynchronization ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle* || HandlesPtr&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || HandlesNum&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || int64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint64_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Works with HandlesNum &amp;lt;= 0x40.&lt;br /&gt;
&lt;br /&gt;
When zero handles are passed, this will wait forever until either timeout or cancellation occurs.&lt;br /&gt;
&lt;br /&gt;
Does not accept 0xFFFF8001 or 0xFFFF8000 as handles.&lt;br /&gt;
&lt;br /&gt;
=== Object types ===&lt;br /&gt;
&#039;&#039;&#039;KDebug:&#039;&#039;&#039; signals when there is a new [[#DebugEventInfo|DebugEvent]] (retrievable via [[#GetDebugEvent]]).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KClientPort:&#039;&#039;&#039; signals when the number of sessions is less than the maximum allowed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KProcess:&#039;&#039;&#039; signals when the process undergoes a state change (retrievable via [[#GetProcessInfo]]).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KReadableEvent:&#039;&#039;&#039; signals when the event&#039;s corresponding KWritableEvent has been signaled via [[#SignalEvent]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KServerPort:&#039;&#039;&#039; signals when there is an incoming connection waiting to be [[#AcceptSession|accepted]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KServerSession:&#039;&#039;&#039; signals when there is an incoming message waiting to be [[#ReplyAndReceive|received]] or the pipe is closed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KThread:&#039;&#039;&#039; signals when the thread has exited.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. One of the objects was signaled before the timeout expired, or one of the objects is a Session with a closed remote. Handle index is updated to indicate which object signaled.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0x7601:&#039;&#039;&#039; Thread termination requested. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid handle. Returned when one of the handles passed is invalid. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe601:&#039;&#039;&#039; Invalid address. Returned when the handles pointer is not a readable address. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xea01:&#039;&#039;&#039; Timeout. Returned when no objects have been signaled within the timeout. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xec01:&#039;&#039;&#039; Interrupted. Returned when another thread uses [[#CancelSynchronization]] to cancel this thread. Handle index is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xee01:&#039;&#039;&#039; Too many handles. Returned when the number of handles passed is &amp;gt; 0x40.&lt;br /&gt;
&lt;br /&gt;
== CancelSynchronization ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the referenced thread is currently in a synchronization call ([[#WaitSynchronization]], [[#ReplyAndReceive]] or [[#ReplyAndReceiveLight]]), that call will be interrupted and return 0xec01.&lt;br /&gt;
If that thread is not currently executing such a synchronization call, the next call to a synchronization call will return 0xec01.&lt;br /&gt;
&lt;br /&gt;
This doesn&#039;t take force-pause (activity/debug pause) into account.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The thread was either interrupted or has had its flag set.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid handle. The handle given was either invalid or not a thread handle.&lt;br /&gt;
&lt;br /&gt;
== ArbitrateLock ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || uint32_t || Tag&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;                                  &lt;br /&gt;
&lt;br /&gt;
== ArbitrateUnlock ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WaitProcessWideKeyAtomic ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || KeyAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void* || TagAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Tag&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || int64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SignalProcessWideKey ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || int32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetSystemTick ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0, R1 || uint64_t || Ticks&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the value of cntpct_el0.&lt;br /&gt;
&lt;br /&gt;
The frequency is 19200000 Hz (constant from official sw).&lt;br /&gt;
&lt;br /&gt;
Official sw reads cntpct_el0 directly from usermode without using this SVC. [[ExeFS|sdk-nso]] has this SVC, but it&#039;s not known to be called anywhere.&lt;br /&gt;
&lt;br /&gt;
== ConnectToNamedPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || char* || PortName&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequestLight ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequest ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SendSyncRequestWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size and Address must be 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xcc01:&#039;&#039;&#039; Address is not 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xca01:&#039;&#039;&#039; Size is not 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xce01:&#039;&#039;&#039; KSessionRequest allocation failed (unlikely) or pointer buffer size exceeded.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Handles does not exist, or handle is not an instance of KClientSession.&lt;br /&gt;
&lt;br /&gt;
== SendAsyncRequestWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ReadableEvent&amp;gt; || EventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size and Address must be 0x1000-aligned.&lt;br /&gt;
&lt;br /&gt;
== GetProcessId ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || ProcessId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadId ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || ThreadId&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Break ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#BreakReason]] || BreakReason&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Info&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the process is attached, report the Break event. Then, if [[#ContinueDebugEvent]] didn&#039;t apply IgnoreException on the thread: if TPIDR_EL0 is 0, adjust ELR_EL1 to retry to svc instruction (and set TPIDR_EL0 to 1).&lt;br /&gt;
&lt;br /&gt;
Otherwise, if bit31 in reason isn&#039;t set, perform crash reporting (see Exception Handling section below), if it doesn&#039;t terminate the process adjust ELR_EL1 as well.&lt;br /&gt;
&lt;br /&gt;
Otherwise just return 0.&lt;br /&gt;
&lt;br /&gt;
== OutputDebugString ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || char* || String&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReturnFromException ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#InfoType]] || InfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || uint64_t || InfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || Info&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushEntireDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MapPhysicalMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Acts like [[#SetHeapSize]] except you can allocate heap at any address you&#039;d like.&lt;br /&gt;
&lt;br /&gt;
Uses current process pool partition.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Invalid size passed. It&#039;s either zero or not 4k-aligned&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Invalid address. (not 4k-aligned)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xDC01:&#039;&#039;&#039; Invalid memory range. It&#039;s either causes overflow, or does not fall into &amp;quot;reserved&amp;quot; address range (aka Alias). See AliasRegionAddress at [[#InfoType]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xFA01:&#039;&#039;&#039; Invalid state. (not enough SystemResource (see [[NPDM#SystemResourceSize]]))&lt;br /&gt;
&lt;br /&gt;
== UnmapPhysicalMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugFutureThreadInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R1 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || LastThreadContextParam0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || LastThreadContextParam1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || LastThreadContextParam2&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X4 || uint64_t || LastThreadContextParam3&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X5 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W6 || uint32_t ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetLastThreadInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || LastThreadContextParam0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || LastThreadContextParam1&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || LastThreadContextParam2&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X4 || uint64_t || LastThreadContextParam3&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X5 || uint64_t ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W6 || uint32_t ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitLimitValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || LimitValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetResourceLimitCurrentValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || int64_t || CurrentValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetThreadActivity ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || [[#ThreadActivity]] || ThreadActivity&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetThreadContext3 ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Thread&amp;gt; || ThreadHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WaitForAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#ArbitrationType]] || ArbitrationType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SignalToAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#SignalType]] || SignalType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || uint32_t || NumToSignal&lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || || ||&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SynchronizePreemptionState ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None ||  || &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DumpInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#DumpInfoType]] || DumpInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || DumpInfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
[4.0.0+] This function was removed and replaced by [[#KernelDebug]].&lt;br /&gt;
&lt;br /&gt;
== KernelDebug ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#KernelDebugType]] || KernelDebugType&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
== ChangeKernelTraceState ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#KernelTraceState]] || KernelTraceState&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stubbed in retail kernel.&lt;br /&gt;
&lt;br /&gt;
== CreateSession ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || bool || IsLight&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ServerSession&amp;gt; || ServerSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || Handle&amp;lt;ClientSession&amp;gt; || ClientSessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== AcceptSession ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Port&amp;gt; || PortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ServerSession&amp;gt; || ServerSessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0xf201:&#039;&#039;&#039; No session waiting to be accepted&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceiveLight ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Port&amp;gt; or Handle&amp;lt;ServerSession&amp;gt; || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceive ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Port&amp;gt;* or Handle&amp;lt;ServerSession&amp;gt;* || Handles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || NumHandles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || Handle&amp;lt;ServerSession&amp;gt; || ReplyTargetSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R0, R4 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If ReplyTargetSessionHandle is not zero, a reply from the TLS will be sent to that session.&lt;br /&gt;
Then it will wait until either of the passed sessions has an incoming message, is closed, a passed port has an incoming connection, or the timeout expires.&lt;br /&gt;
If there is an incoming message, it is copied to the TLS.&lt;br /&gt;
&lt;br /&gt;
If ReplyTargetSessionHandle is zero, the TLS should contain a blank message. If this message has a C descriptor, the buffer it points to will be used as the pointer buffer. See [[IPC_Marshalling#IPC_buffers]]. Note that a pointer buffer cannot be specified if ReplyTargetSessionHandle is not zero.&lt;br /&gt;
&lt;br /&gt;
After being validated, passed handles will be enumerated in order; even if a session has been closed, if one that appears earlier in the list has an incoming message, it will take priority and a result code of 0x0 will be returned.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. Either a session has an incoming message or a port has an incoming connection. HandleIndex is set appropriately.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xea01:&#039;&#039;&#039; Timeout. No handles were signalled before the timeout expired. HandleIndex is not updated.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xf601:&#039;&#039;&#039; Port remote dead. One of the sessions has been closed. HandleIndex is set appropriately.&lt;br /&gt;
&lt;br /&gt;
== ReplyAndReceiveWithUserBuffer ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || Handle&amp;lt;Port&amp;gt;* or Handle&amp;lt;ServerSession&amp;gt;* || Handles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R0 || uint32_t || NumHandles&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R4 || Handle&amp;lt;ServerSession&amp;gt; || ReplyTargetSessionHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X6 || R5, R6 || uint64_t || Timeout&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || HandleIndex&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;WritableEvent&amp;gt; || WritableEventHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || Handle&amp;lt;ReadableEvent&amp;gt; || ReadableEventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MapPhysicalMemoryUnsafe ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Same as [[#MapPhysicalMemory]] except it always uses pool partition 0.&lt;br /&gt;
&lt;br /&gt;
== UnmapPhysicalMemoryUnsafe ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetUnsafeLimit ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || uint64_t || Limit&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;CodeMemory&amp;gt; || CodeMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes an address range with backing memory to create the code memory object.&lt;br /&gt;
&lt;br /&gt;
The memory is initially memset to 0xFF after being locked.&lt;br /&gt;
&lt;br /&gt;
== ControlCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;CodeMemory&amp;gt; || CodeMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#CodeMemoryOperation]] || CodeMemoryOperation&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4, R5 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R6 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the backing memory for a CodeMemory object into the current process.&lt;br /&gt;
&lt;br /&gt;
For [[#CodeMemoryOperation|MapOwner]], memory permission must be RW-.&lt;br /&gt;
&lt;br /&gt;
For [[#CodeMemoryOperation|MapSlave]], memory permission must be R-- or R-X.&lt;br /&gt;
&lt;br /&gt;
Operations [[#CodeMemoryOperation|UnmapOwner/UnmapSlave]] unmap memory that was previously mapped this way.&lt;br /&gt;
&lt;br /&gt;
This allows one &amp;quot;secure JIT&amp;quot; process to map the code memory as RW-, and the other &amp;quot;slave&amp;quot; process to map it R-X.&lt;br /&gt;
&lt;br /&gt;
[5.0.0+] Error 0xE401 is now returned when the process owner of the Code memory object is the same as the current process.&lt;br /&gt;
&lt;br /&gt;
== SleepSystem ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || || &lt;br /&gt;
|-&lt;br /&gt;
| (Out) None || || &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReadWriteRegister ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || RegisterAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R0 || uint32_t || RwMask&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R1 || uint32_t || InValue&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || OutValue&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Read/write IO registers with a hardcoded whitelist. Input address is physical-address and must be aligned to 4.&lt;br /&gt;
&lt;br /&gt;
rw_mask is 0 for reading and 0xffffffff for writing. You can also write individual bits by using a mask value.&lt;br /&gt;
&lt;br /&gt;
You can only write to registers inside physical pages 0x70019000 (MC), 0x7001C000 (MC0), 0x7001D000 (MC1), and they all share the same whitelist.&lt;br /&gt;
&lt;br /&gt;
The whitelist is same for writing as for reading.&lt;br /&gt;
&lt;br /&gt;
The whitelist is:&lt;br /&gt;
&lt;br /&gt;
0x054, 0x090, 0x094, 0x098, 0x09c, 0x0a0, 0x0a4, 0x0a8, 0x0ac, 0x0b0, 0x0b4, 0x0b8, 0x0bc, 0x0c0, 0x0c4, 0x0c8, 0x0d0, 0x0d4, 0x0d8, 0x0dc, 0x0e0, 0x100, 0x108, 0x10c, 0x118, 0x11c, 0x124, 0x128, 0x12c, 0x130, 0x134, 0x138, 0x13c, 0x158, 0x15c, 0x164, 0x168, 0x16c, 0x170, 0x174, 0x178, 0x17c, 0x200, 0x204, 0x2e4, 0x2e8, 0x2ec, 0x2f4, 0x2f8, 0x310, 0x314, 0x320, 0x328, 0x344, 0x348, 0x370, 0x374, 0x37c, 0x380, 0x390, 0x394, 0x398, 0x3ac, 0x3b8, 0x3bc, 0x3c0, 0x3c4, 0x3d8, 0x3e8, 0x41c, 0x420, 0x424, 0x428, 0x42c, 0x430, 0x44c, 0x47c, 0x480, 0x484, 0x50c, 0x554, 0x558, 0x55c, 0x670, 0x674, 0x690, 0x694, 0x698, 0x69c, 0x6a0, 0x6a4, 0x6c0, 0x6c4, 0x6f0, 0x6f4, 0x960, 0x970, 0x974, 0xa20, 0xa24, 0xb88, 0xb8c, 0xbc4, 0xbc8, 0xbcc, 0xbd0, 0xbd4, 0xbd8, 0xbdc, 0xbe0, 0xbe4, 0xbe8, 0xbec, 0xc00, 0xc5c, 0xcac&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] Whitelist was extended with 0x4c4, 0x4c8, 0x4cc, 0x584, 0x588, 0x58c.&lt;br /&gt;
&lt;br /&gt;
[2.0.0+] The IO registers in range 0x7000E400 (PMC) size 0xC00 skip the whitelist, and do a TrustZone call using [[SMC#ReadWriteRegister|ReadWriteRegister]].&lt;br /&gt;
&lt;br /&gt;
[4.0.0+] Access to the Memory Controller (0x70019000) also uses smcReadWriteRegister.&lt;br /&gt;
&lt;br /&gt;
Here is the whitelist imposed by that SMC, relative to the start of the PMC registers:&lt;br /&gt;
&lt;br /&gt;
0x000, 0x00c, 0x010, 0x014, 0x01c, 0x020, 0x02c, 0x030, 0x034, 0x038, 0x03c, 0x040, 0x044, 0x048, 0x0dc, 0x0e0, 0x0e4, 0x160, 0x164, 0x168, 0x170, 0x1a8, 0x1b8, 0x1bc, 0x1c0, 0x1c4, 0x1c8, 0x2b4, 0x2d4, 0x440, 0x4d8&lt;br /&gt;
&lt;br /&gt;
Here is the whitelist imposed by the SMC [[SMC#ReadWriteRegister|ReadWriteRegister]] (checked in addition to the whitelist in the ReadWriteRegister SVC), relative to the start of the MC registers:&lt;br /&gt;
&lt;br /&gt;
0x000, 0x004, 0x008, 0x00C, 0x010, 0x01C, 0x020, 0x030, 0x034, 0x050, 0x054, 0x090, 0x094, 0x098, 0x09C, 0x0A0, 0x0A4, 0x0A8, 0x0AC, 0x0B0, 0x0B4, 0x0B8, 0x0BC, 0x0C0, 0x0C4, 0x0C8, 0x0D0, 0x0D4, 0x0D8, 0x0DC, 0x0E0, 0x100, 0x108, 0x10C, 0x118, 0x11C, 0x124, 0x128, 0x12C, 0x130, 0x134, 0x138, 0x13C, 0x158, 0x15C, 0x164, 0x168, 0x16C, 0x170, 0x174, 0x178, 0x17C, 0x200, 0x204, 0x238, 0x240, 0x244, 0x250, 0x254, 0x258, 0x264, 0x268, 0x26C, 0x270, 0x274, 0x280, 0x284, 0x288, 0x28C, 0x294, 0x2E4, 0x2E8, 0x2EC, 0x2F4, 0x2F8, 0x310, 0x314, 0x320, 0x328, 0x344, 0x348, 0x370, 0x374, 0x37C, 0x380, 0x390, 0x394, 0x398, 0x3AC, 0x3B8, 0x3BC, 0x3C0, 0x3C4, 0x3D8, 0x3E8, 0x41C, 0x420, 0x424, 0x428, 0x42C, 0x430, 0x44C, 0x47C, 0x480, 0x484, 0x4C4, 0x4C8, 0x4CC, 0x50C, 0x554, 0x558, 0x55C, 0x584, 0x588, 0x58C, 0x670, 0x674, 0x690, 0x694, 0x698, 0x69C, 0x6A0, 0x6A4, 0x6C0, 0x6C4, 0x6F0, 0x6F4, 0x960, 0x970, 0x974, 0x9B8, 0xA20, 0xA24, 0xA88, 0xA94, 0xA98, 0xA9C, 0xAA0, 0xAA4, 0xAA8, 0xAAC, 0xAB0, 0xAB4, 0xAB8, 0xABC, 0xAC0, 0xAC4, 0xAC8, 0xACC, 0xAD0, 0xAD4, 0xAD8, 0xADC, 0xAE0, 0xB88, 0xB8C, 0xBC4, 0xBC8, 0xBCC, 0xBD0, 0xBD4, 0xBD8, 0xBDC, 0xBE0, 0xBE4, 0xBE8, 0xBEC, 0xC00, 0xC5C, 0xCAC&lt;br /&gt;
&lt;br /&gt;
== SetProcessActivity ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || [[#ProcessActivity]] || ProcessActivity&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreateSharedMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#MemoryPermission]] || LocalMemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || RemoteMemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;SharedMemory&amp;gt; || SharedMemoryHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other perm can be used to enforce permission 1, 3, or 0x10000000 if don&#039;t care.&lt;br /&gt;
&lt;br /&gt;
Allocates memory from the current process&#039; pool partition.&lt;br /&gt;
&lt;br /&gt;
== MapTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You must pass same size and permissions as given in [[#CreateTransferMemory]], otherwise error.&lt;br /&gt;
&lt;br /&gt;
== UnmapTransferMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || Handle&amp;lt;TransferMemory&amp;gt; || TransferMemoryHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Size must match size given in map syscall, otherwise there&#039;s an invalid-size error.&lt;br /&gt;
&lt;br /&gt;
== CreateInterruptEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#Interrupt]] || Interrupt&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || [[#InterruptType]] || InterruptType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ReadableEvent&amp;gt; || ReadableEventHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an event handle for the given IRQ number. Waiting on this handle will wait until the IRQ is triggered. The InterruptType argument configures the triggering. If it is 0, the IRQ is active HIGH level sensitive, if it is 1 it is rising-edge sensitive.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF001:&#039;&#039;&#039; Flags was &amp;gt; 1&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF201:&#039;&#039;&#039; IRQ above 0x3FF or outside the [[NPDM#Kernel_Access_Control|IRQ access mask]] was given.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCE01:&#039;&#039;&#039; A SlabHeap was exhausted (too many interrupts created).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF401:&#039;&#039;&#039; IRQ already has an event registered.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xD201:&#039;&#039;&#039; The handle table is full. Try closing some handles.&lt;br /&gt;
&lt;br /&gt;
== QueryPhysicalAddress ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || VirtualAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]]|| Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || PhysicalMemoryInfoAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X2 || uint64_t || PhysicalMemoryInfoBaseAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X3 || uint64_t || PhysicalMemoryInfoSize&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Queries the physical address of a virtual address. Will always fetch the lowest page-aligned mapping that contains the provided physical address.&lt;br /&gt;
&lt;br /&gt;
The returned PhysicalMemoryInfoBaseAddress is the virtual address of that page-aligned mapping, while PhysicalMemoryInfoAddress is the physical address of that page. PhysicalMemoryInfoSize is the amount of continuous physical memory in that mapping.&lt;br /&gt;
&lt;br /&gt;
== QueryIoMapping ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || IoAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R0 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1 || void* || VirtualAddress&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns a virtual address mapped to a given IO range.&lt;br /&gt;
&lt;br /&gt;
== CreateDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || DeviceAddressSpaceStartAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R0, R1 || uint64_t || DeviceAddressSpaceEndAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a virtual address space for binding device address spaces and returns a handle.&lt;br /&gt;
&lt;br /&gt;
StartAddr is normally set to 0 and EndAddr is normally set to 0xFFFFFFFF.&lt;br /&gt;
&lt;br /&gt;
== AttachDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#DeviceName]] || DeviceName&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a device address space to a [[#DeviceName|device]].&lt;br /&gt;
&lt;br /&gt;
== DetachDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || [[#DeviceName]] || DeviceName&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches a device address space from a [[#DeviceName|device]].&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpaceByForce ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps an attached device address space to an userspace address.&lt;br /&gt;
&lt;br /&gt;
Address is the userspace destination address, while DeviceAddressSpaceAddress is the source address between DeviceAddressSpaceStartAddress and DeviceAddressSpaceEndAddress (passed to [[#CreateDeviceAddressSpace]]).&lt;br /&gt;
&lt;br /&gt;
The userspace destination address must have the [[SVC#MemoryState|FlagCanDeviceMap]] bit set. Bit [[SVC#MemoryAttribute|DeviceShared]] will be set after mapping.&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpaceAligned ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W5 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps an attached device address space to an userspace address.&lt;br /&gt;
&lt;br /&gt;
Same as [[#MapDeviceAddressSpaceByForce]], but the userspace destination address must have the [[SVC#MemoryState|FlagCanAlignedDeviceMap]] bit set instead.&lt;br /&gt;
&lt;br /&gt;
== MapDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X5 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W6 || R7 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1 || uint64_t || Size&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== UnmapDeviceAddressSpace ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;DeviceAddressSpace&amp;gt; || DeviceAddressSpaceHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || DeviceAddressSpaceSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R5, R6 || uint64_t || DeviceAddressSpaceAddress&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps an attached device address space from an userspace address.&lt;br /&gt;
&lt;br /&gt;
== InvalidateProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== StoreProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FlushProcessDataCache ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DebugActiveProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || ProcessId&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== BreakDebugProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== TerminateDebugProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#DebugEventInfo]]* || DebugEventInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugEvent ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || uint32_t || [[#ContinueDebugFlags]] ([1.0.0-2.3.0] [[#ContinueDebugFlagsOld]])&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 ([1.0.0-2.3.0] R2, R3) || uint64_t* ([1.0.0-2.3.0] uint64_t)|| ThreadIdList ([1.0.0-2.3.0] ThreadId)&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3 || uint64_t || [3.0.0+] NumThreadIds&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maximum NumThreadIds is 64. 0 means &amp;quot;all threads&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success. The process has been resumed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe401:&#039;&#039;&#039; Invalid debug handle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xf401:&#039;&#039;&#039; Process has debug events queued or is already running.&lt;br /&gt;
&lt;br /&gt;
== GetProcessList ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || uint64_t* || ProcessIdBuffer&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || ProcessIdBufferSize&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || NumProcesses&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fills the provided array with the pids of currently living processes. A process &amp;quot;lives&amp;quot; so long as it is currently running or a handle to it still exists.&lt;br /&gt;
&lt;br /&gt;
It returns the total number of processes currently alive. If this number is bigger than the size of ProcessIdBuffer, the user won&#039;t have all the pids.&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xd401:&#039;&#039;&#039; The provided buffer is outside the process address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xe601:&#039;&#039;&#039; copyToUser failed. The provided buffer is not user-accessible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xee01:&#039;&#039;&#039; The provided buffer size is too big. Max value is 0xFFFFFFF.&lt;br /&gt;
&lt;br /&gt;
== GetThreadList ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || uint64_t* || ThreadIdBuffer&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || uint32_t || ThreadIdBufferSize&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || uint32_t || NumThreads&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetDebugThreadContext ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R4 || uint32_t || [[#ThreadContextFlags]]&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetDebugThreadContext ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1 || [[#ThreadContext]]* || ThreadContext&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R4 || uint32_t || [[#ThreadContextFlags]]&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== QueryDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ReadDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || void* || MemoryBufferAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== WriteDebugProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || void* || MemoryBufferAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetHardwareBreakPoint ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || [[#HardwareBreakPointRegisterName]] || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || uint64_t || Flags&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Value&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets one of the AArch64 hardware breakpoints. The nintendo switch has 6 hardware breakpoints, and 4 hardware watchpoints. The syscall has two behaviors depending on the value of HardwareBreakPointRegisterName:&lt;br /&gt;
&lt;br /&gt;
If HardwareBreakPointRegisterName &amp;lt; 0x10, then it sets one of the AArch64 hardware breakpoints. Flags will go to DBGBCRn_EL1, and value to DBGBVRn_EL1. The only flags the user is allowed to set are those in the bitmask 0x7F01E1. Furthermore, the kernel will or it with 0x4004, in order to set various security flags to guarantee the watchpoints only triggers for code in EL0. If the user asks for a Breakpoint Type of ContextIDR match, the kernel shall use the given DebugHandle to set DBGBVRn_EL1 to the ContextID of the debugged process.&lt;br /&gt;
&lt;br /&gt;
If HardwareBreakPointRegisterName is between 0x10 and 0x20 (exclusive), then it sets one of the AArch64 hardware watchpoints. Flags will go to DBGWCRn_EL1, and the value to DBGWVRn_EL1. The only flags the user is allowed to set are those in the bitmask 0xFF0F1FF9. Furthermore, the kernel will or it with 0x104004. This will set various security flags, and set the watchpoint type to be a Linked Watchpoint. This means that you need to link it to a Linked ContextIDR breakpoint. Check the ARM documentation for more information.&lt;br /&gt;
&lt;br /&gt;
Note that HardwareBreakPointRegisterName 0 to 4 match only to Virtual Address, while HardwareBreakPointRegisterName 5 and 6 match against either Virtual Address, ContextID, or VMID. As such, if you are configuring a breakpoint to link for a watchpoint, make sure you use hardware_breakpoint_id 5 or 6.&lt;br /&gt;
&lt;br /&gt;
For more documentation for hardware breakpoints, check out the AArch64 documentation for the [http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0488h/way1382455558968.html DBGBCRn_EL1 register] and the [http://infocenter.arm.com/help/topic/com.arm.doc.ddi0488h/way1382455560629.html DBGWCRn_EL1 register]&lt;br /&gt;
&lt;br /&gt;
== GetDebugThreadParam ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2 || Handle&amp;lt;Debug&amp;gt; || DebugHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R0, R1 || uint64_t || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| (In) W4 || R3 || [[#DebugThreadParam]] || DebugThreadParam&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || Out0&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || R3 || uint32_t || Out1&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetSystemInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#SystemInfoType]] || SystemInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || Handle || Handle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || uint64_t || SystemInfoSubType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || uint64_t || SystemInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CreatePort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || MaxSessions&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R3 || bool || IsLight&lt;br /&gt;
|-&lt;br /&gt;
| (In) X4 || R0 || uint64_t || Name&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || Handle&amp;lt;Port&amp;gt; || ServerPortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W2 || R2 || Handle&amp;lt;Port&amp;gt; || ClientPortHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ManageNamedPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || char* || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || int32_t || MaxSessions&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Port&amp;gt; || ServerPortHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== ConnectToPort ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || Handle&amp;lt;Port&amp;gt; || ClientPortHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Session&amp;gt; || SessionHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetProcessMemoryPermission ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || Addr&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (In) W3 || R5 || [[#MemoryPermission]] || MemoryPermission&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This sets the memory permissions for the specified memory with the supplied process handle.&lt;br /&gt;
&lt;br /&gt;
This throws an error(0xD801) when the input perm is &amp;gt;0x5, hence -WX and RWX are not allowed.&lt;br /&gt;
&lt;br /&gt;
== MapProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maps the src address from the supplied process handle into the current process.&lt;br /&gt;
&lt;br /&gt;
This allows mapping code and rodata with RW- permission.&lt;br /&gt;
&lt;br /&gt;
== UnmapProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R4 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps what was mapped by [[#MapProcessMemory]].&lt;br /&gt;
&lt;br /&gt;
== QueryProcessMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || [[#MemoryInfo]]* || MemoryInfo&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R1, R3 || void* || Address&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || R1 || [[#PageInfo]] || PageInfo&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Equivalent to [[#QueryMemory]] except takes a process handle.&lt;br /&gt;
&lt;br /&gt;
== MapProcessCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R5, R6 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a process handle, and maps normal heap in that process as executable code in that process. Used when loading NROs. This does not support using the current-process handle alias.&lt;br /&gt;
&lt;br /&gt;
== UnmapProcessCodeMemory ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || R2, R3 || void* || DstAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R1, R4 || void* || SrcAddress&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R5, R6 || uint64_t || Size&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unmaps what was mapped by [[#MapProcessCodeMemory]].&lt;br /&gt;
&lt;br /&gt;
== CreateProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1 || [[#CreateProcessParameter]]* || CreateProcessParameter&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || uint32_t* || Capabilities&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || int32_t || CapabilitiesNum&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a [[#CreateProcessParameter]] as input.&lt;br /&gt;
Capabilities points to an array of [[NPDM#Kernel_Access_Control|kernel capabilities]].&lt;br /&gt;
CapabilitiesNum is a number of capabilities in the Capabilities array (number of element, not number of bytes).&lt;br /&gt;
&lt;br /&gt;
=== Result codes ===&lt;br /&gt;
&#039;&#039;&#039;0x0:&#039;&#039;&#039; Success.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCA01:&#039;&#039;&#039; Attempted to map more code pages than available in address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xCC01:&#039;&#039;&#039; Provided CodeAddr is invalid (make sure it&#039;s in range?)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE401:&#039;&#039;&#039; The resource handle passed is invalid.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE601:&#039;&#039;&#039; Attempt to copy procinfo from user-supplied pointer failed. Attempt to copy capabilities_num from user-supplied pointer failed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xE801:&#039;&#039;&#039; Attempted to create a 32-bit process with a 36-bit address space.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;0xF001:&#039;&#039;&#039; Unused bits are set in mmuflags. Unknown address space type used.&lt;br /&gt;
&lt;br /&gt;
== StartProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || int32_t || MainThreadPriority&lt;br /&gt;
|-&lt;br /&gt;
| (In) W2 || R2 || int32_t || DefaultCpuId&lt;br /&gt;
|-&lt;br /&gt;
| (In) X3 || R3, R4 || uint64_t || MainThreadStackSize&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== TerminateProcess ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GetProcessInfo ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R1 || Handle&amp;lt;Process&amp;gt; || ProcessHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R2 || [[#ProcessInfoType]] || ProcessInfoType&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1 || R1, R2 || uint64_t || [[#ProcessState]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns an enum with value 0-7.&lt;br /&gt;
&lt;br /&gt;
== CreateResourceLimit ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) None || ||&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || [[#Result]] || Result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W1 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== SetResourceLimitLimitValue ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) W0 || R0 || Handle&amp;lt;ResourceLimit&amp;gt; || ResourceLimitHandle&lt;br /&gt;
|-&lt;br /&gt;
| (In) W1 || R1 || [[#LimitableResource]] || LimitableResource&lt;br /&gt;
|-&lt;br /&gt;
| (In) X2 || R2, R3 || int64_t || LimitValue&lt;br /&gt;
|-&lt;br /&gt;
| (Out) W0 || R0 || [[#Result]] || Result&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CallSecureMonitor ==&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block;&amp;quot;&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Argument64 || Argument32 || Type || Name&lt;br /&gt;
|-&lt;br /&gt;
| (In) X0 || R0 || uint64_t || [[SMC#Secure_Monitor_calls|FunctionId]]&lt;br /&gt;
|-&lt;br /&gt;
| (In) X1-X7 || R1-R7 || uint64_t || SMC arguments&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X0 || R0 || [[SMC#Result|Result]] || SMC result&lt;br /&gt;
|-&lt;br /&gt;
| (Out) X1-X7 || R1-R7 || uint64_t || SMC output&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes in a SMC function ID in X0, and arguments for that SMC function in X1-X7.&lt;br /&gt;
&lt;br /&gt;
Passing an invalid SMC function ID or calling from a core other than core 3 will result in a secure monitor panic.&lt;br /&gt;
&lt;br /&gt;
The kernel parses bits 9-15 in the passed SMC function ID (per the ARM SMC calling convention), and when set uses as an indicator to translate a pointer in the associated register (X1-X7) to a physical address. The kernel will translate any address mapped as R-W, other addresses (R--, R-X, or invalid pointers) will be translated as 0/NULL.&lt;br /&gt;
&lt;br /&gt;
Output is returned raw from the Secure Monitor; X0 will be the untranslated SMC result and X1-X7 will contain other SMC output (or be unchanged, depending on the SMC).&lt;br /&gt;
&lt;br /&gt;
== Debugging ==&lt;br /&gt;
[2.0.0+] Exactly 6 debug SVCs require that [[SPL_services#GetConfig|IsDebugMode]] is non-zero. Error 0x4201 is returned otherwise.&lt;br /&gt;
* BreakDebugProcess&lt;br /&gt;
* ContinueDebugEvent&lt;br /&gt;
* WriteDebugProcessMemory&lt;br /&gt;
* SetDebugThreadContext&lt;br /&gt;
* TerminateDebugProcess&lt;br /&gt;
* SetHardwareBreakPoint&lt;br /&gt;
&lt;br /&gt;
DebugActiveProcess stops execution of the target process, the normal method for resuming it requires ContinueDebugEvent(see above). Closing the debug handle also results in execution being resumed.&lt;br /&gt;
&lt;br /&gt;
= Enum/Structures =&lt;br /&gt;
== InfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Handle type || InfoType || InfoSubType || Description&lt;br /&gt;
|-&lt;br /&gt;
| Process || 0 || 0 || CoreMask&lt;br /&gt;
|-&lt;br /&gt;
| Process || 1 || 0 || PriorityMask&lt;br /&gt;
|-&lt;br /&gt;
| Process || 2 || 0 || AliasRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 3 || 0 || AliasRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 4 || 0 || HeapRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 5 || 0 || HeapRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 6 || 0 || TotalMemorySize. Total memory available(free+used).&lt;br /&gt;
|-&lt;br /&gt;
| Process || 7 || 0 || UsedMemorySize. Total used size of codebin memory + main-thread stack + allocated heap.&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 8 || 0 || DebuggerAttached&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 9 || 0 || ResourceLimit&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 10 || -1, {current coreid} || IdleTickCount&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 11 || 0-3 || RandomEntropy. Used to seed usermode PRNGs.&lt;br /&gt;
|-&lt;br /&gt;
| Process || 12 || 0 || [2.0.0+] AslrRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 13 || 0 || [2.0.0+] AslrRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 14 || 0 || [2.0.0+] StackRegionAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 15 || 0 || [2.0.0+] StackRegionSize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 16 || 0 || [3.0.0+] SystemResourceSizeTotal&lt;br /&gt;
|-&lt;br /&gt;
| Process || 17 || 0 || [3.0.0+] SystemResourceSizeUsed&lt;br /&gt;
|-&lt;br /&gt;
| Process || 18 || 0 || [3.0.0+] ProgramId&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 19 || 0 || [4.0.0-4.1.0] InitialProcessIdRange_LowerBound&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 19 || 1 || [4.0.0-4.1.0] InitialProcessIdRange_UpperBound&lt;br /&gt;
|-&lt;br /&gt;
| Process || 20 || 0 || [5.0.0+] UserExceptionContextAddress&lt;br /&gt;
|-&lt;br /&gt;
| Process || 21 || 0 || [6.0.0+] TotalNonSystemMemorySize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 22 || 0 || [6.0.0+] UsedNonSystemMemorySize&lt;br /&gt;
|-&lt;br /&gt;
| Process || 23 || 0 || [9.0.0+] IsApplication&lt;br /&gt;
|-&lt;br /&gt;
| Thread  || 0xF0000002 || 0-3, -1 || ThreadTickCount. When 0-3 are passed, gets specific core CPU ticks spent on thread. When -1 is passed, gets total CPU ticks spent on thread.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SystemInfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Handle type || SystemInfoType || SystemInfoSubType || Description&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 0 || TotalPhysicalMemorySize_Application&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 1 || TotalPhysicalMemorySize_Applet&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 2 || TotalPhysicalMemorySize_System&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 0 || 3 || TotalPhysicalMemorySize_SystemUnsafe&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 0 || UsedPhysicalMemorySize_Application&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 1 || UsedPhysicalMemorySize_Applet&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 2 || UsedPhysicalMemorySize_System&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 1 || 3 || UsedPhysicalMemorySize_SystemUnsafe&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 2 || 0 || InitialProcessIdRange_LowerBound&lt;br /&gt;
|-&lt;br /&gt;
| Zero    || 2 || 1 || InitialProcessIdRange_UpperBound&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ThreadContextFlags ==&lt;br /&gt;
Bitfield of one of more of these:&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || General-purpose registers || If in 64-bit mode, GPRs 0–28 will be read/written. If in 32-bit mode, GPRs 0–12 will be read/written.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || Control registers || Reads/writes the FP, LR, PC, SP, PSTATE, and TPIDR registers.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || Floating-point registers || Reads/writes the floating-point vector registers.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 8 || Floating-point control registers || Reads/writes the FPCR and FPSR registers.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== DeviceName ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AFI&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AVPC&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DC&lt;br /&gt;
|-&lt;br /&gt;
| 3 || DCB&lt;br /&gt;
|-&lt;br /&gt;
| 4 || HC&lt;br /&gt;
|-&lt;br /&gt;
| 5 || HDA&lt;br /&gt;
|-&lt;br /&gt;
| 6 || ISP2&lt;br /&gt;
|-&lt;br /&gt;
| 7 || MSENCNVENC&lt;br /&gt;
|-&lt;br /&gt;
| 8 || NV&lt;br /&gt;
|-&lt;br /&gt;
| 9 || NV2&lt;br /&gt;
|-&lt;br /&gt;
| 10 || PPCS&lt;br /&gt;
|-&lt;br /&gt;
| 11 || SATA&lt;br /&gt;
|-&lt;br /&gt;
| 12 || VI&lt;br /&gt;
|-&lt;br /&gt;
| 13 || VIC&lt;br /&gt;
|-&lt;br /&gt;
| 14 || XUSB_HOST&lt;br /&gt;
|-&lt;br /&gt;
| 15 || XUSB_DEV&lt;br /&gt;
|-&lt;br /&gt;
| 16 || TSEC&lt;br /&gt;
|-&lt;br /&gt;
| 17 || PPCS1&lt;br /&gt;
|-&lt;br /&gt;
| 18 || DC1&lt;br /&gt;
|-&lt;br /&gt;
| 19 || SDMMC1A&lt;br /&gt;
|-&lt;br /&gt;
| 20 || SDMMC2A&lt;br /&gt;
|-&lt;br /&gt;
| 21 || SDMMC3A&lt;br /&gt;
|-&lt;br /&gt;
| 22 || SDMMC4A&lt;br /&gt;
|-&lt;br /&gt;
| 23 || ISP2B&lt;br /&gt;
|-&lt;br /&gt;
| 24 || GPU&lt;br /&gt;
|-&lt;br /&gt;
| 25 || GPUB&lt;br /&gt;
|-&lt;br /&gt;
| 26 || PPCS2&lt;br /&gt;
|-&lt;br /&gt;
| 27 || NVDEC&lt;br /&gt;
|-&lt;br /&gt;
| 28 || APE&lt;br /&gt;
|-&lt;br /&gt;
| 29 || SE&lt;br /&gt;
|-&lt;br /&gt;
| 30 || NVJPG&lt;br /&gt;
|-&lt;br /&gt;
| 31 || HC1&lt;br /&gt;
|-&lt;br /&gt;
| 32 || SE1&lt;br /&gt;
|-&lt;br /&gt;
| 33 || AXIAP&lt;br /&gt;
|-&lt;br /&gt;
| 34 || ETR&lt;br /&gt;
|-&lt;br /&gt;
| 35 || TSECB&lt;br /&gt;
|-&lt;br /&gt;
| 36 || TSEC1&lt;br /&gt;
|-&lt;br /&gt;
| 37 || TSECB1&lt;br /&gt;
|-&lt;br /&gt;
| 38 || NVDEC1&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CodeMemoryOperation ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || MapOwner&lt;br /&gt;
|-&lt;br /&gt;
| 1 || MapSlave&lt;br /&gt;
|-&lt;br /&gt;
| 2 || UnmapOwner&lt;br /&gt;
|-&lt;br /&gt;
| 3 || UnmapSlave&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== LimitableResource ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || PhysicalMemoryMax || Bytes of memory a process may allocate.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || ThreadCountMax || Amount of threads a process can create.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || EventCountMax || Amount of events a process can create through [[#CreateEvent]] or [[#SendAsyncRequestWithUserBuffer]].&lt;br /&gt;
|-&lt;br /&gt;
| 3 || TransferMemoryCountMax || Amount of TransferMemory a process can create through [[#CreateTransferMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 4 || SessionCountMax || Amount of session a process can create through [[#CreateSession]], [[#ConnectToPort]] or [[#ConnectToNamedPort]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= ThreadActivity =&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || None&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Runnable&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessActivity ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || None&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Runnable&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessInfoType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || [[#ProcessState|ProcessState]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ProcessState ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name || Notes&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Created ||&lt;br /&gt;
|-&lt;br /&gt;
| 1 || CreatedAttached ||&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Started ||&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Crashed || Processes will not enter this state unless they were created with [[#CreateProcessParameter|EnableDebug]].&lt;br /&gt;
|-&lt;br /&gt;
| 4 || StartedAttached ||&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Exiting ||&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Exited ||&lt;br /&gt;
|-&lt;br /&gt;
| 7 || DebugSuspended ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== DebugThreadParam ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || DynamicPriority&lt;br /&gt;
|-&lt;br /&gt;
| 1 || SchedulingStatus&lt;br /&gt;
|-&lt;br /&gt;
| 2 || PreferredCpuCore&lt;br /&gt;
|-&lt;br /&gt;
| 3 || CurrentCpuCore&lt;br /&gt;
|-&lt;br /&gt;
| 4 || AffinityMask&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Dynamic priority: output in out2&lt;br /&gt;
&lt;br /&gt;
Scheduling status: out1 contains bit0: is debug-suspended, bit1: is user-suspended ([[#SetThreadActivity]] 1 or [[#SetProcessActivity]] 1).&lt;br /&gt;
Out2 contains {suspended, idle, running, terminating} =&amp;gt; {5, 0, 1, 4}&lt;br /&gt;
&lt;br /&gt;
PreferredCpuCore: output in out2&lt;br /&gt;
&lt;br /&gt;
CurrentCpuCore: output in out2&lt;br /&gt;
&lt;br /&gt;
AffinityMask: output in out1&lt;br /&gt;
&lt;br /&gt;
== CreateProcessParameter ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Bits || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 12 || || ProcessName (doesn&#039;t have to be null-terminated)&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C || 4 || || ProcessCategory (0: regular title, 1: kernel built-in)&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 8 || || TitleId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || 8 || || CodeAddr&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 4 || || CodeNumPages&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 4 || || Flags&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit0 || Is64BitInstruction&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit3-1 || [[#AddressSpaceType]]&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit4 || [2.0.0+] EnableDebug&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit5 || EnableAslr&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit6 || IsApplication&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit7 || [4.0.0] UseSecureMemory&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit10-7 || [5.0.0+] MemoryRegion (0 = Application, 1 = Applet, 2 = SecureSystem, 3 = NonSecureSystem)&lt;br /&gt;
|-&lt;br /&gt;
| || || Bit11 || [7.0.0+] OptimizeMemoryAllocation (only allowed in combination with IsApplication)&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || 4 || || ResourceLimitHandle (can be zero)&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || 4 || || [3.0.0+] SystemResourceNumPages&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On [1.0.0] there&#039;s only one MemoryRegion.&lt;br /&gt;
&lt;br /&gt;
On [2.0.0-4.0.0] MemoryRegion is 1 for built-ins and 0 for rest.&lt;br /&gt;
&lt;br /&gt;
On [5.0.0] MemoryRegion is specified in CreateProcessArgs. There are now 4 pool partitions.&lt;br /&gt;
&lt;br /&gt;
On [5.0.0] (maybe lower?) a zero ResourceLimitHandle defaults to sysmodule limits and 0x12300000 bytes of memory.&lt;br /&gt;
&lt;br /&gt;
The PersonalMmHeap are allocated as follows:&lt;br /&gt;
* For the application, normal insecure pool is used. Carveout 5 is used to provide protection.&lt;br /&gt;
* For the applet, a pre-allocated secure pool segment of size 0x400000 is used.&lt;br /&gt;
* For sysmodules, secure pool is allocated.&lt;br /&gt;
&lt;br /&gt;
=== AddressSpaceType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Type || Name || Width || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AddressSpace32Bit || 32 ||&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AddressSpace64BitOld || 36 ||&lt;br /&gt;
|-&lt;br /&gt;
| 2 || AddressSpace32BitNoReserved || 32 || Appears to be missing map region [?]&lt;br /&gt;
|-&lt;br /&gt;
| 3 || [2.0.0+] AddressSpace64Bit || 39 ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryInfo ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 8 || BaseAddress&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 8 || Size&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || 4 || [[#MemoryType]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x14 || 4 || [[#MemoryAttribute]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || 4 || [[#MemoryPermission]]&lt;br /&gt;
|-&lt;br /&gt;
| 0x1C || 4 || IpcRefCount&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 4 || DeviceRefCount&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 4 || Padding: always zero&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryPermission ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Read || Can be set by [[#SetMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Write || Can be set by [[#SetMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Execute || Can be set by [[#SetProcessMemoryPermission]] and [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 28 || DontCare ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryAttribute ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Name || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Locked || Used by MapMemory, as an async IPC user buffer.&lt;br /&gt;
|-&lt;br /&gt;
| 1 || IpcLocked || True when IpcRefCount &amp;gt; 0.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DeviceShared || True when DeviceRefCount &amp;gt; 0.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Uncached || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== MemoryState ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bits || Description || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 7-0 || [[#MemoryType]] || &lt;br /&gt;
|-&lt;br /&gt;
| 8 || [[#SetMemoryPermission|FlagCanReprotect]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 9 || FlagCanDebug || Allows using [[#WriteDebugProcessMemory]] on segments mapped read-only.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || FlagCanUseIpc || Allows sending this region as an IPC A/B/W buffer with flags=0.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || FlagCanUseNonDeviceIpc || Allows sending this region as an IPC A/B/W buffer with flags=1.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || FlagCanUseNonSecureIpc || Allows sending this region as an IPC A/B/W buffer with flags=3.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || FlagMapped ||&lt;br /&gt;
|-&lt;br /&gt;
| 14 || [[#SetProcessMemoryPermission|FlagCode]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 15 || [[#MapMemory|FlagCanAlias]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 16 || [[#MapProcessCodeMemory|FlagCanCodeAlias]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 17 || [[#CreateTransferMemory|FlagCanTransfer]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 18 || [[#QueryPhysicalAddress|FlagCanQueryPhysical]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 19 || [[#MapDeviceAddressSpace|FlagCanDeviceMap]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 20 || [[#MapDeviceAddressSpaceAligned|FlagCanAlignedDeviceMap]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 21 || [[#SendSyncRequestWithUserBuffer|FlagCanIpcUserBuffer]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 22 || FlagReferenceCounted || The physical memory blocks backing this region are refcounted.&lt;br /&gt;
|-&lt;br /&gt;
| 23 || [[#MapProcessMemory|FlagCanMapProcess]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 24 || [[#SetMemoryAttribute|FlagCanChangeAttribute]] ||&lt;br /&gt;
|-&lt;br /&gt;
| 25 || [4.0.0+] [[#CreateCodeMemory|FlagCanCodeMemory]] ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== MemoryType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000000 || Free ||&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002001 || Io || Mapped by kernel capability parsing in [[#CreateProcess]]. &lt;br /&gt;
|-&lt;br /&gt;
| 0x00042002 || Static || Mapped by kernel capability parsing in [[#CreateProcess]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00DC7E03 || Code || Mapped during [[#CreateProcess]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x01FEBD04&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x03FEBD04&lt;br /&gt;
|| CodeData || Transition from 0xDC7E03 performed by [[#SetProcessMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
0x017EBD05&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x037EBD05&lt;br /&gt;
|| Normal || Mapped using [[#SetHeapSize]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402006 || Shared || Mapped using [[#MapSharedMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00482907 || [1.0.0] Alias || Mapped using [[#MapMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00DD7E08 || AliasCode || Mapped using [[#MapProcessCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| [1.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x01FFBD09&lt;br /&gt;
&lt;br /&gt;
[4.0.0+]&lt;br /&gt;
&lt;br /&gt;
0x03FFBD09&lt;br /&gt;
|| AliasCodeData || Transition from 0xDD7E08 performed by [[#SetProcessMemoryPermission]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3C0A || [[IPC_Marshalling|Ipc]] || IPC buffers with descriptor flags=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3C0B || Stack || Mapped using [[#MapMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x0040200C || [[Thread Local Storage|ThreadLocal]] || Mapped during [[#CreateThread]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x015C3C0D || Transfered || Mapped using [[#MapTransferMemory]] when the owning process has perm=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C380E || SharedTransfered || Mapped using [[#MapTransferMemory]] when the owning process has perm!=0.&lt;br /&gt;
|-&lt;br /&gt;
| 0x0040380F || SharedCode || Mapped using [[#MapProcessMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00000010 || Inaccessible ||&lt;br /&gt;
|-&lt;br /&gt;
| 0x005C3811 || [[IPC_Marshalling|NonSecureIpc]] || IPC buffers with descriptor flags=1.&lt;br /&gt;
|-&lt;br /&gt;
| 0x004C2812 || [[IPC_Marshalling|NonDeviceIpc]] || IPC buffers with descriptor flags=3.&lt;br /&gt;
|-&lt;br /&gt;
| 0x00002013 || Kernel || Mapped in kernel during [[#CreateThread]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402214 || [4.0.0+] GeneratedCode || Mapped in kernel during [[#ControlCodeMemory]].&lt;br /&gt;
|-&lt;br /&gt;
| 0x00402015 || [4.0.0+] CodeOut || Mapped in kernel during [[#ControlCodeMemory]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ArbitrationType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || WaitIfLessThan&lt;br /&gt;
|-&lt;br /&gt;
| 0x1 || DecrementAndWaitIfLessThan&lt;br /&gt;
|-&lt;br /&gt;
| 0x2 || WaitIfEqual&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== SignalType ==&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Type&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || Signal&lt;br /&gt;
|-&lt;br /&gt;
| 0x1 || SignalAndIncrementIfEqual&lt;br /&gt;
|-&lt;br /&gt;
| 0x2 || SignalAndModifyBasedOnWaitingThreadCountIfEqual&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugFlagsOld ==&lt;br /&gt;
[1.0.0-2.3.0]&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || IgnoreException (note: ResumeAllThreads or debug-suspended-thread-id needed)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || SwallowException&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || ResumeAllThreads&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== ContinueDebugFlags ==&lt;br /&gt;
[3.0.0+]&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Bit || Bitmask || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || IgnoreException (note: doesn&#039;t need to be set in the same call than Resume)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || DontCatchExceptions&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 4 || Resume&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 8 || IgnoreOtherThreadsExceptions&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
IgnoreExceptionsOfOthers is like IgnoreException but acts on all threads that aren&#039;t in the input list. The affected threads are resumed.&lt;br /&gt;
&lt;br /&gt;
Only one of of Resume and IgnoreOtherThreadsExceptions can be set at a time.&lt;br /&gt;
&lt;br /&gt;
If the input number of threads is 0, this means &amp;quot;all threads&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== DebugEventInfo ==&lt;br /&gt;
The below table is for the Aarch64 version of the system call. For A32, all u64 fields but title/process/thread id are actually u32, making the structure 0x28-byte-big (0x40 for a64).&lt;br /&gt;
&lt;br /&gt;
Size: 0x40&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || u32 || EventType&lt;br /&gt;
|-&lt;br /&gt;
| 4 || u32 || Flags (bit0: NeedsContinue)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || u64 || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || || PerTypeSpecifics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AttachProcess specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u64 || TitleId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || ProcessId&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || char[12] || ProcessName&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || u32 || MmuFlags&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || u64 || [5.0.0+] UserExceptionContextAddr&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
AttachThread specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u64 || ThreadId&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || TlsPtr&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u64 || Entrypoint&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Exit specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u32|| Type (0=PausedThread, 1=RunningThread, 2=ExitedProcess, 3=TerminatedProcess)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Exception specific:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x10 || u32 || ExceptionType&lt;br /&gt;
|-&lt;br /&gt;
| 0x18 || u64 || FaultRegister&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || || PerExceptionSpecifics&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== DebugEventType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || AttachProcess&lt;br /&gt;
|-&lt;br /&gt;
| 1 || AttachThread&lt;br /&gt;
|-&lt;br /&gt;
| 2 || ExitProcess&lt;br /&gt;
|-&lt;br /&gt;
| 3 || ExitThread&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Exception&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== DebugExceptionType ===&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Trap (*)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || InstructionAbort&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DataAbortMisc (**)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || PcSpAlignmentFault&lt;br /&gt;
|-&lt;br /&gt;
| 4 || DebuggerAttached&lt;br /&gt;
|-&lt;br /&gt;
| 5 || BreakPoint&lt;br /&gt;
|-&lt;br /&gt;
| 6 || UserBreak&lt;br /&gt;
|-&lt;br /&gt;
| 7 || DebuggerBreak&lt;br /&gt;
|-&lt;br /&gt;
| 8 || BadSvcId&lt;br /&gt;
|-&lt;br /&gt;
| 9 || [2.0.0+] SError&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt; Undefined instructions, software breakpoints, some other traps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; Data aborts, FP traps, and everything else that doesn&#039;t belong to any of the above.&lt;br /&gt;
&lt;br /&gt;
Trap specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || Opcode&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
BreakPoint specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || IsWatchpoint&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
UserBreak specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || Info0&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || u64 || Info1&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || u64 || Info2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
BadSvcId specifics:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || u32 || SvcId&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Exception handling =&lt;br /&gt;
First of all, a function that might be called by synchronous exception handler and that is called by the SError handler fetches the exception info, adjusts PC, panics on exceptions taken from EL1, then dispatches the exception.&lt;br /&gt;
&lt;br /&gt;
The dispatcher has two mutually exclusive exception reporting methods:&lt;br /&gt;
* by storing information at the start of the process&#039;s TLS memregion (TPIDRRO_EL0) and jumping back to the crt0&lt;br /&gt;
* by using KDebug&lt;br /&gt;
&lt;br /&gt;
KDebug dispatching is used when at least one of the following conditions are met:&lt;br /&gt;
* SMC ConfigItem KernelMemConfig bit 1 is NOT set (it isn&#039;t on retail), unless: this is a software or hardware breakpoint, or a watchpoint, or [4.0.0+?] the process is attached and this is a Google PNaCl trap instruction (see LLVM source)&lt;br /&gt;
* FAR doesn&#039;t point to a valid address in mapped-readable CodeStatic memory (i.e. this is the case for NRO and JIT memory) or this is one of the following exceptions (it particular, that doesn&#039;t include FP exceptions occurring in CodeStatic memory):&lt;br /&gt;
** Uncategorized&lt;br /&gt;
** IllegalState&lt;br /&gt;
** SupervisorCallA32&lt;br /&gt;
** SupervisorCallA64&lt;br /&gt;
** PCAlignment&lt;br /&gt;
** SPAlignment&lt;br /&gt;
** SError&lt;br /&gt;
** BreakpointLowerEl&lt;br /&gt;
** SoftwareStepLowerEl (note: no way set single-step flag; not parsed)&lt;br /&gt;
** WatchpointLowerEl&lt;br /&gt;
** SoftwareBreakpointA32 (note: not parsed)&lt;br /&gt;
** SoftwareBreakpointA64 (note: not parsed)&lt;br /&gt;
    &lt;br /&gt;
In all other cases the userland-handled exception path is taken.&lt;br /&gt;
&lt;br /&gt;
KDebug path:&lt;br /&gt;
&lt;br /&gt;
If the process is attached, the exception is reported to the KDebug. If the thread was continued using flag IgnoreExceptions, it returns from the exception as if nothing happened.&lt;br /&gt;
&lt;br /&gt;
If the latter is not the case, or if the process isn&#039;t attached, proceed to [2.0.0+] crash reporting (or in [1.0.0] just terminate the process): &lt;br /&gt;
if EnableDebug is set, and depending on the process state (more than one crash per process isn&#039;t permitted) it may signal itself with ProcessState_Crashed so that PM asks NS to start creport so that creport attaches to it and reports the crashes. Otherwise, just terminate.&lt;br /&gt;
&lt;br /&gt;
Userland reporting path and [[#ReturnFromException]]:&lt;br /&gt;
&lt;br /&gt;
TLS region start (A64):&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x148 || Exception stack&lt;br /&gt;
|-&lt;br /&gt;
| 0x148 || 0x78 || ExceptionFrameA64&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
ExceptionFrameA64:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x48 (8*9) || GPRs 0..8.&lt;br /&gt;
|-&lt;br /&gt;
| 0x48 || 0x8 || lr&lt;br /&gt;
|-&lt;br /&gt;
| 0x50 || 0x8 || sp&lt;br /&gt;
|-&lt;br /&gt;
| 0x58 || 0x8 || pc (elr_el1)&lt;br /&gt;
|-&lt;br /&gt;
| 0x60 || 0x4 || pstate &amp;amp; 0xFF0FFE20&lt;br /&gt;
|-&lt;br /&gt;
| 0x64 || 0x4 || afsr0&lt;br /&gt;
|-&lt;br /&gt;
| 0x68 || 0x4 || afsr1&lt;br /&gt;
|-&lt;br /&gt;
| 0x6C || 0x4 || esr&lt;br /&gt;
|-&lt;br /&gt;
| 0x70 || 0x8 || far&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TLS region start (A32):&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x178 || Exception stack&lt;br /&gt;
|-&lt;br /&gt;
| 0x148 || 0x44 || ExceptionFrameA32&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
ExceptionFrameA32:&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Offset || Length || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0x0 || 0x20 (8*4) || GPRs 0..7.&lt;br /&gt;
|-&lt;br /&gt;
| 0x20 || 0x4 || sp&lt;br /&gt;
|-&lt;br /&gt;
| 0x24 || 0x4 || lr&lt;br /&gt;
|-&lt;br /&gt;
| 0x28 || 0x4 || pc (elr_el1)&lt;br /&gt;
|-&lt;br /&gt;
| 0x2C || 0x4 || tpidr_el0 = 1&lt;br /&gt;
|-&lt;br /&gt;
| 0x30 || 0x4 || cpsr &amp;amp; 0xFF0FFE20&lt;br /&gt;
|-&lt;br /&gt;
| 0x34 || 0x4 || afsr0&lt;br /&gt;
|-&lt;br /&gt;
| 0x38 || 0x4 || afsr1&lt;br /&gt;
|-&lt;br /&gt;
| 0x3C || 0x4 || esr&lt;br /&gt;
|-&lt;br /&gt;
| 0x40 || 0x4 || far&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In that case, after storing the regs in the TLS, the exception handler returns to the application&#039;s crt0 (entrypoint), with X0=&amp;lt;error description code&amp;gt; (see below) and X1=SP=frame=&amp;lt;stack top&amp;gt; (see above)&lt;br /&gt;
&lt;br /&gt;
{| class=wikitable&lt;br /&gt;
! Desc. code || Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 0x100 || Instruction abort&lt;br /&gt;
|-&lt;br /&gt;
| 0x102 || Misaligned PC&lt;br /&gt;
|-&lt;br /&gt;
| 0x103 || Misaligned SP&lt;br /&gt;
|-&lt;br /&gt;
| 0x106 || [2.0.0+] SError&lt;br /&gt;
|-&lt;br /&gt;
| 0x301 || Bad SVC&lt;br /&gt;
|-&lt;br /&gt;
| 0x104 || Uncategorized, CP15RTTrap, CP15RRTTrap, CP14RTTrap, CP14RRTTrap, IllegalState, SystemRegisterTrap&lt;br /&gt;
|-&lt;br /&gt;
| 0x101 || None of the above, EC &amp;lt;= 0x34 and not a breakpoint&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(During normal app boot the process is invoked with X0=0 and X1=main_thread_handle. The crt0 of retail apps determines whether to boot normally or handle an exception if X0 is set to 0 or not)&lt;br /&gt;
&lt;br /&gt;
The application is supposed to promptly update the contents of elr_el1 to a user handler (and any other regs it sees fit) and call [[#ReturnFromException]] (error code) to call that handler. The latter is then expected to promptly abort the program.&lt;br /&gt;
&lt;br /&gt;
[[#ReturnFromException]] updates the contents of the kernel stack frame with what the user provided in the TLS structure, sets TPIDR_EL0 to 1, then:&lt;br /&gt;
* if the provided error code is 0, gracefully pivots and returns from exception&lt;br /&gt;
* if it is not, replays the exception and pass it to the KDebug (see above). One can pass 0x10001 to prevent process termination. If the process is attached, this also prevents crash-collection/termination (different from the exception handler behavior)&lt;br /&gt;
&lt;br /&gt;
If an exception occurs from the above user handler, the entire exception handling process will repeat with the new exception.&lt;br /&gt;
&lt;br /&gt;
Note that if a thread that wasn&#039;t faulting calls [[#ReturnFromException]], it signals an &amp;quot;invalid syscall&amp;quot; exception&lt;br /&gt;
&lt;br /&gt;
Note that [[SMC|IsDebugMode]] is not used during exception-handling, except for enabling printing a message to UART-A. This UART code causes a system-hang on retail (likely due to a loop that doesn&#039;t exit). This printing doesn&#039;t seem to run when the process is attached for debugging?&lt;/div&gt;</summary>
		<author><name>DCNick3</name></author>
	</entry>
</feed>