mmap going to wrong physical address
I am writting an application that needs control over large (1gig+) portions of contiguous memory. I am currently doing this by using mem=1024m during boot. My system is a dual opteron with 5 gig of memory. In my program I have
if ((fd=open("/dev/mem", O_RDWR))<0)
{perror("open");
exit(-1);
}
PtrMemoryBase = (void *) mmap64(
NULL,
size,PROT_READ | PROT_WRITE,MAP_FILE | MAP_SHARED,
fd,
base );
size = 1MB
I also have -D_FILE_OFFSET_BITS=64.
If base is between 1 and 3 gig the process works fine. When base is 4 gig + the mmap64 works but the memory does not seem to be mapped to the base location. I write a pattern to PtrMemoryBase then have my hardware start doing DMA transfers from the base address but I do not get the data I wrote to PtrMemoryBase.
Thanks for any help
Mark
Quoted 24 lines · mark slutz
I am writting an application that needs control over large (1gig+) portions of contiguous memory. I am currently doing this by using mem=1024m during boot. My system is a dual opteron with 5 gig of memory. In my program I have
if ((fd=open("/dev/mem", O_RDWR))<0)
{perror("open");
exit(-1);
}PtrMemoryBase = (void *) mmap64(
NULL,
size,PROT_READ|PROT_WRITE,MAP_FILE|MAP_SHARED,
fd,
base );size = 1MB
I also have -D_FILE_OFFSET_BITS=64.
Quoted 7 lines
If base is between 1 and 3 gig the process works fine. When base is 4 gig + the mmap64 works but the memory does not seem to be mapped to the base location. I write a pattern to PtrMemoryBase then have my hardware start doing DMA transfers from the base address but I do not get the data I wrote to PtrMemoryBase.
Thanks for any help
I'm not sure it will help, but have you tried the MAP_FIXED option, and is your address which doesn't work a multiple of the page size?
Signature · 3 lines
-bill davidsen ([email protected]) "The secret to procrastination is to put things off until the last possible moment - but no longer" -me