The problem I'm experimenting with is not related to the function open()or mmap(), which are executed properly. I disabled it CONFIG_STRICT_DEVMEMin the kernel, so I can read from /dev/memwithout problems. In fact, I can do the following:
const char *path = "/dev/mem"
int fd = open(path, O_RDWR);
p = mmap(0, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, BASE_ADDR);
And the code is not interrupted. However, I use this code to write to the PCI address space. So, basically BASE_ADDR- 0xc000000, and the size is 256 MiB ( 0x10000000, all PCI address space).
He said that when I try to write at these positions (with a specific offset, BDF format), nothing is written; again, the code fails, it just doesn't write anything.
In case of incorrect code, I tried BusyBox with the following parameters:
[horro@ ~]$ sudo busybox devmem 0xc00b0a8c w 0xffffffff
[horro@ ~]$ sudo busybox devmem 0xc00b0a8c
0x00000000
So basically it doesn't write anything.