https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0f8de896aaabd54f8fae579b98525d7c648dddfa

commit 0f8de896aaabd54f8fae579b98525d7c648dddfa
Author:     Dmitry Borisov <[email protected]>
AuthorDate: Tue Sep 15 18:10:52 2020 +0600
Commit:     GitHub <[email protected]>
CommitDate: Tue Sep 15 15:10:52 2020 +0300

    [PCIIDEX] Implement missing PciIdeXDebugPrint function (#3146)
    
    It's useful for debugging IDE controller minidrivers, and it makes 
pciidex.sys work on Windows XP/2003.
    - 
https://user-images.githubusercontent.com/37072976/92856412-39d56b80-f415-11ea-880f-48998c11112d.png
    
    CORE-17256
---
 drivers/storage/ide/pciidex/miniport.c   | 29 +++++++++++++++++++++++++++++
 drivers/storage/ide/pciidex/pciidex.spec |  1 +
 drivers/storage/inc/ide.h                |  4 ++--
 3 files changed, 32 insertions(+), 2 deletions(-)

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 <debug.h>
 
+/** @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,
     ...
     );
 

Reply via email to