Listing 4: Setting up and using "poor man's" shared memory
// User space code:
if (fd = open("/dev/mem", O_RDWR)) < 0) { ...oops! error }
rtshm_ptr = (char * ) mmap (0, 0x100000, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, 0x7F00000);
if (rtshm_ptr == MAP_FAILED) { ...oops! error }
else { ...use it }
// and in your real-time module:
rtshmbase = (long*) ioremap(0x7f00000, 0x100000);
|