Is there anyone out there who has any experience of writing NT Device
Drivers for Busmaster devices or could point me in the direction of some
appropriate font of knowledge?
I am trying to write a device driver that supports a device that can write
into NT host memory. To this end, I have written a driver that:
- Uses HalGetAdapter() to create an adapter object.
Output: NumberOfMapRegisters = 1. - Uses MmCreateMdl() to allocate and initialise an MDL. The driver passes
the base and length of a local static buffer. The driver passes NULL as
the input MDL in order to allocate and initialise an MDL from nonpaged
pool.
[I also tried the alternative route of IoAllocateMdl() followed by MmProbeAndLockPages, but this was no more successful.] - Runs KeFlushIoBuffers() on this MDL with ReadOperation = FALSE and
DmaOperation = TRUE. - Uses IoAllocateAdapterChannel() (with required adjustment of IRQL) to
register a suitable AdapterControl callback routine:
Output: status = STATUS_SUCCESS - The callback routine now runs and stores away the MapRegisterBase that
was passed to it.
Output: MapRegisterBase = 0x80D13A55 - The main thread now continues and uses MmGetMdlVirtualAddress() to
obtain the VirtualAddress of the MDL that was created.
Output: VirtualAddress = 0xF385BC48 - The driver then uses IoMapTransfer() to set up the map register and
generate an address that the Busmaster device can use to write to NT host
memory.
Output: PhysicalAddress = 0x00211C48 - The driver passes this value to the Busmaster device which receives the
message and uses this address to write back into host memory. The
Busmaster device can confirm that the data it has written can be read
back. But when my driver looks at the local static buffer, it does not
find the data that was written. Apparently the Busmaster device has
written it somewhere else. - The driver finally runs IoFlushAdapterBuffers() with a NULL Adapter
Object, but that does not make the data appear.
Output: result = TRUE
Can anyone point out where I am going wrong or what step I have missed
out? Do the values that I am obtaining seem appropriate?
Thanks to anyone who can help.
Richard