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

标签 c linux-kernel include kernel

我需要使用函数 void clflush_cache_range(void *vaddr, unsigned int size)arch/x86/mm/pageattr.c 中实现,但我遇到了两个问题。

  1. 如何正确识别对应的header?我天真地搜索了符号,似乎 arch/x86/include/asm/cacheflush.h就是一个。

  2. 如何包含标题 arch/x86/include/asm/cacheflush.h (如果它是正确的)?我试过 include <asm/cacheflush.h> ,但没有用。

fatal error: asm/cacheflush.h: No such file or directory

最佳答案

虽然这不是很直接的方法,但如果其他文件正在使用该功能,我会查看它们并尝试执行相同的操作。例如查看 drivers/iommu/intel-iommu.c,了解它们如何使用 clflush_cache_range()

引用http://www.thegeekstuff.com/2013/07/write-linux-kernel-module/关于如何编写内核代码。

关于c - 如何在内核源代码中使用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28816594/

相关文章:

对 getChar 和 printf 的调用似乎修改了不相关的数据

gcc - 使用gcc 4.6在内核3.0上编译LLVM 2.9的gcc 4.2

c - 通过设备驱动程序访问 AXIS FIFO 寄存器时出现未处理的故障

javascript - laravel包含基于语言的js脚本

python - 如何在Python代码中使用IDA反编译的C函数?

C插件系统: dlopen fails

c - "File scope"和 "program scope"有什么区别

android - 内核 c 多重函数定义错误

html - 如何在不将 Html 更改为 sHtml 的情况下包含其他代码(菜单栏或侧边栏)

c++ - 通过将前向声明替换为包含来更改代码的含义