--- qemu/roms/seabios/src/output.c 2018/04/24 17:36:48 1.1 +++ qemu/roms/seabios/src/output.c 2018/04/24 18:27:31 1.1.1.3 @@ -25,7 +25,7 @@ struct putcinfo { #define DEBUG_TIMEOUT 100000 void -debug_serial_setup() +debug_serial_setup(void) { if (!CONFIG_DEBUG_SERIAL) return; @@ -59,7 +59,7 @@ debug_serial(char c) // Make sure all serial port writes have been completely sent. static void -debug_serial_flush() +debug_serial_flush(void) { if (!CONFIG_DEBUG_SERIAL) return; @@ -84,11 +84,13 @@ putc_debug(struct putcinfo *action, char debug_serial(c); } -// In 16bit mode just need a dummy variable (putc_debug is always used -// anyway), and in 32bit mode need a pointer to the 32bit instance of -// putc_debug(). +// In segmented mode just need a dummy variable (putc_debug is always +// used anyway), and in 32bit flat mode need a pointer to the 32bit +// instance of putc_debug(). #if MODE16 static struct putcinfo debuginfo VAR16; +#elif MODESEGMENT +static struct putcinfo debuginfo VAR32SEG; #else static struct putcinfo debuginfo = { putc_debug }; #endif @@ -132,8 +134,8 @@ static struct putcinfo screeninfo = { pu static void putc(struct putcinfo *action, char c) { - if (MODE16) { - // Only debugging output supported in 16bit mode. + if (MODESEGMENT) { + // Only debugging output supported in segmented mode. putc_debug(action, c); return; } @@ -193,21 +195,24 @@ putsinglehex(struct putcinfo *action, u3 // Output an integer in hexadecimal. static void -puthex(struct putcinfo *action, u32 val, int width) +puthex(struct putcinfo *action, u32 val, int width, int spacepad) { if (!width) { u32 tmp = val; width = 1; - if (tmp > 0xffff) { - width += 4; - tmp >>= 16; - } - if (tmp > 0xff) { - width += 2; - tmp >>= 8; + while (tmp >>= 4) + width++; + } else if (spacepad) { + u32 tmp = val; + u32 count = 1; + while (tmp >>= 4) + count++; + if (width > count) { + count = width - count; + width -= count; + while (count--) + putc(action, ' '); } - if (tmp > 0xf) - width += 1; } switch (width) { @@ -242,11 +247,15 @@ bvprintf(struct putcinfo *action, const } const char *n = s+1; int field_width = 0; + int spacepad = 1; for (;;) { c = GET_GLOBAL(*(u8*)n); if (!isdigit(c)) break; - field_width = field_width * 10 + c - '0'; + if (!field_width && (c == '0')) + spacepad = 0; + else + field_width = field_width * 10 + c - '0'; n++; } if (c == 'l') { @@ -277,9 +286,10 @@ bvprintf(struct putcinfo *action, const putc(action, '0'); putc(action, 'x'); field_width = 8; + spacepad = 0; case 'x': val = va_arg(args, s32); - puthex(action, val, field_width); + puthex(action, val, field_width, spacepad); break; case 'c': val = va_arg(args, int); @@ -325,13 +335,13 @@ panic(const char *fmt, ...) void __dprintf(const char *fmt, ...) { - if (!MODE16 && CONFIG_THREADS && CONFIG_DEBUG_LEVEL >= DEBUG_thread + if (!MODESEGMENT && CONFIG_THREADS && CONFIG_DEBUG_LEVEL >= DEBUG_thread && *fmt != '\\' && *fmt != '/') { struct thread_info *cur = getCurThread(); if (cur != &MainThread) { // Show "thread id" for this debug message. putc_debug(&debuginfo, '|'); - puthex(&debuginfo, (u32)cur, 8); + puthex(&debuginfo, (u32)cur, 8, 0); putc_debug(&debuginfo, '|'); putc_debug(&debuginfo, ' '); } @@ -347,7 +357,7 @@ __dprintf(const char *fmt, ...) void printf(const char *fmt, ...) { - ASSERT32(); + ASSERT32FLAT(); va_list args; va_start(args, fmt); bvprintf(&screeninfo, fmt, args); @@ -382,7 +392,7 @@ putc_str(struct putcinfo *info, char c) int snprintf(char *str, size_t size, const char *fmt, ...) { - ASSERT32(); + ASSERT32FLAT(); if (!size) return 0; struct snprintfinfo sinfo = { { putc_str }, str, str + size }; @@ -409,12 +419,12 @@ hexdump(const void *d, int len) while (len > 0) { if (count % 8 == 0) { putc(&debuginfo, '\n'); - puthex(&debuginfo, count*4, 8); + puthex(&debuginfo, count*4, 8, 0); putc(&debuginfo, ':'); } else { putc(&debuginfo, ' '); } - puthex(&debuginfo, *(u32*)d, 8); + puthex(&debuginfo, *(u32*)d, 8, 0); count++; len-=4; d+=4; @@ -483,6 +493,29 @@ __warn_unimplemented(struct bregs *regs, } } +// Report a detected internal inconsistency. +void +__warn_internalerror(int lineno, const char *fname) +{ + dprintf(1, "WARNING - internal error detected at %s:%d!\n" + , fname, lineno); +} + +// Report on an allocation failure. +void +__warn_noalloc(int lineno, const char *fname) +{ + dprintf(1, "WARNING - Unable to allocate resource at %s:%d!\n" + , fname, lineno); +} + +// Report on a timeout exceeded. +void +__warn_timeout(int lineno, const char *fname) +{ + dprintf(1, "WARNING - Timeout at %s:%d!\n", fname, lineno); +} + // Report a handler reporting an invalid parameter to the caller. void __set_invalid(struct bregs *regs, int lineno, const char *fname)