Mail Archives: djgpp/1998/02/03/21:23:57
At 11:58 2/3/1998 -0500, Ulf Griesmann wrote:
>
>Dear All,
>
>I am trying to access a memory-mapped buffer on a PCI device with
>a DJGPP program. Item 18.7 of the FAQ should apply directly to my
>problem. Unfortunately, the answer given in the FAQ does not
>tell me how to actually access the memory buffer once I have a
>selector and a linear address. Can anyone help, maybe with an
>example ?
The FAQ gets you to the point where you have created a selector that maps
directly to the linear address where you mapped the device. Now all you have
to do is use farptr functions to access that segment. Examples, assuming
`pci_sel' is the selector you got:
#include <sys/farptr.h>
#include <sys/segments.h>
#include <sys/movedata.h>
_farpokeb(pci_sel, 3, 42); /* Write a 42 to the 3rd byte of the device */
movedata(_my_ds(), buffer, pci_sel, 0, 16384);
/* Blit 16K from the device to a buffer */
You can also use the `nearptr' method, although this is very dangerous. See
FAQ section 18.6 if interested. I believe you take the linear address
obtained from __dpmi_physical_memory_mapping (or whatever it's called, step
2 in the FAQ's procedure) and add `__djgpp_conventional_base' to obtain a
pointer which may be accessed like any other buffer. Note that nearptrs will
sidestep memory protection and allow bugs in your program to wipe out DOS or
do several other unpleasant things.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -