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.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<TITLE>OS_InitContext</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">OS_InitContext <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;
16
17void OS_InitContext( OSContext* context,
18                     u32         newpc,
19u32         newsp );</CODE></PRE>
20</DL>
21<H2>Arguments</H2>
22<TABLE border="1" width="100%">
23  <TBODY>
24    <TR>
25<TD width="13%"><CODE>context</CODE></TD>
26<TD width="87%">Context</TD>
27    </TR>
28    <TR>
29<TD width="13%"><code>newpc</code></TD>
30<TD width="87%">Start address</TD>
31    </TR>
32    <TR>
33<TD width="13%"><CODE>newsp</CODE></TD>
34<TD width="87%">Stack</TD>
35    </TR>
36  </TBODY>
37</TABLE>
38<H2>Return Values</H2>
39<P>None.</P>
40<H2>Description</H2>
41<P>Initializes context.</P>
42<P>The context structure <code>OSContext</code> has the following members:</P>
43<TABLE border="1">
44  <TBODY>
45    <TR>
46<TD bgcolor="#ffeeee"><CODE>u32 cpsr</CODE></TD>
47<TD bgcolor="#ffeeee">CPSR (Current Program Status Register)</TD>
48    </TR>
49    <TR>
50<TD bgcolor="#ffeeee"><CODE>u32 r[13]</CODE></TD>
51<TD bgcolor="#ffeeee">Registers R0-R12</TD>
52    </TR>
53    <TR>
54<TD bgcolor="#ffeeee"><CODE>u32 sp</CODE></TD>
55<TD bgcolor="#ffeeee">Stack pointer (R13 register)</TD>
56    </TR>
57    <TR>
58<TD bgcolor="#ffeeee"><CODE>u32 lr</CODE></TD>
59<TD bgcolor="#ffeeee">Link register (R14 register)</TD>
60    </TR>
61    <TR>
62<TD bgcolor="#ffeeee"><CODE>u32 pc_plus4</CODE></TD>
63<TD bgcolor="#ffeeee">Program counter + 4 (R15 register+4)</TD>
64    </TR>
65    <TR>
66<TD bgcolor="#ffeeee"><CODE>u32 sp_svc</CODE></TD>
67<TD bgcolor="#ffeeee">Used to save to stack in Supervisor mode (see note 1)</TD>
68    </TR>
69    <TR>
70<TD><CODE>CPContext cp_context</CODE></TD>
71<TD>Context for the divider / square root calculator (see note 2)</TD>
72    </TR>
73  </TBODY>
74</TABLE>
75<P><B>Note 1:</B> May not exist according to compile options. <B>Note 2:</B> Exists only in ARM9.</P>
76<P>With the <CODE>OS_InitContext</CODE> function, the stack for SVC is allocated downward from <CODE>newsp</CODE>. (Depending on the compile option, this process may not occur.) <CODE>cpsr</CODE> is set appropriately by checking the processor mode (distinguishing ARM and THUMB) from the CPSR register. <CODE>r[0]</CODE> &ndash; <CODE>r[12]</CODE> (registers R0-R12) and <CODE>lr</CODE> (register R14) are zero-cleared. <CODE>pc_plus4</CODE> takes a value 4 more than the specified value of <CODE>newpc</CODE>.</P>
77<P><code>cp_context</code> exists only in ARM9 as a member of the <CODE>CPContext</CODE> structure and is the context for the divider/square root calculator. CPContext structure contains the following members.</P>
78<TABLE border="1">
79  <TBODY>
80    <TR>
81<TD><CODE>u64 div_numer</CODE></TD>
82<TD>Parameter of the divider (divisor)</TD>
83    </TR>
84    <TR>
85<TD><CODE>u64 div_denom</CODE></TD>
86<TD>Parameter for the divider (dividend)</TD>
87    </TR>
88    <TR>
89<TD><CODE>u64 sqrt</CODE></TD>
90<TD>Parameter for the square root calculator</TD>
91    </TR>
92    <TR>
93<TD><CODE>u16 div_mode</CODE></TD>
94<TD>Divider mode</TD>
95    </TR>
96    <TR>
97<TD><CODE>u16 sqrt_mode</CODE></TD>
98<TD>Square root calculator mode</TD>
99    </TR>
100  </TBODY>
101</TABLE>
102<P> The <CODE>OS_InitContext</CODE> function does not change the content of <CODE>cp_context</CODE>.</P>
103<H2>See Also</H2>
104<P><A href="OS_SaveContext.html"><CODE>OS_SaveContext</CODE></A><BR> <A href="OS_LoadContext.html"><CODE>OS_LoadContext</CODE></A><BR> <A href="OS_DumpContext.html"><CODE>OS_DumpContext</CODE></A></P>
105<H2>Revision History</H2>
106<P>2004/06/30 Described <CODE>cp_context</CODE>.<BR>2003/12/01 Initial version.</P>
107<hr><p>CONFIDENTIAL</p></body>
108</HTML>