<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=GasInfinity</id>
	<title>3dbrew - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.3dbrew.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=GasInfinity"/>
	<link rel="alternate" type="text/html" href="https://www.3dbrew.org/wiki/Special:Contributions/GasInfinity"/>
	<updated>2026-04-10T07:54:28Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=Kernel_ABI&amp;diff=23691</id>
		<title>Kernel ABI</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=Kernel_ABI&amp;diff=23691"/>
		<updated>2025-08-29T18:08:43Z</updated>

		<summary type="html">&lt;p&gt;GasInfinity: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Calling Convention =&lt;br /&gt;
Seems to be [https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#the-base-procedure-call-standard AAPCS]-based (with modifications)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
* &amp;lt;code&amp;gt;r0–r3&amp;lt;/code&amp;gt; : Argument / Scratch registers (caller-saved), inherited from AAPCS. &#039;&#039;If an input is to be placed on the stack, it will instead use the next free register starting from &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Outputs ===&lt;br /&gt;
* &amp;lt;code&amp;gt;r0-r1&amp;lt;/code&amp;gt; : Result, inherited from AAPCS. &#039;&#039;If multiple outputs are returned (e.g., &amp;lt;code&amp;gt;ControlMemory&amp;lt;/code&amp;gt;), they are placed in consecutive registers starting from &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;code&amp;gt;Result ControlMemory(uintptr_t* out, uintptr_t addr0, uintptr_t addr1, size_t size, MemoryOperation operation, MemoryPermission permissions)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
Following standard [https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#the-base-procedure-call-standard AAPCS] register selection:&lt;br /&gt;
; &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; -&amp;gt; addr0&lt;br /&gt;
; &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; -&amp;gt; addr1&lt;br /&gt;
; &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; -&amp;gt; size&lt;br /&gt;
&lt;br /&gt;
As there are still more arguments, the next free registers are selected starting from &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;&lt;br /&gt;
; &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; -&amp;gt; operation&lt;br /&gt;
; &amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt; -&amp;gt; permissions&lt;br /&gt;
&lt;br /&gt;
=== Outputs ===&lt;br /&gt;
; &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; -&amp;gt; Result&lt;br /&gt;
; &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; -&amp;gt; uintptr_t out&lt;br /&gt;
&lt;br /&gt;
== System calls ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  ID&lt;br /&gt;
!  Name&lt;br /&gt;
!  Inputs&lt;br /&gt;
!  Outputs&lt;br /&gt;
|-&lt;br /&gt;
| 0x01&lt;br /&gt;
| ControlMemory&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory Management#enum_MemoryOperation|MemoryOperation]] operation&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* addr0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* addr1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 size&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory Management#enum_MemoryPermission|MemoryPermission]] permissions&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* addr_out&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x02&lt;br /&gt;
| QueryMemory&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;?: &amp;lt;code&amp;gt;u32/void* addr&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 base_process_virtual_address&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 size&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory Management#enum_MemoryPermission|MemoryPermission]] permission&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory_Management#enum_MemoryState|MemoryState]] state&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r5&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory_Management#enum_PageFlags|PageFlags]] page_flags&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x03&lt;br /&gt;
| ExitProcess&lt;br /&gt;
| None&lt;br /&gt;
| None, doesn&#039;t return&lt;br /&gt;
|-&lt;br /&gt;
| 0x04&lt;br /&gt;
| GetProcessAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[out] u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x05&lt;br /&gt;
| SetProcessAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[in] const u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x06&lt;br /&gt;
| GetProcessIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;?: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: Clobbered?&lt;br /&gt;
|-&lt;br /&gt;
| 0x07&lt;br /&gt;
| SetProcessIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x08&lt;br /&gt;
| CreateThread&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 thread_priority&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;ThreadFunc entrypoint&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 arg&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* stack_top&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processor_id&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x09&lt;br /&gt;
| ExitThread&lt;br /&gt;
| None&lt;br /&gt;
| None, doesn&#039;t return&lt;br /&gt;
|-&lt;br /&gt;
| 0x0A&lt;br /&gt;
| SleepThread&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0-r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s64 nanoseconds&amp;lt;/code&amp;gt;&lt;br /&gt;
| None&lt;br /&gt;
|-&lt;br /&gt;
| 0x0B&lt;br /&gt;
| GetThreadPriority&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: Ignored?&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle thread_handle&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 thread_priority&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: Clobbered?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C&lt;br /&gt;
| SetThreadPriority&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 thread_priority&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x0D&lt;br /&gt;
| GetThreadAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[out] u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x0E&lt;br /&gt;
| SetThreadAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[in] const u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x0F&lt;br /&gt;
| GetThreadIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: Ignored?&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| SetThreadIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x11&lt;br /&gt;
| GetProcessorID&lt;br /&gt;
|&lt;br /&gt;
None&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x24&lt;br /&gt;
| WaitSynchronization1&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KSynchronizationObject]]&amp;gt; handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2-r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s64 timeout&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x1B&lt;br /&gt;
| SetTimer&lt;br /&gt;
| Timer handle, initial_low, interval_low, initial_high, interval_high&lt;br /&gt;
| Result&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| GetSystemTick&lt;br /&gt;
| None&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Low 32 bits of the tick count&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;High 32 bits of the tick count&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x2D&lt;br /&gt;
| ConnectToPort&lt;br /&gt;
| ??&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;pointer to port name&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;handle to [[KClientSession]]&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x32&lt;br /&gt;
| SendSyncRequest&lt;br /&gt;
| &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;handle to [[KClientSession]]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;code&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>GasInfinity</name></author>
	</entry>
	<entry>
		<id>https://www.3dbrew.org/w/index.php?title=Kernel_ABI&amp;diff=23690</id>
		<title>Kernel ABI</title>
		<link rel="alternate" type="text/html" href="https://www.3dbrew.org/w/index.php?title=Kernel_ABI&amp;diff=23690"/>
		<updated>2025-08-29T18:01:54Z</updated>

		<summary type="html">&lt;p&gt;GasInfinity: document the calling convention of literally all syscalls&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Calling Convention =&lt;br /&gt;
Seems to be [https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#the-base-procedure-call-standard AAPCS]-based (with modifications)&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
* &amp;lt;code&amp;gt;r0–r3&amp;lt;/code&amp;gt; : Argument / Scratch registers (caller-saved), inherited from AAPCS. &#039;&#039;If an input is to be placed on the stack, it will instead use the next free register starting from &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Outputs ===&lt;br /&gt;
* &amp;lt;code&amp;gt;r0-r1&amp;lt;/code&amp;gt; : Result, inherited from AAPCS. &#039;&#039;If multiple outputs are returned (e.g., &amp;lt;code&amp;gt;ControlMemory&amp;lt;/code&amp;gt;), they are placed in consecutive registers starting from &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;code&amp;gt;Result ControlMemory(uintptr_t* out, uintptr_t addr0, uintptr_t addr1, size_t size, MemoryOperation operation, MemoryPermission permissions)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
Following standard [https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#the-base-procedure-call-standard AAPCS] register selection:&lt;br /&gt;
; &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; -&amp;gt; addr0&lt;br /&gt;
; &amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt; -&amp;gt; addr1&lt;br /&gt;
; &amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt; -&amp;gt; size&lt;br /&gt;
&lt;br /&gt;
As there are still have more arguments, the next free registers are selected starting from &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;&lt;br /&gt;
; &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; -&amp;gt; operation&lt;br /&gt;
; &amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt; -&amp;gt; permissions&lt;br /&gt;
&lt;br /&gt;
=== Outputs ===&lt;br /&gt;
; &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt; -&amp;gt; Result&lt;br /&gt;
; &amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt; -&amp;gt; uintptr_t out&lt;br /&gt;
&lt;br /&gt;
== System calls ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!  ID&lt;br /&gt;
!  Name&lt;br /&gt;
!  Inputs&lt;br /&gt;
!  Outputs&lt;br /&gt;
|-&lt;br /&gt;
| 0x01&lt;br /&gt;
| ControlMemory&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory Management#enum_MemoryOperation|MemoryOperation]] operation&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* addr0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* addr1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 size&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory Management#enum_MemoryPermission|MemoryPermission]] permissions&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* addr_out&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x02&lt;br /&gt;
| QueryMemory&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;?: &amp;lt;code&amp;gt;u32/void* addr&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 base_process_virtual_address&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 size&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory Management#enum_MemoryPermission|MemoryPermission]] permission&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory_Management#enum_MemoryState|MemoryState]] state&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r5&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[[Memory_Management#enum_PageFlags|PageFlags]] page_flags&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x03&lt;br /&gt;
| ExitProcess&lt;br /&gt;
| None&lt;br /&gt;
| None, doesn&#039;t return&lt;br /&gt;
|-&lt;br /&gt;
| 0x04&lt;br /&gt;
| GetProcessAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[out] u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x05&lt;br /&gt;
| SetProcessAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[in] const u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x06&lt;br /&gt;
| GetProcessIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;?: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: Clobbered?&lt;br /&gt;
|-&lt;br /&gt;
| 0x07&lt;br /&gt;
| SetProcessIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KProcess]]&amp;gt; process&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x08&lt;br /&gt;
| CreateThread&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 thread_priority&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;ThreadFunc entrypoint&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32 arg&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;u32/void* stack_top&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r4&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processor_id&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x09&lt;br /&gt;
| ExitThread&lt;br /&gt;
| None&lt;br /&gt;
| None, doesn&#039;t return&lt;br /&gt;
|-&lt;br /&gt;
| 0x0A&lt;br /&gt;
| SleepThread&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0-r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s64 nanoseconds&amp;lt;/code&amp;gt;&lt;br /&gt;
| None&lt;br /&gt;
|-&lt;br /&gt;
| 0x0B&lt;br /&gt;
| GetThreadPriority&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: Ignored?&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle thread_handle&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 thread_priority&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: Clobbered?&lt;br /&gt;
|-&lt;br /&gt;
| 0x0C&lt;br /&gt;
| SetThreadPriority&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 thread_priority&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x0D&lt;br /&gt;
| GetThreadAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[out] u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x0E&lt;br /&gt;
| SetThreadAffinityMask&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;[in] const u8* affinitymask&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorcount&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x0F&lt;br /&gt;
| GetThreadIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: Ignored?&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x10&lt;br /&gt;
| SetThreadIdealProcessor&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KThread]]&amp;gt; thread_handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x11&lt;br /&gt;
| GetProcessorID&lt;br /&gt;
|&lt;br /&gt;
None&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s32 processorid&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x24&lt;br /&gt;
| WaitSynchronization1&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Handle&amp;lt;[[KSynchronizationObject]]&amp;gt; handle&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;r2-r3&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;s64 timeout&amp;lt;/code&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x1B&lt;br /&gt;
| SetTimer&lt;br /&gt;
| Timer handle, initial_low, interval_low, initial_high, interval_high&lt;br /&gt;
| Result&lt;br /&gt;
|-&lt;br /&gt;
| 0x28&lt;br /&gt;
| GetSystemTick&lt;br /&gt;
| None&lt;br /&gt;
|&lt;br /&gt;
&amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Low 32 bits of the tick count&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;High 32 bits of the tick count&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x2D&lt;br /&gt;
| ConnectToPort&lt;br /&gt;
| ??&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;pointer to port name&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&amp;lt;code&amp;gt;r1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;handle to [[KClientSession]]&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 0x32&lt;br /&gt;
| SendSyncRequest&lt;br /&gt;
| &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;handle to [[KClientSession]]&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;r0&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;Result&amp;lt;code&amp;gt;&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>GasInfinity</name></author>
	</entry>
</feed>