注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

时间记录器

记录我的Linux、Android学习之路

 
 
 

日志

 
 

驱动里的头文件  

2010-08-06 14:54:22|  分类: Linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

在实际编写特定平台的驱动程序的时候往往涉及很多头文件,比如下面以

drivers/video/sep0718_fb.c中的头文件为例:

#include <linux/module.h>

#include <linux/kernel.h>

#include <linux/errno.h>

#include <linux/string.h>

#include <linux/mm.h>

#include <linux/tty.h>

#include <linux/slab.h>

#include <linux/delay.h>

#include <linux/fb.h>

#include <linux/init.h>

#include <linux/dma-mapping.h>

#include <linux/interrupt.h>

#include <linux/workqueue.h>

#include <linux/wait.h>

#include <linux/platform_device.h>

#include <linux/clk.h>

#include <linux/console.h>

 

#include <asm/io.h>

#include <asm/uaccess.h>

#include <asm/div64.h>

 

#include <mach/hardware.h>

#include "sep0718_fb.h"

一、其中 linux/*.h asm/*.h 在你的编译器所在目录下的include目录下:

/usr/local/arm/3.4.1/arm-linux/include/asm

/usr/local/arm/3.4.1/arm-linux/include/linux

其中/usr/local/arm/3.4.1/是我的交叉编译器的安装目录。

 

二、而mach/hardware.h则比较让人头疼,在内核目录下使用如下命令查找文件名为hardware.h的文件:

[root@localhost sep0718linux-2.6.32]# pwd

/sep0718linux-2.6.32

[root@localhost sep0718linux-2.6.32]# find -name hardware.h

./arch/xtensa/platforms/xt2000/include/platform/hardware.h

./arch/xtensa/platforms/iss/include/platform/hardware.h

./arch/xtensa/platforms/s6105/include/platform/hardware.h

./arch/xtensa/variants/s6000/include/variant/hardware.h

./arch/parisc/include/asm/hardware.h

./arch/arm/mach-sa1100/include/mach/hardware.h

./arch/arm/mach-integrator/include/mach/hardware.h

./arch/arm/mach-footbridge/include/mach/hardware.h

./arch/arm/mach-ebsa110/include/mach/hardware.h

./arch/arm/mach-mv78xx0/include/mach/hardware.h

./arch/arm/mach-ns9xxx/include/mach/hardware.h

./arch/arm/mach-s3c2410/include/mach/hardware.h

./arch/arm/mach-at91/include/mach/hardware.h

./arch/arm/mach-s3c6400/include/mach/hardware.h

./arch/arm/mach-ixp4xx/include/mach/hardware.h

./arch/arm/mach-ixp23xx/include/mach/hardware.h

./arch/arm/mach-realview/include/mach/hardware.h

./arch/arm/mach-gemini/include/mach/hardware.h

./arch/arm/mach-ep93xx/include/mach/hardware.h

./arch/arm/mach-davinci/include/mach/hardware.h

./arch/arm/mach-netx/include/mach/hardware.h

./arch/arm/mach-loki/include/mach/hardware.h

./arch/arm/mach-shark/include/mach/hardware.h

./arch/arm/mach-u300/include/mach/hardware.h

./arch/arm/mach-pnx4008/include/mach/hardware.h

./arch/arm/mach-pxa/include/mach/hardware.h

./arch/arm/mach-ks8695/include/mach/hardware.h

./arch/arm/mach-versatile/include/mach/hardware.h

./arch/arm/mach-bcmring/include/mach/hardware.h

./arch/arm/mach-iop33x/include/mach/hardware.h

./arch/arm/mach-kirkwood/include/mach/hardware.h

./arch/arm/mach-h720x/include/mach/hardware.h

./arch/arm/mach-aaec2000/include/mach/hardware.h

./arch/arm/mach-l7200/include/mach/hardware.h

./arch/arm/mach-iop32x/include/mach/hardware.h

./arch/arm/mach-msm/include/mach/hardware.h

./arch/arm/mach-iop13xx/include/mach/hardware.h

./arch/arm/mach-sep0718/include/mach/hardware.h

./arch/arm/mach-mmp/include/mach/hardware.h

./arch/arm/mach-nomadik/include/mach/hardware.h

./arch/arm/mach-rpc/include/mach/hardware.h

./arch/arm/mach-orion5x/include/mach/hardware.h

./arch/arm/mach-clps711x/include/mach/hardware.h

./arch/arm/plat-mxc/include/mach/hardware.h

./arch/arm/mach-w90x900/include/mach/hardware.h

./arch/arm/mach-ixp2000/include/mach/hardware.h

./arch/arm/plat-omap/include/mach/hardware.h

./arch/arm/mach-lh7a40x/include/mach/hardware.h

./arch/arm/mach-s5pc100/include/mach/hardware.h

./arch/arm/plat-stmp3xxx/include/mach/hardware.h

./include/asm-arm/mach-sep0718/hardware.h

./drivers/isdn/sc/hardware.h

./drivers/char/pcmcia/ipwireless/hardware.h

[root@localhost sep0718linux-2.6.32]#

可以看到,与#include <mach/hardware.h>相似的就有

./arch/arm/mach-msm/include/mach/hardware.h

./arch/arm/mach-iop13xx/include/mach/hardware.h

./arch/arm/mach-sep0718/include/mach/hardware.h

./arch/arm/mach-mmp/include/mach/hardware.h

./arch/arm/mach-nomadik/include/mach/hardware.h

这类的很多,而上面绿色的是我们感兴趣的。这说明#include <mach/hardware.h>有很多符合项,那什么时候哪个路径下的/hardware.h参加编译呢?

我们看arch/arm/Makefile这个文件line179开始有:

# The first directory contains additional information for the boot setup code

ifneq ($(machine-y),)

MACHINE  := arch/arm/mach-$(word 1,$(machine-y))/

else

MACHINE  :=

endif

 

machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))

platdirs := $(patsubst %,arch/arm/plat-%/,$(plat-y))

 

ifeq ($(KBUILD_SRC),)

KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs) $(platdirs))

else

KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs) $(platdirs))

endif

 

export     TEXT_OFFSET GZFLAGS MMUEXT

 

# Do we have FASTFPE?

FASTFPE              :=arch/arm/fastfpe

ifeq ($(FASTFPE),$(wildcard $(FASTFPE)))

FASTFPE_OBJ      :=$(FASTFPE)/

endif

 

# If we have a machine-specific directory, then include it in the build.

core-y                          += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/

core-y                          += $(machdirs) $(platdirs)

core-$(CONFIG_FPE_NWFPE)   += arch/arm/nwfpe/

core-$(CONFIG_FPE_FASTFPE)       += $(FASTFPE_OBJ)

core-$(CONFIG_VFP)         += arch/arm/vfp/

猜想:

这里就描述了make的时候传进来的平台参数了,通过这样的选择,上面一大堆的hardware.h其实在编译的时候只有一个路径下的参加编译,控制方法来自你make是传入的参数。

问题:./include/asm-arm/mach-sep0718/hardware.h中的hardware.h是在什么时候被谁调用的呢?    好像这个文件和刚才那个文件不一样呀!等待别人解答。

三、#include "sep0718_fb.h"文件比较简单,它是以" "来包含的,这个明显能在当前目录下找到。

  评论这张
 
阅读(1000)| 评论(1)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017