summaryrefslogtreecommitdiff
path: root/stage3/shell.c
diff options
context:
space:
mode:
authorLizzy Fleckenstein <lizzy@vlhl.dev>2023-12-21 08:56:51 +0100
committerLizzy Fleckenstein <lizzy@vlhl.dev>2023-12-21 08:56:51 +0100
commit5b61e495721fe414e43cc52298987f02c9bce24c (patch)
treec3249ee6d0129e40c2f2310dd7b187804aed37c1 /stage3/shell.c
parentb62ea8cffcf257f64215bd2c480dbd8990814f42 (diff)
downloadcuddles-5b61e495721fe414e43cc52298987f02c9bce24c.tar.xz
debug: add register watchdog
to detect potential changes that ISRs might make to registers
Diffstat (limited to 'stage3/shell.c')
-rw-r--r--stage3/shell.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/stage3/shell.c b/stage3/shell.c
index 7341eea..5b79e58 100644
--- a/stage3/shell.c
+++ b/stage3/shell.c
@@ -267,6 +267,40 @@ void cmd_cheese(str arg)
free(texture);
}
+struct __attribute__((packed)) {
+ u64 reg;
+ u64 to;
+ u64 from;
+} watchdog_err;
+
+void watchdog();
+
+static void cmd_watchdog(str arg)
+{
+ (void) arg;
+
+ str regs[] = {
+ S("rax"), S("rbx"),
+ S("rcx"), S("rdx"),
+ S("rdi"), S("rsi"),
+ S("rbp"), S("rsp"),
+ S("r8"), S("r9"),
+ S("r10"), S("r11"),
+ S("r12"), S("r13"),
+ S("r14"), S("r15"),
+ };
+
+ watchdog();
+
+ print(S("watchdog: register "));
+ print(regs[watchdog_err.reg]);
+ print(S(" changed from "));
+ print_hex(watchdog_err.from);
+ print(S(" to "));
+ print_hex(watchdog_err.to);
+ print(S("\n"));
+}
+
typedef struct {
str name;
void (*fn)(str arg);
@@ -287,6 +321,7 @@ static command registry[] = {
{ S("ls"), &cmd_ls },
{ S("shutdown"), &cmd_shutdown },
{ S("cheese"), &cmd_cheese },
+ { S("watchdog"), &cmd_watchdog },
};
void shell_run_cmd(str cmd)