Implement generic support for early printf. Thought I can't find the

paper trail now, this patch is similar to one posted for one of the
preliminary versions of a new armv6 port. I took them and made them
more generic. Option not enabled by default since each board/port has
to provide its own eputc, and possibly do other things as well...
This commit is contained in:
Warner Losh 2014-01-22 21:20:08 +00:00
parent de78d5d8fd
commit 26fbe13c56
3 changed files with 27 additions and 0 deletions

View File

@ -62,6 +62,7 @@ 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

View File

@ -1137,3 +1137,25 @@ hexdump(const void *ptr, int length, const char *hdr, int flags)
}
}
#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

View File

@ -196,6 +196,10 @@ 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);