2017-04-04 130 views
0

我看着我的內核源代碼,發現如下定義KERNELDIR /弓/ 86 /包括/ ASM/processor.h如何在Linux內核模塊中獲取CPU信息?

extern void cpu_detect(struct cpuinfo_x86 *c); 

我試圖在樹外的我的內核使用此使用此代碼模塊:

#include <asm/processor.h> 
struct cpuinfo_x86 cpu; 
cpu_detect(&cpu); 
if(cpu.x86_model == 28) // Intel Atom 
{ 
    // do stuff 
} 

當我建我的源代碼,我得到以下警告:

Building modules, stage 2. 
MODPOST 1 modules 
WARNING: "cpu_detect" [<my-kernel-module-path>.ko] undefined! 

的是重新獲得更好的方式從我的模塊內核空間獲取CPU信息?如果我這樣做的方式是正確的,是否有任何特殊的鏈接選項需要傳遞,以便我可以獲取目標代碼?

回答