VOID OsrFxEvtDeviceSelfManagedIoFlush( _In_ WDFDEVICE Device ) /*++ Routine Description: This routine handles flush activity for the device's self-managed I/O operations. Arguments: Device - Handle to a framework device object. Return Value: None --*/ { // Service the interrupt message queue to drain any outstanding // requests OsrUsbIoctlGetInterruptMessage(Device, STATUS_DEVICE_REMOVED); }
VOID OsrFxEvtUsbInterruptPipeReadComplete( WDFUSBPIPE Pipe, WDFMEMORY Buffer, size_t NumBytesTransferred, WDFCONTEXT Context ) /*++ Routine Description: This the completion routine of the continour reader. This can called concurrently on multiprocessor system if there are more than one readers configured. So make sure to protect access to global resources. Arguments: Buffer - This buffer is freed when this call returns. If the driver wants to delay processing of the buffer, it can take an additional referrence. Context - Provided in the WDF_USB_CONTINUOUS_READER_CONFIG_INIT macro Return Value: NT status value --*/ { PMOUSE_STATE mouseState = NULL; WDFDEVICE device; PDEVICE_CONTEXT pDeviceContext = Context; UNREFERENCED_PARAMETER(Pipe); device = WdfObjectContextGetObject(pDeviceContext); // // Make sure that there is data in the read packet. Depending on the device // specification, it is possible for it to return a 0 length read in // certain conditions. // if (NumBytesTransferred == 0) { TraceEvents(TRACE_LEVEL_WARNING, DBG_INIT, "OsrFxEvtUsbInterruptPipeReadComplete Zero length read " "occured on the Interrupt Pipe's Continuous Reader\n" ); return; } ASSERT(NumBytesTransferred == sizeof(UCHAR)); mouseState = WdfMemoryGetBuffer(Buffer, NULL); TraceEvents(TRACE_LEVEL_INFORMATION, DBG_INIT, "OsrFxEvtUsbInterruptPipeReadComplete SwitchState %x\n", *mouseState); pDeviceContext->CurrentMouseState = *mouseState; // // Handle any pending Interrupt Message IOCTLs. Note that the OSR USB device // will generate an interrupt message when the the device resumes from a low // power state. So if the Interrupt Message IOCTL was sent after the device // has gone to a low power state, the pending Interrupt Message IOCTL will // get completed in the function call below, before the user twiddles the // dip switches on the OSR USB device. If this is not the desired behavior // for your driver, then you could handle this condition by maintaining a // state variable on D0Entry to track interrupt messages caused by power up. // OsrUsbIoctlGetInterruptMessage(device); }