Mail Archives: djgpp/1998/05/08/13:19:04
From: | "Jan Humme" <humme AT EuroNet DOT NL>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Why does reading from memory mapped PCI board cause a page fault?
|
Date: | 8 May 1998 17:12:06 GMT
|
Organization: | Imedia Engineering BV
|
Lines: | 64
|
Message-ID: | <6ived6$j7t@news3.euro.net>
|
NNTP-Posting-Host: | p718.asd.euronet.nl
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
I have a memory-mapped PCI board; the memory map is at 0xE5000000.
I try to read from the device using the following program (faq 18.7), but
get a Page fault
as soon as I try to read ("i = _farpeek(......);").
Why?
Jan Humme,
Imedia Engineering BV,
jan DOT humme AT imedia-engineering DOT nl
=================================
#define ADDR 0xe5000000
short ldt;
void map_device()
{
__dpmi_meminfo mi;
if((ldt = __dpmi_allocate_ldt_descriptors(1)) < 0)
{
printf("LDT allocation error\n");
exit(1);
}
mi.handle = ldt;
mi.size = 4 * 1024 * 1024;
mi.address = ADDR;
if(__dpmi_physical_address_mapping(&mi) < 0
|| __dpmi_lock_linear_region(&mi) < 0
|| __dpmi_set_segment_base_address(ldt, ADDR) < 0
|| __dpmi_set_segment_limit(ldt, 0x10000 - 1) < 0)
{
printf("physical mapping error\n");
exit(1);
}
}
void main(int argc, char **argv)
{
int i;
map_device();
i = _farpeekl(ldt, 0);
// here comes the page fault
printf("%08x", i);
__dpmi_free_ldt_descriptor(ldt);
exit(0);
}
--
Jan Humme
Imedia Engineering BV
Amsterdam, the Netherlands
- Raw text -