Newbie question about usage of mmap
I have a PCI device and I tried to write a short code to access it in user space with mmap.
first I "cat /proc/bus/pci/devices" and get the device's address: 0x00001800.
then I write the following code:
int src = 0;
base = 0x00001800;
length = 0xFF;
fd = open("/dev/mem", O_RDWR);
map = mmap(NULL, (size_t)length, (PROT_READ | PROT_WRITE), MAP_SHARED, fd,(off_t)base);
if (map == MAP_FAILED)
printf("map failed: %s\n",strerror(errno));
I run the code and got the error says that "Invalid Argument", I guess that is because of some misuse of mmap, but where is the error?