Date: Tue, 3 Feb 1998 18:22:52 -0800 (PST) Message-Id: <199802040222.SAA04992@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Ulf Griesmann , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Accessing memory-mapped buffer of a PCI device Precedence: bulk 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 #include #include _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