diff --git a/drivers/storage/ide/pciidex/miniport.c b/drivers/storage/ide/pciidex/miniport.c index bb0ea2afbf7..c58f3d1397b 100644 --- a/drivers/storage/ide/pciidex/miniport.c +++ b/drivers/storage/ide/pciidex/miniport.c @@ -11,6 +11,9 @@ #define NDEBUG #include +/** @brief Global debugging level. Valid values are between 0 (Error) and 3 (Trace). */ +ULONG PciIdeDebug = 0; + static DRIVER_DISPATCH PciIdeXForwardOrIgnore; static NTSTATUS NTAPI PciIdeXForwardOrIgnore( @@ -90,6 +93,32 @@ PciIdeXPnpDispatch( return PciIdeXPdoPnpDispatch(DeviceObject, Irp); } +/** + * @brief Prints the given string with printf-like formatting to the kernel debugger. + * @param[in] DebugPrintLevel Level of the debug message. + * Valid values are between 0 (Error) and 3 (Trace). + * @param[in] DebugMessage Format of the string/arguments. + * @param[in] ... Variable number of arguments matching the format + * specified in \a DebugMessage. + * @sa PciIdeDebug + */ +VOID +PciIdeXDebugPrint( + _In_ ULONG DebugPrintLevel, + _In_z_ _Printf_format_string_ PCCHAR DebugMessage, + ...) +{ + va_list ap; + + /* Check if we can print anything */ + if (DebugPrintLevel <= PciIdeDebug) + DebugPrintLevel = 0; + + va_start(ap, DebugMessage); + vDbgPrintEx(DPFLTR_PCIIDE_ID, DebugPrintLevel, DebugMessage, ap); + va_end(ap); +} + NTSTATUS NTAPI PciIdeXInitialize( IN PDRIVER_OBJECT DriverObject, diff --git a/drivers/storage/ide/pciidex/pciidex.spec b/drivers/storage/ide/pciidex/pciidex.spec index b31793550f3..a5dd343ba7a 100644 --- a/drivers/storage/ide/pciidex/pciidex.spec +++ b/drivers/storage/ide/pciidex/pciidex.spec @@ -1,3 +1,4 @@ +@ varargs PciIdeXDebugPrint(long str) @ stdcall PciIdeXGetBusData(ptr ptr long long) @ stdcall PciIdeXInitialize(ptr ptr ptr long) @ stdcall PciIdeXSetBusData(ptr ptr ptr long long) diff --git a/drivers/storage/inc/ide.h b/drivers/storage/inc/ide.h index b4912499fe7..53f40d0447c 100644 --- a/drivers/storage/inc/ide.h +++ b/drivers/storage/inc/ide.h @@ -478,8 +478,8 @@ typedef struct _PCIIDE_CONFIG_HEADER { VOID PciIdeXDebugPrint( - ULONG DebugPrintLevel, - PCCHAR DebugMessage, + _In_ ULONG DebugPrintLevel, + _In_z_ _Printf_format_string_ PCCHAR DebugMessage, ... );