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_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%"><CODE>handler</CODE></TD>
26<TD width="87%">Function to be called when an exception is generated</TD>
27    </TR>
28    <TR>
29<TD width="13%"><CODE>arg</CODE></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, <CODE>arg</CODE>, is specified by the second argument of <A href="OS_SetUserExceptionHandler.html"><CODE>OS_SetUserExceptionHandler</CODE></A>, which is passed unchanged.</P>
42<P><BR>
43<BR>
44<B>Contexts During Exceptions:</B></P>
45<P>The context of the function specified in the first argument is a pointer to a structure of type <CODE>OSExcpContext</CODE>.</P>
46<BLOCKQUOTE style="background-color:#ffffc0;">
47<PRE>
48typedef struct
49{
50  OSContext context;
51  u32 cp15;
52  u32 spsr;
53  u32 exinfo;
54} OSExcpContext;</PRE>
55
56</BLOCKQUOTE>
57<P>
58<ul><li>Here, <CODE>context</CODE> represents the values in a <CODE>OSContext</CODE>-type structure.<BR></li>
59<li><CODE>cp15</CODE> is the status of the coprocessor.</li>
60<li><CODE>spsr</CODE> is the SPSR. It will be undefined in modes that don't have SPSR.</li>
61<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></ul>
62</P>
63<P><BR>
64<BR>
65<B>Exceptions with IS-TWL-DEBUGGER</B></P>
66<P>As described in <A href="about_exception.html">Overview (Exceptions)</A>, <FONT color="#ff0000"><B>it is not possible to display exception contexts or call users' exception handlers using 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 this information based on the information in the <B>Register</B> or <B>Call Stack</B> windows in the debugger.</P>
67<H2>See Also</H2>
68<P><A href="about_exception.html">Overview (Exceptions)</A><BR>
69<A href="OS_InitException.html"><CODE>OS_InitException</CODE></A><BR>
70<A href="../context/OS_InitContext.html"><CODE>OS_InitContext</CODE></A></P>
71<H2>Revision History</H2>
72<P>2008/04/18 Added a description of the context during an exception.<BR>
732005/03/08 Standardized how the term &quot;interrupt&quot; is written in Japanese.<BR>
742004/02/19 Initial value.</P>
75<hr><p>CONFIDENTIAL</p></body>
76</HTML>