diff options
Diffstat (limited to 'dlog.h')
| -rw-r--r-- | dlog.h | 41 |
1 files changed, 35 insertions, 6 deletions
@@ -29,14 +29,18 @@ /** If 0, these routines become nops */ #define ENABLE_DLOG 0 /** 1 means target serial port, 0 means target IO port. */ -#define DLOG_TARGET_SERIAL 0 -/** IO port to target. +#define DLOG_TARGET DLOG_TARGET_IOPORT +/** When using DLOG_TARGET_IOPORT, which IO port to target. * VirtualBox uses 0x504, Bochs, DOSBox and descendants use 0xE9. - * When using DLOG_TARGET_SERIAL, use desired UART IO base port. (e.g. COM1 = 0x3F8). */ + * When using DLOG_TARGET_SERIAL, the desired UART IO base port. (e.g. COM1 = 0x3F8). */ #define DLOG_TARGET_PORT 0x504 // End of customizable defines +#define DLOG_TARGET_BIOSTTY 1 +#define DLOG_TARGET_SERIAL 2 +#define DLOG_TARGET_IOPORT 3 + #if ENABLE_DLOG /** Initializes the debug log port. */ @@ -45,7 +49,22 @@ static void dlog_init(); /** Logs a single character to the debug message IO port. */ static inline void dputc(char c); -#if DLOG_TARGET_SERIAL +#if DLOG_TARGET == DLOG_TARGET_BIOSTTY + +static inline void dlog_init() +{ + // No initialization required +} + +static inline void dputc(char c); +#pragma aux dputc = \ + "mov ah, 0x0E" \ + "xor bx, bx" \ + "int 0x10" \ + __parm [AL] \ + __modify __exact [AH AL BH BL]; + +#elif DLOG_TARGET == DLOG_TARGET_SERIAL static void dlog_init() { @@ -65,7 +84,7 @@ static inline void dputc(char c) outp(DLOG_TARGET_PORT, c); } -#else /* DLOG_TARGET_SERIAL */ +#elif DLOG_TARGET == DLOG_TARGET_IOPORT static inline void dlog_init() { @@ -77,7 +96,7 @@ static inline void dputc(char c) outp(DLOG_TARGET_PORT, c); } -#endif /* DLOG_TARGET_SERIAL */ +#endif /* DLOG_TARGET */ static void d_utoa(unsigned num, unsigned base) { @@ -265,6 +284,16 @@ static void dprintf(const char *fmt, ...) break; } break; + case 'b': + switch (size) { + case sizeof(int): + d_utoa(va_arg(va, int), 2); + break; + case sizeof(long): + d_ultoa(va_arg(va, long), 2); + break; + } + break; case 'p': if (is_far) { void __far *p = va_arg(va, void __far *); |
