您的位置:首页 > 运维架构 > Linux

linux2.6下IDE驱动分析

2010-10-13 11:05 113 查看
近段时间由于项目上的需要不得不关注linux下IDE硬盘的实现,目的是为了移植IDE接口的硬盘到S3C2440平台上,采用的驱动方式是PIO模式。因此在分析代码之余做了些简单的笔记,一则加深印象,二来方便对linux设备驱动感兴趣的朋友,多多交流。由于整个IDE驱动实现比较复杂,加之分析过程比较充忙,难免有许多错误之处,请发现问题的朋友能帮忙指正。
这里是以linux2.6.32内核为基础,重点分析ide硬盘驱动的实现。通过前面子系统的分析,不难发现任何一个底层驱动的实现都离不开其他内核模块的支持。同时内核对各个模块的加载有着一定的先后顺序,要想对一个子系统进行深入分析,首先必须对整个子系统的构架有个充分的了解,更通俗的来讲就是当使用make menuconfig 来配置内核模块的时候,要清楚的知道这些module之间的层次关系,以及这些module分别对应于内核中的那些.c文件。而这些信息也正是由kconfig和makefile文件得到的。具体到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.c、ide-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个层次了。那么接下来的事
情就是对这三块一一进行分析……
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: