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 (NITRO-SDK)</TITLE>
9<LINK rel="stylesheet" href="../css/apilist.css">
10</HEAD>
11<BODY>
12<H1>Description of Header Files (NITRO-SDK)</H1>
13<H3><A name="System">NITRO-SDK System Header</A></H3>
14<TABLE border="1" width="100%">
15  <TBODY>
16    <TR>
17      <TH width="25%"><code>nitro.h</code></TH>
18      <TD>The definition file for the NITRO-SDK standard library.</TD>
19    </TR>
20    <TR>
21      <TH width="25%"><code>nitro_win32.h</code></TH>
22      <TD>Contains the definitions that are needed when creating tools on a Windows PC, such as the variable types defined for the NITRO-SDK.</TD>
23    </TR>
24  </TBODY>
25</TABLE>
26<P>Include these header files in modules that use NITRO-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="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="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="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="init/NitroStaticInit.html">NitroStaticInit()</A></CODE> when the overlay module is linked.</P>
38<H3><A name="Arch">Switching Between ARM &amp; THUMB Instruction Sets</A></H3>
39<TABLE border="1" width="100%">
40  <TBODY>
41    <TR>
42      <TH width="25%"><CODE>nitro/code32.h</CODE></TH>
43      <TD>All subsequent code is output as ARM instructions (32-bit code).</TD>
44    </TR>
45    <TR>
46      <TH width="25%"><CODE>nitro/code16.h</CODE></TH>
47      <TD>All subsequent code is output as THUMB instructions (16-bit code).</TD>
48    </TR>
49    <TR>
50      <TH width="25%"><CODE>nitro/codereset.h</CODE></TH>
51      <TD>At the compile time, all subsequent code is output 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 NINTENDO DS can use two kinds of instruction sets: ARM and THUMB instructions. Using jump instructions, you can switch between these two instruction sets. 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 &lt;nitro/code32.h&gt;     // This outputs the following arm_inst() using an ARM instruction set
59int arm_inst(int n)<BR>{<BR>    // 32-bit code area
60    return n * n;
61}#include &lt;nitro/codereset.h&gt;  // 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%">nitro/dtcm_begin.h<BR>
68      nitro/dtcm_end.h</TH>
69      <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>
70    </TR>
71    <TR>
72      <TH width="25%">nitro/itcm_begin.h<BR>
73      nitro/itcm_end.h</TH>
74      <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>
75    </TR>
76  </TBODY>
77</TABLE>
78<P>The NINTENDO DS 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>
79<P>When defining the functions you want to place in the TCM region, enclose them with <CODE>nitro/itcm_begin.h</CODE> and <CODE>nitro/itcm_end.h</CODE> as shown below. Function regions that are enclosed this way are transferred to the instruction TCM (ITCM) region at startup.</P>
80<BLOCKQUOTE>
81<PRE>#include &lt;nitro/itcm_begin.h&gt;  //  Place the following tcm_inst() in ITCM
82int tcm_inst(int n)
83{
84    // 32-bit code area
85    return n * n;
86}
87#include &lt;nitro/item_end.h&gt;    // Return the placement destination to normal</PRE>
88</BLOCKQUOTE>
89<P>When you want to place a data block in the data TCM (DTCM) region, enclose it with <CODE>nitro/dtcm_begin.h</CODE> and <CODE>nitro/dtcm_end.h</CODE>, as shown below.</P>
90<BLOCKQUOTE>
91<PRE>#include &lt;nitro/dtcm_begin.h&gt;  // Place the following tcm_data() in DTCM
92u32  tcm_data[] =
93{
94    0, 1, 2, 3, 4, 5, 6, 7, 8, 9
95}
96#include &lt;nitro/dtem_end.h&gt;    // Returns placement destination to normal</PRE>
97</BLOCKQUOTE>
98<H3><A name="OtherSection">Specifying Special Sections</A></H3>
99<TABLE border="1" width="100%">
100  <TBODY>
101    <TR>
102      <TH width="25%">nitro/parent_begin.h<BR>
103      nitro/parent_end.h</TH>
104      <TD>The code in between gets output to the <CODE>*.parent</CODE> section. This is used during a clone boot operation.</TD>
105    </TR>
106    <TR>
107      <TH width="25%">nitro/version_begin.h<BR>
108      nitro/version_end.h</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 NITRO-SDK library.</TD>
110    </TR>
111    <TR>
112      <TH width="25%">nitro/wram_begin.h<BR>
113      nitro/wram_end.h</TH>
114      <TD>The code in between is output to the <CODE>*.wram</CODE> section. This is enabled only in ARM7.</TD>
115    </TR>
116  </TBODY>
117</TABLE>
118<P>There are also other special sections besides the TCM sections.</P>
119<P>The <CODE>*.parent</CODE> section is essential for clone boot--one form of DS Download Play. For further detail, read the section about clone booting in the document that explains DS Download Play (<CODE>$NitroSDK/docs/TechnicalNotes/AboutMultiBoot.pdf</CODE>).</P>
120<P>The <CODE>*.version</CODE> section and the <CODE>*.wram</CODE> section are used in the NITRO SDK implementation internally, so there is no need to be careful when using them.</P>
121<H3><A name="Version">NITRO-SDK Version Information</A></H3>
122<TABLE border="1" width="100%">
123  <TBODY>
124    <TR>
125      <TH><code>nitro/version.h</code></TH>
126      <TD>This is version information about the NITRO-SDK.</TD>
127    </TR>
128  </TBODY>
129</TABLE>
130<P>This defines the NITRO-SDK version information.</P>
131<TABLE border="0" height="100%">
132  <TBODY>
133    <TR>
134      <TD style="background-color : white;"></TD>
135    </TR>
136  </TBODY>
137</TABLE>
138<hr><p>CONFIDENTIAL</p></body>
139</HTML>