Index: sys/conf/options.powerpc =================================================================== --- sys/conf/options.powerpc +++ sys/conf/options.powerpc @@ -12,6 +12,8 @@ FPU_EMU +EARLY_UART_PA opt_global.h +EARLY_UART_VA opt_global.h COMPAT_FREEBSD32 opt_compat.h GFB_DEBUG opt_gfb.h Index: sys/kern/kern_cons.c =================================================================== --- sys/kern/kern_cons.c +++ sys/kern/kern_cons.c @@ -162,6 +162,7 @@ * Release early console. */ early_putc = NULL; + early_getc = NULL; #endif } @@ -389,7 +390,14 @@ cngetc(void) { int c; - +#ifdef EARLY_PRINTF + if (early_getc != NULL) { + c = early_getc(); + if (c == '\r') + c = '\n'; + return c; + } +#endif if (cn_mute) return (-1); while ((c = cncheckc()) == -1) @@ -405,7 +413,14 @@ struct cn_device *cnd; struct consdev *cn; int c; - +#ifdef EARLY_PRINTF + if (early_getc != NULL) { + c = early_getc(); + if (c == '\r') + c = '\n'; + return c; + } +#endif if (cn_mute) return (-1); STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { Index: sys/powerpc/booke/pmap.c =================================================================== --- sys/powerpc/booke/pmap.c +++ sys/powerpc/booke/pmap.c @@ -3415,6 +3415,10 @@ tsz = (mas1 & MAS1_TSIZE_MASK) >> MAS1_TSIZE_SHIFT; kernsize += (tsz > 0) ? tsize2size(tsz) : 0; +#if defined (EARLY_PRINTF) + tlb1_set_entry(EARLY_UART_VA, EARLY_UART_PA, + PAGE_SIZE, _TLB_ENTRY_SHARED | _TLB_ENTRY_IO); +#endif /* Setup TLB miss defaults */ set_mas4_defaults(); } Index: sys/powerpc/mpc85xx/platform_mpc85xx.c =================================================================== --- sys/powerpc/mpc85xx/platform_mpc85xx.c +++ sys/powerpc/mpc85xx/platform_mpc85xx.c @@ -80,6 +80,11 @@ extern uint32_t *bootinfo; vm_offset_t ccsrbar_va; +#if defined(EARLY_PRINTF) +void mpc85xx_early_putc(int c); +int mpc85xx_early_getc(void); +#endif + static int cpu, maxcpu; static int mpc85xx_probe(platform_t); @@ -567,3 +572,33 @@ return (0); } + +#if defined(EARLY_PRINTF) +void +mpc85xx_early_putc(int c) +{ + int limit; + static vm_offset_t ccsr = EARLY_UART_VA; + + limit = 250000; + while ((*(volatile uint8_t*)(ccsr + 0x505)& 0x20) == 0 && --limit) + DELAY(4); + *(volatile uint8_t *)(ccsr + 0x500) = c; + limit = 250000; + while ((*(volatile uint8_t *)(ccsr + 0x505) & 0x40) == 0 && --limit) + DELAY(4); +} + +int +mpc85xx_early_getc(void) +{ + static vm_offset_t ccsr = EARLY_UART_VA; + + while ((*(volatile uint8_t *)(ccsr + 0x505) & 0x1) == 0) + DELAY(100); + return *(volatile uint8_t *)(ccsr + 0x500); +} + +early_putc_t *early_putc = mpc85xx_early_putc; +early_getc_t *early_getc = mpc85xx_early_getc; +#endif Index: sys/sys/systm.h =================================================================== --- sys/sys/systm.h +++ sys/sys/systm.h @@ -208,6 +208,8 @@ #ifdef EARLY_PRINTF typedef void early_putc_t(int ch); extern early_putc_t *early_putc; +typedef int early_getc_t(void); +extern early_getc_t *early_getc; #endif int kvprintf(char const *, void (*)(int, void*), void *, int, __va_list) __printflike(1, 0);