ENTERPRISE

Windows 7 : Programming KMDF Hardware Driver - Handling Interrupts (part 2) - Deferred Processing for Interrupts

2/24/2014 12:49:37 AM

2. Deferred Processing for Interrupts

When the DPC runs, KMDF calls the driver’s EvtInterruptDpc callback. This function performs device-specific interrupt processing and reenables the interrupt for the device. It runs at DISPATCH_LEVEL and therefore must not attempt any operations that might cause a page fault (or wait on any dispatcher objects).

2.1. Code for EvtInterruptDpc Callback

The following is the PCIDRV sample’s EvtInterruptDpc callback:

VOID
NICEvtInterruptDpc(
IN WDFINTERRUPT WdfInterrupt,
IN WDFOBJECT WdfDevice
)
{
PFDO_DATA fdoData = NULL;

fdoData = FdoGetData (WdfDevice);

WdfSpinLockAcquire (fdoData->RcvLock);
NICHandleRecvInterrupt (fdoData);
WdfSpinLockRelease (fdoData->RcvLock);

//
// Handle send interrupt.
//

WdfSpinLockAcquire (fdoData->SendLock);
NICHandleSendInterrupt (fdoData);
WdfSpinLockRelease (fdoData->SendLock);

//
// Check if any queued sends need to be reprocessed.
//
NICCheckForQueuedSends (fdoData);

//
// Start the receive unit if it was stopped
//

WdfSpinLockAcquire (fdoData->RcvLock);
NICStartRecv (fdoData);
WdfSpinLockRelease (fdoData->RcvLock);

//
// Reenable the interrupt.
//

WdfInterruptSynchronize (
WdfInterrupt,
NICEnableInterrupt,
fdoData);

return;
}


Most of the code in this callback is device specific. However, its use of spin locks is worth noting.

When the driver created its I/O queues, it also created two spin locks and stored their handles in its device context area. One (RcvLock) protects read-related buffers and operations, and the (SendLock) protects write-related buffers and operations. In this function, it uses these spin locks to protect against preemption and concurrent users while it processes the results of the I/O operation. The driver calls WdfSpinLockAcquire and WdfSpinLockRelease to acquire and release the locks.

When the driver has completed all device-specific processing, it reenables the interrupt. The function that reenables the interrupt (NICEnableInterrupt) must run at DIRQL, so the driver calls WdfInterruptSynchronize to run it. WdfInterruptSynchronize takes a handle to the interrupt object, a pointer to the function to be run (NICEnableInterrupt), and a pointer to the device context area, which it passed as an argument to NICEnableInterrupt. WdfInterruptSynchronize raises IRQL to DIRQL and calls NICEnableInterrupt. When NICEnableInterrupt completes, KMDF lowers the IRQL to DISPATCH_LEVEL and returns.

Other  
  •  Windows 7 : Programming KMDF Hardware Driver - Support Device Interrupts (part 2) - Post-Interrupt Enable and Pre-Interrupt Disable Processing
  •  Windows 7 : Programming KMDF Hardware Driver - Support Device Interrupts (part 1) - Creating an Interrupt Object,Enabling and Disabling Interrupts
  •  Microsoft Exchange Server 2010 : Managing Data and Database Availability Groups - Content Indexing
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 5) - Switching over Servers and Databases
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 4) - Configuring Database Availability Group Properties
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 3) - Managing Database Availability Group Networks
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 2) - Managing Availability Group Membership
  •  Microsoft Exchange Server 2010 : Creating and Managing Database Availability Groups (part 1) - Creating Database Availability Groups
  •  Microsoft Exchange Server 2010 : Navigating the Information Store (part 2) - Improving Availability, Introducing Active Manager
  •  Microsoft Exchange Server 2010 : Navigating the Information Store (part 1) - Using Databases, Understanding Database Structures
  •  
    Video
    Video tutorials
    - How To Install Windows 8

    - How To Install Windows Server 2012

    - How To Install Windows Server 2012 On VirtualBox

    - How To Disable Windows 8 Metro UI

    - How To Install Windows Store Apps From Windows 8 Classic Desktop

    - How To Disable Windows Update in Windows 8

    - How To Disable Windows 8 Metro UI

    - How To Add Widgets To Windows 8 Lock Screen

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010
    programming4us programming4us
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    Popular Tags
    Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone