[syslinux] [PATCH 1/1] dprintf: add debug console support
Jonathan Boeing
jonathan.n.boeing at gmail.com
Sun Feb 8 08:13:03 PST 2015
Add a vdprintf implementation that prints to a QEMU/Bochs style debug
console.
A debug console is an I/O port; writes to it are trapped by the host
and printed to a target.
Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com>
---
com32/include/dprintf.h | 2 +-
com32/lib/dprintf.c | 4 ++--
com32/lib/vdprintf.c | 21 ++++++++++++++++++++-
core/lwip/src/netif/undiif.c | 2 +-
mk/devel.mk | 1 +
5 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/com32/include/dprintf.h b/com32/include/dprintf.h
index b3f1b46..24cab7b 100644
--- a/com32/include/dprintf.h
+++ b/com32/include/dprintf.h
@@ -7,7 +7,7 @@
#include <syslinux/debug.h>
-#if !defined(DEBUG_PORT) && !defined(DEBUG_STDIO)
+#if !defined(DEBUG_PORT) && !defined(DEBUG_STDIO) && !defined(DEBUG_IO_PORT)
# undef CORE_DEBUG
#endif
diff --git a/com32/lib/dprintf.c b/com32/lib/dprintf.c
index dea77b3..e9dacb3 100644
--- a/com32/lib/dprintf.c
+++ b/com32/lib/dprintf.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdarg.h>
-#ifdef DEBUG_PORT
+#if defined(DEBUG_PORT) || defined(DEBUG_IO_PORT)
void vdprintf(const char *, va_list);
@@ -18,4 +18,4 @@ void dprintf(const char *format, ...)
va_end(ap);
}
-#endif /* DEBUG_PORT */
+#endif /* DEBUG_PORT || DEBUG_IO_PORT */
diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c
index bcf55bb..95c10e9 100644
--- a/com32/lib/vdprintf.c
+++ b/com32/lib/vdprintf.c
@@ -10,7 +10,26 @@
#include <sys/io.h>
#include <sys/cpu.h>
-#ifdef DEBUG_PORT
+#ifdef DEBUG_IO_PORT
+
+#define BUFFER_SIZE 0x100
+
+void vdprintf(const char *format, va_list ap)
+{
+ int rv;
+ char buffer[BUFFER_SIZE];
+ char *p;
+
+ rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
+ if (rv < 0)
+ return;
+
+ p = buffer;
+ while(*p)
+ outb(*p++, DEBUG_IO_PORT);
+}
+
+#elif defined DEBUG_PORT
#define BUFFER_SIZE 4096
diff --git a/core/lwip/src/netif/undiif.c b/core/lwip/src/netif/undiif.c
index e62a984..05606e6 100644
--- a/core/lwip/src/netif/undiif.c
+++ b/core/lwip/src/netif/undiif.c
@@ -52,7 +52,7 @@
# ifndef DEBUG
# define DEBUG 1
# endif
-# ifndef DEBUG_PORT
+# if !defined(DEBUG_PORT) && !defined(DEBUG_IO_PORT)
# define DEBUG_PORT 0x3f8
# endif
#endif /* UNDIIF_ID_FULL_DEBUG */
diff --git a/mk/devel.mk b/mk/devel.mk
index b1fca87..1e57dcf 100644
--- a/mk/devel.mk
+++ b/mk/devel.mk
@@ -2,6 +2,7 @@
GCCWARN += -Wno-clobbered
#GCCWARN += -DDEBUG_MALLOC
# GCCWARN += -DDEBUG_PORT=0x3f8 -DCORE_DEBUG=1
+# GCCWARN += -DDEBUG_IO_PORT=0x402 -DCORE_DEBUG=1
GCCWARN += -DDYNAMIC_DEBUG
## The following will enable printing ethernet/arp/ip/icmp/tcp/udp headers
--
2.3.0
More information about the Syslinux
mailing list