Crashdump yay

This commit is contained in:
Adrien Bourmault 2019-05-19 01:33:16 +02:00
parent 718ea275c5
commit d1a46d7acd
9 changed files with 25 additions and 100 deletions

View File

@ -73,6 +73,7 @@ void KeSetupIDT(void);
void KeSendEOItoPIC(uchar isr);
void KeSetIDTGate(uchar rank, ulong base, ushort selector, uchar flags);
error_t KeRegisterISR(void (*isr)(ISRFrame_t *regs), uchar isrNo);
void KeBrkDumpRegisters(ISRFrame_t *regs);
//----------------------------------------------------------------------------//

View File

@ -55,7 +55,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
// Memory
MmInitMemoryMap();
//MmInitGdt();
MmInitGdt();
MmInitPaging();
MmInitHeap();

View File

@ -25,6 +25,8 @@
#include <io/spkr.h>
#include <ke/time.h>
extern bool KeIdtIsInitialized;
void IoStartSpeaker(int freq)
{
uchar temp;
@ -58,6 +60,7 @@ void IoDoTone(uint tone, uint time)
void IoDoBeep(void)
{
if (KeIdtIsInitialized)
IoDoTone(1000, 100);
}

View File

@ -70,7 +70,6 @@ static char *ExceptionsChar[32] = {
static void EnablePIC(void);
static void EarlyExceptionHandler(ISRFrame_t *regs);
static void BreakPointHandler(ISRFrame_t *regs);
//
// Registers an isr with his IRQ to handle driver interrupts
@ -176,7 +175,7 @@ void KeSetupIDT(void)
KeRegisterISR(EarlyExceptionHandler, i);
}
KeRegisterISR(BreakPointHandler, 0x3);
KeRegisterISR(KeBrkDumpRegisters, 0x3);
// Load IDT
KeLoadIDT();
@ -281,62 +280,23 @@ void _KeHandleISR(ISRFrame_t *regs)
static void EarlyExceptionHandler(ISRFrame_t *regs)
{
bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel %s\n\n"
" Error code : 0x%x (%b)\n\n"
" Error code : 0x%x (%b)",
" RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n"
" SS: %#016lx CS: %#016lx CR0: %#016lx\n"
" CR2: %#016lx CR3: %#016lx CR4: %#016lx\n"
" CR8: %#016lx EFE: %#016lx \n\n"
" RAX: %#016lx RBX: %#016lx RCX: %#016lx\n"
" RDX: %#016lx RSI: %#016lx RDI: %#016lx\n"
" R8: %#016lx R9: %#016lx R10: %#016lx\n"
" R11: %#016lx R12: %#016lx R13: %#016lx\n"
" R14: %#016lx R15: %#016lx \n\n"
" RFLAGS: %#022b (%#06x)",
VGA_COLOR_LIGHT_RED,
regs->intNo,
ExceptionsChar[regs->intNo],
regs->ErrorCode,
regs->ErrorCode,
regs->rip,
regs->rsp,
regs->rbp,
regs->ss,
regs->cs,
regs->cr0,
regs->cr2,
regs->cr3,
regs->cr4,
regs->cr8,
regs->efer,
regs->rax,
regs->rbx,
regs->rcx,
regs->rdx,
regs->rsi,
regs->rdi,
regs->r8,
regs->r9,
regs->r10,
regs->r11,
regs->r12,
regs->r13,
regs->r14,
regs->r15,
regs->rflags,
regs->rflags
regs->ErrorCode
);
KeBrkDumpRegisters(regs);
BStdOut->flusher(BStdOut);
KeHaltCPU();
}
static void BreakPointHandler(ISRFrame_t *regs)
void KeBrkDumpRegisters(ISRFrame_t *regs)
{
bprintf(BStdOut, "\n\n"

View File

@ -51,6 +51,7 @@ noreturn void KeStartPanic(const char *fmt, ...)
{
va_list ap;
bprintf(BStdOut, "%C\nPANIC\n\a", VGA_COLOR_LIGHT_RED);
KeDisableIRQs();
KeCurProc = NULL;
@ -73,8 +74,6 @@ 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", VGA_COLOR_LIGHT_RED);
va_start(ap, fmt);
vbprintf(BStdOut, fmt, ap);

View File

@ -48,7 +48,6 @@ MmLoadGdt:
;; Stores the GDT
;;
MmStoreGdt:
;; Loading the gdt via the gdtPtr pointer
sgdt [rel gdtPtr]
sgdt [gdtPtr]
ret

View File

@ -65,10 +65,7 @@ static void SetTssEntry(uchar index, ulong base, ulong limit)
void MmInitGdt(void)
{
gdtPtr.limit = (sizeof(GdtEntry_t) * 5) - 1;
gdtPtr.base = (uint)(ullong)&gdtEntries;
MmStoreGdt();
//MmStoreGdt();
/* SetGdtEntry(1, 0x0, 0xfffff, 0x02 | 0x08); */
@ -76,7 +73,7 @@ void MmInitGdt(void)
/* SetTssEntry(2, (ulong)&tssEntry, sizeof(TssEntry_t)); */
MmLoadGdt();
//MmLoadGdt();
}

View File

@ -168,56 +168,17 @@ void MmReloadPaging(void)
static void PagingHandler(ISRFrame_t *regs)
{
bprintf(BStdOut, "\n\n%CPANIC\n[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
" Error code : 0x%x (%b)\n\n"
" Error code : 0x%x (%b)",
" RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n"
" SS: %#016lx CS: %#016lx CR0: %#016lx\n"
" CR2: %#016lx CR3: %#016lx CR4: %#016lx\n"
" CR8: %#016lx EFE: %#016lx \n\n"
" RAX: %#016lx RBX: %#016lx RCX: %#016lx\n"
" RDX: %#016lx RSI: %#016lx RDI: %#016lx\n"
" R8: %#016lx R9: %#016lx R10: %#016lx\n"
" R11: %#016lx R12: %#016lx R13: %#016lx\n"
" R14: %#016lx R15: %#016lx \n\n"
" RFLAGS: %#022b (%#06x)",
VGA_COLOR_LIGHT_RED,
regs->intNo,
regs->cr2,
regs->ErrorCode,
regs->ErrorCode,
regs->rip,
regs->rsp,
regs->rbp,
regs->ss,
regs->cs,
regs->cr0,
regs->cr2,
regs->cr3,
regs->cr4,
regs->cr8,
regs->efer,
regs->rax,
regs->rbx,
regs->rcx,
regs->rdx,
regs->rsi,
regs->rdi,
regs->r8,
regs->r9,
regs->r10,
regs->r11,
regs->r12,
regs->r13,
regs->r14,
regs->r15,
regs->rflags,
regs->rflags
regs->ErrorCode
);
KeBrkDumpRegisters(regs);
BStdOut->flusher(BStdOut);
KeHaltCPU();

View File

@ -23,6 +23,7 @@
//----------------------------------------------------------------------------//
#include <lib/buf.h>
#include <io/spkr.h>
//
// Writes a character on a buffer
@ -77,6 +78,10 @@ error_t bputc(Buffer_t *buf, uchar ch)
if (buf->flusher) buf->flusher(buf);
}
else if (ch == '\a') {
IoDoBeep();
}
// Deal with carriage returns
else if (ch == '\r') {
buf->wp -= buf->lastLF;