Friday, January 7, 2011

windows dma another take

http://msdn.microsoft.com/en-us/library/ff540590(v=vs.85).aspx

1.wdm dma
uses IoGetDmaAdapter
DeviceDescription parameter in this determines map buffer or scatter gather method

2.map buffer dma
AllocateAdapterChannel uses user mode mdl request
it checks preallocated map registers
when dma is possible for the adapter, adapter routine is called
from adapter routine, map transfer for mdl,length is done.it returned the device logical address
the device logical address is programmed into the hardware
return deallocate adapter
for scatter gather simulation call maptransfer continuously,each map transfer is 1 map register,1 sge,maximum of num of map register for which maptransfer can be called depends on IoGetDmaAdapter
The above step is for single irp, and sequential processing

3.scatter gather dma
for a single irp driver calls getscattergatherlist,which invokes adapterlistcontrol routine
adapterlistcontrol has gets sgl,mapregisterbase

after a dma for current fdo is finished ,its map registers should be freed so that another fdo
in the system can do a allocateadapterchannel adaptercontrol callback

so dma hops from one fdo to another like isr searching entire system.

Also we can allocate a commonbuffer and skip adaptercontrol and do the dma directly.this is
because for common buffer we already get the device logical address(phy address),in former we
had to wait for the adapter control to get the map register and then call maptransfer to get the
device logical address

In get/setscattergatherlist method we can parallelly issue multiple getscattergatherlist and
then adapterlistcontrolgets called async,we process the sgl input and program the device

2.ndis dma
NdisMInitializescattergatherlist() if called uses get/setscattergatherlist method above.
otherwise, the first method is used.

A serialized nic uses NdisMAllocateMapRegisters
A deserialized one uses other

the first method allocates shared memory,copy data into shared memory,get map register using
NdisMStartBufferPhysicalMapping the resultant device logical address is programmed,maybe shared
memory address is directly used,output is similar to sgl but for single mdl

maptransfer gives output single mapregister entry with length.this can be multiple contiguous
physical page.the length of output is given in one of the parameters.

max dma size lso - 64k
max dma offld - 1mb

common windbg commands

1.!analyze -v
2.lm
3.!sym noisy
4..reload /n
5.bl,bp,bc
6.ld
7.x
8.http://windbg.info/doc/1-common-cmds.html#7_symbols
9.lm vm module -- timestamp
10.http://blogs.technet.com/b/marcelofartura/archive/2008/06/18/kernel-dump-analysis-bugcheck-1e-kmode-exception-not-handled.aspx
11.http://www.wd-3.com/archive/registercontext.htm
12.

At the start of called function:
1.push ebp ; Save the old stack base
2.mov ebp, esp ; Stack base becomes the current top of the stack
3.sub esp, 0xc ; Save space for local variables
4.mov eax, [ebp+8] ; example reference to one of the parameters
==========================================
1.http://www.technochakra.com/assembly-and-the-art-of-debugging/
==========================================

windows qos application

1.DSMark is supported only from vista
http://blogs.msdn.com/b/wndp/rss.aspx?Tags=QoS
2.DSMark in 2003
http://technet.microsoft.com/en-us/library/cc737728(WS.10).aspx
3.reflection in driver
http://blogs.msdn.com/b/wndp/archive/2007/09/07/detecting-802-1p-priority-tags.aspx
4.http://blogs.msdn.com/b/wndp/archive/tags/qos/
5.code for checking dscp and 802.1Q
http://read.pudn.com/downloads118/sourcecode/hack/501599/Priority_Inspection_LWF/src/filter/filter.c__.htm
6.Flow control snippet
http://blogs.msdn.com/b/wndp/rss.aspx
7.http://msdn.microsoft.com/en-us/library/aa374094(v=VS.85).aspx