I try to use mmap() to access dual port ram but not work

I try to use mmap() function to access dual port ram but not work. data is not correct, which my c code is

long *x, *y;

main ()
fd = shm_open(" /botts",O_RDWR|O_CREAT, 0777);
x = mmap(0x0800,1024*1024,

y = (long *)(0x0804);
printf( " address %6.6X\n",y);
printf( " data %d\n",*y);

on Dos version i use

y = (long *)(MK_FP(0x0800,0x0804));
printf( " address %6.6X\n",y);
printf( " data %d\n",*y);

How to correct it based on QNX 6.2

x = mmap_device_memory(0, 1024 * 1024,
0, 0x0800);
if (x != (long *)MAP_FAILED) {
y = (long *)((char *)x + 4);
printf(" address %6.6X\n", y);
printf(" data %d\n", *y);


A little more info. QNX is based on virtual addressing, Mmaping insertes in your virtual address space the physical memory location you specify. But that doesn’t mean you can access it by specifying the physical address. Mmap returns a virtual pointer to the physical memory, and it can only be reference through that address, which is 99% of the time no the same as the physical address.

You program probably crashed (SIGSEGV) because you tried to access memory that was not in your virtual space.

That being said 0x800 sounds like a weird address to me (assuming it’s a PC). I don’t recall what MK_FP exaclty does but from memory 0x800 for segment and 0x804 for data equal to physical address (0x8804) not 0x800.

  • Mario