List of Operations System API Functions

# List of operating system (OS) API functions

### Initialization

OS_Init | Initializes the system.
OS_InitChina | Initializes system for applications designed for China.
OS_ShowAttentionChina | Displays the startup screen for applications designed for China.
NitroStartUp | Describes initialization processes to be executed before static constructor calls.
NitroStaticInit | Describes the static initializer.

### Reset

OS_InitReset | This function initializes the reset system.
OS_ResetSystem | Re-executes the program.
OS_GetResetParameter | Obtains the reset parameter value.

### System State

OS_EnableInterrupts | Enable CPSR IRQ interrupts.
OS_DisableInterrupts | Disable CPSR IRQ interrupts.
OS_RestoreInterrupts | Put CPSR IRQ interrupts into designated state.
OS_EnableInterrupts_IrqAndFiq | Enables IRQ, FIQ interrupts in CPSR.
OS_DisableInterrupts_IrqAndFiq | Prohibits IRQ, FIQ interrupts in CPSR.
OS_RestoreInterrupts_IrqAndFiq | Sets IRQ, FIQ interrupts in CPSR to a specified status.
OS_GetCpsrIrq | Obtain current CPSR IRQ and FIQ interrupts.
OS_GetProcMode | Obtain current processor mode.
OS_Halt | Sets the processor to HALT condition.
OS_Terminate | Sets the processor to HALT status and loops.
OS_Exit | Displays the exit status and calls `OS_Terminate()`.
OS_SpinWait | Sets the processor to idle.

### TCM

OS_EnableITCM | This function enables the Instruction TCM.
OS_DisableITCM | Disables the Instruction TCM.
OS_GetITCMAddress | Enables data TCM.
OS_EnableDTCM | This function enables the Data TCM.
OS_DisableDTCM | This function disables the Data TCM.
OS_SetITCMParam | Sets instruction TCM parameters.
OS_GetITCMParam | Obtains instruction TCM parameters.
OS_SetDTCMParam | Sets data TCM parameters.
OS_GetDTCMParam | Obtains the data TCM parameters.
OS_SetDTCMAddress | Sets the data TCM address.
OS_GetDTCMAddress | Obtains the data TCM address.

### Protection Unit

OS_EnableProtectionUnit | This function enables the protection unit.
OS_DisableProtectionUnit | This function disables the protection unit.
OS_SetProtectionRegion | Sets the protection region.
OS_SetProtectionRegionParam | Sets the protection region with parameter specification.
OS_GetProtectionRegionAddress | Obtains the base address of the protection region setting.
OS_GetProtectionRegionSize | Obtains the region size of the protection region setting.
OS_GetProtectionRegionParam | Obtains the setting parameters of the protection region.

### Exceptions

OS_InitException | Initializes the exception display system.
OS_SetUserExceptionHandler | Sets the user handler to be used when an exception is generated.
OS_SetExceptionVectorLower | Sets the exception vector position as a normalized address.
OS_SetExceptionVectorUpper | Sets the exception vector position as a high vector.

### Interrupts

OS_EnableIrq | Enables all IRQ interrupts.
OS_DisableIrq | Disables all IRQ interrupts.
OS_RestoreIrq | Puts all interrupts into designated state.
OS_SetIrqMask | Sets IRQ interrupt parameters.
OS_GetIrqMask | Obtains currently established IRQ interrupt parameters.
OS_EnableIrqMask | Enables IRQ of designated interrupt parameters.
OS_DisableIrqMask | Disables IRQ of designated interrupt parameters.
OS_ResetRequestIrqMask | Releases the interrupt request's designated interrupt parameters.
OS_GetRequestIrqMask | Obtains current interrupt request state.
OS_InitIrqTable | Initializes IRQ handler table.
OS_SetIrqFunction | Sets handler corresponding to designated IRQ.
OS_GetIrqFunction | Obtains handler corresponding to designated IRQ.
OS_SetIrqCheckFlag | Sets the interrupt check flag.
OS_ClearIrqCheckFlag | Clears the interrupt check flag.
OS_GetIrqCheckFlag | Obtains the interrupt check flag.
OS_WaitIrq | Waits for the specified IRQ.
OS_WaitAnyIrq | Waits for all IRQ.
OS_WaitInterrupt | Waits for the specified IRQ. (A thread switch is not done.))
OS_WaitVBlankIntr | Waits for V-Blank. (A thread switch is done.)
OS_GetVBlankCount | Obtains the value of the V-Blank counter.

### Timer

OS_StartTimer | Set timer and start. The counter value is 16-bit.
OS_StartTimer32 | Using two timers, start the 32-bit long timer.
OS_StartTimer48 | Using three timers, start the 48-bit long timer.
OS_StartTimer64 | Using four timers, start the 64-bit long timer.
OS_StopTimer | Stops the timer. The counter value is 16-bit.
OS_StopTimer32 | Stops the two timers. Used when the 32-bit timer is being used.
OS_StopTimer48 | Stops the three timers. Used when the 48-bit timer is being used.
OS_StopTimer64 | Stops the four timers. Used when the 64-bit timer is being used.

### Alarms

OS_InitAlarm | Allocates a timer for an alarm system and initializes.
OS_EndAlarm | Frees a timer that was allocated to an alarm system.
OS_IsAlarmAvailable | Checks whether an alarm system is initialized and available.
OS_CreateAlarm | Initializes the alarm structure.
OS_SetAlarm | Sets an alarm.
OS_SetPeriodicAlarm | Sets a periodic alarm.
OS_SetAlarmTag | Sets a tag to an alarm.
OS_CancelAlarm | Cancels an alarm.
OS_CancelAlarms | Cancels alarms that have a specified tag.
OS_CancelAllAlarms | This function cancels all alarms.

### V-Count Alarms

OS_InitVAlarm | Initializes a V-count alarm system.
OS_EndVAlarm | Ends a V-count alarm system.
OS_IsVAlarmAvailable | Checks whether a V-count alarm system is initialized and available.
OS_CreateVAlarm | Initializes a V-count alarm structure.
OS_SetVAlarm | Sets a V-count alarm.
OS_SetOneTimeVAlarm | Sets a V-count alarm. (Function added to maintain backwards-compatibility.)
OS_SetPeriodicVAlarm | Sets a periodic V-count alarm.
OS_SetVAlarmTag | Sets a tag to a V-count alarm.
OS_CancelVAlarm | Cancels a V-count alarm.
OS_CancelVAlarms | Cancels V-count alarms that have a specified tag.
OS_CancelAllVAlarms | This function cancels all of the V-count alarms.

### Time

OS_InitTick | Allocates a timer for ticks.
OS_IsTickAvailable | Checks whether a tick is initialized and available.
OS_GetTick | Acquires a tick value.
OS_GetTickLo | Acquires the lower order 16-bit value of a tick value.
OS_SetTick | Sets a tick value.
OS_MicroSecondsToTicks* | Converts from microseconds to a tick value.
OS_MilliSecondsToTicks* | Converts from milliseconds to a tick value.
OS_SecondsToTicks* | Converts from seconds to a tick value.
OS_TicksToMicroSeconds* | Converts from a tick value to microseconds.
OS_TicksToMilliSeconds* | Converts from a tick value to milliseconds.
OS_TicksToSeconds* | Converts from a tick value to seconds.

### Thread

OS_InitThread | Initialize thread system.
OS_IsThreadAvailable | Checks whether a thread is initialized and available.
OS_CreateThread | Creates threads.
OS_InitThreadQueue | Create thread queue.
OS_ExitThread | Exits current thread. The thread destructor is called.
OS_KillThread | Ends the specified thread. The thread destructor is called.
OS_KillThreadWithPriority | Sets the priority for the specified thread and then exits. The thread destructor is called.
OS_DestroyThread | Ends the specified thread. The thread destructor is not called.
OS_JoinThread | Joins a thread and waits for it to terminate.
OS_IsThreadTerminated | Determines whether the thread has completed.
OS_SelectThread | Select the next thread to be operated.
OS_SetSwitchThreadCallback | Sets the callback during thread switch.
OS_RescheduleThread | Conduct thread scheduling.
OS_YieldThread | Gives threads with same prority level a chance to execute and performs thread scheduling.
OS_SleepThread | Put thread into sleep state.
OS_Sleep | Set threads to sleep status for a prescribed time.
OS_WakeupThread | Put thread into an operable state.
OS_WakeupThreadDirect | Put thread into an operable state.
OS_SetThreadPriority | Sets thread priority.
OS_GetThreadPriority | Obtains thread priority.
OS_GetCurrentThread | This function gets the current thread.
OS_GetNumberOfThread | Obtains the number of threads being created.
OS_DisableScheduler | Stops thread rescheduling temporarily.
OS_EnableScheduler | Restarts thread rescheduling.
OS_SetThreadrParameter | Sets user parameters.
OS_GetThreadParameter | Gets user parameters.
OS_SetThreadDestructor | Sets the thread destructor.
OS_GetThreadDestructor | Gets the thread destructor.
OS_SetThreadDestructorStack | Sets the stack to execute thread destructor.
OS_DumpThreadList | Display all threads (for debugging).

### Exclusion Control

OS_InitMutex | Initialize mutex structure used for exclusive control.
OS_LockMutex | Lock thread using mutex.
OS_UnlockMutex | Unlock the thread locked with mutex.
OS_TryLockMutex | Attempt to lock the thread locked with mutex.

OS_InitLock | Performs exclusive-control initialization.
OS_LockCard | Spin locks the card for exclusive control.
OS_LockCartridge | Spin locks the Game Pak for exclusive control.
OS_UnlockCard | Release a spin lock for the card.
OS_UnlockCartridge | Release a spin lock for the Game Pak.
OS_TryLockCard | Attempts to spin lock the card for exclusive control.
OS_TryLockCartridge | Attempts to spin lock the Game Pak for exclusive control.
OS_GetLockID | Obtains the lock ID for spin lock.
OS_ReleaseLockID | Releases the lock ID used for spin lock.

### Context

OS_InitContext | This function initializes context.
OS_SaveContext | Save current context.
OS_LoadContext | Load current context.
OS_DumpContext | Display contents of context structure (for debugging). (For debugging)

### Message

OS_InitMessageQueue | Initialize message queue structure.
OS_SendMessage | Insert message at end of message queue.
OS_JamMessage | Inserts a message in the front of the message queue.
OS_ReceiveMessage | Extract message from message queue.
OS_ReadMessage | Copies the message that is at the front of the message queue.

### Cache

DC_Enable | Permits all data cache to be used.
DC_Disable | Prohibits all data cache from being used.
DC_Restore | Selects whether to permit or prohibit use of all data cache.
DC_InvalidateAll | Invalidates the data in the entire data cache region.
DC_StoreAll (DC_CleanAll) | Stores all data from data cache regions to memory.
DC_FlushAll (DC_CleanAndInvalidateAll) | Flushes all data in all data caches.
DC_InvalidateRange | Invalidates the data in the specified data cache region.
DC_StoreRange (DC_CleanRange) | Stores in the specified region of data cache to memory.
DC_FlushRange (DC_CleanAndInvalidateRange) | Flushes the data cache in the specified region.
DC_TouchRange | This function does not actually do anything.
DC_LockdownRange | Locks down specified range of data cache.
DC_Unlockdown | Releases the locked-down data cache in block-sized units.
DC_UnlockdownAll | Releases the entire locked-down data cache.
DC_WaitWriteBufferEmpty | Waits for the write buffer to empty.
IC_Enable | Permits the use of all instruction caches.
IC_Disable | Prohibits the use of all instruction caches.
IC_Restore | Selects whether to permit or prohibit use of all instruction cache.
IC_InvalidateAll | Invalidates instruction code through the entire instruction cache region.
IC_InvalidateRange | Disables specified range of instruction cache.
IC_PrefetchRange | Pre-fetches specified range of instruction cache.
IC_LockdownRange | Locks down specified range of instruction cache.
IC_Unlockdown | Releases the locked-down instruction cache in block-sized units.
IC_UnlockdownAll | Releases the entire locked-down instruction cache.

### Arena

OS_InitArena | Initializes the arena.
OS_EnableMainExArena | Declares use of main memory extended arena.
OS_DisableMainExArena | Declares disuse of main memory extended arena.
OS_SetArenaHi | Sets the upper boundary of the arena.
OS_Set*ArenaHi | Sets the upper boundary of the arena. (Arena specification)
OS_SetArenaLo | Sets the lower boundary of the arena.
OS_Set*ArenaLo | Sets the lower boundary of the arena. (Arena specification)
OS_GetArenaHi | Gets the upper boundary of the arena.
OS_Get*ArenaHi | Gets the upper boundary of the arena. (Arena specification)
OS_GetArenaLo | Gets the lower boundary of the arena.
OS_Get*ArenaLo | Gets the lower boundary of the arena. (Arena specification)
OS_AllocFromArenaHi | Allocates a region of specified size from the upper arena.
OS_AllocFrom*ArenaHi | Allocates a region of specified size from the upper arena. (Arena specification)
OS_AllocFromArenaLo | Allocates a region of specified size from the lower arena.
OS_AllocFrom*ArenaLo | Allocates a region of specified size from the lower arena. (Arena specification)

### Memory Allocation

OS_InitAlloc | Initializes the memory allocation system.
OS_ClearAlloc | Destroys the memory allocation system information.
OS_CreateHeap | Creates a heap.
OS_DestroyHeap | Destroys a heap.
OS_ClearHeap | Initializes a heap
OS_AddToHeap | Adds the specified memory block to the heap.
OS_SetCurrentHeap | Sets the current heap.
OS_AllocFromHeap | Allocate memory from the heap region.
OS_AllocFrom* | Allocate memory from the heap region. (Arena specification)
OS_Alloc | Allocate memory from the heap region. (Main memory arena)
OS_AllocFixed | Allocate the specified region.
OS_FreeToHeap | Free memory to the heap region.
OS_FreeTo* | Free memory to the heap region. (Arena specification)
OS_Free | Free memory to the heap region. (Main memory arena)
OS_FreeAllToHeap | Frees all allocated memory to the heap region.
OS_FreeAllTo* | Frees all allocated memory to the heap region. (Arena specification)
OS_FreeAll | Frees all allocated memory to the heap region. (Main memory arena)
OS_CheckHeap | Checks heap.
OS_DumpHeap | Displays heap contents (for debugging). (For debugging)
OS_ReferentSize | Gets the size in memory of the memory block (excluding the header).
OS_VisitAllocated | Applies the specified function to all memory blocks.
OS_GetTotalAllocSize | This function obtains the total size of the memory blocks allocated to the heap. Header is not included.
OS_GetTotalOccupiedSize | This function obtains the total size of the memory blocks (including the header) allocated to the heap.
OS_GetTotalFreeSize | Gets total size of free blocks in heaps.
OS_GetMaxFreeSize | Gets the size of the largest free block in the heaps.

### System Information

OS_GetOwnerInfo | Obtains the owner information.
OSOwnerInfo | Structure that indicates the owner information.
OS_GetOwnerRtcOffset | Obtains the RTC modification offset information.
OS_GetMacAddress | Obtains the MAC address that is unique to each Nintendo DS system.
OS_GetFavoriteColorTable | Gets a pointer to an array containing the RGBA color values that correspond to the IPL's "favorite color" menu.
OS_GetFavoriteColor | Gets color value of "favorite color" owner information.
OS_FAVORITE_COLOR_* | Definition value of "favorite color" owner information.
OS_GetLowEntropyData | Different values are generated from system status for each execution, and these values are returned.

### Debug (Operation Environment)

OS_IsRunOnEmulator | Checks if the program is running on ensata.
OS_GetConsoleType | Checks the operation environment of the program.

### Debug (Character String Display)

OS_PutString | Displays the character string.
OS_Printf | Displays the character string with formatting.
OS_TPrintf | Displays the character string with formatting. This is a simplified version of `OS_Printf`.
OS_VPrintf | Displays the character string with formatting. Uses the list of arguments.
OS_TVPrintf | Displays the character string with formatting. This is a simplified version of `OS_VPrintf`.
OS_SPrintf | Outputs the formatted character string to the memory with variable arguments.
OS_VSPrintf | Outputs the formatted character string to the memory with the argument list.
OS_SNPrintf | Outputs the formatted character string to the memory with variable arguments. (The size is specified).
OS_VSNPrintf | Outputs the formatted character string to the memory with the argument list. (The size is specified).
OS_Warning | Displays a warning.
OS_TWarning | Displays a warning. This is a simplified version of `OS_TWarning`.
OS_InitPrintServer | Initializes for display of debug message from ARM7. There is normally no need for this.
OS_PrintServer | Displays debug messages from ARM7. There is normally no need for this.

### Debug (Assert)

SDK_ASSERT* | Checks the requirements, displays a warning, and stops the program.
SDK_WARNING | Checks the conditions and displays a warning.
OS_Panic | Stops the program.
OS_TPanic | Stops the program. This is a simplified version of `OS_Panic`.
SDK_COMPILER_ASSERT | Conditions are inspected when compiling, and if conditions are not met, a compile error is made.

### Debug (Function Call Trace)

OS_InitCallTrace | Sets the buffer of the function call trace.
OS_DumpCallTrace | Displays the contents of the function call trace buffer.
OS_DumpThreadCallTrace | Displays the contents of the function call trace buffer for the specified thread.
OS_CalcCallTraceLines | Calculates the number of lines for the function call trace from the buffer size.
OS_CalcCallTraceBufferSize | Calculates the buffer size for the function call trace from the number of lines.
OS_ClearCallTraceBuffer | Clears the contents of the function call trace buffer.
OS_EnableCallTrace | This function enables the function call trace feature.
OS_DisableCallTrace | This function disables the function call trace feature.
OS_RestoreCallTrace | Sets the function call trace features to enabled or disabled.

### Debug (Function Cost Measurement)

OS_InitFunctionCost | Sets the function cost measurement buffer.
OS_CalcFunctionCostLines | Calculates the amount of information for the function cost measurement from the buffer size.
OS_CalcFunctionCostBufferSize | Calculates the buffer size for the function cost measurement from the number of lines.
OS_ClearFunctionCostBuffer | Clears the contents of the function cost measurement buffer.
OS_EnableFunctionCost | This function enables the function cost calculation feature.
OS_DisableFunctionCost | This function disables the function cost calculation feature.
OS_RestoreFunctionCost | Sets the features of the function cost measurement to enabled or disabled.
OS_InitStatistics | Initializes the function cost calculation buffer.
OS_CalcStatistics | Calculates the contents of the measurement buffer to the function cost calculation buffer.
OS_CalcThreadStatitics | Calculates the contents of the measurement buffer to the function cost calculation buffer with a thread specification.
OS_DumpStatistics | Outputs the contents of the function cost calculation buffer.

### Debug (Stack Check)

OS_SetThreadStackWarningOffset | Sets the warning level for the thread stack overflow check.
OS_CheckStack | Checks the thread stack overflow.
OS_GetStackStatus | Obtains the stack overflow status of the thread.

OS_SetIrqStackChecker | Set the magic number to check if the stack used for IRQ mode has overflowed.
OS_SetIrqStackWarningOffset | Set the warning level to check if the stack used for IRQ mode has overflowed.
OS_CheckIrqStack | Check if the stack used for IRQ mode has overflowed.
OS_GetIrqStackStatus | Get the overflow status of the stack used for IRQ mode.

### Debug (Argument)

OS_GetArgc | Gets the number of arguments.
OS_GetArgv | Gets the character string position of arguments.
OS_GetOpt* | Gets the information for the argument options for the command line.
OS_ConvertToArguments | Converts character strings to argument data.
OS_SetArgumentBuffer | Sets argument data.
OS_GetArgumentBuffer | Gets argument data.