From: Neil Goldberg Newsgroups: comp.os.msdos.djgpp Subject: Re: Device Driver programming with DJGPP Date: Tue, 10 Aug 1999 08:59:13 +0100 Organization: The MITRE Corporation Lines: 55 Message-ID: <37AFDBD1.1B1F@mitre.org> References: <37AFF7CF DOT 9973C001 AT eso DOT org> NNTP-Posting-Host: mm58842-pc.mitre.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: top.mitre.org 934289822 7019 128.29.96.60 (10 Aug 1999 12:57:02 GMT) X-Complaints-To: usenet AT news DOT mitre DOT org NNTP-Posting-Date: 10 Aug 1999 12:57:02 GMT X-Mailer: Mozilla 3.04 (WinNT; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Javier Reyes wrote: > > Hi Guys, > > I need to program a very simple device driver for a PCI card. I just > need to be able to read and write to/from memory at 0xF0000000. Can > anyone tell me where to find the source code sample to do it ? > > Thanks in advance, > > Javier > > PS: Please reply to me if possible. I sent two replies. You have to something from both of them. Let's try this again, from start to finish so there's no confusion. This should work fine: #include "dpmi.h" #include "go32.h" //Include your other headers... some function { //Yadda Yadda Yadda, get all your preliminary stuff.. __dpmi_meminfo MABuffer; //Buffer with all your info... MABuffer.size = total_interface_size_in_bytes; MABuffer.address = 0xF0000000; //That's what you want, right? __dpmi_physical_address_mapping(&MABuffer); //Replace MABuffer.address with an equivalent linear address. int selector = __dpmi_allocate_ldt_descriptors(1); __dpmi_set_segment_base_address(selector, MABuffer.address); __dpmi_set_segment_limit(selector, total_pages_size_in_bytes); //Set up your selector to point to this buffer /*The physical region 0xF0000000 is now mapped into linear, protected memory and now you've got a selector to access it*/ //Here's your code that uses the selector to access your PCI card (use _far* functions or movedata, etc.) __dpmi_free_ldt_descriptor(selector); //Free the selector at the end. } If anything bad happens with that code, give me all the specifics (all values, selectors, sizes, addresses to map, etc). It'll help me to see what went wrong. moogla