Board index » delphi » Question: Physical memory access in DOS protected mode

Question: Physical memory access in DOS protected mode

My application requires access to a PCI memory mapped device. The memory
aperture is necessarily mapped above the 1 MB boundary.

My application is written in Borland Pascal with Objects Version 7.0 and
compiled for protected mode. Switching to another compiler or target are not
options.

How do you access physical memory located above the 1 MB boundary?

I think I need to do something like the following:

  Selector := AllocSelector(DSeg);
  SetSelectorBase(Selector, HiWord(PhysicalAddress) shl 4
+LoWord(PhysicalAddress));
  SetSelectorLimit(Selector, Size);

  Value := mem[Selector : 0];

Of course, this only works when the physical address is below the 1 MB
boundary. Otherwise, any attempt to perform a read or write with this selector
generates unhandled exception error 000D.

I understand that SetSelectorBase needs to receive a linear address and not
a physical address.

I wrote some inline assembly to call int31h, function 800h to obtain a
linear address, but I still seem to have the problem.

I am new to this newsgroup and apologize in advance if this topic has already
been beaten to death.

Any help would be greatly appreciated.

Thanks.

 

Re:Question: Physical memory access in DOS protected mode


Quote
jhay...@interlog.com wrote:
>My application requires access to a PCI memory mapped device. The memory
>aperture is necessarily mapped above the 1 MB boundary.

  Selector := AllocSelector(DSeg);
  SetSelectorBase(Selector, PhysicalAddress);
  SetSelectorLimit(Selector, Size);

The PhysicalAddress has to be the LINEAR address.

BandiT

Re:Question: Physical memory access in DOS protected mode


Quote
In article <65h7ch$fg...@gentiana.datanet.hu>, apa...@mol.hu (BandiT) wrote:
>jhay...@interlog.com wrote:

>>My application requires access to a PCI memory mapped device. The memory
>>aperture is necessarily mapped above the 1 MB boundary.

>  Selector := AllocSelector(DSeg);
>  SetSelectorBase(Selector, PhysicalAddress);
>  SetSelectorLimit(Selector, Size);

>The PhysicalAddress has to be the LINEAR address.

>BandiT

>jhay...@interlog.com wrote:

>>My application requires access to a PCI memory mapped device. The memory
>>aperture is necessarily mapped above the 1 MB boundary.

>  Selector := AllocSelector(DSeg);
>  SetSelectorBase(Selector, PhysicalAddress);
>  SetSelectorLimit(Selector, Size);

>The PhysicalAddress has to be the LINEAR address.

>BandiT

If I understand you correctly, you are saying that if I wish to read absolute
address $500000, I should call SetSetSelectorBase as follows:

SetSelectorBase(Selector, $500000)

This is, in fact, the first thing I tried. The function returns a non-zero
selector value, but the first time I use it to access this address, my program
crashes.

Once again, Any help would be greatly appreciated.

Other Threads