NtPlugPlayControl: Implement PlugPlayControlResetDevice case

svn path=/trunk/; revision=18335
This commit is contained in:
Hervé Poussineau 2005-10-08 14:47:25 +00:00
parent ac31de9a31
commit 23b8989476
3 changed files with 63 additions and 3 deletions

View file

@ -65,7 +65,8 @@ typedef enum _PLUGPLAY_CONTROL_CLASS
PlugPlayControlProperty = 0x0A,
PlugPlayControlGetRelatedDevice = 0x0C,
PlugPlayControlDeviceStatus = 0x0E,
PlugPlayControlGetDeviceDepth
PlugPlayControlGetDeviceDepth,
PlugPlayControlResetDevice = 0x14
} PLUGPLAY_CONTROL_CLASS;
typedef enum _PLUGPLAY_BUS_CLASS
@ -362,12 +363,18 @@ typedef struct _PLUGPLAY_CONTOL_STATUS_DATA
} PLUGPLAY_CONTROL_STATUS_DATA, *PPLUGPLAY_CONTROL_STATUS_DATA;
/* Class 0x0F */
typedef struct _PLUGPLAY_CONTOL_DEPTH_DATA
typedef struct _PLUGPLAY_CONTROL_DEPTH_DATA
{
UNICODE_STRING DeviceInstance;
ULONG Depth;
} PLUGPLAY_CONTROL_DEPTH_DATA, *PPLUGPLAY_CONTROL_DEPTH_DATA;
/* Class 0x14 */
typedef struct _PLUGPLAY_CONTROL_RESET_DEVICE_DATA
{
UNICODE_STRING DeviceInstance;
} PLUGPLAY_CONTROL_RESET_DEVICE_DATA, *PPLUGPLAY_CONTROL_RESET_DEVICE_DATA;
typedef struct _PLUGPLAY_BUS_TYPE
{
PLUGPLAY_BUS_CLASS BusClass;

View file

@ -304,6 +304,22 @@ RawFsDriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath);
/* pnpmgr.c */
PDEVICE_NODE
FASTCALL
IopGetDeviceNode(PDEVICE_OBJECT DeviceObject);
NTSTATUS
IopActionConfigureChildServices(PDEVICE_NODE DeviceNode,
PVOID Context);
NTSTATUS
IopActionInitChildServices(PDEVICE_NODE DeviceNode,
PVOID Context,
BOOLEAN BootDrivers);
/* pnproot.c */
NTSTATUS

View file

@ -562,7 +562,7 @@ IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
if (DeviceObject == NULL)
return STATUS_NO_SUCH_DEVICE;
DeviceNode = ((PEXTENDED_DEVOBJ_EXTENSION)DeviceObject->DeviceObjectExtension)->DeviceNode;
DeviceNode = IopGetDeviceNode(DeviceObject);
DepthData->Depth = DeviceNode->Level;
@ -572,6 +572,38 @@ IopGetDeviceDepth(PPLUGPLAY_CONTROL_DEPTH_DATA DepthData)
}
static NTSTATUS
IopResetDevice(PPLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData)
{
PDEVICE_OBJECT DeviceObject;
PDEVICE_NODE DeviceNode;
NTSTATUS Status;
DPRINT("IopResetDevice() called\n");
DPRINT("Device name: %wZ\n", &ResetDeviceData->DeviceInstance);
/* Get the device object */
DeviceObject = IopGetDeviceObjectFromDeviceInstance(&ResetDeviceData->DeviceInstance);
if (DeviceObject == NULL)
return STATUS_NO_SUCH_DEVICE;
DeviceNode = IopGetDeviceNode(DeviceObject);
/* FIXME: we should stop the device, before starting it again */
/* Start the device */
IopDeviceNodeClearFlag(DeviceNode, DNF_DISABLED);
Status = IopActionConfigureChildServices(DeviceNode, DeviceNode->Parent);
if (NT_SUCCESS(Status))
Status = IopActionInitChildServices(DeviceNode, DeviceNode->Parent, FALSE);
ObDereferenceObject(DeviceObject);
return Status;
}
/*
* NtPlugPlayControl
*
@ -698,6 +730,11 @@ NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
return STATUS_INVALID_PARAMETER;
return IopGetDeviceDepth((PPLUGPLAY_CONTROL_DEPTH_DATA)Buffer);
case PlugPlayControlResetDevice:
if (!Buffer || BufferLength < sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA))
return STATUS_INVALID_PARAMETER;
return IopResetDevice((PPLUGPLAY_CONTROL_RESET_DEVICE_DATA)Buffer);
default:
return STATUS_NOT_IMPLEMENTED;
}