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>Exceptions: Overview</TITLE><LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 8</HEAD> 9<BODY> 10<H1 align="left">Exceptions: Overview <img src="../../image/NTR.gif" align="middle"><img src="../../image/TWL.gif" align="middle"></H1> 11<P>This page explains the exception display system used by the TWL-SDK to show information about exceptions generated on the ARM processors.</P> 12<H2>Exception Types</H2> 13<P>The following exceptions exist for the ARM processors:<BR> 14</P> 15<TABLE border="1"> 16 <TBODY> 17 <TR bgcolor="red"> 18 <TH>Exception Type</TH> 19 <TH>Normal Vector Address</TH> 20 <TH>High Vector Address</TH> 21 </TR> 22 <TR> 23 <TD>Reset</TD> 24 <TD>0x00000000</TD> 25 <TD>0xFFFF0000</TD> 26 </TR> 27 <TR> 28 <TD>Undefined instruction</TD> 29 <TD>0x00000004</TD> 30 <TD>0xFFFF0004</TD> 31 </TR> 32 <TR> 33 <TD>Software interrupt</TD> 34 <TD>0x00000008</TD> 35 <TD>0xFFFF0008</TD> 36 </TR> 37 <TR> 38 <TD>Pre-fetch abort</TD> 39 <TD>0x0000000C</TD> 40 <TD>0xFFFF000C</TD> 41 </TR> 42 <TR> 43 <TD>Data abort</TD> 44 <TD>0x00000010</TD> 45 <TD>0xFFFF0010</TD> 46 </TR> 47 <TR> 48 <TD>IRQ</TD> 49 <TD>0x00000018</TD> 50 <TD>0xFFFF0018</TD> 51 </TR> 52 <TR> 53 <TD>FIQ</TD> 54 <TD>0x0000001C</TD> 55 <TD>0xFFFF001C</TD> 56 </TR> 57 </TBODY> 58</TABLE> 59<P><BR> Out of this list, the <I>reset interrupt</I> and <I>FIQ</I> exceptions are used by the system or debugger, so they cannot be used by users.</P> 60<P>The <I>IRQ</I> exception can be used as an interrupt. See the following for information about interrupts.→ <A href="../irq/about_irq.html">Interrupts (Overview)</A></P> 61<P>Some of the undefined instructions are used by the debugger for breakpoints and other such data.</P> 62<P>When an exception occurs, control is transferred to the pertinent vector address, as shown in the table above. This normally involves use of high vector addresses.</P> 63<H2>Positioning the Exception Vector</H2> 64<P>The ARM processor specifications allow you to set the exception vector addresses at either the range <CODE>0x00000000</CODE> to <CODE>0x0000001C</CODE> or the range <CODE>0xFFFF0000</CODE> to <CODE>0xFFFF001C</CODE>. The former are called normal vectors, and the latter are called high vectors.</P> 65<P>The <a href="OS_SetExceptionVectorLower.html"><nobr><code>OS_SetExceptionVectorLower</code></nobr></a> function sets the exception vectors to addresses <code>0x0000000</code> to <code>0x0000001C</code> (normal vectors).</P> 66<P>The <a href="OS_SetExceptionVectorUpper.html"><nobr><code>OS_SetExceptionVectorUpper</code></nobr></a> function sets the exception vectors to addresses <code>0xFFFF0000</code> to <code>0xFFFF001C</code> (high vectors).</P> 67<P>The TWL-SDK uses the high vectors by default.<FONT color="#ff0033"> Unless you have a special reason, use the high vectors and do not change this setting.</FONT></P> 68<H2>Displaying Contexts During Exceptions</H2> 69<P>The TWL-SDK contains a mechanism for displaying the context (the contents of the registers and the CPU status) to the debug window (console) when an exception occurs. This exception display mechanism is initialized using the <A href="OS_InitException.html"><CODE>OS_InitException</CODE></A> function, but this function is called from the <A href="../init/OS_Init.html"><CODE>OS_Init</CODE></A> function, so no real preparation is required in applications that use the <A href="../init/OS_Init.html"><CODE>OS_Init</CODE></A> function.</P> 70<P>The example below shows what is displayed. The error output from the <A href="../debug/OS_FPrintf.html"><CODE>OS_FPrintf</CODE></A> function is used to display the information.</P> 71<BLOCKQUOTE style="background-color:#ffffc0;"><BR> <CODE> **** Exception Occurred ****<BR> R00=00000000 R01=12345678 R02=2000001F R03=02030340 <BR> R04=200000D7 R05=0000000F R06=00000001 R07=00000002 <BR> R08=02FFFFA8 R09=04000130 R10=00000001 R11=0201C25C <BR> R12=0200E240 SP =02FE3750 LR =02005130 PC =02005140<BR> CPSR=2000001F SPSR=00000000 CP15=0005707D</CODE><BR> <BR> 72</BLOCKQUOTE> 73<H2>Setting a User Handler</H2> 74<P>When exceptions occur, control can be transferred to a user-specified exception handler. To do this, register the handler with the <a href="OS_SetUserExceptionHandler.html" target="_self"><nobr><code>OS_SetUserExceptionHandler</code></nobr></a> function. For details, see the function reference.</P> 75<H2>Environments in Which Displaying Contexts During Exceptions and Calling Users' Exception Handlers Is Possible</H2> 76<P>The table below indicates whether the context can be displayed to the debug window (console) when an exception occurs and whether control can be moved to the user's exception handler. The table is broken down by operating environment. One caveat is that with FINALROM builds the <A href="../debug/OS_FPrintf.html"><CODE>OS_FPrintf</CODE></A> function cannot be used, so the context information cannot be displayed during an exception, regardless of the operating environment. This will hold true even if a given cell is marked as "<B><FONT color="#ff0000">OK</FONT></B>." Calls to user-defined exception handlers do not depend on the build type.</P> 77<P>Note that this table is divided by the operating environment. For example, the context cannot be displayed on IS-TWL-DEBUGGER when an exception occurs with a HYBRID ROM that is running in NITRO mode, but it can be displayed on IS-NITRO-DEBUGGER if the same ROM is running in the same mode.</P> 78<TABLE border="1"> 79 <TBODY> 80 <TR> 81 <TH colspan="3" style="background-color:#304040;"><FONT color="#ffffff">For NITRO Mode:</FONT> <img src="../../image/NTR.gif" align="middle"></TH> 82 </TR> 83 <TR> 84 <TH>Operating Environment</TH> 85 <TH>Displaying Contexts<BR>During Exceptions:</TH> 86 <TH>Calling Users'<BR>Exception Handlers:</TH> 87 </TR> 88 <TR> 89 <TD>Actual DS unit</TD> 90 <TD><B>N/A</B> (There is no console)</TD> 91 <TD><FONT color="#ff0000"><B>OK</B></FONT></TD> 92 </TR> 93 <TR> 94 <TD>Actual TWL unit</TD> 95 <TD><B>N/A</B> (There is no console)</TD> 96 <TD><FONT color="#ff0000"><B>OK</B></FONT></TD> 97 </TR> 98 <TR> 99 <TD>IS-NITRO-DEBUGGER</TD> 100 <TD><FONT color="#ff0000"><B>OK</B></FONT></TD> 101 <TD><FONT color="#ff0000"><B>OK</B></FONT></TD> 102 </TR> 103 <TR> 104 <TD>ENSATA EMULATOR</TD> 105 <TD>???</TD> 106 <TD>???</TD> 107 </TR> 108 <TR> 109 <TD>IS-TWL-DEBUGGER(For standard development: ARM9) </TD> 110 <TD><B>N/A</B></TD> 111 <TD><B>N/A</B></TD> 112 </TR> 113 <TR> 114 <TD>IS-TWL-DEBUGGER (For component development: ARM9 + ARM7)</TD> 115 <TD><B>N/A</B></TD> 116 <TD><B>N/A</B></TD> 117 </TR> 118 <TR> 119 <TH colspan="3" style="background-color:#304040;"><FONT color="#ffffff">For TWL Mode:</FONT> <img src="../../image/TWL.gif" align="middle"></TH> 120 </TR> 121 <TR> 122 <TH>Operating Environment</TH> 123 <TH>Displaying Contexts<BR>During Exceptions:</TH> 124 <TH>Calling Users'<BR>Exception Handlers:</TH> 125 </TR> 126 <TR> 127 <TD>Actual TWL unit</TD> 128 <TD><B>N/A</B> (There is no console)</TD> 129 <TD><FONT color="#ff0000"><B>OK</B></FONT></TD> 130 </TR> 131 <TR> 132 <TD>IS-TWL-DEBUGGER (For standard development: ARM9)</TD> 133 <TD><B>N/A</B></TD> 134 <TD><B>N/A</B></TD> 135 </TR> 136 <TR> 137 <TD>IS-TWL-DEBUGGER (For component development: ARM9 + ARM7)</TD> 138 <TD><B>N/A</B></TD> 139 <TD><B>N/A</B></TD> 140 </TR> 141 </TBODY> 142</TABLE> 143<P><BR> 144</P> 145<H2>Process Flow When Exceptions Occur</H2> 146<P>When an interrupt occurs, control will jump to the exception vector region. As previously mentioned, the high vectors are usually used for exception vectors, but for a data abort exception, control will move to <CODE>0xFFFFFF10</CODE>.</P> 147<P>Control then moves to the address stored in <CODE>HW_EXCP_VECTOR_MAIN </CODE> (<CODE>0x2FFFFD9C</CODE>) in the system area. (In the ARM7, this address is located at the dedicated work RAM offset <CODE>0x7FDC</CODE>.) The address of the TWL-SDK's exception handler is set here.</P> 148<P>The TWL-SDK's exception handler will display the context when an exception occurs, and then call the user-defined handler registered with the <A href="OS_SetUserExceptionHandler.html"><CODE>OS_SetUserExceptionHandler</CODE></A> function, if such a handler exists.</P> 149<P>The program then stops.</P> 150<BLOCKQUOTE><BR> <IMG src="image_exception_flow.gif" border="0"></BLOCKQUOTE> 151<H2>See Also</H2> 152<P><A href="../list_os.html#Exception">List of OS Functions (Exception)</A></P> 153<H2>Revision History</H2> 154<P>2008/04/18 Added a table of context display environments when exceptions occur. <BR>2005/03/08 Standardized the Japanese term for "interrupt."<BR>2004/12/14 Revised terminology and word endings. <br>2004/11/16 Initial version.</P> 155<hr><p>CONFIDENTIAL</p></body> 156</HTML>