A driver written in user mode uses WinDriver's API (WDC_xxx and/or
WD_xxxWDC_xxx /
WD_xxx function calls from the user mode to the kernel without
modification, since the same WinDriver API is supported both in the user mode and
in the Kernel PlugIn.
There are two types of interaction between the WinDriver kernel and the WinDriver Kernel PlugIn:
At the end of your Kernel PlugIn development cycle, your driver will have the following components:
WDC_xxx / WD_xxx API.
WDC_xxx / WD_xxx API, and contains the driver
functionality that you have selected to bring down to the kernel level.
The following is a typical event sequence that covers all the functions that you can implement in your Kernel PlugIn:
| Event/Callback | Notes |
|---|---|
| Event: Windows loads your Kernel PlugIn driver. | This takes place at boot time, by dynamic loading, or as instructed by the registry. |
Callback: Your KP_Init Kernel PlugIn routine |
KP_Init informs WinDriver of the name(s) of your
KP_Open routine(s) |
|
• WDC_KernelPlugInOpen()• WDC_xxxDeviceOpen() (PCI• WD_KernelPlugInOpen() — when using the
low-level WinDriver API (see the WinDriver PCI Low-Level API Reference)
| |
KP_Open Kernel PlugIn callback routine |
KP_Open |
| Event/Callback | Notes |
|---|---|
WDC_CallKerPlug()WD_KernelPlugInCall() function (see the
WinDriver PCI Low-Level API Reference).
|
WDC_CallKerPlug() /
WD_KernelPlugInCall() to execute code in the kernel mode (in
the Kernel PlugIn driver). The application passes a message to the Kernel
PlugIn driver. The Kernel PlugIn driver will select the code to execute
according to the message sent.
|
Callback: Your KP_Call Kernel PlugIn routine |
KP_Call |
| Event/Callback | Notes |
|---|---|
WDC_IntEnable()fUseKP parameter set to TRUE (after having opened
a handle to the Kernel PlugIn), or calls the low-level
InterruptEnable() or WD_IntEnable() functions
(see the WinDriver PCI Low-Level API Reference) with a handle to a Kernel PlugIn driver (set in
the hKernelPlugIn field of the WD_INTERRUPT
structure passed to the function).
| |
Callback: Your
KP_IntEnable Kernel PlugIn routine | This function should contain any initialization required for your Kernel PlugIn interrupt handling. |
| Event: Your hardware creates an interrupt. | |
KP_IntAtIrqlKP_IntAtIrqlMSI |
KP_IntAtIrqlKP_IntAtIrqlMSIIf more interrupt processing is required, KP_IntAtIrql
(legacy interrupts) or KP_IntAtIrqlMSI
(MSI/MSI-X) can return TRUE in order
to defer additional processing to the relevant deferred processing
interrupt handler — KP_IntAtDpcKP_IntAtDpcMSI |
WDC_IntDisable()InterruptDisable() or
WD_IntDisable() functions (see the WinDriver PCI Low-Level API Reference), when
the interrupts were previously enabled in the Kernel PlugIn (see the
description of the interrupt enable event above).
| |
Callback: Your
KP_IntDisable Kernel PlugIn routine |
This function should free any memory that was allocated by the
KP_IntEnable callback |
| Event/Callback | Notes |
|---|---|
Event: The Kernel PlugIn high-IRQL interrupt handler —
KP_IntAtIrqlKP_IntAtIrqlMSITRUE.
| This informs WinDriver that additional interrupt processing is required as a Deferred Procedure Call (DPC) in the kernel. |
Callback: Your Kernel PlugIn DPC interrupt handler —
KP_IntAtDpcKP_IntAtDpcMSI | Processes the rest of the interrupt code, but at a lower priority than the high-IRQL interrupt handler. |
Event: The DPC interrupt handler — KP_IntAtDpcKP_IntAtDpcMSI | This informs WinDriver that additional user-mode interrupt processing is required. |
Callback: WD_IntWait() (see the WinDriver PCI Low-Level API Reference)
returns.
| Your user-mode interrupt handler routine is executed. |
| Event/Callback | Notes |
|---|---|
WDC_EventRegister()fUseKP
parameter set to TRUE (after having opened the device with a
Kernel PlugIn), or calls the low-level EventRegister()
(see the WinDriver PCI Low-Level API Reference) or WD_EventRegister() functions
with a handle to a Kernel PlugIn driver (set in the
hKernelPlugIn field of the WD_EVENT structure
that is passed to the function).
| |
| Event: A Plug-and-Play or power management event (to which the application registered to listen) occurs. | |
Callback: Your KP_Event Kernel PlugIn routine |
KP_Event receives information about the event that occurred
and can proceed to handle it as needed.
|
Event: KP_EventTRUE.
| This informs WinDriver that the event also requires user-mode handling. |
Callback: WD_IntWait() (see the WinDriver PCI Low-Level API Reference)
returns.
| Your user-mode event handler routine is executed. |