From - Thu Sep 25 07:41:09 1997
Path: news.mitre.org!blanket.mitre.org!agate!newsgate.duke.edu!nntprelay.mathworks.com!EU.net!main.Germany.EU.net!main.de.uu.net!Dortmund.Germany.EU.net!Dortmund.de.uu.net!spock.skd.de!not-for-mail
From: "Stephan Wolf" <swolf@syskonnect.de>
Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode
Subject: Re: Some NDIS and DMA related questions
Date: Thu, 25 Sep 1997 09:35:00 GMT
Organization: SysKonnect
Lines: 62
Message-ID: <342a2c4a.4627023@spock>
References: <3429858E.4A5C@dtix.com>
NNTP-Posting-Host: swolf.skd.de
X-Newsreader: Forte Free Agent 1.11/32.235

On Wed, 24 Sep 1997 17:26:39 -0400, Ashish Lal <lal@dtix.com> wrote:

>(1) Why can NdisMAllocateSharedMemory be called only during
>initialization or IRQL_PASSIVE_LEVEL ?

Probably because the system does only allow allocating this type of
memory at IRQL_PASSIVE_LEVEL. Use NdisMAllocateSharedMemoryAsync() for
IRQL <= DISPATCH_LEVEL (NDIS4 only).

>	Also, what is the difference
>between NdisMAllocateSharedMemory and NdisAllocateMemory with the
>NDIS_MEMORY_CONTIGUOUS flag on (caching not important). Of course, I am
>asking for difference other than the fact that NdisMAllocateSharedMemory
>returns with a physical address and it is not necessary to call
>NdisMStartBufferPhysicalMapping later for small transfers. What is the
>difference in the "kind" of memory allocated ? (both contiguous ?)

Yes, they are both contiguous. And yes, the difference *is* the fact
that the "shared" memory is physically locked all the time, whereas
"normal" memory must explicitly be locked before you can DMA from/to
it.

>Would calling NdisAllocateMemory with NDIS_MEMORY_CONTIGUOUS flag and
>later calling NdisMStartBufferPhysicalMapping to get the physical
>address be the same as calling NdisMAllocateSharedMemory ? 
>(NdisFlushBuffer, NdisMUpdateSharedMemory etc unimportant in this
>discussion).

Yes, but I don't think the system would be very happy if you don't
call NdisMCompleteBufferPhysicalMapping() shortly after you lock the
memory with the "start" call.

>(2) After memory has been setup and during the actual DMA transfer, I
>have seen in some timing diagrams that many devices expect a DEVSEL#
>(device select complement) signal from the PCI bus. (I am talking about
>PCI Bus Master DMA only). My impression is that this signal is usually
>up and goes low during the period of DMA (I donot know why) so that DMA
>can take place. Is this in any way related to memory that has been setup
>for DMA ? Can someone please tell me more about this DEVSEL signal from
>the PCI Bus ?

I'm only a poor software guy, but I strongly guess the DEVSEL has
absoluetly nothing to do with how your driver allocates its memory.

>(3) Any difference between starting the driver at boot time and starting
>it manually ? (I mean is there any difference between allocating DMA
>memory at boot time and allocating it after the system is up by doing a
>"net start XXdriver" from the command line (or starting the driver
>manually from the control panel->devices) ? )

Hmm, according to MS "shared" memory is a sparse resource and its
availability even gets worse the longer the system is up and running.
This is because memory gets fragmented more and more. You might be
able to allocate large contiguous amounts of "shared" memory when the
system comes up, but you possibly can't do this when your driver is
started later via NET START.

(Note that allocating large contiguous amounts of "shared" memory
isn't a good idea, anyway.)

Stephan Wolf <swolf@syskonnect.de> http://www.syskonnect.de
SysKonnect - The Server Connectivity Company