repository: C:/dev/kvm-guest-drivers-windows
branch: master
commit 0564cf4d975e6307d7f52b603dc2aab7d5789ae2
Author: Yan Vugenfirer <[email protected]>
Date: Sun Feb 7 18:24:58 2010 +0200
[WIN-GUEST-DRIVERS] NetKVM: Improve debug mechanism that can output debug
printouts to QEMU though debug IO port.
Signed-off-by: Yan Vugenfirer <[email protected]>
diff --git a/NetKVM/Common/DebugData.h b/NetKVM/Common/DebugData.h
index be75e26..b0a0ab9 100644
--- a/NetKVM/Common/DebugData.h
+++ b/NetKVM/Common/DebugData.h
@@ -31,7 +31,7 @@ typedef enum _etagHistoryLogOperation
hopSysReset, // implementation driver, 1/0 -
entry/completion
hopHalt, // implementation
driver, 1/0 - entry/completion
hopConnectIndication, // implementation
- hopDPC, // common::DpcWorkBody
(none, 1, interrupt status, none) (none, 0, free buffers, free desc)
+ hopDPC, // common::DpcWorkBody
(1, none, none, none) (0, left, free buffers, free desc)
hopSend, // implementation, when
Send requested (nbl, nof lists, nof bufs, nof bytes) (packet, 1, nof packets,
none)
hopSendNBLRequest, // ndis6 implementation (nbl,
nof packets, none, none)
hopSendPacketRequest, // not used
diff --git a/NetKVM/Common/ParaNdis-Debug.c b/NetKVM/Common/ParaNdis-Debug.c
index 71494ef..86b9cae 100644
--- a/NetKVM/Common/ParaNdis-Debug.c
+++ b/NetKVM/Common/ParaNdis-Debug.c
@@ -70,20 +70,26 @@ static void DebugPrint(const char *fmt, ...)
va_start(list, fmt);
vDbgPrintEx(DPFLTR_DEFAULT_ID, 9 | DPFLTR_MASK, fmt, list);
#if defined(VIRTIO_DBG_USE_IOPORT)
- if (1)
{
- char buf[256];
- size_t len, i;
- buf[0] = 0;
- status = RtlStringCbVPrintfA(buf, sizeof(buf), fmt, list);
- if (status == STATUS_SUCCESS) len = strlen(buf);
- else if (status == STATUS_BUFFER_OVERFLOW) len = sizeof(buf);
- else { memcpy(buf, "Can't print", 11); len = 11; }
- for (i = 0; i < len; ++i)
+ // use this way of output only for DISPATCH_LEVEL,
+ // higher requires more protection
+ if (KeGetCurrentIrql() <= DISPATCH_LEVEL)
{
- NdisRawWritePortUchar(VIRTIO_DBG_USE_IOPORT, buf[i]);
+ char buf[256];
+ size_t len, i;
+ buf[0] = 0;
+ status = RtlStringCbVPrintfA(buf, sizeof(buf), fmt,
list);
+ if (status == STATUS_SUCCESS) len = strlen(buf);
+ else if (status == STATUS_BUFFER_OVERFLOW) len =
sizeof(buf);
+ else { memcpy(buf, "Can't print", 11); len = 11; }
+ NdisAcquireSpinLock(&CrashLock);
+ for (i = 0; i < len; ++i)
+ {
+ NdisRawWritePortUchar(VIRTIO_DBG_USE_IOPORT,
buf[i]);
+ }
+ NdisRawWritePortUchar(VIRTIO_DBG_USE_IOPORT, '\n');
+ NdisReleaseSpinLock(&CrashLock);
}
- NdisRawWritePortUchar(VIRTIO_DBG_USE_IOPORT, '\n');
}
#endif
}
@@ -148,9 +154,9 @@ void ParaNdis_DebugInitialize(PVOID DriverObject,PVOID
RegistryPath)
BOOLEAN res;
WPP_INIT_TRACING(DriverObject, RegistryPath);
+ NdisAllocateSpinLock(&CrashLock);
KeInitializeCallbackRecord(&CallbackRecord);
ParaNdis_PrepareBugCheckData();
- NdisAllocateSpinLock(&CrashLock);
NdisInitUnicodeString(&usRegister, L"KeRegisterBugCheckReasonCallback");
NdisInitUnicodeString(&usDeregister,
L"KeDeregisterBugCheckReasonCallback");
pr = MmGetSystemRoutineAddress(&usRegister);
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html