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 http-equiv="Content-Style-Type" content="text/css"> 6<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows"> 7<BASE target="main"> 8<TITLE>Description of Header Files (TWL-SDK)</TITLE> 9<LINK rel="stylesheet" href="../css/apilist.css"> 10</HEAD> 11<BODY> 12<H1>Description of Header Files (TWL-SDK)</H1> 13<H3><A name="System">TWL-SDK System Header</A></H3> 14<TABLE border="1" width="100%"> 15 <TBODY> 16 <TR> 17<TH width="25%">twl.h</TH> 18<TD>The definition file for the TWL-SDK standard library.</TD> 19 </TR> 20 <TR> 21<TH width="25%">twl_win32.h</TH> 22<TD>Contains the definitions that are needed when creating tools on a Windows PC, such as the variable types defined for the TWL-SDK.</TD> 23 </TR> 24 </TBODY> 25</TABLE> 26<P>Include these header files in modules that use TWL-SDK.</P> 27<H3><A name="Sinit">Module Initialization Function</A></H3> 28<TABLE border="1" width="100%"> 29 <TBODY> 30 <TR> 31<TH><code>nitro/sinit.h</code></TH> 32<TD>This header file enables use of the module initialization function <CODE><A href="../os/init/NitroStaticInit.html">NitroStaticInit</A></CODE>.</TD> 33 </TR> 34 </TBODY> 35</TABLE> 36<P>Enables the use of the C language static initializer <CODE><A href="../os/init/NitroStaticInit.html">NitroStaticInit()</A></CODE>.</P> 37<P>Place this header file in an include statement only in the module that defines <CODE><A href="../os/init/NitroStaticInit.html">NitroStaticInit()</A></CODE>. The static initializer of the overlay module starts when the overlay is linked. With this mechanism, you can prepare an entry for a pointer to a function so that the corresponding function gets registered in <CODE><A href="../os/init/NitroStaticInit.html">NitroStaticInit()</A></CODE> when the overlay module is linked.</P> 38<H3><A name="Arch">Switching Between ARM & THUMB Instruction Sets</A></H3> 39<TABLE border="1" width="100%"> 40 <TBODY> 41 <TR> 42<TH width="25%">twl/code32.h</TH> 43<TD>All subsequent code is output as ARM instructions (32-bit code).</TD> 44 </TR> 45 <TR> 46<TH width="25%">twl/code16.h</TH> 47<TD>All subsequent code is output as THUMB instructions (16-bit code).</TD> 48 </TR> 49 <TR> 50<TH width="25%">twl/codereset.h</TH> 51<TD>At compile time, all subsequent code is outputted as an instruction set, according to the specified options.</TD> 52 </TR> 53 </TBODY> 54</TABLE> 55<P>The ARM9 and ARM7 CPUs of the TWL can use two kinds of instruction sets: ARM and THUMB instructions. You can switch between these two instruction sets using jump instructions. In C, switching between jump instructions is performed with function calls. Therefore, the instruction set is normally selected by a function.</P> 56<P>Use <CODE>code32.h</CODE> or <CODE>code16.h</CODE> by combining with <CODE>codereset.h</CODE>. With <CODE>code32.h</CODE> and <CODE>codereset.h</CODE>, enclose the function for the instruction set you want to fix with the ARM. With <CODE>code16.h</CODE> and <CODE>codereset.h</CODE>, enclose the function you want to fix with the THUMB. When you are using assembly, always enclose the function with <CODE>code32.h</CODE> or <CODE>code16.h</CODE>, depending on the instruction set.</P> 57<BLOCKQUOTE> 58<PRE>#include <twl/code32.h> // This outputs the following arm_inst() using the ARM instruction set 59int arm_inst(int n)<BR>{<BR> // 32-bit code area 60 return n * n; 61}<BR>#include <twl/codereset.h> // The instruction set is restored (as per the compiler options)</PRE> 62</BLOCKQUOTE> 63<H3><A name="TCM_Section">Using TCM</A> (TCM section specification)</H3> 64<TABLE border="1" width="100%"> 65 <TBODY> 66 <TR> 67<TH width="25%">twl/dtcm_begin.h<BR> twl/dtcm_end.h</TH> 68<TD>The code in between is output to the <CODE>*.dtcm</CODE> section. According to the SDK standard setting, the <CODE>*.dtcm</CODE> section is placed in ARM9 DTCM (data TCM).</TD> 69 </TR> 70 <TR> 71<TH width="25%">twl/itcm_begin.h<BR> twl/itcm_end.h</TH> 72<TD>The code in between is output to the <CODE>*.itcm</CODE> section. According to the SDK standard setting, the <CODE>*.itcm</CODE> section is placed in ARM9 ITCM (instruction TCM).</TD> 73 </TR> 74 </TBODY> 75</TABLE> 76<P>The TWL ARM9 processor has a scratchpad region in CPU (a high-speed buffer region that is fixed in the memory map) called TCM. The region can be accessed as fast as cache in the CPU; so by making better use of this region you can limit the slow-down in processing speed that might otherwise occur because of a cache miss.</P> 77<P>When defining the functions you want to place in the TCM region, enclose them with twl/itcm_begin.h and twl/itcm_end.h as shown below. Function regions that are enclosed this way are transferred to the instruction TCM (ITCM) region at startup.</P> 78<BLOCKQUOTE> 79<PRE>#include <twl/itcm_begin.h> // Place the following tcm_inst() in ITCM 80int tcm_inst(int n) 81{ 82 // 32-bit code area 83 return n * n; 84} 85#include <twl/item_end.h> // Return the placement destination to normal</PRE> 86</BLOCKQUOTE> 87<P>When you want to place a data block in the data TCM (DTCM) region, enclose it with twl/dtcm_begin.h and twl/dtcm_end.h, as shown below.</P> 88<BLOCKQUOTE> 89<PRE>#include <twl/dtcm_begin.h> // Place the following tcm_data() in DTCM 90u32 tcm_data[] = 91{ 92 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 93} 94#include <twl/dtcm_end.h> // Return the placement destination to normal</PRE> 95</BLOCKQUOTE> 96<H3><A name="OtherSection">Specifying Special Sections</A></H3> 97<TABLE border="1" width="100%"> 98 <TBODY> 99 <TR> 100<TH width="25%"><CODE>nitro/parent_begin.h<BR> nitro/parent_end.h</CODE></TH> 101<TD>The code in between gets output to the <CODE>*.parent</CODE> section. This is used during a clone boot operation.</TD> 102 </TR> 103 <TR> 104<TH width="25%">twl/ltdmain_begin.h<BR> twl/ltdmain_end.h</TH> 105<TD>The code in between is output to the <CODE>.ltdmain</CODE> section. This is used with HYBRID applications.</TD> 106 </TR> 107 <TR> 108<TH width="25%"><CODE>nitro/version_begin.h<BR> nitro/version_end.h</CODE></TH> 109<TD>The code in between gets output to the <CODE>*.version</CODE> section. Do not use this section; it is reserved in the TWL-SDK library.</TD> 110 </TR> 111 <TR> 112<TH width="25%">twl/wram_begin.h<BR> twl/wram_end.h</TH> 113<TD>The code in between is output to the <CODE>*.wram</CODE> section. This is enabled only in the ARM7.</TD> 114 </TR> 115 </TBODY> 116</TABLE> 117<P> 118There are also other special sections besides the TCM sections. 119</P> 120<P> 121The <CODE>*.parent</CODE> section is essential for clone boot--one form of DS Download Play. <!--- ????DS??????????????????($TwlSDK/docs/TechnicalNotes/AboutMultiBoot.pdf) ???????????????????????---> 122</P> 123<P> 124The <CODE>.ltdmain</CODE> section is used with HYBRID applications. This section is only loaded when an application runs on TWL, not when an application is run on a Nintendo DS. 125</P> 126<P>The <CODE>*.version</CODE> section and the <CODE>*.wram</CODE> section are used in the TWL-SDK implementation internally, so there is no need to be aware of them when using the SDK. 127</P> 128<H3><A name="Version">TWL-SDK Version Information</A></H3> 129<TABLE border="1" width="100%"> 130 <TBODY> 131 <TR> 132<TH>twl/version.h</TH> 133<TD>This library contains TWL-SDK version information.<br>Defines the macro <CODE><A href="version/SDK_VERSION_NUMBER.html">SDK_VERSION_NUMBER</A></CODE> and the constant <CODE><A href="version/SDK_CURRENT_VERSION_NUMBER.html">SDK_CURRENT_VERSION_NUMBER</A></CODE>. 134 </TD> 135 </TR> 136 </TBODY> 137</TABLE> 138<P>This defines the TWL-SDK version information.</P> 139<TABLE border="0" height="100%"> 140 <TBODY> 141 <TR> 142 <TD style="background-color : white;"></TD> 143 </TR> 144 </TBODY> 145</TABLE> 146<hr><p>CONFIDENTIAL</p></body> 147</HTML>