Index: branches/azimutz/Chazileon/CHANGES =================================================================== --- branches/azimutz/Chazileon/CHANGES (revision 385) +++ branches/azimutz/Chazileon/CHANGES (revision 386) @@ -1,3 +1,5 @@ +- Added Booter Log Dump Tool +- 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: branches/azimutz/Chazileon/i386/libsaio/console.c =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/console.c (revision 385) +++ branches/azimutz/Chazileon/i386/libsaio/console.c (revision 386) @@ -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: branches/azimutz/Chazileon/i386/libsaio/cpu.c =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/cpu.c (revision 385) +++ branches/azimutz/Chazileon/i386/libsaio/cpu.c (revision 386) @@ -14,7 +14,7 @@ #if DEBUG_CPU #define DBG(x...) printf(x) #else -#define DBG(x...) +#define DBG(x...) msglog(x) #endif /* @@ -310,7 +310,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); @@ -320,6 +320,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: branches/azimutz/Chazileon/i386/libsaio/saio_internal.h =================================================================== --- branches/azimutz/Chazileon/i386/libsaio/saio_internal.h (revision 385) +++ branches/azimutz/Chazileon/i386/libsaio/saio_internal.h (revision 386) @@ -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: branches/azimutz/Chazileon/i386/boot2/boot.c =================================================================== --- branches/azimutz/Chazileon/i386/boot2/boot.c (revision 385) +++ branches/azimutz/Chazileon/i386/boot2/boot.c (revision 386) @@ -199,6 +199,8 @@ else drawBootGraphics(); + setupBooterLog(); + finalizeBootStruct(); // Jump to kernel's entry point. There's no going back now. @@ -253,6 +255,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. @@ -411,15 +415,15 @@ if ( status == -1 ) continue; //Azi: doing this earlier to get the verbose from loadOverrideConfig. - // Draw background, turn off any GUI elements and update VRAM. + // Turn off any GUI elements, draw background and update VRAM. if ( bootArgs->Video.v_display == GRAPHICS_MODE ) - { - drawBackground(); // order matters!! - gui.devicelist.draw = false; // Needed when the verbose "flips" the screen. - gui.bootprompt.draw = false; // ? - gui.menu.draw = false; // ? - gui.infobox.draw = false; // Enter doesn't work with this drawn; most probably it's not needed!? + { + gui.devicelist.draw = false; + gui.bootprompt.draw = false; + gui.menu.draw = false; + gui.infobox.draw = false; gui.logo.draw = false; + drawBackground(); updateVRAM(); } Index: branches/azimutz/Chazileon/i386/util/bdmesg.c =================================================================== --- branches/azimutz/Chazileon/i386/util/bdmesg.c (revision 0) +++ branches/azimutz/Chazileon/i386/util/bdmesg.c (revision 386) @@ -0,0 +1,38 @@ +/* + * BooterLog Dump Tool, part of the Chameleon Boot Loader Project + * + * Copyright 2010 by Islam M. Ahmed Zaid. All rights reserved. + * + */ + +#include +#include +#include +#include + +#include "IOKit/IOKitLib.h" + + +int main(int argc, char *argv[]) +{ + io_registry_entry_t root = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); + if (!root) + { + printf("IORegistryEntry \"IOIOService:/\" not found.\n"); + return 0; + } + + CFTypeRef bootLog = IORegistryEntryCreateCFProperty(root, CFSTR("boot-log"), kCFAllocatorDefault, 0); + if (!bootLog) + { + printf("\"boot-log\" property not found.\n"); + return 0; + } + //CFShow(bootLog); + const UInt8 *msglog = CFDataGetBytePtr((CFDataRef)bootLog); + if (msglog) + printf("%s\n", msglog); + + return 0; +} + Index: branches/azimutz/Chazileon/i386/util/Makefile =================================================================== --- branches/azimutz/Chazileon/i386/util/Makefile (revision 385) +++ branches/azimutz/Chazileon/i386/util/Makefile (revision 386) @@ -18,7 +18,7 @@ CFILES = machOconv.c ALLSRC = $(CFILES) $(MFILES) $(HFILES) $(EXPORT_HFILES) -PROGRAMS = machOconv +PROGRAMS = machOconv bdmesg OUTFILES = $(PROGRAMS) @@ -30,6 +30,9 @@ machOconv: machOconv.o $(CC) $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $(SYMROOT)/$(@F) machOconv.o +bdmesg: bdmesg.o + $(CC) $(CFLAGS) $(LDFLAGS) -framework IOKit -framework CoreFoundation -o $(SYMROOT)/$(@F) bdmesg.o + include ../MakeInc.dir #dependencies