Index: head/sys/mips/broadcom/bcm_machdep.c =================================================================== --- head/sys/mips/broadcom/bcm_machdep.c +++ head/sys/mips/broadcom/bcm_machdep.c @@ -198,6 +198,21 @@ /* 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 @@ 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 */ Index: head/sys/mips/conf/BCM =================================================================== --- head/sys/mips/conf/BCM +++ head/sys/mips/conf/BCM @@ -52,6 +52,7 @@ #options BHND_LOGLEVEL=BHND_DEBUG_LEVEL #options BUS_DEBUG #makeoptions BUS_DEBUG +options EARLY_PRINTF #options VERBOSE_SYSINIT #makeoptions VERBOSE_SYSINIT Index: head/sys/mips/conf/SENTRY5 =================================================================== --- head/sys/mips/conf/SENTRY5 +++ head/sys/mips/conf/SENTRY5 @@ -31,9 +31,8 @@ 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 BUS_DEBUG #makeoptions BUS_DEBUG +options EARLY_PRINTF device bhnd device siba