From owner-svn-src-head@FreeBSD.ORG Wed Jan 22 21:20:09 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 34E95DB6; Wed, 22 Jan 2014 21:20:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 06ECA14A5; Wed, 22 Jan 2014 21:20:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0MLK8dZ067610; Wed, 22 Jan 2014 21:20:08 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0MLK8lG067607; Wed, 22 Jan 2014 21:20:08 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201401222120.s0MLK8lG067607@svn.freebsd.org> From: Warner Losh Date: Wed, 22 Jan 2014 21:20:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261038 - in head/sys: conf kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jan 2014 21:20:09 -0000 Author: imp Date: Wed Jan 22 21:20:08 2014 New Revision: 261038 URL: http://svnweb.freebsd.org/changeset/base/261038 Log: 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... Modified: head/sys/conf/options head/sys/kern/subr_prf.c head/sys/sys/systm.h Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Wed Jan 22 19:57:11 2014 (r261037) +++ head/sys/conf/options Wed Jan 22 21:20:08 2014 (r261038) @@ -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 Modified: head/sys/kern/subr_prf.c ============================================================================== --- head/sys/kern/subr_prf.c Wed Jan 22 19:57:11 2014 (r261037) +++ head/sys/kern/subr_prf.c Wed Jan 22 21:20:08 2014 (r261038) @@ -1137,3 +1137,25 @@ hexdump(const void *ptr, int length, con } } +#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 Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Wed Jan 22 19:57:11 2014 (r261037) +++ head/sys/sys/systm.h Wed Jan 22 21:20:08 2014 (r261038) @@ -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);