version 1.1.1.1, 2008/06/03 10:38:40 |
version 1.1.1.1.2.1, 2008/08/13 17:12:20 |
|
|
/* |
/* |
* debug.c - loader debug functions |
* debug.c - loader debug functions |
*/ |
*/ |
|
|
#include <prex/bootinfo.h> |
#include <prex/bootinfo.h> |
#include <platform.h> |
#include <platform.h> |
#include <boot.h> |
#include <boot.h> |
|
|
#undef printk |
#ifdef DEBUG |
|
|
/* |
/* |
* printk - print formated string |
* printf - print formated string |
*/ |
*/ |
void |
void |
printk(const char *fmt, ...) |
printf(const char *fmt, ...) |
{ |
{ |
#ifdef DEBUG |
static const char digits[] = "0123456789abcdef"; |
static const char digits[16] = "0123456789abcdef"; |
|
va_list ap; |
va_list ap; |
char buf[10]; |
char buf[10]; |
char *s; |
char *s; |
|
|
c = *fmt++; |
c = *fmt++; |
switch (c) { |
switch (c) { |
case 'c': |
case 'c': |
putc(va_arg(ap, int)); |
putchar(va_arg(ap, int)); |
continue; |
continue; |
case 's': |
case 's': |
for (s = va_arg(ap, char *); *s; s++) |
s = va_arg(ap, char *); |
putc((int)*s); |
if (s == NULL) |
|
s = "<NULL>"; |
|
for (; *s; s++) { |
|
putchar((int)*s); |
|
} |
continue; |
continue; |
case 'u': |
case 'u': |
case 'x': |
case 'x': |
|
|
*s++ = digits[u % r]; |
*s++ = digits[u % r]; |
while (u /= r); |
while (u /= r); |
while (--s >= buf) |
while (--s >= buf) |
putc((int)*s); |
putchar((int)*s); |
continue; |
continue; |
} |
} |
} |
} |
putc((int)c); |
putchar((int)c); |
} |
} |
va_end(ap); |
va_end(ap); |
#endif /* DEBUG */ |
|
} |
} |
|
#endif /* DEBUG */ |
|
|
/* |
/* |
* Show error and hang up. |
* Show error and hang up. |
|
|
panic(const char *msg) |
panic(const char *msg) |
{ |
{ |
|
|
printk("Panic: %s\n", msg); |
#ifdef DEBUG |
for (;;); |
printf("Panic: %s\n", msg); |
|
#endif |
|
machine_panic(); |
|
/* NOTREACHED */ |
} |
} |