define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / rom / exec / alert.c
blobb5592e52cae45b8a21d203718de79b94ed1b5d19
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Display an alert.
6 Lang: english
7 */
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <exec/alerts.h>
11 #include <proto/exec.h>
13 #ifdef kprintf
14 #undef kprintf
15 #endif
16 int kprintf(const UBYTE *, ...);
18 /*****************************************************************************
20 NAME */
22 AROS_LH1(void, Alert,
24 /* SYNOPSIS */
25 AROS_LHA(ULONG, alertNum, D7),
27 /* LOCATION */
28 struct ExecBase *, SysBase, 18, Exec)
30 /* FUNCTION
31 Alerts the user of a serious system problem.
33 INPUTS
34 alertNum - This is a number which contains information about
35 the reason for the call.
37 RESULT
38 This routine may return, if the alert is not a dead-end one.
40 NOTES
41 You should not call this routine because it halts the machine,
42 displays the message and then may reboot it.
44 EXAMPLE
45 // Dead-End alert: 680x0 Access To Odd Address
46 Alert (0x80000003);
48 BUGS
50 SEE ALSO
52 INTERNALS
54 ******************************************************************************/
56 AROS_LIBFUNC_INIT
57 static const char * CPUStrings[] =
59 "Hardware bus fault/access error",
60 "Illegal address access (ie: odd)",
61 "Illegal instruction",
62 "Divide by zero",
63 "Check instruction error",
64 "TrapV instruction error",
65 "Privilege violation error",
66 "Trace error",
67 "Line 1010 Emulator error",
68 "Line 1111 Emulator error",
69 "Stack frame format error",
70 "Spurious interrupt error",
71 "AutoVector Level 1 interrupt error",
72 "AutoVector Level 2 interrupt error",
73 "AutoVector Level 3 interrupt error",
74 "AutoVector Level 4 interrupt error",
75 "AutoVector Level 5 interrupt error",
76 "AutoVector Level 6 interrupt error",
77 "AutoVector Level 7 interrupt error",
79 * GenPurposeStrings[] =
81 "No memory",
82 "Make library",
83 "Open library",
84 "Open device",
85 "Open resource",
86 "I/O error",
87 "No signal",
88 "Bad parameter",
89 "Close library",
90 "Close device",
91 "Create process",
93 * AlertObjects[] =
95 "Exec",
96 "Graphics",
97 "Layers",
98 "Intuition",
100 "Math",
101 "DOS",
102 "RAM",
103 "Icon",
105 "Expansion",
106 "Diskfont",
107 "Utility",
108 "Keymap",
110 NULL,
111 NULL,
112 NULL,
113 NULL,
114 /* 0x10 */
115 "Audio",
116 "Console",
117 "Gameport",
118 "Keyboard",
120 "Trackdisk",
121 "Timer",
122 NULL,
123 NULL,
125 NULL,
126 NULL,
127 NULL,
128 NULL,
130 NULL,
131 NULL,
132 NULL,
133 NULL,
134 /* 0x20 */
135 "CIA",
136 "Disk",
137 "Misc",
138 NULL,
140 NULL,
141 NULL,
142 NULL,
143 NULL,
145 NULL,
146 NULL,
147 NULL,
148 NULL,
150 NULL,
151 NULL,
152 NULL,
153 NULL,
154 /* 0x30 */
155 "Bootstrap",
156 "Workbench",
157 "Diskcopy",
158 "Gadtools",
160 "Unknown",
162 * ExecStrings[] =
164 "68000 exception vector checksum",
165 "Execbase checksum",
166 "Library checksum failure",
167 NULL,
169 "Corrupt memory list detected in FreeMem",
170 "No memory for interrupt servers",
171 "InitStruct() of an APTR source",
172 "A semaphore is in an illegal state at ReleaseSemaphore",
174 "Freeing memory already freed",
175 "Illegal 68k exception taken",
176 "Attempt to reuse active IORequest",
177 "Sanity check on memory list failed",
179 "IO attempted on closed IORequest",
180 "Stack appears to extend out of range",
181 "Memory header not located. (Usually an invalid address passed to FreeMem())",
182 "An attempt was made to use the old message semaphores",
186 struct Task * task;
188 # define GetSubSysId(a) (((a) >> 24) & 0x7F)
189 # define GetGenError(a) (((a) >> 16) & 0xFF)
190 # define GetSpecError(a) ((a) & 0xFFFF)
192 task = FindTask (NULL);
194 /* since this is an emulation, we just show the bug in the console */
195 kprintf ( "GURU Meditation %04lx %04lx\n"
196 , alertNum >> 16
197 , alertNum & 0xFFFF
200 if (alertNum & 0x80000000)
201 kprintf ( "Deadend/" );
202 else
203 kprintf( "Recoverable/" );
205 switch (GetSubSysId (alertNum))
207 case 0: /* CPU/OS/App */
208 if (GetGenError (alertNum) == 0)
210 kprintf( "CPU/" );
212 if (GetSpecError (alertNum) >= 2 && GetSpecError (alertNum) <= 0x1F)
213 kprintf ("%s"
214 , CPUStrings[GetSpecError (alertNum) - 2]
216 else
217 kprintf ("*unknown*");
219 else if (GetGenError (alertNum) <= 0x0B)
221 kprintf ("%s/"
222 , GenPurposeStrings[GetGenError (alertNum) - 1]
225 if (GetSpecError (alertNum) >= 0x8001
226 && GetSpecError (alertNum) <= 0x8035)
228 kprintf ("%s"
229 , AlertObjects[GetSpecError (alertNum) - 0x8001]
232 else
233 kprintf ("*unknown*");
236 break;
238 case 1: /* Exec */
239 kprintf ("Exec/");
241 if (!GetGenError (alertNum)
242 && GetSpecError (alertNum) >= 0x0001
243 && GetSpecError (alertNum) <= 0x0010)
245 kprintf ("%s"
246 , ExecStrings[GetSpecError (alertNum) - 0x0001]
249 else
251 kprintf ("*unknown*");
254 break;
256 case 2: /* Graphics */
257 kprintf ("Graphics/*unknown*");
259 break;
261 default:
262 kprintf ("*unknown*/*unknown*");
265 kprintf ("\nTask: %p (%s)\n"
266 , task
267 , (task && task->tc_Node.ln_Name) ?
268 task->tc_Node.ln_Name
269 : "-- unknown task --"
272 if (alertNum & AT_DeadEnd)
274 /* Um, we have to do something here in order to prevent the
275 computer from continuing... */
276 ColdReboot();
278 AROS_LIBFUNC_EXIT
279 } /* Alert */