linux2.6下IDE驱动分析

近段时间由于项目上的需要不得不关注linux下IDE硬盘的实现,目的是为了移植IDE接口的硬盘到S3C2440平台上,采用的驱动方式是PIO模式。因此在分析代码之余做了些简单的笔记,一则加深印象,二来方便对linux设备驱动感兴趣的朋友,多多交流。由于整个IDE驱动实现比较复杂,加之分析过程比较充忙,难免有许多错误之处,请发现问题的朋友能帮忙指正。

这里是以linux2.6.32内核为基础,重点分析ide硬盘驱动的实现。通过前面子系统的分析,不难发现任何一个底层驱动的实现都离不开其他内核模块的支持。同时内核对各个模块的加载有着一定的先后顺序,要想对一个子系统进行深入分析,首先必须对整个子系统的构架有个充分的了解,更通俗的来讲就是当使用make menuconfig 来配置内核模块的时候,要清楚的知道这些module之间的层次关系,以及这些module分别对应于内核中的那些.c文件。而这些信息也正是由kconfigmakefile文件得到的。具体到ide硬盘驱动,我们首先来看看/driver/ide目录下的kconfig文件….

menuconfig IDE

       tristate "ATA/ATAPI/MFM/RLL support"

       depends on HAVE_IDE

       depends on BLOCK

if IDE

….

endif # IDE

也就是说这里的IDE是一切ide驱动的基础,对应到文件就是ide-core.c

ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o /

ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o /

ide-io-std.o ide-eh.o

然后就到了硬盘驱动的配置:

config IDE_GD

       tristate "generic ATA/ATAPI disk support",对应到makefile中的文件就是ide-gd.cide-gd_mod.c

       config CONFIG_IDE_GD_ATA对应到makefile中的文件就是ide-disk.o ide-disk_ioctl.o

       最后,就是与硬件平台相关的了,对于ARM体系结构,属于generic IDE driver,同样对应的文件即是ide-generic.o

  config IDE_GENERIC

       tristate "generic/default IDE chipset support"

       depends on ALPHA || X86 || IA64 || M32R || MIPS || ARCH_RPC || ARCH_SHARK

       default ARM && (ARCH_RPC || ARCH_SHARK)

       help

         This is the generic IDE driver.  This driver attaches to the

         fixed legacy ports (e.g. on PCs 0x1f0/0x170, 0x1e8/0x168 and

         so on).  Please note that if this driver is built into the

         kernel or loaded before other ATA (IDE or libata) drivers

         and the controller is located at legacy ports, this driver

         may grab those ports and thus can prevent the controller

         specific driver from attaching.

         Also, currently, IDE generic doesn't allow IRQ sharing

         meaning that the IRQs it grabs won't be available to other

         controllers sharing those IRQs which usually makes drivers

         for those controllers fail.  Generally, it's not a good idea

         to load IDE generic driver on modern systems.

         If unsure, say N.

好了,看完这些个以后,大致清楚了IDE子系统分为那3个层次了。那么接下来的事

情就是对这三块一一进行分析……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值