three kinds of addresses...

Hello,

As per my knowlwdge, there are three kinds of addresses

  1. Logical address--- which we used in application program.
  2. Linear address-- After doing segmentation of logical address, we get this.
  3. Physical address-- gotten from linear address( from paging) and it is the
    address which is placed on address bus.

I am bit confused here, who is responsible for getting these address. Winodws
NT(i.e. Operating system) or Microprocessor?

And my second query is, which one of the above mentioned address do we see in
WinDbg and SoftIce?

Thanks,
Giri


This e-mail has been sent to you courtesy of OperaMail, as a free service from
Opera Software, makers of the award-winning Web Browser, Opera. Visit us at
http://www.opera.com/ or our portal at: http://www.myopera.com/ Your free e-mail
account is waiting at: http://www.operamail.com/


You are currently subscribed to ntdev as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-ntdev-$subst('Recip.MemberIDChar')@lists.osr.com

Giri,

The general, non-device-type-specific Windows NT/2000/XP docs use a slightly
different terminology. It gets confusing, but here are some general
guidelines to help keep it straight:

For DMA operations:

  1. Virtual Address - used in code running on the host CPU to access memory
    space (a pointer)
  2. Physical Address - value placed onto the host processor’s bus by the
    host processor’s MMU when the code accesses a Virtual address (generally
    worthless for DMA to/from main memory, the subject of much abuse because in
    many implementations these map 1:1 to Logical Addresses)
  3. Logical Address - translated, bus-relative address that a device on a
    bus can use to access memory space (the value you program into the
    hardware’s registers)

For PIO or configuration:

  1. Virtual Address - same as above, just a pointer.
  2. Physical Address - bus-relative Physical Address, such as from a
    device’s configuration registers
    3. Physical Address - processor-relative physical address, not
    necessarily the same as the Raw value. This is what you should pass to
    MmMapIoSpace if necessary.

    For user-mode to kernel-mode address translation/mappings:
    1. Virtual Address - pointer valid only in the context of the original
    calling thread.
    2. System Address - pointer valid in kernel mode in ANY context - note,
    however, that just because it’s VALID, doesn’t imply it’s PRESENT - touching
    a system address that points to Paged memory is incorrect if the current
    IRQL >= DISPATCH_LEVEL.

    These guidelines don’t apply as well to the SCSI, NDIS, and Video
    driver-specific docs, which simplify this somewhat.

    -Tim

    Timothy A. Johns — xxxxx@driverdev.com
    Driver Development Corporation — 800.841.0092
    Bring Up Your Hardware — Fast. www.driverdev.com

    > -----Original Message-----
    > From: xxxxx@lists.osr.com
    > [mailto:xxxxx@lists.osr.com]On Behalf Of Girish Desai
    > Sent: Thursday, June 14, 2001 5:16 PM
    > To: NT Developers Interest List
    > Subject: [ntdev] three kinds of addresses…
    >
    >
    > Hello,
    >
    > As per my knowlwdge, there are three kinds of addresses
    > 1. Logical address— which we used in application program.
    > 2. Linear address-- After doing segmentation of logical address,
    > we get this.
    > 3. Physical address-- gotten from linear address( from paging)
    > and it is the
    > address which is placed on address bus.
    >
    > I am bit confused here, who is responsible for getting these
    > address. Winodws
    > NT(i.e. Operating system) or Microprocessor?
    >
    > And my second query is, which one of the above mentioned address
    > do we see in
    > WinDbg and SoftIce?
    >
    > Thanks,
    > Giri
    >
    > ------------------------------------------------------------
    > This e-mail has been sent to you courtesy of OperaMail, as a
    > free service from
    > Opera Software, makers of the award-winning Web Browser,
    > Opera. Visit us at
    > http://www.opera.com/ or our portal at: http://www.myopera.com/
    > Your free e-mail
    > account is waiting at: http://www.operamail.com/
    > ------------------------------------------------------------
    >
    >
    > —
    > You are currently subscribed to ntdev as: xxxxx@driverdev.com
    > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
    >


    You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
    To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> 1. Logical address— which we used in application program.

NT uses segmentation only to a very limited extent.

  1. Linear address-- After doing segmentation of logical address, we get
    this.

Called “virtual addresses” in NT.

And my second query is, which one of the above mentioned address do we see
in
WinDbg and SoftIce?

Virtual.
There are also means to see the physical addresses.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I have couple of questions about this topic as well.

From the point of view of DMA operation. Is there a way to convert a Logical
Address into Virtual Address. For example, when we use
AllocateCommonBuffer() it gives out both of these addresses for the
non-paged memory allocated. The Logical Address is the one to be used by the
device so it can access this common memory. Question is …is it possible to
get back to the corresponding virtual address from the logical address alone
?

Second question is …can one consider logical address also equal to
bus-relative physical address or they definitely poles apart ?

regards,
Hassan

From: “Timothy A. Johns”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: three kinds of addresses…
>Date: Thu, 14 Jun 2001 17:57:08 -0700
>
>Giri,
>
>The general, non-device-type-specific Windows NT/2000/XP docs use a
>slightly
>different terminology. It gets confusing, but here are some general
>guidelines to help keep it straight:
>
>For DMA operations:
>1. Virtual Address - used in code running on the host CPU to access memory
>space (a pointer)
>2. Physical Address - value placed onto the host processor’s bus by the
>host processor’s MMU when the code accesses a Virtual address (generally
>worthless for DMA to/from main memory, the subject of much abuse because in
>many implementations these map 1:1 to Logical Addresses)
>3. Logical Address - translated, bus-relative address that a device on a
>bus can use to access memory space (the value you program into the
>hardware’s registers)
>
>For PIO or configuration:
>1. Virtual Address - same as above, just a pointer.
>2. Physical Address - bus-relative Physical Address, such as from a
>device’s configuration registers
>3. Physical Address - processor-relative physical address,
>not
>necessarily the same as the Raw value. This is what you should pass to
>MmMapIoSpace if necessary.
>
>For user-mode to kernel-mode address translation/mappings:
>1. Virtual Address - pointer valid only in the context of the original
>calling thread.
>2. System Address - pointer valid in kernel mode in ANY context - note,
>however, that just because it’s VALID, doesn’t imply it’s PRESENT -
>touching
>a system address that points to Paged memory is incorrect if the current
>IRQL >= DISPATCH_LEVEL.
>
>These guidelines don’t apply as well to the SCSI, NDIS, and Video
>driver-specific docs, which simplify this somewhat.
>
>-Tim
>
>Timothy A. Johns — xxxxx@driverdev.com
>Driver Development Corporation — 800.841.0092
>Bring Up Your Hardware — Fast. www.driverdev.com
>
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com]On Behalf Of Girish Desai
> > Sent: Thursday, June 14, 2001 5:16 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] three kinds of addresses…
> >
> >
> > Hello,
> >
> > As per my knowlwdge, there are three kinds of addresses
> > 1. Logical address— which we used in application program.
> > 2. Linear address-- After doing segmentation of logical address,
> > we get this.
> > 3. Physical address-- gotten from linear address( from paging)
> > and it is the
> > address which is placed on address bus.
> >
> > I am bit confused here, who is responsible for getting these
> > address. Winodws
> > NT(i.e. Operating system) or Microprocessor?
> >
> > And my second query is, which one of the above mentioned address
> > do we see in
> > WinDbg and SoftIce?
> >
> > Thanks,
> > Giri
> >
> > ------------------------------------------------------------
> > This e-mail has been sent to you courtesy of OperaMail, as a
> > free service from
> > Opera Software, makers of the award-winning Web Browser,
> > Opera. Visit us at
> > http://www.opera.com/ or our portal at: http://www.myopera.com/
> > Your free e-mail
> > account is waiting at: http://www.operamail.com/
> > ------------------------------------------------------------
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@driverdev.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hassan,

Please see below, in the text of your message.

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Hassan I Khan
Sent: Friday, June 15, 2001 1:57 AM
To: NT Developers Interest List
Subject: [ntdev] RE: three kinds of addresses…

I have couple of questions about this topic as well.

From the point of view of DMA operation. Is there a way to
convert a Logical
Address into Virtual Address. For example, when we use
AllocateCommonBuffer() it gives out both of these addresses for the
non-paged memory allocated. The Logical Address is the one to be
used by the
device so it can access this common memory. Question is …is it
possible to
get back to the corresponding virtual address from the logical
address alone
?

You’ve got to track it yourself, from the base virtual and base physical
addresses you got back from AllocateCommonBuffer. Assuming the result is
inside the region you’ve mapped, LogicalAddress + SomeOffset corresponds to
VirtualAddress + SomeOffset. I don’t believe there’s a documented (or even
well-known undocumented) way to get a virtual address given some logical
address.

Second question is …can one consider logical address also equal to
bus-relative physical address or they definitely poles apart ?

A logical address is a bus-relative physical address of something. The
problem with making a general statement is that during certain DMA
operations (non-scatter-gather, packet-based being a common one) you can’t
be assured that ‘something’ is actually your buffer in main memory. You
can, however, visualize it that way for the purpose of understanding, and
all will be fine as long as you ‘follow the rules’ for DMA from the DDK
docs. To answer your question directly, you can’t always consider them to
be the exact same thing, but they’re really not poles apart, either -
they’re definately conceptually similar.

regards,
Hassan


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> device so it can access this common memory. Question is …is it possible
to

get back to the corresponding virtual address from the logical address
alone
?

I think no, though maybe MmMapIoSpace will allocate the virtual address for
this.

Second question is …can one consider logical address also equal to
bus-relative physical address or they definitely poles apart ?

IIRC yes.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Sorry, this is a test, please do not respond


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hassan:

If you really need that information, a sequential scanning of the page
tables can
do it. It will take a lot of time unless you have already some idea of what
the virtual
addresses might be.

Of course I assume that while you scan the page tables they are not
changing too
much and affect your scan. You probably have to do it at DISPATCH_LEVEL.

George

At 10:49 PM 6/14/01 -0700, you wrote:

Hassan,

Please see below, in the text of your message.

-Tim

Timothy A. Johns — xxxxx@driverdev.com
Driver Development Corporation — 800.841.0092
Bring Up Your Hardware — Fast. www.driverdev.com

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com]On Behalf Of Hassan I Khan
> Sent: Friday, June 15, 2001 1:57 AM
> To: NT Developers Interest List
> Subject: [ntdev] RE: three kinds of addresses…
>
>
> I have couple of questions about this topic as well.
>
> From the point of view of DMA operation. Is there a way to
> convert a Logical
> Address into Virtual Address. For example, when we use
> AllocateCommonBuffer() it gives out both of these addresses for the
> non-paged memory allocated. The Logical Address is the one to be
> used by the
> device so it can access this common memory. Question is …is it
> possible to
> get back to the corresponding virtual address from the logical
> address alone
> ?

You’ve got to track it yourself, from the base virtual and base physical
addresses you got back from AllocateCommonBuffer. Assuming the result is
inside the region you’ve mapped, LogicalAddress + SomeOffset corresponds to
VirtualAddress + SomeOffset. I don’t believe there’s a documented (or even
well-known undocumented) way to get a virtual address given some logical
address.

>
> Second question is …can one consider logical address also equal to
> bus-relative physical address or they definitely poles apart ?

A logical address is a bus-relative physical address of something. The
problem with making a general statement is that during certain DMA
operations (non-scatter-gather, packet-based being a common one) you can’t
be assured that ‘something’ is actually your buffer in main memory. You
can, however, visualize it that way for the purpose of understanding, and
all will be fine as long as you ‘follow the rules’ for DMA from the DDK
docs. To answer your question directly, you can’t always consider them to
be the exact same thing, but they’re really not poles apart, either -
they’re definately conceptually similar.

>
>
> regards,
> Hassan
>
>


You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi George,

this looks like an idea. But before I try it do you think it would be faster
than scanning a linked list containing matching Virtual addresses. The
linked list max length is not expected to be more than 50-60 nodes. For the
time being I am searching my linked list for the corresponding virtual
address. Once found I use that address to mark the common buffer unused. But
I was looking for a faster method. Just like the one I saw in the linux
driver. Our linux driver just uses bus_to_virt() call & bingo. No need to
save the virtual addresses in a linked list and search for it afterwards !

And Tim,

thanks for your insightful explanation. Though I confess, I need to work
more on it get a proper feel of this whole drama. I know the facts now. But
I really want to know ‘why’ do you have to have all these flavors of
addresses. Reference to any book/article that goes deeper into this subject
and answer the ‘why’ question would be greatly appreciated or even reference
to something that explains ‘how’ the addresses are calculated underwater by
HAL would be equally useful.

Thanks again,
regards,
Hassan

From: George Blat
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] RE: three kinds of addresses…
>Date: Fri, 15 Jun 2001 10:12:08 -0700
>
>
>Hassan:
>
>If you really need that information, a sequential scanning of the page
>tables can
>do it. It will take a lot of time unless you have already some idea of what
>the virtual
>addresses might be.
>
>Of course I assume that while you scan the page tables they are not
>changing too
>much and affect your scan. You probably have to do it at DISPATCH_LEVEL.
>
>George
>
>
>
>At 10:49 PM 6/14/01 -0700, you wrote:
>>Hassan,
>>
>>Please see below, in the text of your message.
>>
>>-Tim
>>
>>
>>Timothy A. Johns — xxxxx@driverdev.com
>>Driver Development Corporation — 800.841.0092
>>Bring Up Your Hardware — Fast. www.driverdev.com
>>
>>
>> > -----Original Message-----
>> > From: xxxxx@lists.osr.com
>> > [mailto:xxxxx@lists.osr.com]On Behalf Of Hassan I Khan
>> > Sent: Friday, June 15, 2001 1:57 AM
>> > To: NT Developers Interest List
>> > Subject: [ntdev] RE: three kinds of addresses…
>> >
>> >
>> > I have couple of questions about this topic as well.
>> >
>> > From the point of view of DMA operation. Is there a way to
>> > convert a Logical
>> > Address into Virtual Address. For example, when we use
>> > AllocateCommonBuffer() it gives out both of these addresses for the
>> > non-paged memory allocated. The Logical Address is the one to be
>> > used by the
>> > device so it can access this common memory. Question is …is it
>> > possible to
>> > get back to the corresponding virtual address from the logical
>> > address alone
>> > ?
>>
>>You’ve got to track it yourself, from the base virtual and base physical
>>addresses you got back from AllocateCommonBuffer. Assuming the result is
>>inside the region you’ve mapped, LogicalAddress + SomeOffset corresponds
>>to
>>VirtualAddress + SomeOffset. I don’t believe there’s a documented (or
>>even
>>well-known undocumented) way to get a virtual address given some logical
>>address.
>>
>> >
>> > Second question is …can one consider logical address also equal to
>> > bus-relative physical address or they definitely poles apart ?
>>
>>A logical address is a bus-relative physical address of something. The
>>problem with making a general statement is that during certain DMA
>>operations (non-scatter-gather, packet-based being a common one) you can’t
>>be assured that ‘something’ is actually your buffer in main memory. You
>>can, however, visualize it that way for the purpose of understanding, and
>>all will be fine as long as you ‘follow the rules’ for DMA from the DDK
>>docs. To answer your question directly, you can’t always consider them to
>>be the exact same thing, but they’re really not poles apart, either -
>>they’re definately conceptually similar.
>>
>> >
>> >
>> > regards,
>> > Hassan
>> >
>> >
>>
>>
>>—
>>You are currently subscribed to ntdev as: xxxxx@ntrealtime.com
>>To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> address. Once found I use that address to mark the common buffer unused.
But

I was looking for a faster method. Just like the one I saw in the linux

The translation formula is:

CommonBufferVirtualBase + ( x - CommonBufferPhysicalBase )

x is your bus address.
Both bases are returned from AllocateCommonBuffer.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com