Please see the KernelDriver\samples and KernelDriver\plx directories for kernel mode driver samples for Windows NT. The steps for other supported OSs are identical on the source code level (except for the special C++ classes, which are currently only supported on Windows NT 4.0) The makefile will differ, of course, since this is platform and compiler dependent.
If you want to write a kernel mode driver using KernelDriver you also need access to the
WinDriver APIs that are implemented by the kernel module windrvr.o/windrvr.sys/windrvr.vxd , so you will need to have this activated. Under Windows, the KernelDriver installation does this automatically. Under Linux, you will need to build and insert into the kernel the module windrvr.o.
Instructions to do this are available with the Linux distribution - you may refer to http://www.jungo.com/support/installation_instructions.html#install_linux for the same instructions.
Stepping into p9054_driver.c code.
- Step 1 - #include "kd.h".
This is the basic KernelDriver include file. It also includes windrvr.h, so you do not need to include it explicitly.
- Step 2 - #include "windrvr_int_thread.h" (a convenience wrapper for InterruptThreadEnable() and InterruptThreadDisable()).
- Step 3 - Make a call to KD_OpenWinDriver(). This opens a connection to the WinDriver module so that you can now access the WinDriver API, including interrupt handling.
- Step 4 - Link phase - For Linux: you need to link in wd_kd.o (you can see this in the makefile under the 9054/linux_module directory). This will give you access to malloc(), free() (kernel mode implementations, so you need not call kmalloc()/kfree()) and KP_DeviceIoControl() and WD_Open() etc.
- Step 5 - Now you can make calls to WD_Open(), WD_Close(), WD_Transfer(), etc. These are used in the kernel in the same way as you see in the code for the user mode sample driver application.
Back to Top
|