Mail Archives: djgpp/2001/09/23/01:34:54
On Sun, 23 Sep 2001, Wiley Black wrote:
> I am trying to get the physical address of a
> selector, particularly the _my_ds() selector.
What do you need this for? If that's for DMA, see section 18.13 of the
DJGPP FAQ list.
In general, the mapping between the logical (a.k.a. linear) and physical
addresses in protected mode is quite arbitrary, and is held in the data
structures called Page Tables. Most DPMI environments don't let you
access the Page Tables, so you cannot know the physical address except in
a few special cases.
In addition to what the FAQ says in section 18.13, there's some sample
code written by Charles Sandmann which allows to compute a physical
address given a linear address, but only if you run under CWSDPMI (i.e.
in plain DOS).
> I
> have used __dpmi_get_segment_base_address() as
> well as using __dpmi_get_descriptor() and then
> assembled the base address based on my reference
> books. Both give me the same result, a base
> address of 0x10000000. This doesn't seem like the
> physical address to me?
No, it's a linear, or logical, address.
> Somewhere in the FAQ I
> had heard about linear and physical addresses
> being different, so I consulted my reference books
> again and my understanding is that the linear
> address is simply the segment right shifted 4 plus
> the offset, in other words, about the same.
This is only true for the first 1MB of the memory address space, i.e. for
the conventional memory. That's why the FAQ suggests to use a buffer in
conventional memory for DMA: it's easy to compute the physical address
there.
> Also,
> my reference seems to indicate the descriptor has
> the physical address anyway.
This is false: the descriptor stores a logical address, and the mapping
between it and the physical address is in the Page Tables.
- Raw text -