Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[viort-serail] BZ840911 - move VIRTIO_CONSOLE_PORT_OPEN controlll mes…
…sage to VIOSerialEvtDeviceD0ExitPreInterruptsDisabled callback
  • Loading branch information
YanVugenfirer committed Oct 17, 2012
1 parent 377b85d commit 4f97902
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
59 changes: 58 additions & 1 deletion vioserial/sys/Device.c
Expand Up @@ -21,6 +21,7 @@ EVT_WDF_DEVICE_PREPARE_HARDWARE VIOSerialEvtDevicePrepareHardware;
EVT_WDF_DEVICE_RELEASE_HARDWARE VIOSerialEvtDeviceReleaseHardware;
EVT_WDF_DEVICE_D0_ENTRY VIOSerialEvtDeviceD0Entry;
EVT_WDF_DEVICE_D0_EXIT VIOSerialEvtDeviceD0Exit;
EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED VIOSerialEvtDeviceD0ExitPreInterruptsDisabled;
EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED VIOSerialEvtDeviceD0EntryPostInterruptsEnabled;


Expand All @@ -33,8 +34,8 @@ static NTSTATUS VIOSerialShutDownAllQueues(IN WDFOBJECT WdfDevice, IN BOOLEAN bF
#pragma alloc_text (PAGE, VIOSerialEvtDevicePrepareHardware)
#pragma alloc_text (PAGE, VIOSerialEvtDeviceReleaseHardware)
#pragma alloc_text (PAGE, VIOSerialEvtDeviceD0Exit)
#pragma alloc_text (PAGE, VIOSerialEvtDeviceD0ExitPreInterruptsDisabled)
#pragma alloc_text (PAGE, VIOSerialEvtDeviceD0EntryPostInterruptsEnabled)

#endif

static UINT gDeviceCount = 0;
Expand Down Expand Up @@ -103,6 +104,7 @@ VIOSerialEvtDeviceAdd(
PnpPowerCallbacks.EvtDeviceReleaseHardware = VIOSerialEvtDeviceReleaseHardware;
PnpPowerCallbacks.EvtDeviceD0Entry = VIOSerialEvtDeviceD0Entry;
PnpPowerCallbacks.EvtDeviceD0Exit = VIOSerialEvtDeviceD0Exit;
PnpPowerCallbacks.EvtDeviceD0ExitPreInterruptsDisabled = VIOSerialEvtDeviceD0ExitPreInterruptsDisabled;
PnpPowerCallbacks.EvtDeviceD0EntryPostInterruptsEnabled = VIOSerialEvtDeviceD0EntryPostInterruptsEnabled;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &PnpPowerCallbacks);

Expand Down Expand Up @@ -583,6 +585,61 @@ VIOSerialEvtDeviceD0Exit(
return STATUS_SUCCESS;
}

NTSTATUS
VIOSerialEvtDeviceD0ExitPreInterruptsDisabled(
IN WDFDEVICE WdfDevice,
IN WDF_POWER_DEVICE_STATE TargetState
)
{
NTSTATUS status = STATUS_SUCCESS;
WDFCHILDLIST portList;
WDF_CHILD_LIST_ITERATOR portIterator;

UNREFERENCED_PARAMETER(TargetState);

TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "--> %s\n", __FUNCTION__);

PAGED_CODE();

portList = WdfFdoGetDefaultChildList(WdfDevice);
WDF_CHILD_LIST_ITERATOR_INIT(&portIterator, WdfRetrievePresentChildren);

WdfChildListBeginIteration(portList, &portIterator);

for (;;)
{
WDF_CHILD_RETRIEVE_INFO childInfo;
WDFDEVICE hChild;
VIOSERIAL_PORT port;

WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER_INIT(
&port.Header, sizeof(port));
WDF_CHILD_RETRIEVE_INFO_INIT(&childInfo, &port.Header);

status = WdfChildListRetrieveNextDevice(portList, &portIterator,
&hChild, &childInfo);
if (!NT_SUCCESS(status) || (status == STATUS_NO_MORE_ENTRIES))
{
break;
}
ASSERT(childInfo.Status == WdfChildListRetrieveDeviceSuccess);

if (port.GuestConnected && !port.Removed)
{
VIOSerialSendCtrlMsg(port.BusDevice, port.PortId,
VIRTIO_CONSOLE_PORT_OPEN, 0);
port.GuestConnected = FALSE;
}
port.Removed = TRUE;
}

WdfChildListEndIteration(portList, &portIterator);

TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "<-- %s: %d\n",
__FUNCTION__, status);

return status;
}

NTSTATUS
VIOSerialEvtDeviceD0EntryPostInterruptsEnabled(
Expand Down
8 changes: 1 addition & 7 deletions vioserial/sys/Port.c
Expand Up @@ -342,14 +342,8 @@ VIOSerialShutdownAllPorts(
WdfIoQueuePurge(vport.IoctlQueue,
WDF_NO_EVENT_CALLBACK,
WDF_NO_CONTEXT);
VIOSerialEnableDisableInterruptQueue(GetInQueue(&vport), FALSE);

if(!vport.Removed && vport.GuestConnected)
{
VIOSerialSendCtrlMsg(vport.BusDevice, vport.PortId, VIRTIO_CONSOLE_PORT_OPEN, 0);
vport.GuestConnected = FALSE;
}
vport.Removed = TRUE;
VIOSerialEnableDisableInterruptQueue(GetInQueue(&vport), FALSE);

WdfSpinLockAcquire(vport.InBufLock);
VIOSerialDiscardPortDataLocked(&vport);
Expand Down

0 comments on commit 4f97902

Please sign in to comment.