From e2f7c99d07eedc929e9a19de6477a15f4b0963b8 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 17 May 2024 13:22:23 -0400 Subject: kernel/amd64: machdep: Beep based on kernel config Signed-off-by: Ian Moffett --- sys/arch/amd64/amd64/machdep.c | 47 ++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'sys/arch/amd64') diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 0f04e7a..6a24232 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -63,6 +63,10 @@ __KERNEL_META("$Hyra$: machdep.c, Ian Marco Moffett, " #define INIT_FLAG_IOAPIC 0x00000001U #define INIT_FLAG_ACPI 0x00000002U +/* Set by kconf(1) */ +#define PANIC_BEEP_HZ __PANIC_BEEP_HZ +#define PANIC_BEEP __PANIC_BEEP + void syscall_isr(void); __attr(interrupt) @@ -158,6 +162,29 @@ backtrace(void) } } +static void +panic_beep(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; + + /* + * If we can use the timer, beep twice to + * alert the user. + */ + if (has_timer) { + for (int i = 0; i < 2; ++i) { + pcspkr_tone(PANIC_BEEP_HZ, 200); + tmr.msleep(100); + } + } +} + void processor_halt(void) { @@ -226,26 +253,10 @@ intr_unmask(void) 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); - } - } + if (PANIC_BEEP) + panic_beep(); processor_halt(); } -- cgit v1.2.3