1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.1.0 for Windows"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<TITLE>OS_IsRunOnTwl</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">OS_IsRunOnTwl <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1> 12<H2>Syntax</H2> 13<DL> 14 <DD><CODE>#include <nitro/os.h></CODE><BR> <BR> <CODE>BOOL OS_IsRunOnTwl( void );</CODE> 15</DL> 16<H2>Arguments</H2> 17<P>None.</P> 18<H2>Return Values</H2> 19<P>If <CODE>TRUE</CODE>, the application is running in TWL mode. The actual operating environment may be either an actual TWL system or the IS-TWL-DEBUGGER hardware.</P> 20<P>If <CODE>FALSE</CODE>, the application is running in some other mode (that is, in NITRO mode). The actual operating environment may be either an actual NITRO console or IS-NITRO-DEBUGGER. This also applies to the case of running an application in NITRO mode on IS-TWL-DEBUGGER.</P> 21<H2>Description</H2> 22<P>Determines whether the program is running in TWL mode.</P> 23<P>The <CODE>OS_IsRunOnTwl</CODE> function determines the <I>operating mode</I>. It does not determine the <I>operating environment</I>. For example, this function will sometimes return <CODE>TRUE</CODE> and sometimes return <CODE>FALSE</CODE>, even though the application is running on the IS-TWL-DEBUGGER hardware in both cases. In other words, programs run on IS-TWL-DEBUGGER will sometimes be run in TWL mode and will sometimes be run in NITRO mode.</P> 24<P><CODE>OS_IsRunOnTwl</CODE> is a useful function when creating TWL/NITRO hybrid ROMs. Hybrid ROMs will run in TWL mode on TWL, and in NITRO mode on NITRO. This function will return <CODE>TRUE</CODE> when run on a TWL, and <CODE>FALSE</CODE> when run on NITRO. This can be used to switch between code dynamically.</P> 25 26<P>Example: How to Split Up Code That Supports NITRO/TWL Hybrid ROMs</P> 27<BLOCKQUOTE style="background-color:#ffffc0"><CODE>if ( <FONT color="#ff0000">OS_IsRunOnTwl()</FONT> )<BR> {<BR> // Code you want to run in TWL mode<BR> }<BR> else<BR> {<BR> // Code you want to run in NITRO mode<BR> }</CODE></BLOCKQUOTE> 28<P><BR> Also, while this will not be a very common case during normal development, you can use code like the following to match the <CODE>#define</CODE> directives defined for the SDK during development of libraries that support all three types of ROMs (NITRO-exclusive, TWL-exclusive, and NITRO/TWL hybrid). This code could be included in the library's source code.</P> 29<P>Example: How to Split Up Code That Supports NITRO-Exclusive ROMs, TWL-Exclusive ROMs, and NITRO/TWL Hybrid ROMs</P> 30<BLOCKQUOTE style="background-color:#ffffc0"><CODE>if ( <FONT color="#ff0000">OS_IsRunOnTwl()</FONT> )<BR> {<BR> #ifdef <FONT color="#ff0000">SDK_TWL</FONT><BR> // Code you want to run in TWL mode<BR> #endif<BR> }<BR> else<BR> {<BR> #ifndef <FONT color="#ff0000">SDK_TWLLTD</FONT><BR> // Code you want to run in NITRO mode<BR> #endif<BR> }</CODE></BLOCKQUOTE> 31<P>The <CODE>OS_IsRunOnTwl</CODE> function determines the platform at run time for hybrid ROMs, but for NITRO-exclusive ROMs, it will return the constant <CODE>FALSE</CODE>, and for TWL-exclusive ROMs, it will return the constant <CODE>TRUE</CODE>. When creating NITRO-exclusive ROMs or TWL-exclusive ROMs, you can expect the cases that do not match the conditions of the <CODE>if</CODE> statement to be deadstripped. However, we have used <CODE>SDK_TWL</CODE> (defined at compile time for TWL-exclusive ROMs and NITRO/TWL hybrid ROMs) and <CODE>SDK_TWLLTD</CODE> (defined at compile time for TWL-exclusive ROMs) to avoid undefined errors and other problems with functions appearing in the code that will be deadstripped.</P> 32<H3>Actual Values Due to the Environment:</H3> 33<P>Below is a list of values that can be returned by the <CODE>OS_IsRunOnTwl</CODE> function. There are no differences as a result of the build type (DEBUG, RELEASE, FINALROM).<BR> 34</P> 35<TABLE border="1"> 36 <TBODY> 37 <TR> 38 <TH colspan="2" style="background-color:#304040;"><FONT color="#ffffff">For NITRO Mode</FONT></TH> 39 </TR> 40 <TR> 41 <TH>Operating Environment</TH> 42 <TH>Value of <CODE>OS_IsRunOnTwl</CODE></TH> 43 </TR> 44 <TR> 45 <TD>Actual DS unit</TD> 46 <TD><B>FALSE</B></TD> 47 </TR> 48 <TR> 49 <TD>Actual TWL unit</TD> 50 <TD><B>FALSE</B></TD> 51 </TR> 52 <TR> 53 <TD>IS-NITRO-DEBUGGER</TD> 54 <TD><B>FALSE</B></TD> 55 </TR> 56 <TR> 57 <TD>ENSATA EMULATOR</TD> 58 <TD><B>FALSE</B></TD> 59 </TR> 60 <TR> 61 <TD>IS-TWL-DEBUGGER<BR>(For standard development: ARM9) </TD> 62 <TD><B>FALSE</B></TD> 63 </TR> 64 <TR> 65 <TD>IS-TWL-DEBUGGER<BR>(For component development<BR>ARM9 + ARM7)</TD> 66 <TD><B>FALSE</B></TD> 67 </TR> 68 <TR> 69 <TH colspan="2" style="background-color:#304040;"><FONT color="#ffffff">For TWL Mode</FONT></TH> 70 </TR> 71 <TR> 72 <TH>Operating Environment</TH> 73 <TH>Value of <CODE>OS_IsRunOnTwl</CODE></TH> 74 </TR> 75 <TR> 76 <TD>Actual TWL unit</TD> 77 <TD><FONT color="#ff0000"><B>TRUE</B></FONT></TD> 78 </TR> 79 <TR> 80 <TD>IS-TWL-DEBUGGER<BR>(For standard development: ARM9)</TD> 81 <TD><FONT color="#ff0000"><B>TRUE</B></FONT></TD> 82 </TR> 83 <TR> 84 <TD>IS-TWL-DEBUGGER<BR>(For component development<BR>ARM9 + ARM7)</TD> 85 <TD><FONT color="#ff0000"><B>TRUE</B></FONT></TD> 86 </TR> 87 </TBODY> 88</TABLE> 89<P><BR> 90</P> 91<H2>Internal Operation</H2> 92<P>Makes the judgment based the value in the System Configuration register.</P> 93<H2>See Also</H2> 94<P><A href="../debug/OS_Printf.html"><CODE>OS_Printf</CODE></A><BR> <A href="OS_GetConsoleType.html"><CODE>OS_GetConsoleType</CODE></A></P> 95<H2>Revision History</H2> 96<P>2007/11/16 Added information.<BR> 2007/11/06 Initial version.</P> 97<hr><p>CONFIDENTIAL</p></body> 98</HTML>