2024年4月28日发(作者:)

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个层次了。那么接下来的事

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