Index: trunk/CHANGES =================================================================== --- trunk/CHANGES (revision 382) +++ trunk/CHANGES (revision 383) @@ -1,3 +1,4 @@ +- Added Booter message Logging (":/boot-log" ioreg property) - Removed obsolete -f option, use -x instead - Removed -x32 option, use arch=i386 instead - Added automatic SMBusspeed detection for lga1156 core i5/7 cpus Index: trunk/i386/libsaio/console.c =================================================================== --- trunk/i386/libsaio/console.c (revision 382) +++ trunk/i386/libsaio/console.c (revision 383) @@ -52,6 +52,68 @@ bool gVerboseMode; bool gErrors; +/* Kabyl: BooterLog */ +#define BOOTER_LOG_SIZE (64 * 1024) +#define SAFE_LOG_SIZE 80 + +char *msgbuf = 0; +char *cursor = 0; + +struct putc_info { + char * str; + char * last_str; +}; + +static void sputc(int c, struct putc_info * pi) +{ + if (pi->last_str) + if (pi->str == pi->last_str) + { + *(pi->str) = '\0'; + return; + } + *(pi->str)++ = c; +} + +void initBooterLog(void) +{ + msgbuf = malloc(BOOTER_LOG_SIZE); + bzero(msgbuf, BOOTER_LOG_SIZE); + cursor = msgbuf; +} + +void msglog(const char * fmt, ...) +{ + va_list ap; + struct putc_info pi; + + if (!msgbuf) + return; + + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) + return; + + va_start(ap, fmt); + pi.str = cursor; + pi.last_str = 0; + prf(fmt, ap, sputc, &pi); + *pi.str = '\0'; + va_end(ap); + cursor += (pi.str - cursor); +} + +void setupBooterLog(void) +{ + if (!msgbuf) + return; + + Node *node = DT__FindNode("/", false); + if (node) + DT__AddProperty(node, "boot-log", strlen((char *)msgbuf) + 1, msgbuf); +} +/* Kabyl: !BooterLog */ + + /* * write one character to console */ @@ -103,6 +165,23 @@ prf(fmt, ap, putchar, 0); else vprf(fmt, ap); + + { + /* Kabyl: BooterLog */ + struct putc_info pi; + + if (!msgbuf) + return 0; + + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) + return 0; + pi.str = cursor; + pi.last_str = 0; + prf(fmt, ap, sputc, &pi); + *pi.str = '\0'; + cursor += (pi.str - cursor); + } + va_end(ap); return 0; } @@ -111,15 +190,32 @@ { va_list ap; + va_start(ap, fmt); if (gVerboseMode) { - va_start(ap, fmt); if (bootArgs->Video.v_display == VGA_TEXT_MODE) prf(fmt, ap, putchar, 0); else vprf(fmt, ap); - va_end(ap); } + + { + /* Kabyl: BooterLog */ + struct putc_info pi; + + if (!msgbuf) + return 0; + + if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE))) + return 0; + pi.str = cursor; + pi.last_str = 0; + prf(fmt, ap, sputc, &pi); + *pi.str = '\0'; + cursor += (pi.str - cursor); + } + + va_end(ap); return(0); } Index: trunk/i386/libsaio/cpu.c =================================================================== --- trunk/i386/libsaio/cpu.c (revision 382) +++ trunk/i386/libsaio/cpu.c (revision 383) @@ -14,7 +14,7 @@ #if DEBUG_CPU #define DBG(x...) printf(x) #else -#define DBG(x...) +#define DBG(x...) msglog(x) #endif /* @@ -297,7 +297,7 @@ p->CPU.TSCFrequency = tscFrequency; p->CPU.FSBFrequency = fsbFrequency; p->CPU.CPUFrequency = cpuFrequency; -#if DEBUG_CPU + DBG("CPU: Vendor/Model/ExtModel: 0x%x/0x%x/0x%x\n", p->CPU.Vendor, p->CPU.Model, p->CPU.ExtModel); DBG("CPU: Family/ExtFamily: 0x%x/0x%x\n", p->CPU.Family, p->CPU.ExtFamily); DBG("CPU: MaxCoef/CurrCoef: 0x%x/0x%x\n", p->CPU.MaxCoef, p->CPU.CurrCoef); @@ -307,6 +307,7 @@ DBG("CPU: CPUFreq: %dMHz\n", p->CPU.CPUFrequency / 1000000); DBG("CPU: NoCores/NoThreads: %d/%d\n", p->CPU.NoCores, p->CPU.NoThreads); DBG("CPU: Features: 0x%08x\n", p->CPU.Features); +#if DEBUG_CPU pause(); #endif } Index: trunk/i386/libsaio/saio_internal.h =================================================================== --- trunk/i386/libsaio/saio_internal.h (revision 382) +++ trunk/i386/libsaio/saio_internal.h (revision 383) @@ -89,8 +89,11 @@ /* console.c */ extern bool gVerboseMode; extern bool gErrors; +extern void initBooterLog(void); +extern void setupBooterLog(void); extern void putchar(int ch); extern int getchar(void); +extern void msglog(const char * format, ...); extern int printf(const char *format, ...); extern int error(const char *format, ...); extern int verbose(const char *format, ...); Index: trunk/i386/boot2/boot.c =================================================================== --- trunk/i386/boot2/boot.c (revision 382) +++ trunk/i386/boot2/boot.c (revision 383) @@ -193,6 +193,8 @@ else drawBootGraphics(); + setupBooterLog(); + finalizeBootStruct(); // Jump to kernel's entry point. There's no going back now. @@ -249,6 +251,8 @@ // Initialize boot info structure. initKernBootStruct(); + initBooterLog(); + // Setup VGA text mode. // Not sure if it is safe to call setVideoMode() before the // config table has been loaded. Call video_mode() instead.