diff options
author | Ian Moffett <ian@osmora.org> | 2024-05-17 13:22:23 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-05-17 13:22:23 -0400 |
commit | e2f7c99d07eedc929e9a19de6477a15f4b0963b8 (patch) | |
tree | 2ce5bf7b3f2bac24cdc2f2968e0c89b14e554b07 /sys/arch | |
parent | d164ed5baac60f21e0435ae49d20009ee8cd6dc1 (diff) |
kernel/amd64: machdep: Beep based on kernel config
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 47 |
1 files changed, 29 insertions, 18 deletions
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(); } |