1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin OS Error Handler API
3   File:     OSError.h
4 
5   Copyright 1998, 1999 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: OSError.h,v $
14   Revision 1.2  2006/02/04 11:56:47  hashida
15   (none)
16 
17   Revision 1.1.1.1  2005/12/29 06:53:28  hiratsu
18   Initial import.
19 
20   Revision 1.1.1.1  2005/05/12 02:41:07  yasuh-to
21   Ported from dolphin source tree.
22 
23 
24     4     2002/08/26 22:17 Shiki
25     Added __OSFpscrEnableBits.
26 
27     3     2002/08/19 21:42 Shiki
28     Added OS_ERROR_FPE.
29 
30     2     2001/08/15 17:55 Shiki
31     Added OS_ERROR_PROTECTION.
32 
33     4     1999/10/08 1:46p Shiki
34     Fixed OSSetErrorHandler() parameter declaration.
35 
36     3     1999/08/03 3:54p Shiki
37     Revised OSErrorHandler() declaration.
38 
39     2     1999/07/13 6:09p Shiki
40     Fixed OSSetErrorHandler() declaration.
41 
42     1     1999/07/12 9:34p Shiki
43     Initial check-in
44 
45   $NoKeywords: $
46  *---------------------------------------------------------------------------*/
47 
48 #ifndef __OSERROR_H__
49 #define __OSERROR_H__
50 
51 #include <revolution/os.h>
52 #include <revolution/os/OSContext.h>
53 #include <revolution/os/OSException.h>
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /*---------------------------------------------------------------------------*
60     Error Handler API
61  *---------------------------------------------------------------------------*/
62 
63 typedef u16    OSError;
64 
65 typedef void (*OSErrorHandler)( OSError error, OSContext* context, ... );
66 /*
67  * Note: for most errors, OSErrorHandler takes third and fourth arguments
68  * /dsisr/ and /dar/, which are of type /u32/ like below:
69  *
70  * void (*OSErrorHandler)( OSError error, OSContext* context,
71  *                         u32 dsisr, u32 dar );
72  *
73  */
74 
75 #define OS_ERROR_SYSTEM_RESET         0
76 #define OS_ERROR_MACHINE_CHECK        1
77 #define OS_ERROR_DSI                  2
78 #define OS_ERROR_ISI                  3
79 #define OS_ERROR_EXTERNAL_INTERRUPT   4
80 #define OS_ERROR_ALIGNMENT            5
81 #define OS_ERROR_PROGRAM              6
82 #define OS_ERROR_FLOATING_POINT       7     // Floating-point unavailable
83 #define OS_ERROR_DECREMENTER          8
84 #define OS_ERROR_SYSTEM_CALL          9
85 #define OS_ERROR_TRACE                10
86 #define OS_ERROR_PERFORMACE_MONITOR   11
87 #define OS_ERROR_BREAKPOINT           12
88 #define OS_ERROR_SYSTEM_INTERRUPT     13
89 #define OS_ERROR_THERMAL_INTERRUPT    14
90 #define OS_ERROR_PROTECTION           15
91 #define OS_ERROR_FPE                  16    // Floating-point exception
92 
93 #define OS_ERROR_MAX                  (OS_ERROR_FPE+1)
94 
95 OSErrorHandler OSSetErrorHandler( OSError error, OSErrorHandler handler );
96 
97 // Default FPSCR enable bits set when OS_ERROR_FPE handler is set
98 extern u32 __OSFpscrEnableBits;     // OR-ed FPSCR_*E bits
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif  // __OSERROR_H__
105