Handling SD Card Interrupts

Secure Digital (SD) card drivers do not have interrupt service routines (ISRs) and they do not acquire interrupt request (IRQ) resources. The SD bus driver detects and intercepts hardware interrupts, and then reports them to the device driver by means of the interrupt notification callback routine PSDBUS_CALLBACK_ROUTINE, as explained in sections Secure Digital (SD) Driver Stack and Opening and Initializing an SD Bus Interface.

The device driver does not have to complete interrupt processing in the context of the interrupt notification callback routine. The driver can return from the callback routine and complete interrupt processing in its own context. When the driver finishes processing the interrupt, it informs the bus driver by an explicit call to an interrupt acknowledgment routine supplied with the SD bus interface. For more information about the interrupt acknowledgment routine, see PSDBUS_ACKNOWLEDGE_INT_ROUTINE. When the bus driver receives this call, it re-enables the interrupt.

SD device drivers have two options with respect to the IRQ levels (IRQLs) at which they run. An SD driver can run exclusively at PASSIVE_LEVEL, or it can run at DISPATCH_LEVEL while in the context of the interrupt notification callback routine and at PASSIVE_LEVEL the rest of the time. When an SD device driver runs exclusively at PASSIVE_LEVEL, the bus driver assumes responsibility for synchronizing interrupts. Choose this option if your device can operate without strict limits on interrupt latency because it will simplify the design of your driver. In addition to offloading the task of interrupt synchronization onto the bus driver, there are other benefits. For instance, drivers must frequently transfer data in response to an interrupt. If the driver's callback routine is running at PASSIVE_LEVEL, it is free to do a synchronous I/O operation rather than an asynchronous one. If the callback routine runs at DISPATCH_LEVEL, the driver must wait until it is running at a lower IRQL before doing synchronous I/O.

An SD device driver specifies the IRQL at which it will run when it initializes the SD bus interface. To run at DISPATCH_LEVEL in the interrupt notification callback routine, the driver must set the CallbackAtDpcLevel member of the SDBUS_INTERFACE_PARAMETERS structure to TRUE and pass this structure to the interface initialization routine. For a description of the interface routine, see PSDBUS_INITIALIZE_INTERFACE_ROUTINE. To run exclusively at PASSIVE_LEVEL, the driver must set CallbackAtDpcLevel to FALSE.

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft