From 1d8a4028ca290cd0a99164038bd5a034cf052afa Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 16 Nov 2025 12:59:49 -0500 Subject: kern: panic: Deprecate mu_panic_preamble() This commit deprecates mu_panic_preamble() in favor of the mu_spinlock_acq() function Signed-off-by: Ian Moffett --- sys/arch/amd64/os/os_panic.c | 19 ------------------- sys/inc/mu/panic.h | 6 ------ sys/kern/kern_panic.c | 5 ++++- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/sys/arch/amd64/os/os_panic.c b/sys/arch/amd64/os/os_panic.c index cd55aac..d6aa95e 100644 --- a/sys/arch/amd64/os/os_panic.c +++ b/sys/arch/amd64/os/os_panic.c @@ -30,25 +30,6 @@ #include #include -void -mu_panic_preamble(void) -{ - static uint64_t sync = 0; - - asm volatile( - "cli\n\t" - "mov $1, %%rax\n\t" - "1:\n\t" - " pause\n\t" - " xchg %0, %%rax\n\t" - " or %%rax, %%rax\n\t" - " jnz 1b\n" - : - : "m" (sync) - : "memory" - ); -} - void mu_panic_hcf(void) { diff --git a/sys/inc/mu/panic.h b/sys/inc/mu/panic.h index b592fcc..257c469 100644 --- a/sys/inc/mu/panic.h +++ b/sys/inc/mu/panic.h @@ -32,12 +32,6 @@ #include -/* - * Called as soon as a panic is invoked, prevents other - * processors from continuing and disables interrupts - */ -void mu_panic_preamble(void); - /* * Used internally by the panic function and implemented * per architecture to bring the system to a halt. diff --git a/sys/kern/kern_panic.c b/sys/kern/kern_panic.c index d6beccb..1ac9c64 100644 --- a/sys/kern/kern_panic.c +++ b/sys/kern/kern_panic.c @@ -30,10 +30,13 @@ #include #include #include +#include #include #include #include +static volatile size_t __sync = 0; + void panic(const char *fmt, ...) { @@ -41,7 +44,7 @@ panic(const char *fmt, ...) static char buf[256]; static va_list ap; - mu_panic_preamble(); + mu_spinlock_acq(&__sync, SPINLOCK_INTTOG); va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); -- cgit v1.2.3