| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
| From: | Honiewelle <honiewelle AT gmail DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Flat memory access |
| Date: | Wed, 4 Jun 2008 04:04:54 -0700 (PDT) |
| Organization: | http://groups.google.com |
| Lines: | 52 |
| Message-ID: | <1df56ce7-2c42-4092-b71b-2c0b988c535e@d19g2000prm.googlegroups.com> |
| NNTP-Posting-Host: | 218.186.11.3 |
| Mime-Version: | 1.0 |
| X-Trace: | posting.google.com 1212577494 473 127.0.0.1 (4 Jun 2008 11:04:54 GMT) |
| X-Complaints-To: | groups-abuse AT google DOT com |
| NNTP-Posting-Date: | Wed, 4 Jun 2008 11:04:54 +0000 (UTC) |
| Complaints-To: | groups-abuse AT google DOT com |
| Injection-Info: | d19g2000prm.googlegroups.com; posting-host=218.186.11.3; |
| posting-account=aex66goAAAChGIzur3np6V2SxBId_WZm | |
| User-Agent: | G2/1.0 |
| X-HTTP-UserAgent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) |
| Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe) | |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Hi,
Is the following code snippet for accessing memory addresses correct?
I read the djgpp faqs until I came up with this code.
I am trying to access a memory space i/o of a PCI device but I am not
getting the correct values.
Any help would be greatly appreciated. Thanks in advance!
/* code starts here */
#include <stdio.h>
#include <pc.h>
#include <dpmi.h>
#include <sys/farptr.h>
#include <go32.h>
int main (void)
{
FILE *fp;
__dpmi_meminfo mi;
int selector;
int ctr;
mi.address = (0xEC080000); // PCI Base Address register
mi.size = 1024;
__dpmi_physical_address_mapping (&mi);
selector = __dpmi_allocate_ldt_descriptors (1);
__dpmi_set_segment_base_address (selector, mi.address);
__dpmi_set_segment_limit (selector, mi.size - 1);
fp=fopen("bar5.txt","wb");
for (ctr=1;ctr<=1024;ctr++)
{
value = _farpeekb(_dos_ds, ctr-1);
putc(value,fp);
}
fclose(fp);
return 0;
}
/* code ends here */
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |