Quote:
/dev/mem is the gateway to the "Physical Address Space" of the processor which might include control registers of many HW peripherals and not just the RAM?
|
Yes it does include peripherals, because there is a preference for using memory mapped I/O in x86 systems. It is still the physical memory space, so the name of the device is reasonable (see also /dev/port).
A segmentation fault won't happen until the read occurs (I'm not clear what values you are using for 'myAddress' and 'MAP_MASK'. But you will need to check the result of the
mmap. On my system it is accessible up to 0x101000.
For example, the following code fragment would typically fail, since the CONFIG_STRICT_DEVMEM=y will cause the mmap to fail:
Code:
int fd = open("/dev/mem", O_RDWR);
char *ptr = mmap(0, 0x180000, PROT_READ, MAP_PRIVATE, fd, 0);
printf("%u\n", (unsigned int) ptr);
return *ptr;