2019-05-16 21:42:23 +02:00
|
|
|
// The OS/K Team licenses this file to you under the MIT license.
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
2019-06-13 23:12:11 +02:00
|
|
|
#include <pc/dev.h>
|
2019-06-16 12:48:30 +02:00
|
|
|
|
|
|
|
int dying = 0;
|
2019-05-16 21:42:23 +02:00
|
|
|
|
|
|
|
void _except(ctx_t *ctx, int code, char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
2019-06-16 12:48:30 +02:00
|
|
|
enable_stdin_echoing();
|
|
|
|
|
|
|
|
if (dying)
|
|
|
|
{
|
|
|
|
log("Exception thrown while dying=1\n");
|
|
|
|
exit(-12);
|
|
|
|
}
|
|
|
|
else dying = 1;
|
2019-06-05 22:59:32 +02:00
|
|
|
|
2019-05-16 21:42:23 +02:00
|
|
|
log("\nException %d - ", code);
|
2019-05-30 12:44:56 +02:00
|
|
|
|
2019-05-16 21:42:23 +02:00
|
|
|
va_start(ap, fmt);
|
|
|
|
vlog(fmt, ap);
|
|
|
|
va_end(ap);
|
2019-05-30 12:44:56 +02:00
|
|
|
|
2019-05-16 21:42:23 +02:00
|
|
|
log("\n");
|
|
|
|
|
|
|
|
dumpregs(ctx);
|
2019-05-30 13:25:30 +02:00
|
|
|
log("\n");
|
|
|
|
|
2019-05-16 21:42:23 +02:00
|
|
|
if (ctx->mp)
|
|
|
|
free(ctx->mp);
|
2019-06-05 19:31:48 +02:00
|
|
|
|
2019-06-05 22:59:32 +02:00
|
|
|
//
|
|
|
|
// Shut down devices
|
|
|
|
//
|
2019-06-08 09:47:19 +02:00
|
|
|
if (devfiniall(ctx) < 0)
|
|
|
|
{
|
2019-06-05 19:31:48 +02:00
|
|
|
log("Couldn't deinitialize devices\n");
|
|
|
|
exit(-100 - code);
|
|
|
|
}
|
|
|
|
|
2019-05-29 16:57:22 +02:00
|
|
|
exit(code);
|
2019-05-16 21:42:23 +02:00
|
|
|
}
|
|
|
|
|