yep - that method (common buffer offset) works just fine. Scsiport uses this for some things.
-p
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of ldx
Sent: Wednesday, June 11, 2003 5:00 PM
To: NT Developers Interest List
Subject: [ntdev] Re: How to translate a physical address to virtual address?
Thanks for your replying.
Your problem can be solved by building a data structure in your driver
that correlates the LOGICAL ADDRESSES you supplied to your device with
the original virtual address. Depending on the number of entries in
this data structure, this can be a linked list, a has table, or a
lookaside table. You search the table using the LOGICAL ADDRESS as the
key to find your virtual address.
You are right, but I want to find a better way to do this, because I think it will cause bad performance to search the table. Under Linux, there are two functions virt_to_bus and bus_to_virt, so I want to find the corresponding functions under NT.
I find another method to solve this. If I allocate a COMMON_BUFFER, then I can get the virtual address(assumed VA) and the LOGICAL_ADDRESS(assumed PA) of this buffer, then I put PA+offset=PEA to register and when the request finished, translate the PEA to VEA (virtual effective address, I just called it this.) by PEA-PA + VA=VEA.
Do u think the above can solve the problem?
Thanks again!
ldx
2003-6-12
--------------- 2003-06-11 You wrote---------------
Ldx,
It sounds like you are inventing your own DMA mechanism, and that is a
REAL BAD THING.
I suspect that Maxim assumed that you were referring to device memory,
instead it seems that you are referring to system memory. Transfers
between device and system memory initiated by the device (DMA) must use
the defined DMA mechanisms in NT. Read the DDK about how to perform DMA operations.
NT requires you to map physical addresses into what the DDK refers to
as a Logical Address. You must use either an MDL or a COMMON_BUFFER in
order to obtain a Logical Address, and you must have an AdapterObject
in order to use the MDL or allocate the COMMON_BUFFER.
Your problem can be solved by building a data structure in your driver
that correlates the LOGICAL ADDRESSES you supplied to your device with
the original virtual address. Depending on the number of entries in
this data structure, this can be a linked list, a has table, or a
lookaside table. You search the table using the LOGICAL ADDRESS as the
key to find your virtual address.
-----Original Message-----
From: ldx [mailto:ldxlq@263.net]
Sent: Tuesday, June 10, 2003 2:00 PM
To: NT Developers Interest List
Subject: [ntdev] Re: How to translate a physical address to virtual address?
hi,Maxim S. Shatskih,
MmMapIoSpace runs at passive level. I need translate it in dispatch level.
and I think this function is for iospace mapping to virtual address. right?
But I want to use the function for this case:
I put many physical addresses(requests) into a memory area and put the
physical address of the area to the register of my device, after the
device finishes some requests, it moves the requests to a list pointed
by another register.
Then I get completed requests from the list but can’t translate the
requests to virtual address to access them. (This is done in a
dpcforisr, executed at DISPATCH_LEVEL.)
Maybe I can use a workitem to do the completerequtest work. Then if
MmMapIoSpace can translate physical to virtual address, the requests
can be translated and be accessed.
I will try it.
Thanks a lot.
ldx
2003-06-11
======= original message=======
>MmMapIoSpace is the correct function. Don’t forget to unmap then.
>
> Max
>
>----- Original Message -----
>From: “ldx”
>>To: “NT Developers Interest List”
>>Sent: Wednesday, June 11, 2003 10:13 AM
>>Subject: [ntdev] How to translate a physical address to virtual
>>address?
>>
>>
>>> Dear all,
>>>
>>> if I got a physical address from my device, how can I access the
>>memory pointed by it?
>>> There is a function named mmGetVirtualForPhysical, but ddk says it
>>is for internal use.
>>> Can I use this function? or any other routines to do it?
>>>
>>> Any suggestion is appreciated!
>>>
>>>
>>> ldx
>>> 2003-06-11
>>>
>>>
>>>
>>>
>>> —
>>> You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
>>> unsubscribe send a blank email to
>>xxxxx@lists.osr.com
>>>
>>
>>
>>
>>—
>>You are currently subscribed to ntdev as: ldxlq@263.net To unsubscribe
>>send a blank email to xxxxx@lists.osr.com
>
>= = = = = = = = = = = = = = = = = = = =
>
>
>
>
>b嫐.Ф\??辷?底痡?瓺hu墁抖??.炈洷殊m?澲洉╀zf?y炞^縨=?b槽(卜(
>
>
>—
>You are currently subscribed to ntdev as: ldxlq@263.net To unsubscribe
>send a blank email to xxxxx@lists.osr.com
-----------------------------------------------------
—
You are currently subscribed to ntdev as: xxxxx@microsoft.com To unsubscribe send a blank email to xxxxx@lists.osr.com