[Spice-devel] [PATCH qxl-win v3] miniport/qxl: add DebugZeroDeviceMemory and use in DBG for hibernate and
Alon Levy
alevy at redhat.com
Thu Jul 7 02:43:15 PDT 2011
We zero the memory explicitly for debugging purposes when going to sleep
to ensure the return path doesn't rely on any initialization done before.
SetPowerState slightly refactored in the process.
---
miniport/qxl.c | 36 ++++++++++++++++++++++++++++++++----
1 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/miniport/qxl.c b/miniport/qxl.c
index 7d6429d..d4b4afd 100644
--- a/miniport/qxl.c
+++ b/miniport/qxl.c
@@ -771,10 +771,29 @@ VP_STATUS GetPowerState(PVOID dev_extension,
return ERROR_DEVICE_REINITIALIZATION_NEEDED;
}
+#ifdef DBG
+static void DebugZeroDeviceMemory(QXLExtension *dev_ext)
+{
+ // don't zero the memory if the ram_start and vram_start are not initialized (a
+ // device has been installed but the monitor is disabled)
+ if (dev_ext->ram_start == 0 || dev_ext->vram_start == 0) {
+ DEBUG_PRINT((dev_ext, 0, "%s: not zeroing memory (addresses not initialized)\n", __FUNCTION__));
+ return;
+ }
+ VideoPortZeroMemory(dev_ext->ram_start, dev_ext->ram_size);
+ VideoPortZeroMemory(dev_ext->vram_start, dev_ext->vram_size);
+}
+#else
+static _inline void DebugZeroDeviceMemory(QXLExtension *dev_ext)
+{
+}
+#endif
+
VP_STATUS SetPowerState(PVOID dev_extension,
ULONG hw_id,
PVIDEO_POWER_MANAGEMENT pm_stat)
{
+ QXLExtension *dev_ext = dev_extension;
PAGED_CODE();
DEBUG_PRINT((0, "%s: %lu\n", __FUNCTION__, pm_stat->PowerState));
@@ -785,19 +804,28 @@ VP_STATUS SetPowerState(PVOID dev_extension,
ResetDeviceWithoutIO(dev_ext);
break;
case VideoPowerStandBy:
+ break;
case VideoPowerSuspend:
+ break;
case VideoPowerOff:
+ DebugZeroDeviceMemory(dev_ext);
+ break;
case VideoPowerShutdown:
+ /* Important: you cannot call out to qxldd.dll here or you get a BSOD. */
+ break;
case VideoPowerHibernate:
- DEBUG_PRINT((0, "%s: OK\n", __FUNCTION__));
- return NO_ERROR;
+ DebugZeroDeviceMemory(dev_ext);
+ break;
+ default:
+ DEBUG_PRINT((0, "%s: unexpected power state\n", __FUNCTION__));
+ return ERROR_DEVICE_REINITIALIZATION_NEEDED;
}
break;
default:
DEBUG_PRINT((0, "%s: unexpected hw_id %lu\n", __FUNCTION__, hw_id));
+ return ERROR_DEVICE_REINITIALIZATION_NEEDED;
}
- DEBUG_PRINT((0, "%s: ERROR_DEVICE_REINITIALIZATION_NEEDED\n", __FUNCTION__));
- return ERROR_DEVICE_REINITIALIZATION_NEEDED;
+ return NO_ERROR;
}
VP_STATUS GetChildDescriptor(IN PVOID dev_extension,
--
1.7.5.4
More information about the Spice-devel
mailing list