diff options
-rw-r--r-- | sys/include/sys/cdefs.h | 7 | ||||
-rw-r--r-- | sys/kern/init_main.c | 11 |
2 files changed, 10 insertions, 8 deletions
diff --git a/sys/include/sys/cdefs.h b/sys/include/sys/cdefs.h index 59c81d4..da78510 100644 --- a/sys/include/sys/cdefs.h +++ b/sys/include/sys/cdefs.h @@ -154,6 +154,13 @@ #define __MODULE_NAME(name) \ __used static const char *__THIS_MODULE = name +/* + * Attempts to call a __weak function. Does nothing + * if routine not implemented. + */ +#define __TRY_CALL(routine, ...) \ + if (routine != NULL) routine(__VA_ARGS__) + #else /* diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index a5d7577..2666b5e 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -76,7 +76,7 @@ main(void) { struct cpu_info *ci; - pre_init(); + __TRY_CALL(pre_init); tty_init(); syslog_init(); PRINT_LOGO(); @@ -86,18 +86,13 @@ main(void) HYRA_BUILDBRANCH); acpi_init(); - - if (chips_init == NULL) { - chips_init(); - } + __TRY_CALL(chips_init); processor_init(); list_timers(); ci = this_cpu(); - if (ap_bootstrap != NULL) { - ap_bootstrap(ci); - } + __TRY_CALL(ap_bootstrap, ci); sched_init_processor(ci); __builtin_unreachable(); |