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 <nitro/os.h></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>Sets the upper and lower boundaries.</P> 25<P>This function only needs to be called once before the <CODE>Alloc</CODE> functions or other <CODE>Arena</CODE> functions. This function is called internally by the <A href="../init/OS_Init.html"><CODE>OS_Init</CODE></A> function, so there is normally no need for the application to call it again. Subsequent calls of this function do nothing.</P> 26<P>It is possible to change the arena boundaries with <A href="OS_SetArenaLo.html"><code>OS_SetArenaLo</code></A> and <A href="OS_SetArenaHi.html"><code>OS_SetArenaHi</code></A> after calling <code>OS_InitArena</code>.</P> 27<P>The TWL-SDK allows you to define nine different arenas: main memory (one for ARM9 and one for ARM7), extended main memory, ITCM, DTCM, shared memory for the SDK, 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>ARM9-dedicated main memory for the game program</TD> 39<TD>From ARM9</TD> 40 </TR> 41 <TR> 42<TD>OS_ARENA_MAIN_SUBPRIV</TD> 43<TD>ARM7-dedicated main memory</TD> 44<TD>From ARM7</TD> 45 </TR> 46 <TR> 47<TD>OS_ARENA_MAINEX</TD> 48<TD>Extended main memory for development debugging only</TD> 49<TD>From ARM9</TD> 50 </TR> 51 <TR> 52<TD>OS_ARENA_ITCM</TD> 53<TD>ITCM</TD> 54<TD>From ARM9</TD> 55 </TR> 56 <TR> 57<TD>OS_ARENA_DTCM</TD> 58<TD>DTCM</TD> 59<TD>From ARM9</TD> 60 </TR> 61 <TR> 62<TD>OS_ARENA_SHARED</TD> 63<TD>Shared memory for the SDK</TD> 64<TD>From ARM9</TD> 65 </TR> 66 <TR> 67 68<TD>OS_ARENA_WRAM_MAIN</TD> 69<TD>ARM9-shared Work RAM</TD> 70<TD>From ARM9</TD> 71 </TR> 72 <TR> 73<TD>OS_ARENA_WRAM_SUB</TD> 74<TD>ARM7-shared Work RAM</TD> 75<TD>From ARM7</TD> 76 </TR> 77 <TR> 78<TD>OS_ARENA_WRAM_SUBPRIV</TD> 79<TD>ARM7-dedicated Work RAM</TD> 80<TD>From ARM7</TD> 81 </TR> 82 </TBODY> 83</TABLE> 84<P> </P> 85<P>Of the nine arenas, <CODE>OS_InitArena</CODE> for ARM7 sets up six the same as <CODE>OS_InitArena</CODE> for ARM9. The three exceptions are ARM7-dedicated main memory, ARM7-dedicated Work RAM, and ARM7-shared Work RAM.</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>ARM9-dedicated main memory</TD> 97<TD><CODE>SDK_MAIN_ARENA_LO</CODE> (obtained from the LCF file)</TD> 98<TD><CODE>HW_MAIN_MEM_MAIN_END( 0x023e0000 )</CODE></TD> 99 </TR> 100 <TR> 101<TD>ARM7-dedicated main memory</TD> 102<TD><CODE>SDK_SUBPRIV_ARENA_LO</CODE> (obtained from the LCF file)</TD> 103<TD>Beginning of ARM7-dedicated main memory</TD> 104 </TR> 105 <TR> 106<TD>Extended main memory</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</TD> 112<TD><CODE>SDK_SECTION_ARENA_ITCM_START</CODE><BR>(obtained from the LCF file)</TD> 113<TD>Highest order ITCM (<CODE>0x02000000</CODE>)</TD> 114 </TR> 115 <TR> 116<TD>DTCM</TD> 117<TD><CODE>SDK_SECTION_ARENA_DTCM_START</CODE><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>Shared memory for the SDK</TD> 122<TD>Bottom of shared memory</TD> 123<TD>Before shared memory region</TD> 124 </TR> 125 <TR> 126<TD>ARM9-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>ARM7-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>ARM7-dedicated Work RAM</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> To use the extended main memory arena, you must declare it with the <CODE><A href="OS_EnableMainExArena.html">OS_EnableMainExArena</A></CODE> function. The upper and lower addresses of the extended main memory arena are 0 when it cannot be used. The commercial version of the Nintendo DS system has no extended main memory, so the extended main memory arena cannot be used for it. 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 if the stack is full. 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 LSF file. (See <A href="../../tools/makelcf.html"><CODE>tools/makelcf</CODE></A> and <A href="../../tools/makelcf.html"><CODE>tools/makelcf.TWL</CODE></A> for more about LSF and LCF 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 shared Work, the empty region becomes the ARM7-shared Work RAM arena. If it does not fit, both the start address and end address become the top address of shared Work, and the size of the arena is 0.</P> 146<P><FONT color="#ff0033"><B>*5</B></FONT> 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><A href="OS_SetArenaHi.html"><CODE>OS_SetArenaHi</CODE></A><BR> <A href="OS_SetArenaLo.html"><CODE>OS_SetArenaLo</CODE></A><BR> <A href="OS_GetArenaHi.html"><CODE>OS_GetArenaHi</CODE></A><BR> <A href="OS_GetArenaLo.html"><CODE>OS_GetArenaLo</CODE></A><BR> <A href="../../tools/makelcf.html"><CODE>tools/makelcf</CODE></A><BR> <A href="about_arena.html">Arena Overview</A></P> 150<H2>Revision History</H2> 151<P>2009/05/19 Revised description related to <CODE>OS_Init</CODE> in <B>Description</B>.<BR> 2005/08/27 Changed the initial addresses of DTCM, ITCM, and the main memory expanded arena.<BR> 2004/10/26 Corrected error in number of initialized arenas.<BR> 2004/10/01 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