From 7895aaff402a021a1b04645ca8d251f760e5662e Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 16:35:51 -0500 Subject: kernel/amd64: trap: Parse TRAP_PAGEFLT error code Signed-off-by: Ian Moffett --- sys/arch/amd64/amd64/trap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index cbcf730..b73048d 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -49,6 +49,20 @@ static const char *trap_type[] = { static const int TRAP_COUNT = __ARRAY_COUNT(trap_type); +static void +dbg_errcode(struct trapframe *tf) +{ + uint64_t ec = tf->error_code; + + if (tf->trapno == TRAP_PAGEFLT) { + kprintf("bits (pwui): %c%c%c%c\n", + __TEST(ec, __BIT(0)) ? 'p' : '-', + __TEST(ec, __BIT(1)) ? 'w' : '-', + __TEST(ec, __BIT(2)) ? 'u' : '-', + __TEST(ec, __BIT(4)) ? 'i' : '-'); + } +} + static void trap_print(struct trapframe *tf) { @@ -57,6 +71,8 @@ trap_print(struct trapframe *tf) } else { kprintf("** Unknown trap %d **\n", tf->trapno); } + + dbg_errcode(tf); } static void -- cgit v1.2.3