Better dump

This commit is contained in:
Adrien Bourmault 2019-05-18 20:31:02 +02:00
parent b87af1d3d1
commit e5f2aaed04
5 changed files with 100 additions and 63 deletions

View File

@ -110,8 +110,28 @@ struct CpuInfo_t
}; };
struct ISRFrame_t { struct ISRFrame_t {
/* The register file */ /* The registers */
ulong regs[20]; ulong efer;
ulong cr0;
ulong cr2;
ulong cr3;
ulong cr4;
ulong cr8;
ulong r15;
ulong r14;
ulong r13;
ulong r12;
ulong r11;
ulong r10;
ulong r9;
ulong r8;
ulong rbp;
ulong rdi;
ulong rsi;
ulong rdx;
ulong rcx;
ulong rbx;
ulong rax;
/* The error code and interrupt id */ /* The error code and interrupt id */
ulong intNo; ulong intNo;

View File

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

View File

@ -277,43 +277,50 @@ static void EarlyExceptionHandler(ISRFrame_t *regs)
{ {
KeStartPanic("[ISR 0x%x] Irrecoverable Kernel %s\n\n" KeStartPanic("[ISR 0x%x] Irrecoverable Kernel %s\n\n"
" Error code : 0x%x (%b)\n\n" " Error code : 0x%x (%b)\n\n"
" RIP: %#016lx CS: %#016lx RSP: %#016lx\n"
" SS: %#016lx RAX: %#016lx RBX: %#016lx\n" " RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n"
" RCX: %#016lx RDX: %#016lx RSI: %#016lx\n"
" RDI: %#016lx RBP: %#016lx R8: %#016lx\n" " SS: %#016lx CS: %#016lx CR0: %#016lx\n"
" R9: %#016lx R10: %#016lx R11: %#016lx\n" " CR2: %#016lx CR3: %#016lx CR4: %#016lx\n"
" R12: %#016lx R13: %#016lx R14: %#016lx\n" " CR8: %#016lx EFE: %#016lx \n\n"
" R15: %#016lx CR0: %#016lx CR2: %#016lx\n"
" CR3: %#016lx CR4: %#016lx CR8: %#016lx\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)", " RFLAGS: %#022b (%#06x)",
regs->intNo, regs->intNo,
ExceptionsChar[regs->intNo], ExceptionsChar[regs->intNo],
regs->ErrorCode, regs->ErrorCode,
regs->ErrorCode, regs->ErrorCode,
regs->rip, regs->rip,
regs->cs,
regs->rsp, regs->rsp,
regs->rbp,
regs->ss, regs->ss,
regs->regs[5], regs->cs,
regs->regs[6], regs->cr0,
regs->regs[7], regs->cr2,
regs->regs[8], regs->cr3,
regs->regs[9], regs->cr4,
regs->regs[10], regs->cr8,
regs->regs[11], regs->efer,
regs->regs[12], regs->rax,
regs->regs[13], regs->rbx,
regs->regs[14], regs->rcx,
regs->regs[15], regs->rdx,
regs->regs[16], regs->rsi,
regs->regs[17], regs->rdi,
regs->regs[18], regs->r8,
regs->regs[19], regs->r9,
regs->regs[0], regs->r10,
regs->regs[1], regs->r11,
regs->regs[2], regs->r12,
regs->regs[3], regs->r13,
regs->regs[4], regs->r14,
regs->r15,
regs->rflags, regs->rflags,
regs->rflags regs->rflags
); );

View File

@ -53,6 +53,9 @@ isrPreHandler:
push rax push rax
mov rax, cr0 mov rax, cr0
push rax push rax
mov rcx, 0xC0000080
rdmsr
push rax
; Check if we are switching from user mode to supervisor mode ; Check if we are switching from user mode to supervisor mode
mov rax, [rsp + 152] mov rax, [rsp + 152]
@ -84,7 +87,7 @@ isrPreHandler:
.SExit: .SExit:
; pop the control registers ; pop the control registers
add rsp, 40 add rsp, 48
popAll popAll
; pop the error code and interrupt id ; pop the error code and interrupt id

View File

@ -166,43 +166,50 @@ static void PagingHandler(ISRFrame_t *regs)
{ {
KeStartPanic("[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n" KeStartPanic("[ISR 0x%x] Irrecoverable Kernel Page Fault at %p\n\n"
" Error code : 0x%x (%b)\n\n" " Error code : 0x%x (%b)\n\n"
" RIP: %#016lx CS: %#016lx RSP: %#016lx\n"
" SS: %#016lx RAX: %#016lx RBX: %#016lx\n" " RIP: %#016lx RSP: %#016lx RBP: %#016lx\n\n"
" RCX: %#016lx RDX: %#016lx RSI: %#016lx\n"
" RDI: %#016lx RBP: %#016lx R8: %#016lx\n" " SS: %#016lx CS: %#016lx CR0: %#016lx\n"
" R9: %#016lx R10: %#016lx R11: %#016lx\n" " CR2: %#016lx CR3: %#016lx CR4: %#016lx\n"
" R12: %#016lx R13: %#016lx R14: %#016lx\n" " CR8: %#016lx EFE: %#016lx \n\n"
" R15: %#016lx CR0: %#016lx CR2: %#016lx\n"
" CR3: %#016lx CR4: %#016lx CR8: %#016lx\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)", " RFLAGS: %#022b (%#06x)",
regs->intNo, regs->intNo,
regs->regs[1], regs->cr2,
regs->ErrorCode, regs->ErrorCode,
regs->ErrorCode, regs->ErrorCode,
regs->rip, regs->rip,
regs->cs,
regs->rsp, regs->rsp,
regs->rbp,
regs->ss, regs->ss,
regs->regs[5], regs->cs,
regs->regs[6], regs->cr0,
regs->regs[7], regs->cr2,
regs->regs[8], regs->cr3,
regs->regs[9], regs->cr4,
regs->regs[10], regs->cr8,
regs->regs[11], regs->efer,
regs->regs[12], regs->rax,
regs->regs[13], regs->rbx,
regs->regs[14], regs->rcx,
regs->regs[15], regs->rdx,
regs->regs[16], regs->rsi,
regs->regs[17], regs->rdi,
regs->regs[18], regs->r8,
regs->regs[19], regs->r9,
regs->regs[0], regs->r10,
regs->regs[1], regs->r11,
regs->regs[2], regs->r12,
regs->regs[3], regs->r13,
regs->regs[4], regs->r14,
regs->r15,
regs->rflags, regs->rflags,
regs->rflags regs->rflags
); );