14.1.1.2  Setting Up Context for an IoTimer Routine

The Context passed to IoInitializeTimer points to a context area where other driver routines and the IoTimer routine can maintain state about timed operations. This Context pointer is passed to the IoTimer routine whenever it is called, as shown by the declaration.

Such a context area must be in resident memory allocated by the driver. Usually, this context area is in the associated device object’s device extension. It can be in a controller extension if the driver uses a controller object or in nonpaged pool allocated by the driver. The contents of the context area are driver-determined.

If it shares a context area with the driver’s ISR, the IoTimer routine must call KeSynchronizeExecution with a driver-supplied SynchCritSection routine in order to access the shared context safely.

If the IoTimer routine shares a context area only with nonISR driver routine(s), the shared area at Context must be protected by an executive spin lock.

For more information about SynchCritSection routines, see Chapter 10. For more information about using executive and interrupt spin locks, see Chapter 16.