i was trying to implement the power management code contained int the OSR USB FX2 for my filter driver (upper->usbser.sys->lower) using WdfDeviceAssignSxWakeSettings (my device has remote wake up feature) but it says that only the power policy owner can do it. So I issue WdfDeviceInitSetPowerPolicy to true for my lower filter driver (or should be the upper?) but how do unselect the current policy manager and select my filter (I suppose that usbser.sys is the current policy owner)? I was able to put to sleep my device after certain time but when the system goes to sleep I got the BSOD. This code looks quite straightforward and so what is the difference with implementing the wake up feature using IRP_MN_WAIT_WAKE? The code is this, is something missing for a sandwich filter?
if(usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE)
{
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings;
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS wakeSettings;
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings,
IdleUsbSelectiveSuspend);
idleSettings.IdleTimeout = 10000;
status = WdfDeviceAssignS0IdleSettings(Device, &idleSettings);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceAssignS0IdleSettings failed with status 0x%08x\n”,
status));
return status;
}
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings);
wakeSettings.DxState = PowerDeviceD2;
status = WdfDeviceAssignSxWakeSettings(Device, &wakeSettings);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceAssignSxWakeSettings failed with status 0x%08x\n”,
status));
return status;
}
There is no way to vote or turn off power policy ownership in a stack and move it around. I think serial.sys is the only one that does allow for that, and that is a static configuration thing (a reg value in the dev node). Usbser might have copied this behavior, but I doubt it
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@pounceconsulting.com
Sent: Wednesday, February 16, 2011 1:54 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfDeviceAssignSxWakeSettings on filter driver
i was trying to implement the power management code contained int the OSR USB FX2 for my filter driver (upper->usbser.sys->lower) using WdfDeviceAssignSxWakeSettings (my device has remote wake up feature) but it says that only the power policy owner can do it. So I issue WdfDeviceInitSetPowerPolicy to true for my lower filter driver (or should be the upper?) but how do unselect the current policy manager and select my filter (I suppose that usbser.sys is the current policy owner)? I was able to put to sleep my device after certain time but when the system goes to sleep I got the BSOD. This code looks quite straightforward and so what is the difference with implementing the wake up feature using IRP_MN_WAIT_WAKE? The code is this, is something missing for a sandwich filter?
if(usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE)
{
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings;
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS wakeSettings;
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings,
IdleUsbSelectiveSuspend);
idleSettings.IdleTimeout = 10000;
status = WdfDeviceAssignS0IdleSettings(Device, &idleSettings);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceAssignS0IdleSettings failed with status 0x%08x\n”,
status));
return status;
}
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings);
wakeSettings.DxState = PowerDeviceD2;
status = WdfDeviceAssignSxWakeSettings(Device, &wakeSettings);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceAssignSxWakeSettings failed with status 0x%08x\n”,
status));
return status;
}
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Doron:
So If I cannot be the power policy owner how I can tell my device to wake-up the system?
Thanks!
You don’t. that is the point of power policy ownership. Onlythe PPO decides if and when the device wakes up. You as a filter can watch for the WW irp to show up and add some additional device programming logic to enable the wake, but that is it. If the WW never shows up, your filter does nothing.
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@pounceconsulting.com
Sent: Wednesday, February 16, 2011 3:45 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceAssignSxWakeSettings on filter driver
Doron:
So If I cannot be the power policy owner how I can tell my device to wake-up the system?
Thanks!
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Ok, hence in order to see if usbser issues this IRP I have to implement this functions in both (or any) of my filter drivers?
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PWSTR path;
DriverObject->MajorFunction[IRP_MJ_CREATE] = PM_Create;
// called when Ring 3 app calls CreateFile()
DriverObject->MajorFunction[IRP_MJ_CLOSE] = PM_Close;
// called when Ring 3 app calls CloseHandle()
DriverObject->DriverUnload = PM_Unload;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PM_Ioctl;
// called when Ring 3 app calls DeviceIoCtrl
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = PM_WMI; // handle WMI irps
DriverObject->MajorFunction[IRP_MJ_PNP] = PM_PnP;
DriverObject->MajorFunction[IRP_MJ_POWER] = PM_Power;
DriverObject->DriverExtension->AddDevice = PM_PnPAddDevice; // called when device
// is plugged in
return ntStatus;
}
I thought this was a KMDF driver. If so, all you would need is to have a preprocess routine for IRP_MJ_POWER/IRP_MN_WAIT_WAKE. For a wdm driver, what you have below is needed for a no op filter driver (modulo MJ_CREATE and MJ_CLOSE)
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@pounceconsulting.com
Sent: Wednesday, February 16, 2011 4:07 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceAssignSxWakeSettings on filter driver
Ok, hence in order to see if usbser issues this IRP I have to implement this functions in both (or any) of my filter drivers?
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT deviceObject = NULL;
PWSTR path;
DriverObject->MajorFunction[IRP_MJ_CREATE] = PM_Create;
// called when Ring 3 app calls CreateFile()
DriverObject->MajorFunction[IRP_MJ_CLOSE] = PM_Close;
// called when Ring 3 app calls CloseHandle()
DriverObject->DriverUnload = PM_Unload;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = PM_Ioctl;
// called when Ring 3 app calls DeviceIoCtrl
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = PM_WMI; // handle
DriverObject->WMI irps MajorFunction[IRP_MJ_PNP] = PM_PnP;
DriverObject->MajorFunction[IRP_MJ_POWER] = PM_Power;
DriverObject->DriverExtension->AddDevice = PM_PnPAddDevice; // called
DriverObject->DriverExtension->when device
// is plugged in
return ntStatus;
}
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Ok I Just implemented
DriverObject->MajorFunction[IRP_MJ_POWER] = PM_Power;
And in PM_POWER implemented all the minor function codes handling, but it looks is not being called, what could be the problem?
Is this a KMDF filter driver?
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@pounceconsulting.com
Sent: Thursday, February 17, 2011 10:53 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceAssignSxWakeSettings on filter driver
Ok I Just implemented
DriverObject->MajorFunction[IRP_MJ_POWER] = PM_Power;
And in PM_POWER implemented all the minor function codes handling, but it looks is not being called, what could be the problem?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Then you do not just assign MJ dispatch routines in driverobject, you use the appropriate KMDF routines to assign a WDM pre process routine
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@pounceconsulting.com
Sent: Thursday, February 17, 2011 11:48 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceAssignSxWakeSettings on filter driver
yes
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Doron:
In this post (http://www.osronline.com/showthread.cfm?link=158541) a guy had a similar problem than mine where I want to wake up the system from an usbser device. Following that post and one of your diagrams can be feasible to implement this:
Upper filter to attend custom IOCTLS
|
|
Usbser.sys
|
|
lower filter to implement interface for custom IOCTLS
|
|
USB PDO
What I am suggesting is this:
Upper filter to attend custom IOCTLS
|
|
Usbser.sys
|
|
lower filter to implement interface for custom IOCTLS
|
|
PDO enumerated by the filter
|
|
Filter (a KMDF driver written by you)-----+
|
|
FDO (a KMDF driver written by you)
|
|
USB PDO
The FDO enables USB swake up via KMDF. The filter is the one that enumerates the PDO that usbser will load on. When the io hits the PDO enumerated by the filter, the filter just sends and forgets all io to the FDO
That will work, but that is a ton of code to enable this scenario. You have to weigh if the cost of the complexity is worth the feature. You can also combine the lower filter functionality with the pdo you enumerate, they are both drivers you own so there is no need to split them apart in that case.
d
dent from a phine with no keynoard
-----Original Message-----
From: xxxxx@pounceconsulting.com
Sent: Friday, February 18, 2011 3:57 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfDeviceAssignSxWakeSettings on filter driver
Doron:
In this post (http://www.osronline.com/showthread.cfm?link=158541) a guy had a similar problem than mine where I want to wake up the system from an usbser device. Following that post and one of your diagrams can be feasible to implement this:
Upper filter to attend custom IOCTLS
|
|
Usbser.sys
|
|
lower filter to implement interface for custom IOCTLS
|
|
USB PDO
What I am suggesting is this:
Upper filter to attend custom IOCTLS
|
|
Usbser.sys
|
|
lower filter to implement interface for custom IOCTLS
|
|
PDO enumerated by the filter
|
|
Filter (a KMDF driver written by you)-----+
|
|
FDO (a KMDF driver written by you)
|
|
USB PDO
The FDO enables USB swake up via KMDF. The filter is the one that enumerates the PDO that usbser will load on. When the io hits the PDO enumerated by the filter, the filter just sends and forgets all io to the FDO
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer