Mail Archives: djgpp/1998/01/06/09:08:20
On Tue, 6 Jan 1998, Robert Smith wrote:
> From section 18.7 of the DJGPP FAQ, I understand that I have to do
> something like the following to initialise a pointer (base address of
> PCI board memory assumed to be 0x1000000, size of memory assumed to
> be 16 Kbytes, error handling not included here for clarity) :
I didn't look at every detail of your code, but it seems like it should
work. It turns out that lock_linear_region call is unnecessary, though
(the FAQ is wrong).
> Then to access the boards memory I must do something like the following:
>
> /* Reading a byte from the start of the boards memory */
> Data8 = _farpeekb(Sel,0l);
>
> /* Inverting the second double word in the boards memory */
> Data32 = _farpeekl(Sel,4l);
> Data32 = ~Data32;
> farpokel(Sel,4l,Data32);
Correct, except that you can express the last 3 lines as a single line:
_farpokel(Sel, 41, ~_farpeekl(Sel, 41);
or even faster:
_farsetsel(Sel);
_farnspokel(41, ~_farnspeekl(41));
> The above does not provide what I want since it is necessary to
> use the routines in <sys/farptr.h> to access the memory, whereas
> I wish to access the memory directly.
Why? What's wrong with using the farptr functions?
> From the DJ Delorie's response to comp.os.msdos.djgpp newsgroup posting
> Re:dos_ds, (Sun 4 Jan 1998), I believe that it is also possible for
> me to access the boards memory as follows:
_dos_ds has nothing to do with accessing memory-mapped devices above
1MB, and cannot be used to access memory above the address 1MB+64K. You
might succeed using nearptr facility to access the memory-mapped device
directly, but I won't recommend that, since it defeats memory protection,
but usually gains you nothing in terms of speed.
> /* Initialise board memory pointer */
> BoardMem = (struct BoardMem_s *) BOARD_BASE_ADDRESS -
> __djgpp_base_address;
This is not enough. You still have to map the device into your address
space, and you need to call `__djgpp_nearptr_enable' before using the
base_address variable. The reason for this is that BOARD_BASE_ADDRESS is
a physical address, whereas the pointers your program uses are logical
addresses. Mapping the device into your address space supplies a logical
address of the device which is the only address you can use from your
program.
- Raw text -