added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / all-unix / exec / alert.c
blobef20a1680e32535a06084b866f8dcc34d59f3307
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 <stdio.h>
11 #include <stdlib.h>
12 #include <exec/alerts.h>
13 #include <proto/exec.h>
15 /*****************************************************************************
17 NAME */
19 AROS_LH1(void, Alert,
21 /* SYNOPSIS */
22 AROS_LHA(ULONG, alertNum, D7),
24 /* LOCATION */
25 struct ExecBase *, SysBase, 18, Exec)
27 /* FUNCTION
28 Alerts the user of a serious system problem.
30 INPUTS
31 alertNum - This is a number which contains information about
32 the reason for the call.
34 RESULT
35 This routine may return, if the alert is not a dead-end one.
37 NOTES
38 You should not call this routine because it halts the machine,
39 displays the message and then may reboot it.
41 EXAMPLE
42 // Dead-End alert: 680x0 Access To Odd Address
43 Alert (0x80000003);
45 BUGS
47 SEE ALSO
49 INTERNALS
51 HISTORY
52 26-08-95 digulla created after EXEC-Routine
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 fprintf (stderr
196 , "\x07" "GURU Meditation %04lx %04lx\n"
197 , alertNum >> 16
198 , alertNum & 0xFFFF
201 if (alertNum & 0x80000000)
202 fprintf (stderr
203 , "Deadend/"
205 else
206 fprintf (stderr
207 , "Recoverable/"
210 switch (GetSubSysId (alertNum))
212 case 0: /* CPU/OS/App */
213 if (GetGenError (alertNum) == 0)
215 fprintf (stderr
216 , "CPU/"
219 if (GetSpecError (alertNum) >= 2 && GetSpecError (alertNum) <= 0x1F)
220 fprintf (stderr
221 , "%s"
222 , CPUStrings[GetSpecError (alertNum) - 2]
224 else
225 fprintf (stderr
226 , "*unknown*"
229 else if (GetGenError (alertNum) <= 0x0B)
231 fprintf (stderr
232 , "%s/"
233 , GenPurposeStrings[GetGenError (alertNum) - 1]
236 if (GetSpecError (alertNum) >= 0x8001
237 && GetSpecError (alertNum) <= 0x8035)
239 fprintf (stderr
240 , "%s"
241 , AlertObjects[GetSpecError (alertNum) - 0x8001]
244 else
245 fprintf (stderr
246 , "*unknown*"
250 break;
252 case 1: /* Exec */
253 fprintf (stderr
254 , "Exec/"
257 if (!GetGenError (alertNum)
258 && GetSpecError (alertNum) >= 0x0001
259 && GetSpecError (alertNum) <= 0x0010)
261 fprintf (stderr
262 , "%s"
263 , ExecStrings[GetSpecError (alertNum) - 0x0001]
266 else
268 fprintf (stderr
269 , "*unknown*"
273 break;
275 case 2: /* Graphics */
276 fprintf (stderr
277 , "Graphics/*unknown*"
280 break;
282 default:
283 fprintf (stderr
284 , "*unknown*/*unknown*"
288 fprintf (stderr
289 , "\nTask: %p (%s)\n"
290 , task
291 , (task && task->tc_Node.ln_Name) ?
292 task->tc_Node.ln_Name
293 : "-- unknown task --"
295 fflush (stderr);
297 if (alertNum & AT_DeadEnd)
298 abort ();
300 AROS_LIBFUNC_EXIT
301 } /* Alert */