2014-07-13 20:07:19 +00:00
|
|
|
|
2014-07-13 23:52:18 +00:00
|
|
|
#include <stdbool.h>
|
2014-07-13 20:07:19 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include <kassert.h>
|
|
|
|
#include <kconfig.h>
|
2014-07-13 20:36:43 +00:00
|
|
|
#include <kdebug.h>
|
2014-07-13 20:07:19 +00:00
|
|
|
#include <mp.h>
|
|
|
|
|
2014-07-13 21:44:05 +00:00
|
|
|
#include "amd64.h"
|
|
|
|
#include "amd64op.h"
|
2014-07-13 20:07:19 +00:00
|
|
|
#include "trap.h"
|
|
|
|
|
|
|
|
TrapFrame *frames[MAX_CPUS];
|
|
|
|
|
|
|
|
void
|
|
|
|
Debug_Breakpoint(TrapFrame *tf)
|
|
|
|
{
|
|
|
|
frames[CPU()] = tf;
|
|
|
|
|
|
|
|
// Stop all processors
|
|
|
|
|
|
|
|
Debug_Prompt();
|
|
|
|
|
|
|
|
// Resume all processors
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Debug_Registers(int argc, const char *argv[])
|
|
|
|
{
|
2014-07-13 21:44:05 +00:00
|
|
|
TrapFrame *tf = frames[CPU()];
|
|
|
|
|
|
|
|
kprintf("Interrupt %d Error Code: %016llx\n",
|
|
|
|
tf->vector, tf->errcode);
|
|
|
|
kprintf("cr0: %016llx cr2: %016llx\n",
|
|
|
|
read_cr0(), read_cr2());
|
|
|
|
kprintf("cr3: %016llx cr4: %016llx\n",
|
|
|
|
read_cr3(), read_cr4());
|
|
|
|
kprintf("dr0: %016llx dr1: %016llx dr2: %016llx\n",
|
|
|
|
read_dr0(), read_dr1(), read_dr2());
|
|
|
|
kprintf("dr3: %016llx dr6: %016llx dr7: %016llx\n",
|
|
|
|
read_dr3(), read_dr6(), read_dr7());
|
|
|
|
kprintf("rip: %04x:%016x rsp: %04x:%016x\n",
|
|
|
|
tf->cs, tf->rip, tf->ss, tf->rsp);
|
|
|
|
kprintf("rflags: %016x ds: %04x es: %04x fs: %04x gs: %04x\n",
|
|
|
|
tf->rflags, read_ds(), read_es(), read_fs(), read_gs());
|
|
|
|
kprintf("rax: %016llx rbx: %016llx rcx: %016llx\n",
|
|
|
|
tf->rax, tf->rbx, tf->rcx);
|
|
|
|
kprintf("rdx: %016llx rsi: %016llx rdi: %016llx\n",
|
|
|
|
tf->rdx, tf->rsi, tf->rdi);
|
|
|
|
kprintf("rbp: %016llx r8: %016llx r9: %016llx\n",
|
|
|
|
tf->rbp, tf->r8, tf->r9);
|
|
|
|
kprintf("r10: %016llx r11: %016llx r12: %016llx\n",
|
|
|
|
tf->r10, tf->r11, tf->r12);
|
|
|
|
kprintf("r13: %016llx r14: %016llx r15: %016llx\n",
|
|
|
|
tf->r13, tf->r14, tf->r15);
|
2014-07-13 20:07:19 +00:00
|
|
|
}
|
|
|
|
|