summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/amd64/machdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64/amd64/machdep.c')
-rw-r--r--sys/arch/amd64/amd64/machdep.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index f73d773..4476053 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -31,6 +31,7 @@
#include <sys/cdefs.h>
#include <sys/panic.h>
#include <sys/ksyms.h>
+#include <sys/timer.h>
#include <machine/trap.h>
#include <machine/idt.h>
#include <machine/io.h>
@@ -40,6 +41,7 @@
#include <machine/lapic.h>
#include <machine/tss.h>
#include <machine/spectre.h>
+#include <machine/isa/spkr.h>
#include <machine/cpu.h>
#include <machine/uart.h>
#include <machine/cpuid.h>
@@ -192,7 +194,7 @@ backtrace_addr_to_name(uintptr_t addr, off_t *off)
return NULL;
}
-void
+static void
backtrace(void)
{
uintptr_t *rbp;
@@ -218,6 +220,36 @@ backtrace(void)
}
}
+/*
+ * Called last within panic()
+ */
+void
+machine_panic(void)
+{
+ struct timer tmr = {0};
+ bool has_timer = true;
+
+ if (req_timer(TIMER_GP, &tmr) != TMRR_SUCCESS)
+ has_timer = false;
+ if (tmr.msleep == NULL)
+ has_timer = false;
+
+ backtrace();
+
+ /*
+ * If we can use the timer, beep twice to
+ * alert the user.
+ */
+ if (has_timer) {
+ for (int i = 0; i < 2; ++i) {
+ pcspkr_tone(1050, 200);
+ tmr.msleep(100);
+ }
+ }
+
+ processor_halt();
+}
+
void
cpu_halt_others(void)
{