简体   繁体   English

如何在内核源代码中使用函数?

[英]how to use a function in kernel source?

I need to use the function void clflush_cache_range(void *vaddr, unsigned int size) implemented in arch/x86/mm/pageattr.c , but I got two problems. 我需要使用arch / x86 / mm / pageattr.c中实现的功能void clflush_cache_range(void *vaddr, unsigned int size) ,但遇到两个问题。

  1. How to identify the corresponding header correctly? 如何正确识别对应的标题? I naively searched the symbol and it seems that arch/x86/include/asm/cacheflush.h is the one. 我天真地搜索了该符号,似乎arch/x86/include/asm/cacheflush.h是其中一个。

  2. How to include the header arch/x86/include/asm/cacheflush.h (if it's the correct one to include)? 如何包含标头arch/x86/include/asm/cacheflush.h (如果要包含的标头是正确的)? I tried to include <asm/cacheflush.h> , but it didn't work. 我试图include <asm/cacheflush.h> ,但是没有用。

fatal error: asm/cacheflush.h: No such file or directory 致命错误:asm / cacheflush.h:没有此类文件或目录

Though its not very straightforward way but I would look at other files if they are using the function and try to do the same. 虽然它不是很简单的方法,但是如果其他文件正在使用该功能,我会看看它们并尝试执行相同的操作。 For eg look at drivers/iommu/intel-iommu.c on how they use clflush_cache_range() 例如,关于drivers/iommu/intel-iommu.c如何使用clflush_cache_range()

Refer to http://www.thegeekstuff.com/2013/07/write-linux-kernel-module/ on how to write kernel code. 有关如何编写内核代码,请参阅http://www.thegeekstuff.com/2013/07/write-linux-kernel-module/

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

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