From owner-svn-src-all@FreeBSD.ORG Thu May 15 21:41:33 2014 Return-Path: Delivered-To: svn-src-all@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 C911C4B3; Thu, 15 May 2014 21:41:33 +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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A8AAA26C6; Thu, 15 May 2014 21:41:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4FLfXa2023035; Thu, 15 May 2014 21:41:33 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4FLfWVI023030; Thu, 15 May 2014 21:41:32 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201405152141.s4FLfWVI023030@svn.freebsd.org> From: Ian Lepore Date: Thu, 15 May 2014 21:41:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266197 - in stable/10/sys: arm/arm arm/at91 kern sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 May 2014 21:41:34 -0000 Author: ian Date: Thu May 15 21:41:32 2014 New Revision: 266197 URL: http://svnweb.freebsd.org/changeset/base/266197 Log: MFC r261786, r261789 Rework the EARLY_PRINTF mechanism. Instead of defining a special eprintf() routine, now a platform can provide a pointer to an early_putc() routine which is used instead of cn_putc(). Control can be handed off from early printf support to standard console support by NULLing out the pointer during standard console init. Convert two while(1); statements into proper panics. Modified: stable/10/sys/arm/arm/machdep.c stable/10/sys/arm/at91/uart_dev_at91usart.c stable/10/sys/kern/kern_cons.c stable/10/sys/kern/subr_prf.c stable/10/sys/sys/systm.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/arm/machdep.c ============================================================================== --- stable/10/sys/arm/arm/machdep.c Thu May 15 21:21:47 2014 (r266196) +++ stable/10/sys/arm/arm/machdep.c Thu May 15 21:41:32 2014 (r266197) @@ -1056,10 +1056,10 @@ initarm(struct arm_boot_params *abp) #endif if (OF_install(OFW_FDT, 0) == FALSE) - while (1); + panic("Cannot install FDT"); if (OF_init((void *)dtbp) != 0) - while (1); + panic("OF_init failed with the found device tree"); /* Grab physical memory regions information from device tree. */ if (fdt_get_mem_regions(mem_regions, &mem_regions_sz, &memsize) != 0) Modified: stable/10/sys/arm/at91/uart_dev_at91usart.c ============================================================================== --- stable/10/sys/arm/at91/uart_dev_at91usart.c Thu May 15 21:21:47 2014 (r266196) +++ stable/10/sys/arm/at91/uart_dev_at91usart.c Thu May 15 21:41:32 2014 (r266197) @@ -228,6 +228,27 @@ static struct uart_ops at91_usart_ops = .getc = at91_usart_getc, }; +#ifdef EARLY_PRINTF +/* + * Early printf support. This assumes that we have the SoC "system" devices + * mapped into AT91_BASE. To use this before we adjust the boostrap tables, + * you'll need to define SOCDEV_VA to be 0xdc000000 and SOCDEV_PA to be + * 0xfc000000 in your config file where you define EARLY_PRINTF + */ +volatile uint32_t *at91_dbgu = (volatile uint32_t *)(AT91_BASE + AT91_DBGU0); + +static void +eputc(int c) +{ + + while (!(at91_dbgu[USART_CSR / 4] & USART_CSR_TXRDY)) + continue; + at91_dbgu[USART_THR / 4] = c; +} + +early_putc_t * early_putc = eputc; +#endif + static int at91_usart_probe(struct uart_bas *bas) { @@ -244,6 +265,22 @@ at91_usart_init(struct uart_bas *bas, in int parity) { +#ifdef EARLY_PRINTF + if (early_putc != NULL) { + printf("Early printf yielding control to the real console.\n"); + early_putc = NULL; + } +#endif + + /* + * This routine is called multiple times, sometimes right after writing + * some output, and the last byte is still shifting out. If that's the + * case delay briefly before resetting, but don't loop on TXRDY because + * we don't want to hang here forever if the hardware is in a bad state. + */ + if (!(RD4(bas, USART_CSR) & USART_CSR_TXRDY)) + DELAY(1000); + at91_usart_param(bas, baudrate, databits, stopbits, parity); /* Reset the rx and tx buffers and turn on rx and tx */ @@ -276,28 +313,6 @@ at91_usart_putc(struct uart_bas *bas, in WR4(bas, USART_THR, c); } -#ifdef EARLY_PRINTF -/* - * Early printf support. This assumes that we have the SoC "system" devices - * mapped into AT91_BASE. To use this before we adjust the boostrap tables, - * You'll need to define SOCDEV_VA to be 0xdc000000 and SOCDEV_PA to be - * 0xfc000000 in your config file where you define EARLY_PRINTF - */ -volatile uint32_t *at91_dbgu = (volatile uint32_t *)(AT91_BASE + AT91_DBGU0); - -void -eputc(int c) -{ - - if (c == '\n') - eputc('\r'); - - while (!(at91_dbgu[USART_CSR / 4] & USART_CSR_TXRDY)) - continue; - at91_dbgu[USART_THR / 4] = c; -} -#endif - /* * Check for a character available. */ Modified: stable/10/sys/kern/kern_cons.c ============================================================================== --- stable/10/sys/kern/kern_cons.c Thu May 15 21:21:47 2014 (r266196) +++ stable/10/sys/kern/kern_cons.c Thu May 15 21:41:32 2014 (r266197) @@ -464,6 +464,15 @@ cnputc(int c) struct consdev *cn; char *cp; +#ifdef EARLY_PRINTF + if (early_putc != NULL) { + if (c == '\n') + early_putc('\r'); + early_putc(c); + return; + } +#endif + if (cn_mute || c == '\0') return; STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { Modified: stable/10/sys/kern/subr_prf.c ============================================================================== --- stable/10/sys/kern/subr_prf.c Thu May 15 21:21:47 2014 (r266196) +++ stable/10/sys/kern/subr_prf.c Thu May 15 21:41:32 2014 (r266197) @@ -1122,25 +1122,3 @@ 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 Modified: stable/10/sys/sys/systm.h ============================================================================== --- stable/10/sys/sys/systm.h Thu May 15 21:21:47 2014 (r266196) +++ stable/10/sys/sys/systm.h Thu May 15 21:41:32 2014 (r266197) @@ -197,8 +197,8 @@ 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); +typedef void early_putc_t(int ch); +extern early_putc_t *early_putc; #endif int kvprintf(char const *, void (*)(int, void*), void *, int, __va_list) __printflike(1, 0);