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) Index: sys/powerpc/mpc85xx/platform_mpc85xx.c =================================================================== --- sys/powerpc/mpc85xx/platform_mpc85xx.c +++ sys/powerpc/mpc85xx/platform_mpc85xx.c @@ -80,6 +80,9 @@ extern uint32_t *bootinfo; vm_offset_t ccsrbar_va; +void mpc85xx_early_putc(int c); +int mpc85xx_early_getc(void); + static int cpu, maxcpu; static int mpc85xx_probe(platform_t); @@ -139,6 +142,7 @@ uint64_t ccsrbar, ccsrsize; int i, law_max, tgt; + if ((cpus = OF_finddevice("/cpus")) != -1) { for (maxcpu = 0, child = OF_child(cpus); child != 0; child = OF_peer(child), maxcpu++) @@ -567,3 +571,33 @@ return (0); } + +#if defined(EARLY_PRINTF) +void +mpc85xx_early_putc(int c) +{ + int limit; + static vm_offset_t ccsr = 0xbffff000; + + 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 = 0xbffff000; + + while ((*(volatile uint8_t *)(ccsr + 0x505) & 0x1) == 0) + DELAY(100); + return *(volatile uint8_t *)(ccsr + 0x500); +} + +early_putc = mpc85xx_early_putc; +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);