aboutsummaryrefslogtreecommitdiff
path: root/dlog.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2026-08-30 02:21:09 +0200
committerJavier <dev.git@javispedro.com>2026-08-30 02:21:09 +0200
commit1b0344660de2832b472b0a413c50ff7f111a9293 (patch)
tree5ae7303643d6c9187da6366cf30a4f6a4c73d54b /dlog.h
parent003a26a76982f512e2f3a1108e46b88aa29ab306 (diff)
downloadvbados-1b0344660de2832b472b0a413c50ff7f111a9293.tar.gz
vbados-1b0344660de2832b472b0a413c50ff7f111a9293.zip
first steps towards (optional) serial mouse support
Diffstat (limited to 'dlog.h')
-rw-r--r--dlog.h41
1 files changed, 35 insertions, 6 deletions
diff --git a/dlog.h b/dlog.h
index 112254e..2878ac9 100644
--- a/dlog.h
+++ b/dlog.h
@@ -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 *);