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>Context: Overview</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">Context: Overview <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1> 12<P>The <em>context</em> indicates the internal state of the system at a given time, or the data (structure) stored in that internal state. The context is normally mainly a collection of register values, but it can also contain other information. The TWL-SDK has a thread system that features operations to save, switch, and restore the context. Below is an explanation of the context information that the TWL-SDK will save.</P> 13<P>There are functions to initialize the context (<nobr><code><a href="OS_InitContext.html">OS_InitContext()</a></code></nobr>), save the existing context (<nobr><code><a href="OS_SaveContext.html">OS_SaveContext()</a></code></nobr>), load the context (<nobr><code><a href="OS_LoadContext.html">OS_LoadContext()</a></code></nobr>), and a function for debugging (<nobr><code><a href="OS_DumpContext.html">OS_DumpContext()</a></code></nobr>). But because the thread system handles these functions, the user seldom calls them directly.</P> 14<H2>Context Information</H2> 15<BLOCKQUOTE>The context structure <code>OSContext</code> is defined in the example below: <BR> 16</BLOCKQUOTE> 17<BLOCKQUOTE> 18<TABLE border="1"> 19 <TBODY> 20 <TR> 21 <TD width="503"> 22<PRE> 23typedef struct OSContext<BR> 24{<BR> u32 cpsr;<BR> u32 r[13];<BR> u32 sp;<BR> u32 lr;<BR> u32 pc_plus4;<BR> 25#ifdef SDK_CONTEXT_HAS_SP_SVC<BR> u32 sp_svc;<BR> 26#endif<BR> 27#ifdef SDK_ARM9<BR> CPContext cp_context;<BR> 28#endif<BR> 29} OSContext; 30</PRE> 31</TD> 32 </TR> 33 </TBODY> 34</TABLE> 35<BR> <BR> <B>cpsr</B> The Current Program Status Register (CPSR). This is a region that stores the register containing the status of flags and interrupt states.</BLOCKQUOTE> 36<BLOCKQUOTE><B>r[13]</B> The region for storing general-use registers R0 to R12.</BLOCKQUOTE> 37<BLOCKQUOTE><B>sp</B> The region for storing the stack pointer (R13)</BLOCKQUOTE> 38<BLOCKQUOTE><B>lr</B> The region for storing the link register (R14)</BLOCKQUOTE> 39<BLOCKQUOTE><B>pc_plus4</B> The region for storing the value of the program counter (PC) To execute from the next command when the context is reset, the PC value is incremented by 4 and stored here.</BLOCKQUOTE> 40<BLOCKQUOTE><B>sp_svc</B> Can be included or excluded according to the definitions during compilation. The value for the stack pointer for SVC (supervisor call) mode is entered here.</BLOCKQUOTE> 41<BLOCKQUOTE><B>cp_context</B> The status of the arithmetic coprocessor Includes the states of the divider and the square rooter. The arithmetic unit is designed to move to the appropriate state even if the context is switched. Since the ARM7 has neither a divider nor a square rooter, this member of the context structure only exists for the ARM9. It is defined as follows:<BR> 42<BLOCKQUOTE> 43<TABLE border="1"> 44 <TBODY> 45 <TR> 46 <TD> 47<PRE> 48typedef struct CPContext 49{ 50 u64 div_numer; 51 u64 div_denom; 52 u64 sqrt; 53 u16 div_mode; 54 u16 sqrt_mode; 55} CPContext; 56</PRE> 57</TD> 58 </TR> 59 </TBODY> 60</TABLE> 61</BLOCKQUOTE> 62</BLOCKQUOTE> 63<H2>See Also</H2> 64<P><CODE><A href="../list_os.html#Context">List of OS Functions (Context)</A><BR></CODE></P> 65<H2>Revision History</H2> 66<P>2004/12/13 Corrected typos.<br /> 2004/11/05 Initial version.</P> 67<hr><p>CONFIDENTIAL</p></body> 68</HTML>