# HG changeset patch # Parent bd7329d84fc47ba7d0027e88ce417b6d39fd10ce diff -r bd7329d84fc4 -r 79717e0173a8 sys/conf/NOTES --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -445,8 +445,17 @@ options DEBUG_MEMGUARD # options DEBUG_REDZONE # +# EARLY_PRINTF enables support for calling a special printf (eprintf) +# very early in the kernel (before cn_init() has been called). This +# should only be used for debugging purposes early in boot. Normally, +# it is not defined. It is commented out here because this feature +# isn't generally available. And the required eputc() isn't defined. +# +#options EARLY_PRINTF + +# # KTRACE enables the system-call tracing facility ktrace(2). To be more # SMP-friendly, KTRACE uses a worker thread to process most trace events # asynchronously to the thread generating the event. This requires a # pre-allocated store of objects representing trace events. The diff -r bd7329d84fc4 -r 79717e0173a8 sys/conf/options --- a/sys/conf/options +++ b/sys/conf/options @@ -61,8 +61,9 @@ KDB opt_global.h KDB_TRACE opt_kdb.h KDB_UNATTENDED opt_kdb.h KLD_DEBUG opt_kld.h SYSCTL_DEBUG opt_sysctl.h +EARLY_PRINTF opt_global.h TEXTDUMP_PREFERRED opt_ddb.h TEXTDUMP_VERBOSE opt_ddb.h # Miscellaneous options. diff -r bd7329d84fc4 -r 79717e0173a8 sys/kern/subr_prf.c --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -1136,4 +1136,26 @@ hexdump(const void *ptr, int length, con printf("\n"); } } +#ifdef EARLY_PRINTF +/* + * Support for calling an alternate printf early in boot (like before + * cn_init() can be called). Platforms need to define eputc that want + * to use this. + */ +static void +early_putc_func(int ch, void *arg __unused) +{ + eputc(ch); +} + +void +eprintf(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + kvprintf(fmt, early_putc_func, NULL, 10, ap); + va_end(ap); +} +#endif diff -r bd7329d84fc4 -r 79717e0173a8 sys/sys/systm.h --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -191,8 +191,12 @@ void critical_exit(void); void init_param1(void); void init_param2(long physpages); void init_static_kenv(char *, size_t); void tablefull(const char *); +#ifdef EARLY_PRINTF +void eprintf(const char *, ...) __printflike(1, 2); +void eputc(int ch); +#endif int kvprintf(char const *, void (*)(int, void*), void *, int, __va_list) __printflike(1, 0); void log(int, const char *, ...) __printflike(2, 3); void log_console(struct uio *);