From db2585fd1204ba27ffb3538e7b594593372bab13 Mon Sep 17 00:00:00 2001 From: Bill Paul Date: Wed, 3 Mar 2004 17:57:05 +0000 Subject: [PATCH] Add proper support for DbgPrint(): only print messages if bootverbose is set, since some drivers with debug info can be very chatty. Also implement DbgBreakPoint(), which is the Windows equivalent of Debugger(). Unfortunately, this forces subr_ntoskrnl.c to include opt_ddb.h. --- sys/compat/ndis/subr_ntoskrnl.c | 31 ++++++++++++++++++++++++++++++- sys/modules/ndis/Makefile | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/sys/compat/ndis/subr_ntoskrnl.c b/sys/compat/ndis/subr_ntoskrnl.c index fd9d984a2c5a..c0a9535bbff6 100644 --- a/sys/compat/ndis/subr_ntoskrnl.c +++ b/sys/compat/ndis/subr_ntoskrnl.c @@ -64,6 +64,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "opt_ddb.h" + #define __regparm __attribute__((regparm(3))) #define FUNC void(*)(void) @@ -166,6 +168,8 @@ __stdcall static ndis_status ntoskrnl_objref(ndis_handle, uint32_t, void *, uint8_t, void **, void **); __stdcall static void ntoskrnl_objderef(/*void * */ void); __stdcall static uint32_t ntoskrnl_zwclose(ndis_handle); +static uint32_t ntoskrnl_dbgprint(char *, ...); +__stdcall static void ntoskrnl_debugger(void); __stdcall static void dummy(void); static struct mtx *ntoskrnl_interlock; @@ -1604,6 +1608,30 @@ ntoskrnl_thread_exit(status) return(0); /* notreached */ } +static uint32_t +ntoskrnl_dbgprint(char *fmt, ...) +{ + va_list ap; + + if (bootverbose) { + va_start(ap, fmt); + vprintf(fmt, ap); + } + + return(STATUS_SUCCESS); +} + +__stdcall static void +ntoskrnl_debugger(void) +{ +#ifdef DDB + Debugger("debug from winkernel module"); +#else + printf("ntoskrnl_debugger(): DDB not present\n"); +#endif + return; +} + __stdcall static void dummy() { @@ -1625,7 +1653,8 @@ image_patch_table ntoskrnl_functbl[] = { { "RtlUnicodeStringToInteger", (FUNC)ntoskrnl_unicode_to_int }, { "sprintf", (FUNC)sprintf }, { "vsprintf", (FUNC)vsprintf }, - { "DbgPrint", (FUNC)printf }, + { "DbgPrint", (FUNC)ntoskrnl_dbgprint }, + { "DbgBreakPoint", (FUNC)ntoskrnl_debugger }, { "strncmp", (FUNC)strncmp }, { "strcmp", (FUNC)strcmp }, { "strncpy", (FUNC)strncpy }, diff --git a/sys/modules/ndis/Makefile b/sys/modules/ndis/Makefile index fe9d308fd7a1..135f2967bf80 100644 --- a/sys/modules/ndis/Makefile +++ b/sys/modules/ndis/Makefile @@ -5,5 +5,6 @@ KMOD= ndis SRCS= subr_pe.c subr_ndis.c subr_hal.c subr_ntoskrnl.c kern_ndis.c SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h card_if.h vnode_if.h +SRCS+= opt_ddb.h .include