programming4us
programming4us
ENTERPRISE

Windows 7 : Programming KMDF Hardware Driver - Support Device Interrupts (part 2) - Post-Interrupt Enable and Pre-Interrupt Disable Processing

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

4. Code to Enable Interrupts

In the PCIDRV sample, the EvtInterruptEnable callback appears in isrdpc.c. The required code is quite simple, as the following shows:

NTSTATUS
NICEvtInterruptEnable(
IN WDFINTERRUPT Interrupt,
IN WDFDEVICE AssociateDevice
)
{
PFDO_DATA fdoData;
fdoData = FdoGetData(AssociateDevice);
NICEnalbeInterrupt(Interrupt, fdoData);
return STATUS_SUCCESS;
}

NICEnableInterupt is simply a macro that sets the PCI device register to enable interrupts.

5. Code to Disable Interrupts

In the PCIDRV sample, the EvtInterruptDisable callback (also in isrdpc.c) simply calls the internal NICDisableInterrupt macro to set the PCI device register to disable interrupts. The following is the code:

NTSTATUS
NICEvtInterruptDisable(
IN WDFINTERRUPT Interrupt,
IN WDFDEVICE AssociatedDevice
)
{
PFDO_DATA fdoData;

fdoData = FdoGetData(AssociatedDevice);
NICDisableInterrupt(fdoData);
return STATUS_SUCCESS;
}

6. Post-Interrupt Enable and Pre-Interrupt Disable Processing

Some devices cause interrupt storms if they are initialized after their interrupts are enabled. The driver for such a device must therefore be able to perform initialization after the device enters DO but before its interrupt is enabled. Other devices, however, cannot be initialized until the interrupt is enabled. To enable correct operation of both types of devices, KMDF supplies post-interrupt enable and pre-interrupt disable events for which drivers can register.

When powering up a device, KMDF invokes a driver’s callbacks in the following order:

  1. EvtDeviceDOEntry

  2. EvtInterruptEnable

  3. EvtDeviceDOEntryPostInterruptsEnabled

KMDF calls EvtDeviceDOEntry first. Drivers that must initialize their devices before the interrupt is connected (for example, to prevent interrupt storms) should do so in this callback. Next, KMDF calls EvtInterruptEnable. Drivers should enable their interrupts and do little or nothing else in this function because it is called at DIRQL. Finally, KMDF calls EvtDeviceDOEntryPostInterruptsEnabled at PASSIVE_LEVEL. Drivers that must initialize their devices after the interrupt is connected should do so in this callback.

At power-down, KMDF calls the corresponding paired functions in the opposite order:

  1. EvtDeviceDOExitPreInterruptsDisabled

  2. EvtInterruptDisable

  3. EvtDeviceDOEXit

To undo work done by the EvtDeviceDOEntryPostInterruptsEnabled, a driver registers an EvtDeviceDOExitPreInterruptsDisabled function. Like the post-enable function, the pre-disable function does work at PASSIVE_LEVEL in preparation for disabling the interrupt.

A driver must register the post-interrupt enable and pre-interrupt disable callbacks in the WDF_PNPPOWER_EVENT_CALLBACKS structure before creating the device object. The PCIDRV sample fills this structure in its EvtDriverDeviceAdd callback, as follows:

pnpPowerCallbacks.EvtDeviceDOEntryPostInterruptsEnabled =
NICEvtDeviceDOEntryPostInterruptsEnabled;
pnpPowerCallbacks.EvtDeviceDOExitPreInterruptsDisabled =
NICEvtDeviceDOExitPreInterruptsDisabled;

In the current version of the PCIDRV sample, both of these functions are stubs.

Other  
  •  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
  •  Byod – Good Or Bad Or Unknown?
  •  Windows 7 : WORKING WITH THE FIREWALL (part 6) - Using the GPO Technique - Adding a New Application Rule, Removing an Application Rule
  •  
    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
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us