1
votes

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
What is "CPU-RAM"? There's a CPU and there's RAM. Do you mean processor cache memory? - sawdust
@sawdust No, I mean RAM :) - Alex
I'm not entirely sure if this is completely relevant to your question.. Give it a quick read if you can though.. tldp.org/LDP/khg/HyperNews/get/devices/addrxlate.html - Guru Prasad
@user1761555 Do I must to use 'ioremap()' to get virtual address in kernel space (allocate PDEs/PTEs) and get access to this memory by virtual address, or can I read physical address directly? And how can I read memory directly by physical address? - Alex

1 Answers

3
votes

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);