diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c index c91c05a3926..954f990a467 100644 --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -161,6 +161,37 @@ SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size, uintptr_t powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *, uint32_t); +#ifdef EARLY_PRINTF +#define POWERPC_EARLYCONS_SZ 8192 + +static char early_console_buffer[POWERPC_EARLYCONS_SZ]; +static int early_console_pos = 0; + +static void +powerpc_earlycons_putc(int c) +{ + if (!early_console_pos) + bzero(&early_console_buffer, POWERPC_EARLYCONS_SZ); + early_console_buffer[early_console_pos] = (char) c; + early_console_pos++; + if (early_console_pos >= POWERPC_EARLYCONS_SZ) { + /* Wrap buffer if overflowed but do not clear again */ + early_console_buffer[0] = '\0'; + early_console_pos = 1; + } +} + +static void +powerpc_earlycons_replay() +{ + for (int i = 0; i < POWERPC_EARLYCONS_SZ ; i++) + cnputc(early_console_buffer[i]); +} + +early_putc_t *early_putc = powerpc_earlycons_putc; + +#endif + long Maxmem = 0; long realmem = 0; @@ -376,6 +407,9 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp, * Initialize the console before printing anything. */ cninit(); +#ifdef EARLY_PRINTF + powerpc_earlycons_replay(); +#endif #ifdef AIM aim_cpu_init(toc); diff --git a/sys/powerpc/conf/GENERIC64 b/sys/powerpc/conf/GENERIC64 index 409062047b2..fe5077ddd01 100644 --- a/sys/powerpc/conf/GENERIC64 +++ b/sys/powerpc/conf/GENERIC64 @@ -26,6 +26,8 @@ machine powerpc powerpc64 makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols makeoptions WITH_CTF=1 +options EARLY_PRINTF + # Platform support options POWERMAC #NewWorld Apple PowerMacs options PS3 #Sony Playstation 3