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_SetUserExceptionHandler</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">OS_SetUserExceptionHandler <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_SetUserExceptionHandler(
17             OSExceptionHandler  handler
18             void*               arg );
19  </CODE></PRE>
20</DL>
21<H2>Arguments</H2>
22<TABLE border="1" width="100%">
23  <TBODY>
24    <TR>
25<TD width="13%"><SPAN class="argument">handler</SPAN></TD>
26<TD width="87%">Function to be called when an exception is generated</TD>
27    </TR>
28    <TR>
29<TD width="13%"><SPAN class="argument">arg</SPAN></TD>
30<TD width="87%">Argument used when calling the user function</TD>
31    </TR>
32  </TBODY>
33</TABLE>
34<H2>Return Values</H2>
35<P>None.</P>
36<H2>Description</H2>
37<P>Sets the user function that will be called when an exception is generated.</P>
38<P>The user function <code>handler</code> is of the type <CODE>OSExceptionHandler</CODE>.</P>
39<BLOCKQUOTE><CODE> typedef void (*OSExceptionHandler)( u32, void* );</CODE></BLOCKQUOTE>
40<P> This function is called when interrupts are prohibited.</P>
41<P>When calling the user function, the first argument is a pointer address to the structure the stores the generated exception's context. The second argument, <SPAN class="argument">arg</SPAN>, is specified by the second argument of <A href="OS_SetUserExceptionHandler.html"><CODE>OS_SetUserExceptionHandler</CODE></A>, which is passed unchanged.</P>
42<P><B>Contexts During Exceptions:</B></P>
43<P>The context of the function specified in the first argument is a pointer to a structure of type <CODE>OSExcpContext</CODE>.</P>
44<BLOCKQUOTE style="background-color:#ffffc0;"><br>
45<PRE>
46 typedef struct
47 {
48   OSContext context;
49   u32 cp15;
50   u32 spsr;
51   u32 exinfo;
52 } OSExcpContext;</PRE><BR>
53</BLOCKQUOTE>
54<BR>
55<P>
56<ul><li><CODE>context</CODE> represents the values in a <CODE>OSContext</CODE>-type structure.</li>
57<li><CODE>cp15</CODE> is the status of the coprocessor.</li>
58<li><CODE>spsr</CODE> is the SPSR. It will be undefined in modes that do not have SPSR.</li>
59<li><CODE>exinfo</CODE> indicates whether it is a reset or an exception. In the case of an exception, it will hold 0. In the case of a reset, it will hold a nonzero value.</li>
60</ul>
61</P>
62<P><B>Exceptions with IS-TWL-DEBUGGER</B></P>
63<P>As described in <A href="about_exception.html">Overview (Exceptions)</A>, <FONT color="#ff0000"><B>you cannot call a user exception handler on IS-TWL-DEBUGGER. This cannot be done on IS-TWL-DEBUGGER, regardless of whether the application is running in TWL mode or NITRO mode.</B></FONT>The debugger will stop the CPU at the point when an exception occurs, so you can find out information based on the context information displayed in the debugger or the <B>Call Stack</B> window in the debugger.</P>
64<H2>See Also</H2>
65<P><A href="about_exception.html">Overview (Exceptions)</A><BR>
66 <A href="OS_InitException.html"><CODE>OS_InitException</CODE></A><BR>
67 <A href="../context/OS_InitContext.html"><CODE>OS_InitContext</CODE></A></P>
68<H2>Revision History</H2>
69<P>2009/07/01 Revised debugger display on IS-TWL-DEBUGGER.<BR>
70 2008/04/18 Added a description of the context during an exception.<BR>
71 2005/03/08 Standardized how the term &quot;interrupt&quot; is written in Japanese.<BR>
72 2004/02/19 Initial value.</P>
73<hr><p>CONFIDENTIAL</p></body>
74</HTML>