OS_GetConsoleType

Syntax

#include <nitro/os.h>

u32 OS_GetConsoleType( void );

Arguments

None.

Return Values

A u32-type value that depends on the program's execution environment. Details are provided in Description.

Description

Returns a u32-type value that represents the program's execution environment.

This function is an effective way to automatically switch processes depending on the operating environment. It allows you to create a common program for multiple operating environments.

OS_GetConsoleType is a function for getting the operating environment, not a function for finding out the operating mode. Use the OS_IsRunOnTwl function to find out the operating mode. For example, games for NTR can be played on the NTR as well as the TWL. The program is running in NTR mode in either case, but the hardware it is running on is different (NTR or TWL).

・The OS_IsRunOnTwl function tells you whether the application is running in NTR mode or TWL mode. However, it will not tell you which hardware the application is running on.
With the OS_GetConsoleType function, you can find out whether the application is running on NTR or TWL. However, it will not tell you what the operating mode is.
(Also, if the FINALROM build of a NITRO-only ROM is run on a TWL, it will return a value that indicates the software is running on NTR.))

The first time it is called, the OS_GetConsoleType function surveys the devices, memory, and other information to determine its return value, but in subsequent calls, it just returns the same value it returned earlier. As a result, there is hardly any overhead in calling this function.

This function's return values are limited in the FINALROM libraries. When running these builds on something other than the production hardware (such as the debugger), values may be returned that represent environments other than the one being used.


Similar Functions

There is a similar function called OS_GetRunningConsoleType. This function is different in that it surveys the actual hardware and returns the appropriate value, even for FINALROM builds.

For example, this difference can be seen by running a TWL FINALROM build on IS-TWL-DEBUGGER. The IS-TWL-DEBUGGER hardware has 32 MB of built-in memory, so the value returned by the OS_GetRunningConsoleType function & OS_CONSOLE_SIZE_MASK is OS_CONSOLE_SIZE_32MB, and the value returned by the OS_GetConsoleType function & OS_CONSOLE_SIZE_MASK is OS_CONSOLE_SIZE_16MB.

If either of these functions for getting the operating environment are being left in a FINALROM build, it would be safer to use the OS_GetConsoleType function instead of the OS_GetRunningConsoleType function. The reason is this: Thinking ahead to when this platform is a retail product, the final ROM should only be running on the production hardware, so we want to eliminate the chances of a value that should never occur in the retail product (such as "operating environment is the debugger") being returned. With that in mind, it would probably be best to limit your use of the OS_GetRunningConsoleType function to debugging purposes.


Values That Can Be Obtained

Operating environment:
The bitwise AND of the return value and OS_CONSOLE_MASK yield the following values depending on the operating environment.
Value Operating Environment
OS_CONSOLE_TWL Running on TWL hardware (*1)
OS_CONSOLE_NITRO Running on NITRO hardware
OS_CONSOLE_TWLDEBUGGER Running on IS-TWL-DEBUGGER (*2)
OS_CONSOLE_ISDEBUGGER Running on IS-NITRO-DEBUGGER
OS_CONSOLE_ENSATA Running on Ensata NITRO Software Emulator
For *1, where the function has determined that the application is running on an actual TWL system, the values are further refined based on the bitwise AND in combination with OS_CONSOLE_TWLTYPE_MASK.
That said, you do not normally have to give consideration to OS_CONSOLE_TWLTYPE_DEV. Based solely upon OS_CONSOLE_TWL, you can treat the hardware as an actual TWL system.
When using TWL debugger without connecting to debugger software, the operating environment is OS_CONSOLE_TWL and the TWL hardware type is OS_CONSOLE_TWLTYPE_DEV.
However, when using NITRO debugger without connecting to debugger software, the operating environment is OS_CONSOLE_IS_DEBUGGER (which is no different from being connected to debugger software).
Value TWL Hardware Types
OS_CONSOLE_TWLTYPE_RETAIL TWL retail hardware
OS_CONSOLE_TWLTYPE_DEV TWL hardware with a different security key for development purposes / Also indicates no connection to TWL debugger software

For *2, where the function has determined that the application is running on IS-TWL-DEBUGGER, the values are further refined based on the bitwise AND in combination with OS_CONSOLE_BOARD_MASK.
Value IS-TWL-DEBUGGER Types
OS_CONSOLE_BOARD_A9_A7 Debugger that supports both the ARM9 and ARM7, for component development
OS_CONSOLE_BOARD_A9 ARM9-only debugger, for application development

Devices for Loading Programs:

The bitwise AND of the return value and OS_CONSOLE_DEV_MASK yield the following values depending on the device loading the program data.
Value Load Device
OS_CONSOLE_DEV_CARD Load from a Game Card device
OS_CONSOLE_DEV_CARTRIDGE Load from a Game Pak (*3)
OS_CONSOLE_DEV_NAND Load from NAND
OS_CONSOLE_DEV_SDCARD Load from an SD Card
OS_CONSOLE_DEV_MEMORY Load from memory
OS_CONSOLE_DEV_DOWNLOAD Load from a download

*3 The TWL system does not include a Game Pak slot, so this value cannot be obtained on the TWL platform.
Memory Size:

The bitwise AND of the return value and OS_CONSOLE_SIZE_MASK takes the following values depending on the size of the implemented memory.
Value Main Memory Size
OS_CONSOLE_SIZE_4MB 4 MB
OS_CONSOLE_SIZE_8MB 8 MB
OS_CONSOLE_SIZE_16MB 16 MB
OS_CONSOLE_SIZE_32MB 32 MB

If a NITRO-only ROM is run on TWL hardware, the memory size is 4 MB, regardless of the build type.


Actual Values Due to the Environment or Build

The table below indicates the values that can be obtained with the OS_GetConsoleType and OS_GetRunningConsoleType functions. The logical sum (bitwise OR) of the items in the table is the value obtained. OS_CONSOLE_DEV_xxx is the value of the device that actually loaded the ROM data.

For NITRO Mode
Operating Environment Build Value of the OS_GetConsoleType Function Value of the OS_GetRunningConsoleType Function Comments
NTR system DEBUG
RELEASE
OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
All 4 are
the same.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
TWL system DEBUG
RELEASE
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
The amount of built-in memory is
4 MB, regardless of the build.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
IS-NITRO-DEBUGGER
(debugger software
even if not connected)
DEBUG
RELEASE
OS_CONSOLE_ISDEBUGGER
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_8MB
OS_CONSOLE_ISDEBUGGER
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_8MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_ISDEBUGGER
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_8MB
ENSATA EMULATOR DEBUG
RELEASE
OS_CONSOLE_ISDEBUGGER
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_8MB
OS_CONSOLE_ISDEBUGGER
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_8MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_ISDEBUGGER
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_8MB
IS-TWL-DEBUGGER
(For general-purpose development: ARM9)
DEBUG
RELEASE
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
IS-TWL-DEBUGGER
(For component development:
ARM9 + ARM7)
DEBUG
RELEASE
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9_A7

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9_A7

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9_A7

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
IS-TWL-DEBUGGER
(For general-purpose development: ARM9)
When not connected to debugger software
DEBUG
RELEASE
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.

The amount of built-in memory is
4 MB, regardless of the build.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
IS-TWL-DEBUGGER
(For component development:
ARM9 + ARM7)
When not connected to debugger software
DEBUG
RELEASE
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.

The amount of built-in memory is
4 MB, regardless of the build.
FINALROM OS_CONSOLE_NITRO
OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV7

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_4MB
For TWL Mode
Operating Environment Build Value of the OS_GetConsoleType Function Value of the OS_GetRunningConsoleType Function Comments
TWL system DEBUG
RELEASE
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
All 4 are
the same.
FINALROM OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
IS-TWL-DEBUGGER
(For general-purpose development: ARM9)
DEBUG
RELEASE
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
IS-TWL-DEBUGGER
(For component development:
ARM9 + ARM7)
DEBUG
RELEASE
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9_A7

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9_A7

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
OS_CONSOLE_TWLDEBUGGER
OS_CONSOLE_BOARD_A9_A7

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
IS-TWL-DEBUGGER
(For general-purpose development: ARM9)
When not connected to debugger software
DEBUG
RELEASE
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
IS-TWL-DEBUGGER
(For component development:
ARM9 + ARM7)
When not connected to debugger software
DEBUG
RELEASE
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB
The only difference is
the OS_GetConsoleType function
for FINALROM builds.
FINALROM OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_RETAIL

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_16MB
OS_CONSOLE_TWL
OS_CONSOLE_TWLTYPE_DEV

OS_CONSOLE_DEV_xxx
OS_CONSOLE_SIZE_32MB



Identifying the Operating Environment in NITRO Mode

When running in NITRO mode, it is impossible to determine whether hardware is NTR or TWL using just the OS_GetConsoleType function. Although the distinction can be made by checking the value of the OS_GetRunningConsoleType function, Nintendo prefers that developers only use the OS_GetRunningConsoleType function for debugging purposes. Although there is usually no need to know which hardware system is running, the OSi_IsNitroModeOnTwl function has been prepared in case you need to identify the system. If this function returns TRUE, it will indicate that a NITRO-mode ROM is running on TWL.

The OSi_IsNitroModeOnTwl function, which includes TWL in its name, was originally handled as private when TWL development first began. This was based on the reasoning that the OSi_IsNitroModeOnTwl function should be used for limited purposes, and that NITRO developers were not familiar with TWL. This function is still private.

See Also

OS_IsRunOnDebugger
OS_IsRunOnEmulator
OS_GetRunningConsoleType

Revision History

2009/10/30 Added information about operation when a debugger is not connected. Revised operating environment identification in NITRO mode.
2008/04/15 Split up tables according to the mode.
2008/03/27 Added actual values dependent on the environment and build.
2007/11/16 Added descriptions.
2007/11/05 Migrated to the OS_GetRunningConsoleType function.


CONFIDENTIAL