ts-7000
[Top] [All Lists]

Re: [ts-7000] Mmap Maps to the Wrong Address

To:
Subject: Re: [ts-7000] Mmap Maps to the Wrong Address
From: "Don W. Carr" <>
Date: Thu, 16 Nov 2006 07:13:00 -0600
Looks like it is working correctly. Remember, it give you an address in your address space that corresponds to the real address. The mapping is done in real-time when you write to that address.

Also, you should use the keyword "volotile" in front of you declarations to memory that has been mapped. Otherwise, the compiler could optimize you code, not realizing this memory can change on its own.

Don.

On 11/15/06, agreensplat <> wrote:

Hi,

I've searched through this list and can't seem to figure out what's
going on.

All that my program does is try to get a start value Mmaped to
0x80840000. The idea is to build stuff on top of this once I get it
working.

I'm having the program print out the file descriptor and the memory
map address.

The output I get is 3 for the FD (which is expected) and mmap sends
the variable start to 2aac2000. If I specify MAP_FIXED, then I get a
zero back (so mmap failed).

Anyone have any thoughts as to what's going on?

Thanks for your help!

Aaron

Here is my code:

#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

main()
{
unsigned int *PADR, *PADDR;
unsigned char *start;
int fd = open("/dev/mem", O_RDWR|O_SYNC);
printf("FD: %d \n",fd);

start = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd,
0x80840000);
printf("Start Address Map: %x \n", start);
close(fd);
}

Output from the program:

$ ./a.out
FD: 3
Start Address Map: 2aac2000
$




--
Dr. Don W. Carr
J. G. Montenegro 2258
Guadalajara, Mexico
+52-333-630-0704
+52-333-836-4500 ext 2930 __._,_.___


SPONSORED LINKS
Single board computer Hardware Computer running slow
Linux os Single board

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU