svn commit: r266197 - in stable/10/sys: arm/arm arm/at91 kern sys

Ian Lepore ian at FreeBSD.org
Thu May 15 21:41:34 UTC 2014


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);


More information about the svn-src-all mailing list