Mail Archives: djgpp/1999/08/11/10:03:29
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
- Raw text -