Well, ignoring for the moment the fact that you CAN apparently call
MmMapIoSpace at DISPATCH (which surprised me too by the way), it doesn’t
matter what you specify for virtual address – you are going to use the
systemaddress anyway, not the user address which is what this parameter is
for.
So:
PMDL MyMdl = IoAllocateMdl(NULL,64*1024,FALSE,FALSE,NULL)
Should get you the mdl. Once it’s initialized, you can setup the physical
page array using the MmGetMdlPfnArray() routine and inserting the physical
page numbers of the 64KB region you want to map into it.
BTW; I don’t know how often you plan on doing this, BUT setting up and
tearing down virtual mappings is a fairly expensive process given that you
have to shoot down the TLB on every processor for both - this means you
invalidate all the TLBs (and take the overhead of sending IPIs to every
processor) twice each time you do this. If you plan on doing this a lot, you
should also plan on caching as many of these mappings as you can (consistent
with not using up all the system resources of course).
This comment applies to using MmMapIoSpace as well btw - you’d better look
into the pattern of 64KB chunks you need access to and come up with a scheme
that minimises the number of times you have to do it…
/simgr
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Michael Huang
Sent: Thursday, February 03, 2005 11:33 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Accessing large physical memory block (128M-1G)
Thanks Simon,
That’s exactly what I want to accomplished, but how could I build a MDL
pointing to the 64KB in that range? I know I could get an MDL by MmCreateMdl
or IoAllocateMdl, but don’t know how to let the MDL pointing to that
specific 64KB, also don’t know what Base addr or VirtualAddress needed to be
passed to MmCreateMdl or IoAllocateMdl call.
Could you shed a light here? Thanks a lot.
Michael
“Graham, Simon” wrote in message
news:xxxxx@ntdev…
> So - you have an area of physical memory pre-allocated for your device
> outside of NT and you want to get virtual access to a 64KB chunk - How
> about
> building a MDL and using MmGetSystemAddressForMdlSafe (or
> MmMapLockedPagesSpecifyCache if you need non-cached access). Both of these
> can be done at DISPATCH.
>
> (I think you also need to make sure you set the MDL_IO_SPACE flag in the
> MDL
> flags; otherwise the routine will expect the pages to be known by NT.)
>
> /simgr
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Michael Huang
> Sent: Wednesday, February 02, 2005 2:41 PM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] Accessing large physical memory block (128M-1G)
>
> Hi Ralf,
>
> Thanks for the reply. We had this space reserved already, not by /MAXMEM
> or
> /BURNMEMORY in boot.ini though. My question is how to access it in
> DISPATCH
> level, less than 64KB each time.
>
> -----------
> Michael
>
> “Ralf Buschmann” wrote in message news:xxxxx@ntdev…
>> Michael,
>>
>> you wrote on Wednesday, February 2, 2005, 18:45:24:
>>
>> MH> We need this space as a special RAM cache for a special app. I’m
>> aware
>
>> of
>> MH> that a driver can’t map too much memory into kernel space due to the
>> limited
>> MH> number of system PTE. But my driver only needs to map less than 64KB
>> each
>> MH> time, it will be unmapped after using, can’t see why it can’t be
>> done.
>>
>> What about /MAXMEM or /BURNMEMORY in boot.ini?
>>
>> –
>> Ralf.
>>
>>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com