Can I load data from RAM by using pointer to memory with physical addressing?

802 views Asked by At

Can I load data from RAM by using pointer to memory with physical addressing(not to virtual) from my driver (Linux-kernel) without allocating pages (PDEs/PTEs) in virtual addressing?

1

There are 1 answers

5
vitorafsr On BEST ANSWER

Yes! "/dev/mem" is an image of physical memory, and you can even access this from user space.

For example, to access physical address 0x7000000, the code below summarizes the steps:

fd = open("/dev/mem", O_RDWR);
map = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x7000000);