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_InitArena</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">OS_InitArena <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1>
12<H2>Syntax</H2>
13<DL>
14  <DD>
15<PRE><CODE>#include &lt;nitro/os.h&gt;</CODE></PRE>
16  <PRE><CODE>void OS_InitArena( void );
17</CODE></PRE>
18</DL>
19<H2>Arguments</H2>
20<P>None.</P>
21<H2>Return Values</H2>
22<P>None.</P>
23<H2>Description</H2>
24<P>This function sets the upper and lower boundaries.</P>
25<P>Call this function once before the <code>Alloc</code> functions or other Arena functions. But because this function is also called from within <CODE><A href="../init/OS_Init.html">OS_Init()</A></CODE>, calling this function has no meaning when <CODE><A href="../init/OS_Init.html">OS_Init()</A></CODE> is called. Second and subsequent calls of this function will be ignored.</P>
26<P>It is possible to change the arena boundaries with <code>OS_SetArenaLo()</code> and <code>OS_SetArenaHi()</code> after calling <code>OS_InitArena()</code>.</P>
27<P>TWL-SDK allows you to define nine different Arena regions: main memory (one for ARM9 and one for ARM7), expanded main memory, ITCM, DTCM, a shared memory user portion, shared work RAM (one for ARM9 and one for ARM7), and ARM7-dedicated work RAM. Each region gets an ID and is defined as an <code>OSArenaId</code> enumerated type, as shown  below.
28</P>
29<TABLE border="1">
30  <TBODY>
31    <TR>
32<TH>Arena ID</TH>
33<TH>Arena</TH>
34<TH>Initialization</TH>
35    </TR>
36    <TR>
37<TD>OS_ARENA_MAIN</TD>
38<TD>Arena in main memory (ARM9-dedicated)</TD>
39<TD>From ARM9</TD>
40    </TR>
41    <TR>
42<TD>OS_ARENA_MAIN_SUBPRIV</TD>
43<TD>Arena in main memory (ARM7-dedicated)</TD>
44<TD>From ARM7</TD>
45    </TR>
46    <TR>
47<TD>OS_ARENA_MAINEX</TD>
48<TD>Main Memory Expanded Arena</TD>
49<TD>From ARM9</TD>
50    </TR>
51    <TR>
52<TD>OS_ARENA_ITCM</TD>
53<TD>ITCM Arena</TD>
54<TD>From ARM9</TD>
55    </TR>
56    <TR>
57<TD>OS_ARENA_DTCM</TD>
58<TD>DTCM Arena</TD>
59<TD>From ARM9</TD>
60    </TR>
61    <TR>
62<TD>OS_ARENA_SHARED</TD>
63<TD>Shared Memory Arena (user region)</TD>
64<TD>From ARM9</TD>
65    </TR>
66    <TR>
67
68<TD>OS_ARENA_WRAM_MAIN</TD>
69<TD>Shared Work RAM Arena (for ARM9)</TD>
70<TD>From ARM9</TD>
71    </TR>
72    <TR>
73<TD>OS_ARENA_WRAM_SUB</TD>
74<TD>Shared Work RAM Arena (for ARM7)</TD>
75<TD>From ARM7</TD>
76    </TR>
77    <TR>
78<TD>OS_ARENA_WRAM_SUBPRIV</TD>
79<TD>Work RAM Arena (ARM7-dedicated)</TD>
80<TD>From ARM7</TD>
81    </TR>
82  </TBODY>
83</TABLE>
84<P> </P>
85<P><CODE>OS_InitArena()</CODE> for ARM7 sets up six of the nine arenas of <CODE>OS_InitArena()</CODE> for ARM9. The three exceptions are the arena on the ARM7-dedicated main memory, the arena on the ARM7 shared work RAM, and ARM7 dedicated work RAM arena.</P>
86<P>Calling <CODE>OS_InitArena()</CODE> from both processors sets each arena's upper and lower boundary as shown below:
87</P>
88<TABLE border="1">
89  <TBODY>
90    <TR>
91<TH bgcolor="#cccccc">Arena</TH>
92<TH bgcolor="#cccccc">Bottom</TH>
93<TH bgcolor="#cccccc">Top</TH>
94    </TR>
95    <TR>
96<TD>Arena in main memory (ARM9-dedicated)</TD>
97<TD><CODE>SDK_MAIN_ARENA_LO</CODE> (acquired from <CODE>lcf</CODE>)</TD>
98<TD><CODE>HW_MAIN_MEM_MAIN_END( 0x023e0000 )</CODE></TD>
99    </TR>
100    <TR>
101<TD>Arena in main memory (ARM7-dedicated)</TD>
102<TD><CODE>SDK_SUBPRIV_ARENA_LO</CODE> (acquired from <CODE>lcf</CODE>)</TD>
103<TD>Beginning of ARM7 dedicated main memory</TD>
104    </TR>
105    <TR>
106<TD>Main Memory Expanded Arena</TD>
107<TD>0 or <CODE>SDK_SECTION_ARENA_EX_START</CODE><BR>(Obtained from the .lcf file) (<B><FONT color="#ff0000">*1</FONT></B>)</TD>
108<TD>0 or<BR> Before the debugger region<BR> <B><FONT color="#ff0000">*1</FONT></B></TD>
109    </TR>
110    <TR>
111<TD>ITCM Arena</TD>
112<TD>SDK_SECTION_ARENA_ITCM_START<BR>(Obtained from the .lcf file)</TD>
113<TD>Highest order ITCM (0x02000000)</TD>
114    </TR>
115    <TR>
116<TD>Arena in DTCM</TD>
117<TD>SDK_SECTION_ARENA_DTCM_START<BR>(Obtained from the .lcf file) (<B><FONT color="#ff0000">*2</FONT></B>)</TD>
118<TD>Before system mode stack <B><FONT color="#ff0000">*2</FONT></B></TD>
119    </TR>
120    <TR>
121<TD>User information arena in shared memory</TD>
122<TD>Bottom of shared memory</TD>
123<TD>Before shared memory system region</TD>
124    </TR>
125    <TR>
126<TD>Arena for ARM9 in shared work RAM</TD>
127<TD>Bottom of shared work RAM (<B><FONT color="#ff0000">*3</FONT></B>)</TD>
128<TD>Bottom of shared work RAM (<B><FONT color="#ff0000">*3</FONT></B>)</TD>
129    </TR>
130    <TR>
131<TD>Arena for ARM7 in shared work RAM</TD>
132      <TD><B><FONT color="#ff0033">*4</FONT></B></TD>
133<TD>Top of Shared work RAM</TD>
134    </TR>
135    <TR>
136<TD>Work RAM Arena (ARM7-dedicated)</TD>
137      <TD><B><FONT color="#ff0033">*5</FONT></B></TD>
138<TD>Before system mode stack</TD>
139    </TR>
140  </TBODY>
141</TABLE>
142<P><BR> <B><FONT color="#ff0000">*1</FONT></B> Use <CODE><A href="OS_EnableMainExArena.html">OS_EnableMainEx()</A></CODE> to declare the main memory expanded arena; it cannot be used without declaring it. The upper and lower addresses of the main memory expanded arena are 0 when it cannot be used. Furthermore, there is no extended main memory in the the production version of the Nintendo DS system, so there will be no expanded arena in the main memory. Also in this case, the upper and lower addresses are 0.</P>
143<P><B><FONT color="#ff0000">*2</FONT></B> The region cannot be allocated for the DTCM arena when using the entire stack. When this happens, the upper and lower addresses of the DTCM arena have the same value. To allocate a region for the DTCM arena, you must prepare an empty region by adjusting the stack size in the <CODE>.lsf</CODE> file. (Refer to <A href="../../tools/makelcf.html"><CODE>tools/makelcf</CODE></A> and <A href="../../tools/makelcfTWL.html"><CODE>tools/makelcf.TWL</CODE></A> for more about <CODE>.lsf</CODE> and <CODE>.lcf</CODE> files.) The stack for system mode is described here, but normally this is the stack for the launcher thread.</P>
144<P><B><FONT color="#ff0000">*3</FONT></B> The top and bottom of the shared work RAM arena (for ARM9) have the same address. By default the size is 0.</P>
145<P><FONT color="#ff0033"><B>*4</B></FONT> This is the lower address of the final address of the ARM7 static module and the highest address of the shared work region. In other words, if the ARM7 static module fits in the shared work the empty region becomes the arena on the ARM7 shared work RAM. If it does not fit, both the start address and end address become the top address of the shared work and the size of the arena is 0.</P>
146<P><FONT color="#ff0033"><B>*5</B></FONT>&nbsp;This is the larger of either (1) the ending address of the ARM7 static module or (2) the lowest address of the ARM7-dedicated work RAM region. In other words, if the ARM7 static module will amount to the ARM7 dedicated work RAM, the empty region excluding this is the ARM7 dedicated work RAM arena. If the module is not that big and will not amount to the ARM7 dedicated work RAM, the arena is from the top of the ARM7 dedicated work RAM.</P>
147<P>For more details, see the <a href="about_arena.html">Arena Overview</a>.</P>
148<H2>See Also</H2>
149<P><CODE><A href="OS_SetArenaHi.html">OS_SetArenaHi</A><BR> <A href="OS_SetArenaLo.html">OS_SetArenaLo</A><BR> <A href="OS_GetArenaHi.html">OS_GetArenaHi</A><BR> <A href="OS_GetArenaLo.html">OS_GetArenaLo</A><BR> <A href="../../tools/makelcf.html">tools/makelcf</A><BR> <A href="about_arena.html">Arena Overview</A><BR></CODE></P>
150<H2>Revision History</H2>
151<P>2005/08/27 Changed the initial addresses of DTCM, ITCM and the main memory expanded arena.<BR>2004/11/02 Corrected error in number of initialized arenas.<BR>2004/10/26 Separated the graphical explanation of arenas. <BR>2004/10/01 Described by associating overlay.<BR>2004/09/29 Described the arena regions with charts.<BR>2004/05/28 Changed description of ARM7 arenas.<BR>2004/02/19 Changed the number of arenas from 6 to 9. Added support for both processors.<BR>2004/01/16 Added<CODE>MainEx</CODE>.<BR>2004/01/06 Initial version.</P>
152<hr><p>CONFIDENTIAL</p></body>
153</HTML>
154