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 {
/* The register file */
ulong regs[20];
/* The registers */
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 */
ulong intNo;

View File

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

View File

@ -277,43 +277,50 @@ static void EarlyExceptionHandler(ISRFrame_t *regs)
{
KeStartPanic("[ISR 0x%x] Irrecoverable Kernel %s\n\n"
" Error code : 0x%x (%b)\n\n"
" RIP: %#016lx CS: %#016lx RSP: %#016lx\n"
" SS: %#016lx RAX: %#016lx RBX: %#016lx\n"
" RCX: %#016lx RDX: %#016lx RSI: %#016lx\n"
" RDI: %#016lx RBP: %#016lx R8: %#016lx\n"
" R9: %#016lx R10: %#016lx R11: %#016lx\n"
" R12: %#016lx R13: %#016lx R14: %#016lx\n"
" R15: %#016lx CR0: %#016lx CR2: %#016lx\n"
" CR3: %#016lx CR4: %#016lx CR8: %#016lx\n"
" 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)",
regs->intNo,
ExceptionsChar[regs->intNo],
regs->ErrorCode,
regs->ErrorCode,
regs->rip,
regs->cs,
regs->rsp,
regs->rbp,
regs->ss,
regs->regs[5],
regs->regs[6],
regs->regs[7],
regs->regs[8],
regs->regs[9],
regs->regs[10],
regs->regs[11],
regs->regs[12],
regs->regs[13],
regs->regs[14],
regs->regs[15],
regs->regs[16],
regs->regs[17],
regs->regs[18],
regs->regs[19],
regs->regs[0],
regs->regs[1],
regs->regs[2],
regs->regs[3],
regs->regs[4],
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
);

View File

@ -53,6 +53,9 @@ isrPreHandler:
push rax
mov rax, cr0
push rax
mov rcx, 0xC0000080
rdmsr
push rax
; Check if we are switching from user mode to supervisor mode
mov rax, [rsp + 152]
@ -84,7 +87,7 @@ isrPreHandler:
.SExit:
; pop the control registers
add rsp, 40
add rsp, 48
popAll
; 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"
" Error code : 0x%x (%b)\n\n"
" RIP: %#016lx CS: %#016lx RSP: %#016lx\n"
" SS: %#016lx RAX: %#016lx RBX: %#016lx\n"
" RCX: %#016lx RDX: %#016lx RSI: %#016lx\n"
" RDI: %#016lx RBP: %#016lx R8: %#016lx\n"
" R9: %#016lx R10: %#016lx R11: %#016lx\n"
" R12: %#016lx R13: %#016lx R14: %#016lx\n"
" R15: %#016lx CR0: %#016lx CR2: %#016lx\n"
" CR3: %#016lx CR4: %#016lx CR8: %#016lx\n"
" 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)",
regs->intNo,
regs->regs[1],
regs->cr2,
regs->ErrorCode,
regs->ErrorCode,
regs->rip,
regs->cs,
regs->rsp,
regs->rbp,
regs->ss,
regs->regs[5],
regs->regs[6],
regs->regs[7],
regs->regs[8],
regs->regs[9],
regs->regs[10],
regs->regs[11],
regs->regs[12],
regs->regs[13],
regs->regs[14],
regs->regs[15],
regs->regs[16],
regs->regs[17],
regs->regs[18],
regs->regs[19],
regs->regs[0],
regs->regs[1],
regs->regs[2],
regs->regs[3],
regs->regs[4],
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
);