svn commit: r304314 - in head/sys/mips: broadcom conf

Landon J. Fuller landonf at FreeBSD.org
Wed Aug 17 20:24:15 UTC 2016


Author: landonf
Date: Wed Aug 17 20:24:14 2016
New Revision: 304314
URL: https://svnweb.freebsd.org/changeset/base/304314

Log:
  mips/broadcom: Implement CFE-based EARLY_PRINTF support.
  
  This adds support for EARLY_PRINTF via the CFE console; the aim is to
  provide a fix for the otherwise cyclic dependency between PMU discovery
  and console printf/DELAY:
  
  - We need to parse the bhnd(4) core table to determine the address (and
    type) of the PMU/PLL registers and calculate the CPU clock frequency.
  - The core table parsing code will emit a printf() if a parse error is
    hit.
  - Safely calling printf() without EARLY_PRINTF requires a working
    DELAY+cninit, which means we need the PMU.
  
  Errors in core table parsing shouldn't happen, but lack of EARLY_PRINTF
  makes debugging more difficult.
  
  Approved by:	adrian (mentor)
  Differential Revision:	https://reviews.freebsd.org/D7498

Modified:
  head/sys/mips/broadcom/bcm_machdep.c
  head/sys/mips/conf/BCM
  head/sys/mips/conf/SENTRY5

Modified: head/sys/mips/broadcom/bcm_machdep.c
==============================================================================
--- head/sys/mips/broadcom/bcm_machdep.c	Wed Aug 17 20:21:33 2016	(r304313)
+++ head/sys/mips/broadcom/bcm_machdep.c	Wed Aug 17 20:24:14 2016	(r304314)
@@ -198,6 +198,21 @@ platform_start(__register_t a0, __regist
 	/* Initialize pcpu stuff */
 	mips_pcpu0_init();
 
+#ifdef CFE
+	/*
+	 * Initialize CFE firmware trampolines. This must be done
+	 * before any CFE APIs are called, including writing
+	 * to the CFE console.
+	 *
+	 * CFE passes the following values in registers:
+	 * a0: firmware handle
+	 * a2: firmware entry point
+	 * a3: entry point seal
+	 */
+	if (a3 == CFE_EPTSEAL)
+		cfe_init(a0, a2);
+#endif
+
 #if 0
 	/*
 	 * Probe the Broadcom on-chip PLL clock registers
@@ -234,23 +249,40 @@ platform_start(__register_t a0, __regist
 
 	mips_timer_early_init(platform_counter_freq);
 
-#ifdef CFE
-	/*
-	 * Initialize CFE firmware trampolines before
-	 * we initialize the low-level console.
-	 *
-	 * CFE passes the following values in registers:
-	 * a0: firmware handle
-	 * a2: firmware entry point
-	 * a3: entry point seal
-	 */
-	if (a3 == CFE_EPTSEAL)
-		cfe_init(a0, a2);
-#endif
-
 	cninit();
 
 	mips_init();
 
 	mips_timer_init_params(platform_counter_freq, socinfo->double_count);
 }
+
+/*
+ * CFE-based EARLY_PRINTF support. To use, add the following to the kernel
+ * config:
+ *	option EARLY_PRINTF
+ *	option CFE
+ *	device cfe
+ */
+#if defined(EARLY_PRINTF) && defined(CFE)
+static void
+bcm_cfe_eputc(int c)
+{
+	static int	fd = -1;
+	unsigned char	ch;
+
+	ch = (unsigned char) c;
+
+	if (fd == -1) {
+		if ((fd = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE)) < 0)
+			return;
+	}
+
+	if (ch == '\n')
+		early_putc('\r');
+
+	while ((cfe_write(fd, &ch, 1)) == 0)
+		continue;
+}
+
+early_putc_t *early_putc = bcm_cfe_eputc;
+#endif /* EARLY_PRINTF */

Modified: head/sys/mips/conf/BCM
==============================================================================
--- head/sys/mips/conf/BCM	Wed Aug 17 20:21:33 2016	(r304313)
+++ head/sys/mips/conf/BCM	Wed Aug 17 20:24:14 2016	(r304314)
@@ -52,6 +52,7 @@ options 	INVARIANT_SUPPORT
 #options	BHND_LOGLEVEL=BHND_DEBUG_LEVEL
 #options 	BUS_DEBUG
 #makeoptions	BUS_DEBUG
+options 	EARLY_PRINTF
 #options	VERBOSE_SYSINIT
 #makeoptions	VERBOSE_SYSINIT
 

Modified: head/sys/mips/conf/SENTRY5
==============================================================================
--- head/sys/mips/conf/SENTRY5	Wed Aug 17 20:21:33 2016	(r304313)
+++ head/sys/mips/conf/SENTRY5	Wed Aug 17 20:24:14 2016	(r304314)
@@ -31,9 +31,8 @@ makeoptions	TRAMPLOADADDR=0x807963c0
 hints		"SENTRY5.hints"
 include		"../broadcom/std.broadcom"
 
-# sentry5 normally ships with cfe firmware; use the console for now
+# sentry5 normally ships with cfe firmware
 options 	CFE
-options 	CFE_CONSOLE
 options 	ALT_BREAK_TO_DEBUGGER
 device		cfe
 
@@ -57,6 +56,7 @@ options 	INVARIANT_SUPPORT
 
 #options 	BUS_DEBUG
 #makeoptions	BUS_DEBUG
+options 	EARLY_PRINTF
 
 device		bhnd
 device		siba


More information about the svn-src-all mailing list