summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-07-10 19:39:54 +0200
committerRichard Braun <rbraun@sceen.net>2018-07-10 19:39:54 +0200
commit7cab594590002ff3737629b76083a298616b665a (patch)
treec2134a28fa7f576485fae373bebcd2bdc1141fc3
parent2670af26286799d9d46ab83c07fd991b942d7d49 (diff)
kern/panic: remove initialization operation
Maintaining correct dependencies for the panic function is too complicated. It may be used very early, but would depend on the console, which is normally available quite late during initialization. Instead, the behavior of panic is now "best effort", i.e. if called at a time where it works, good, otherwise, the behavior is undefined, but should result in a freeze or a reset most of the time.
-rw-r--r--arch/x86/machine/biosmem.c1
-rw-r--r--arch/x86/machine/boot.c1
-rw-r--r--arch/x86/machine/cpu.c4
-rw-r--r--kern/intr.c1
-rw-r--r--kern/log.c1
-rw-r--r--kern/panic.c11
-rw-r--r--kern/panic.h13
-rw-r--r--kern/sref.c1
-rw-r--r--kern/work.c1
9 files changed, 6 insertions, 28 deletions
diff --git a/arch/x86/machine/biosmem.c b/arch/x86/machine/biosmem.c
index 8e2108c7..d9b577b1 100644
--- a/arch/x86/machine/biosmem.c
+++ b/arch/x86/machine/biosmem.c
@@ -973,6 +973,5 @@ biosmem_free_usable(void)
INIT_OP_DEFINE(biosmem_free_usable,
INIT_OP_DEP(boot_save_data, true),
- INIT_OP_DEP(panic_setup, true),
INIT_OP_DEP(log_setup, true),
INIT_OP_DEP(vm_page_setup, true));
diff --git a/arch/x86/machine/boot.c b/arch/x86/machine/boot.c
index f62ad09b..0ffbe8d1 100644
--- a/arch/x86/machine/boot.c
+++ b/arch/x86/machine/boot.c
@@ -492,7 +492,6 @@ boot_save_data(void)
INIT_OP_DEFINE(boot_save_data,
INIT_OP_DEP(kmem_setup, true),
- INIT_OP_DEP(panic_setup, true),
INIT_OP_DEP(vm_kmem_setup, true));
void __init
diff --git a/arch/x86/machine/cpu.c b/arch/x86/machine/cpu.c
index 520faecc..10e9a89b 100644
--- a/arch/x86/machine/cpu.c
+++ b/arch/x86/machine/cpu.c
@@ -1184,10 +1184,8 @@ cpu_check_bsp(void)
return 0;
}
-// TODO Remove panic_setup
INIT_OP_DEFINE(cpu_check_bsp,
- INIT_OP_DEP(cpu_setup, true),
- INIT_OP_DEP(panic_setup, true));
+ INIT_OP_DEP(cpu_setup, true));
void *
cpu_get_intr_stack_ptr(void)
diff --git a/kern/intr.c b/kern/intr.c
index ac2cea6f..a6034d35 100644
--- a/kern/intr.c
+++ b/kern/intr.c
@@ -336,7 +336,6 @@ intr_bootstrap(void)
INIT_OP_DEFINE(intr_bootstrap,
INIT_OP_DEP(kmem_setup, true),
INIT_OP_DEP(log_setup, true),
- INIT_OP_DEP(panic_setup, true),
INIT_OP_DEP(spinlock_setup, true),
INIT_OP_DEP(thread_bootstrap, true));
diff --git a/kern/log.c b/kern/log.c
index 04afbcd8..55578955 100644
--- a/kern/log.c
+++ b/kern/log.c
@@ -467,7 +467,6 @@ log_start(void)
INIT_OP_DEFINE(log_start,
INIT_OP_DEP(log_setup, true),
- INIT_OP_DEP(panic_setup, true),
INIT_OP_DEP(thread_setup, true));
static void
diff --git a/kern/panic.c b/kern/panic.c
index bd1f6658..9e7d1d53 100644
--- a/kern/panic.c
+++ b/kern/panic.c
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <kern/atomic.h>
-#include <kern/init.h>
#include <kern/panic.h>
#include <machine/cpu.h>
#include <machine/strace.h>
@@ -55,13 +54,3 @@ panic(const char *format, ...)
* Never reached.
*/
}
-
-static int __init
-panic_setup(void)
-{
- return 0;
-}
-
-INIT_OP_DEFINE(panic_setup,
- INIT_OP_DEP(cpu_setup, true),
- INIT_OP_DEP(printf_setup, true));
diff --git a/kern/panic.h b/kern/panic.h
index af858c74..2a25eb01 100644
--- a/kern/panic.h
+++ b/kern/panic.h
@@ -20,18 +20,15 @@
#include <stdnoreturn.h>
-#include <kern/init.h>
-
/*
* Print the given message and halt the system immediately.
+ *
+ * If in doubt whether to call this function or not because of dependency
+ * issues, users are encouraged to call this function, even if it results
+ * in undefined behavior, because it should most likely cause a freeze or
+ * reset, which is considered better than a silent failure.
*/
noreturn void panic(const char *format, ...)
__attribute__((format(printf, 1, 2)));
-/*
- * This init operation provides :
- * - module fully initialized
- */
-INIT_OP_DECLARE(panic_setup);
-
#endif /* KERN_PANIC_H */
diff --git a/kern/sref.c b/kern/sref.c
index 3539e46d..589b00c1 100644
--- a/kern/sref.c
+++ b/kern/sref.c
@@ -880,7 +880,6 @@ INIT_OP_DEFINE(sref_setup,
INIT_OP_DEP(cpu_mp_probe, true),
INIT_OP_DEP(cpumap_setup, true),
INIT_OP_DEP(log_setup, true),
- INIT_OP_DEP(panic_setup, true),
INIT_OP_DEP(sref_bootstrap, true),
INIT_OP_DEP(thread_setup, true));
diff --git a/kern/work.c b/kern/work.c
index 6151ba48..ee35c610 100644
--- a/kern/work.c
+++ b/kern/work.c
@@ -525,7 +525,6 @@ INIT_OP_DEFINE(work_setup,
INIT_OP_DEP(cpumap_setup, true),
INIT_OP_DEP(kmem_setup, true),
INIT_OP_DEP(log_setup, true),
- INIT_OP_DEP(panic_setup, true),
INIT_OP_DEP(spinlock_setup, true),
INIT_OP_DEP(syscnt_setup, true),
INIT_OP_DEP(thread_setup, true),