mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Crashdump yay
This commit is contained in:
parent
718ea275c5
commit
d1a46d7acd
@ -73,6 +73,7 @@ void KeSetupIDT(void);
|
|||||||
void KeSendEOItoPIC(uchar isr);
|
void KeSendEOItoPIC(uchar isr);
|
||||||
void KeSetIDTGate(uchar rank, ulong base, ushort selector, uchar flags);
|
void KeSetIDTGate(uchar rank, ulong base, ushort selector, uchar flags);
|
||||||
error_t KeRegisterISR(void (*isr)(ISRFrame_t *regs), uchar isrNo);
|
error_t KeRegisterISR(void (*isr)(ISRFrame_t *regs), uchar isrNo);
|
||||||
|
void KeBrkDumpRegisters(ISRFrame_t *regs);
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
|||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
MmInitMemoryMap();
|
MmInitMemoryMap();
|
||||||
//MmInitGdt();
|
MmInitGdt();
|
||||||
MmInitPaging();
|
MmInitPaging();
|
||||||
MmInitHeap();
|
MmInitHeap();
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include <io/spkr.h>
|
#include <io/spkr.h>
|
||||||
#include <ke/time.h>
|
#include <ke/time.h>
|
||||||
|
|
||||||
|
extern bool KeIdtIsInitialized;
|
||||||
|
|
||||||
void IoStartSpeaker(int freq)
|
void IoStartSpeaker(int freq)
|
||||||
{
|
{
|
||||||
uchar temp;
|
uchar temp;
|
||||||
@ -58,6 +60,7 @@ void IoDoTone(uint tone, uint time)
|
|||||||
|
|
||||||
void IoDoBeep(void)
|
void IoDoBeep(void)
|
||||||
{
|
{
|
||||||
|
if (KeIdtIsInitialized)
|
||||||
IoDoTone(1000, 100);
|
IoDoTone(1000, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,6 @@ static char *ExceptionsChar[32] = {
|
|||||||
|
|
||||||
static void EnablePIC(void);
|
static void EnablePIC(void);
|
||||||
static void EarlyExceptionHandler(ISRFrame_t *regs);
|
static void EarlyExceptionHandler(ISRFrame_t *regs);
|
||||||
static void BreakPointHandler(ISRFrame_t *regs);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Registers an isr with his IRQ to handle driver interrupts
|
// Registers an isr with his IRQ to handle driver interrupts
|
||||||
@ -176,7 +175,7 @@ void KeSetupIDT(void)
|
|||||||
KeRegisterISR(EarlyExceptionHandler, i);
|
KeRegisterISR(EarlyExceptionHandler, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeRegisterISR(BreakPointHandler, 0x3);
|
KeRegisterISR(KeBrkDumpRegisters, 0x3);
|
||||||
|
|
||||||
// Load IDT
|
// Load IDT
|
||||||
KeLoadIDT();
|
KeLoadIDT();
|
||||||
@ -281,62 +280,23 @@ void _KeHandleISR(ISRFrame_t *regs)
|
|||||||
static void EarlyExceptionHandler(ISRFrame_t *regs)
|
static void EarlyExceptionHandler(ISRFrame_t *regs)
|
||||||
{
|
{
|
||||||
bprintf(BStdOut, "\n\n%CPANIC\n[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"
|
" 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,
|
VGA_COLOR_LIGHT_RED,
|
||||||
regs->intNo,
|
regs->intNo,
|
||||||
ExceptionsChar[regs->intNo],
|
ExceptionsChar[regs->intNo],
|
||||||
regs->ErrorCode,
|
regs->ErrorCode,
|
||||||
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
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
KeBrkDumpRegisters(regs);
|
||||||
|
|
||||||
BStdOut->flusher(BStdOut);
|
BStdOut->flusher(BStdOut);
|
||||||
|
|
||||||
KeHaltCPU();
|
KeHaltCPU();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BreakPointHandler(ISRFrame_t *regs)
|
void KeBrkDumpRegisters(ISRFrame_t *regs)
|
||||||
{
|
{
|
||||||
bprintf(BStdOut, "\n\n"
|
bprintf(BStdOut, "\n\n"
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ noreturn void KeStartPanic(const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
bprintf(BStdOut, "%C\nPANIC\n\a", VGA_COLOR_LIGHT_RED);
|
||||||
KeDisableIRQs();
|
KeDisableIRQs();
|
||||||
|
|
||||||
KeCurProc = NULL;
|
KeCurProc = NULL;
|
||||||
@ -73,8 +74,6 @@ 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", VGA_COLOR_LIGHT_RED);
|
|
||||||
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vbprintf(BStdOut, fmt, ap);
|
vbprintf(BStdOut, fmt, ap);
|
||||||
|
@ -48,7 +48,6 @@ MmLoadGdt:
|
|||||||
;; Stores the GDT
|
;; Stores the GDT
|
||||||
;;
|
;;
|
||||||
MmStoreGdt:
|
MmStoreGdt:
|
||||||
|
|
||||||
;; Loading the gdt via the gdtPtr pointer
|
;; Loading the gdt via the gdtPtr pointer
|
||||||
sgdt [rel gdtPtr]
|
sgdt [gdtPtr]
|
||||||
ret
|
ret
|
||||||
|
@ -65,10 +65,7 @@ static void SetTssEntry(uchar index, ulong base, ulong limit)
|
|||||||
|
|
||||||
void MmInitGdt(void)
|
void MmInitGdt(void)
|
||||||
{
|
{
|
||||||
gdtPtr.limit = (sizeof(GdtEntry_t) * 5) - 1;
|
//MmStoreGdt();
|
||||||
gdtPtr.base = (uint)(ullong)&gdtEntries;
|
|
||||||
|
|
||||||
MmStoreGdt();
|
|
||||||
|
|
||||||
/* SetGdtEntry(1, 0x0, 0xfffff, 0x02 | 0x08); */
|
/* SetGdtEntry(1, 0x0, 0xfffff, 0x02 | 0x08); */
|
||||||
|
|
||||||
@ -76,7 +73,7 @@ void MmInitGdt(void)
|
|||||||
|
|
||||||
/* SetTssEntry(2, (ulong)&tssEntry, sizeof(TssEntry_t)); */
|
/* SetTssEntry(2, (ulong)&tssEntry, sizeof(TssEntry_t)); */
|
||||||
|
|
||||||
MmLoadGdt();
|
//MmLoadGdt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,56 +168,17 @@ void MmReloadPaging(void)
|
|||||||
static void PagingHandler(ISRFrame_t *regs)
|
static void PagingHandler(ISRFrame_t *regs)
|
||||||
{
|
{
|
||||||
bprintf(BStdOut, "\n\n%CPANIC\n[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"
|
" 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,
|
VGA_COLOR_LIGHT_RED,
|
||||||
regs->intNo,
|
regs->intNo,
|
||||||
regs->cr2,
|
regs->cr2,
|
||||||
regs->ErrorCode,
|
regs->ErrorCode,
|
||||||
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
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
KeBrkDumpRegisters(regs);
|
||||||
|
|
||||||
BStdOut->flusher(BStdOut);
|
BStdOut->flusher(BStdOut);
|
||||||
|
|
||||||
KeHaltCPU();
|
KeHaltCPU();
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
#include <lib/buf.h>
|
#include <lib/buf.h>
|
||||||
|
#include <io/spkr.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Writes a character on a buffer
|
// Writes a character on a buffer
|
||||||
@ -77,6 +78,10 @@ error_t bputc(Buffer_t *buf, uchar ch)
|
|||||||
if (buf->flusher) buf->flusher(buf);
|
if (buf->flusher) buf->flusher(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (ch == '\a') {
|
||||||
|
IoDoBeep();
|
||||||
|
}
|
||||||
|
|
||||||
// Deal with carriage returns
|
// Deal with carriage returns
|
||||||
else if (ch == '\r') {
|
else if (ch == '\r') {
|
||||||
buf->wp -= buf->lastLF;
|
buf->wp -= buf->lastLF;
|
||||||
|
Loading…
Reference in New Issue
Block a user