1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/vm/pc/except.c
julianb0 d6089b3999
vm
2019-06-08 09:47:19 +02:00

45 lines
749 B
C

// The OS/K Team licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#include <dv/dev.h>
#include <termio.h>
void _except(ctx_t *ctx, int code, char *fmt, ...)
{
va_list ap;
//
// Restore stdin echoing
//
struct termios t;
tcgetattr(0, &t);
t.c_lflag |= ECHO;
tcsetattr(0, TCSANOW, &t);
log("\nException %d - ", code);
va_start(ap, fmt);
vlog(fmt, ap);
va_end(ap);
log("\n");
dumpregs(ctx);
log("\n");
if (ctx->mp)
free(ctx->mp);
//
// Shut down devices
//
if (devfiniall(ctx) < 0)
{
log("Couldn't deinitialize devices\n");
exit(-100 - code);
}
exit(code);
}