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
{
VGA_COLOR_BLACK,
VGA_COLOR_BLUE,
VGA_COLOR_GREEN,
VGA_COLOR_CYAN,
VGA_COLOR_RED,
VGA_COLOR_MAGENTA,
VGA_COLOR_BROWN,
VGA_COLOR_LIGHT_GREY,
VGA_COLOR_DARK_GREY,
VGA_COLOR_LIGHT_BLUE,
VGA_COLOR_LIGHT_GREEN,
VGA_COLOR_LIGHT_CYAN,
VGA_COLOR_LIGHT_RED,
VGA_COLOR_LIGHT_MAGENTA,
VGA_COLOR_LIGHT_BROWN,
VGA_COLOR_WHITE,
VGA_COLOR_CURRENT = -1,
VGA_COLOR_BLACK,
VGA_COLOR_BLUE,
VGA_COLOR_GREEN,
VGA_COLOR_CYAN,
VGA_COLOR_RED,
VGA_COLOR_MAGENTA,
VGA_COLOR_BROWN,
VGA_COLOR_LIGHT_GREY,
VGA_COLOR_DARK_GREY,
VGA_COLOR_LIGHT_BLUE,
VGA_COLOR_LIGHT_GREEN,
VGA_COLOR_LIGHT_CYAN,
VGA_COLOR_LIGHT_RED,
VGA_COLOR_LIGHT_MAGENTA,
VGA_COLOR_LIGHT_BROWN,
VGA_COLOR_WHITE,
VGA_COLOR_CURRENT = -1,
};
extern const char *RtlColorNames[VGA_COLOR_WHITE+1];

View File

@ -112,7 +112,7 @@ void BtDoSanityChecks(uint mbMagic) {
if (!(mbMagic == MULTIBOOT_BOOTLOADER_MAGIC))
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);
}

View File

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

View File

@ -27,6 +27,7 @@
#include <io/vga.h>
error_t vbprintf(Buffer_t *buf, const char *fmt, va_list ap);
extern bool KeIdtIsInitialized;
//
// Failed assert() handler
@ -72,17 +73,16 @@ noreturn void KeStartPanic(const char *fmt, ...)
// We don't check vbprintf's output
// 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);
vbprintf(BStdOut, fmt, ap);
va_end(ap);
interrupt(0x3);
bputc(BStdOut, '\n');
if (KeIdtIsInitialized)
interrupt(0x3);
BStdOut->flusher(BStdOut);
KeHaltCPU();

View File

@ -167,8 +167,8 @@ void MmReloadPaging(void)
//
static void PagingHandler(ISRFrame_t *regs)
{
bprintf(BStdOut, "\n\n%CPANIC\n%C[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
" Error code : 0x%x (%b)\n\n%C"
bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
" Error code : 0x%x (%b)\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"
" RFLAGS: %#022b (%#06x)",
VGA_COLOR_WHITE,
VGA_COLOR_LIGHT_RED,
regs->intNo,
regs->cr2,
regs->ErrorCode,
regs->ErrorCode,
VGA_COLOR_WHITE,
regs->rip,
regs->rsp,
regs->rbp,
@ -220,8 +218,6 @@ static void PagingHandler(ISRFrame_t *regs)
regs->rflags
);
bputc(BStdOut, '\n');
BStdOut->flusher(BStdOut);
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)
{
KernLog("OS/K, version %s (x86-64)\n", _KALEID_VERSION);
KernLog("Copyright (C) 2019 The OS/K Team.\n");
KernLog("License GPLv3+: GNU GPL version 3 "
"or later <http://gnu.org/licenses/gpl.html>\n");
KernLog("OS/K version %s (x86-64)\n", _KALEID_VERSION);
KernLog("Copyright (C) 2018-2019 The OS/K Team\n");
KernLog("License GNU GPL version 3 "
"or later, see <http://gnu.org/licenses/gpl.html>\n");
KernLog("This is free software; you are "
"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;
}
@ -239,7 +239,7 @@ Command_t cmdtable[] =
{ "shell", CmdShell, "Start a new shell (nested)", },
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
{ "time", CmdTime, "Print time" },
{ "vers", CmdVersion, "Version and legal infos" },
{ "ver", CmdVersion, "Version and legal infos" },
{ NULL, NULL, NULL }
};