Crashdump yay

This commit is contained in:
Adrien Bourmault 2019-05-19 00:38:58 +02:00
parent ec83428ec1
commit f07fdafd52
6 changed files with 39 additions and 46 deletions

View File

@ -33,24 +33,24 @@
enum enum
{ {
VGA_COLOR_BLACK, VGA_COLOR_BLACK,
VGA_COLOR_BLUE, VGA_COLOR_BLUE,
VGA_COLOR_GREEN, VGA_COLOR_GREEN,
VGA_COLOR_CYAN, VGA_COLOR_CYAN,
VGA_COLOR_RED, VGA_COLOR_RED,
VGA_COLOR_MAGENTA, VGA_COLOR_MAGENTA,
VGA_COLOR_BROWN, VGA_COLOR_BROWN,
VGA_COLOR_LIGHT_GREY, VGA_COLOR_LIGHT_GREY,
VGA_COLOR_DARK_GREY, VGA_COLOR_DARK_GREY,
VGA_COLOR_LIGHT_BLUE, VGA_COLOR_LIGHT_BLUE,
VGA_COLOR_LIGHT_GREEN, VGA_COLOR_LIGHT_GREEN,
VGA_COLOR_LIGHT_CYAN, VGA_COLOR_LIGHT_CYAN,
VGA_COLOR_LIGHT_RED, VGA_COLOR_LIGHT_RED,
VGA_COLOR_LIGHT_MAGENTA, VGA_COLOR_LIGHT_MAGENTA,
VGA_COLOR_LIGHT_BROWN, VGA_COLOR_LIGHT_BROWN,
VGA_COLOR_WHITE, VGA_COLOR_WHITE,
VGA_COLOR_CURRENT = -1, VGA_COLOR_CURRENT = -1,
}; };
extern const char *RtlColorNames[VGA_COLOR_WHITE+1]; extern const char *RtlColorNames[VGA_COLOR_WHITE+1];

View File

@ -112,7 +112,7 @@ void BtDoSanityChecks(uint mbMagic) {
if (!(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC)) if (!(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC))
KeStartPanic("Magic number %x is incorrect\n", mbMagic); KeStartPanic("Magic number %x is incorrect\n", mbMagic);
DebugLog("\tKernel successfully loaded at %p\n", DebugLog("\t Kernel successfully loaded at %p\n",
BtLoaderInfo.kernelAddr); BtLoaderInfo.kernelAddr);
} }

View File

@ -29,6 +29,7 @@
IdtEntry_t idt[256] = { 0 }; IdtEntry_t idt[256] = { 0 };
IdtPtr_t _KeIdtPtr; IdtPtr_t _KeIdtPtr;
bool KeIdtIsInitialized = 0;
static ISRList_t isrList = { 0 }; static ISRList_t isrList = { 0 };
@ -79,7 +80,7 @@ error_t KeRegisterISR(void (*isr)(ISRFrame_t *regs), uchar isrNo)
uchar n = isrList.n; uchar n = isrList.n;
int OverWriting = 0; int OverWriting = 0;
assert(idt[0].flags!=0); // IDT initialized assert(KeIdtIsInitialized); // IDT initialized
if (n == 0) goto settingUp; if (n == 0) goto settingUp;
@ -168,6 +169,8 @@ void KeSetupIDT(void)
KeSetIDTGate(0x2E, (ulong)isr46, codeSeg, 0x8E); KeSetIDTGate(0x2E, (ulong)isr46, codeSeg, 0x8E);
KeSetIDTGate(0x2F, (ulong)isr47, codeSeg, 0x8E); KeSetIDTGate(0x2F, (ulong)isr47, codeSeg, 0x8E);
KeIdtIsInitialized++;
//Setup Early Exception handler //Setup Early Exception handler
for (uchar i = 0 ; i < 0x20 ; i++) { for (uchar i = 0 ; i < 0x20 ; i++) {
KeRegisterISR(EarlyExceptionHandler, i); KeRegisterISR(EarlyExceptionHandler, i);
@ -277,8 +280,8 @@ void _KeHandleISR(ISRFrame_t *regs)
// //
static void EarlyExceptionHandler(ISRFrame_t *regs) static void EarlyExceptionHandler(ISRFrame_t *regs)
{ {
bprintf(BStdOut, "\n\n%CPANIC\n%C[ISR 0x%x] Irrecoverable Kernel %s\n\n" bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel %s\n\n"
" Error code : 0x%x (%b)\n\n%C" " Error code : 0x%x (%b)\n\n"
" RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n" " RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n"
@ -294,13 +297,11 @@ static void EarlyExceptionHandler(ISRFrame_t *regs)
" R14: %#016lx R15: %#016lx \n\n" " R14: %#016lx R15: %#016lx \n\n"
" RFLAGS: %#022b (%#06x)", " RFLAGS: %#022b (%#06x)",
VGA_COLOR_WHITE,
VGA_COLOR_LIGHT_RED, VGA_COLOR_LIGHT_RED,
regs->intNo, regs->intNo,
ExceptionsChar[regs->intNo], ExceptionsChar[regs->intNo],
regs->ErrorCode, regs->ErrorCode,
regs->ErrorCode, regs->ErrorCode,
VGA_COLOR_WHITE,
regs->rip, regs->rip,
regs->rsp, regs->rsp,
regs->rbp, regs->rbp,
@ -330,8 +331,6 @@ static void EarlyExceptionHandler(ISRFrame_t *regs)
regs->rflags regs->rflags
); );
bputc(BStdOut, '\n');
BStdOut->flusher(BStdOut); BStdOut->flusher(BStdOut);
KeHaltCPU(); KeHaltCPU();
@ -355,7 +354,7 @@ static void BreakPointHandler(ISRFrame_t *regs)
" R14: %#016lx R15: %#016lx \n\n" " R14: %#016lx R15: %#016lx \n\n"
" RFLAGS: %#022b (%#06x)", " RFLAGS: %#022b (%#06x)",
VGA_COLOR_WHITE, VGA_COLOR_LIGHT_RED,
regs->rip, regs->rip,
regs->rsp, regs->rsp,
regs->rbp, regs->rbp,
@ -385,7 +384,5 @@ static void BreakPointHandler(ISRFrame_t *regs)
regs->rflags regs->rflags
); );
bputc(BStdOut, '\n');
BStdOut->flusher(BStdOut); BStdOut->flusher(BStdOut);
} }

View File

@ -27,6 +27,7 @@
#include <io/vga.h> #include <io/vga.h>
error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap); error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap);
extern bool KeIdtIsInitialized;
// //
// Failed assert() handler // Failed assert() handler
@ -72,17 +73,16 @@ noreturn void KeStartPanic(const char *fmt, ...)
// We don't check vbprintf's output // We don't check vbprintf's output
// If it fails, what could we do anyway? // If it fails, what could we do anyway?
bprintf(BStdOut, "%C\nPANIC\n%C", VGA_COLOR_WHITE, VGA_COLOR_LIGHT_RED); bprintf(BStdOut, "%C\nPANIC\n", VGA_COLOR_LIGHT_RED);
va_start(ap, fmt); va_start(ap, fmt);
vbprintf(BStdOut, fmt, ap); vbprintf(BStdOut, fmt, ap);
va_end(ap); va_end(ap);
interrupt(0x3);
bputc(BStdOut, '\n'); if (KeIdtIsInitialized)
interrupt(0x3);
BStdOut->flusher(BStdOut); BStdOut->flusher(BStdOut);
KeHaltCPU(); KeHaltCPU();

View File

@ -167,8 +167,8 @@ void MmReloadPaging(void)
// //
static void PagingHandler(ISRFrame_t *regs) static void PagingHandler(ISRFrame_t *regs)
{ {
bprintf(BStdOut, "\n\n%CPANIC\n%C[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n" bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
" Error code : 0x%x (%b)\n\n%C" " Error code : 0x%x (%b)\n\n"
" RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n" " RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n"
@ -184,13 +184,11 @@ static void PagingHandler(ISRFrame_t *regs)
" R14: %#016lx R15: %#016lx \n\n" " R14: %#016lx R15: %#016lx \n\n"
" RFLAGS: %#022b (%#06x)", " RFLAGS: %#022b (%#06x)",
VGA_COLOR_WHITE,
VGA_COLOR_LIGHT_RED, VGA_COLOR_LIGHT_RED,
regs->intNo, regs->intNo,
regs->cr2, regs->cr2,
regs->ErrorCode, regs->ErrorCode,
regs->ErrorCode, regs->ErrorCode,
VGA_COLOR_WHITE,
regs->rip, regs->rip,
regs->rsp, regs->rsp,
regs->rbp, regs->rbp,
@ -220,8 +218,6 @@ static void PagingHandler(ISRFrame_t *regs)
regs->rflags regs->rflags
); );
bputc(BStdOut, '\n');
BStdOut->flusher(BStdOut); BStdOut->flusher(BStdOut);
KeHaltCPU(); KeHaltCPU();

View File

@ -207,13 +207,13 @@ error_t CmdMemUsage(int argc, char **argv, char *cmdline);
error_t CmdVersion(int argc, char **argv, char *cmdline) error_t CmdVersion(int argc, char **argv, char *cmdline)
{ {
KernLog("OS/K, version %s (x86-64)\n", _KALEID_VERSION); KernLog("OS/K version %s (x86-64)\n", _KALEID_VERSION);
KernLog("Copyright (C) 2019 The OS/K Team.\n"); KernLog("Copyright (C) 2018-2019 The OS/K Team\n");
KernLog("License GPLv3+: GNU GPL version 3 " KernLog("License GNU GPL version 3 "
"or later <http://gnu.org/licenses/gpl.html>\n"); "or later, see <http://gnu.org/licenses/gpl.html>\n");
KernLog("This is free software; you are " KernLog("This is free software; you are "
"free to change and redistribute it.\n"); "free to change and redistribute it.\n");
KernLog("There is NO WARRANTY, to the extent permitted by law.\n"); KernLog("There is NO WARRANTY, to the extent permitted by law.\n\n");
return EOK; return EOK;
} }
@ -239,7 +239,7 @@ Command_t cmdtable[] =
{ "shell", CmdShell, "Start a new shell (nested)", }, { "shell", CmdShell, "Start a new shell (nested)", },
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" }, { "stkov", CmdStackOverflow, "Provoke a stack overflow" },
{ "time", CmdTime, "Print time" }, { "time", CmdTime, "Print time" },
{ "vers", CmdVersion, "Version and legal infos" }, { "ver", CmdVersion, "Version and legal infos" },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };