简体   繁体   English

如何从Linux内核的struct页面获取物理地址

[英]How to get physical address from struct page in linux kernel

Suppose I get a pointer to struct page from allocator, how could I get corresponding physical address? 假设我从分配器中获得了指向struct page的指针,我该如何获取相应的物理地址? Whether does kernel provide functions to achieve it? 内核是否提供实现它的功能?
Thanks. 谢谢。

The answer is page_to_phys(), but please make sure that this is really what you need. 答案是page_to_phys(),但是请确保这确实是您所需要的。 eg, if you want the physical address in order to hand it off to some device for DMA it is very likely what you need is the bus address for the page, which may or may not be the physical address. 例如,如果您想要物理地址以便将其传递给某些设备进行DMA,则很有可能您需要的是页面的总线地址,该地址可能是也可能不是物理地址。

http://lxr.free-electrons.com/source/include/asm-generic/page.h#L90 http://lxr.free-electrons.com/source/include/asm-generic/page.h#L90

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM