MMAP Question: 'length' parameter in mmap not serving its purpose
I am using mmap to be able to access some HW registers on a chip which are memory mapped. The registers I need to access start at the base address 0xfd000000.
I have the following code:
#define LEN 0x1 //place the size here
#define OFFSET 0xfd000000 //place the offset address here
volatile uint32_t* map = (volatile uint32_t*)mmap(0,LEN,PROT_READ|PROT_WRITE, MAP_SHARED,_fdmem,OFFSET);
length is supposed to be in bytes. Now if I place a value of 1 for len, I should only be able to access one byte of the mapped memory. But this is not the case. I can access a lot more, I have not checked the limit, but I was able to R/W to memory atleast 1000 bytes more then I should be allowed.
Technically, I should only be able to access 0xfd00000-0xfd000001.
Why is this the case? The reason I want to know is because it seems the 'len' parameter is not functioning as it should.