7 #define VIDEORAM 0xb8000
15 static inline int hex_to_rstr(
unsigned d,
char *out)
17 const char *hex_table =
"0123456789abcdef";
22 out[ret++] = hex_table[(d % 16)];
26 out[ret++] = hex_table[(d % 16)];
30 static inline int unsigned_to_rstr(
unsigned d,
char *out)
36 out[ret++] = (d % 10) +
'0';
40 out[ret++] = (d % 10) +
'0';
44 static inline int signed_to_rstr(
int d,
char *out)
50 out[ret++] = ((d % 10) * (d < 0 ? -1 : 1)) +
'0';
54 out[ret++] = ((d % 10) * (d < 0 ? -1 : 1)) +
'0';
62 static inline int dbg_putc(
char ch,
off_t *offset)
71 *offset += (
COLS - ((*offset) %
COLS));
74 *offset -= (*offset %
COLS);
77 video += (*offset << 1);
91 static inline int dbg_vfprintf(
off_t *offset,
const char *format,
va_list ap)
118 if (state == NORMAL) {
119 dbg_putc(ch, offset);
126 dbg_putc(ch, offset);
130 dbg_putc(
'0', offset);
131 dbg_putc(
'x', offset);
135 va_arg(ap,
unsigned), digit);
137 ret = dbg_putc(digit[j], offset);
145 j = unsigned_to_rstr(
146 va_arg(ap,
unsigned), digit);
148 ret = dbg_putc(digit[j], offset);
156 j = signed_to_rstr(
va_arg(ap,
int), digit);
158 ret = dbg_putc(digit[j], offset);
166 str = (
char*)
va_arg(ap,
char*);
168 ret = dbg_putc(*str++, offset);
176 ch = (char)
va_arg(ap,
unsigned int);
177 ret = dbg_putc(ch, offset);
200 static off_t offset = 0;
204 ret = dbg_vfprintf(&offset, format, ap);