- 论坛徽章:
- 0
|
原帖由 assiss 于 2006-2-17 15:13 发表
水平有限,错误再所难免。请大家多批评指正。
tex文档可到我BLOG下载。
autoconf 的部分我重翻了一下,供你参考:
The autoconf machinery is quite simple once you figure out the way it
works. If you want to ignore the exact details of how the device probe
tree is built and walked on runtime, the bits needed for each
individual "leaf" driver are like this:
一旦知道 autoconf 是如何工作的,那么 autoconf 的机制就显得很简单。如果
不想知道设备探测树(device probe tree)在运行时是如何建立和遍历的细节,每
个独立的 "leaf" 驱动所需的内容如下:
1. each driver specifies a structure holding three things - size of
its private structure, probe function and attach function; this
is compiled in and used in runtime - example:
每个驱动指定一个 structure 包含三项内容 - 私有 structrue 的尺寸、
probe 函数和 attach 函数;它被编译并在运行时使用 - 例如:
struct cfattach foo_baz_ca = {
sizeof(struct foo_baz_softc), foo_baz_match, foo_baz_attach
};
2. on kernel startup, once the time comes to attach the device,
autoconf code calls device's probe routine and passes it pointer
to parent (struct device *parent), pointer to attach tag
structure (void *aux), and appropriate autoconf node (struct
cfdata *cf). The driver is expected to find out if it's where
it's supposed to be (commonly, the location and configuration
information is passed by the attach tag). If yes, the probe
routine should return 1. If device is not there, probe routine
has to return 0. NO STATE SHOULD BE KEPT in either case.
内核启动后,attach 设备时,autoconf 代码调用设备的探测程序(probe
routine) 并传入父设备 (struct device *parent) 、attach tag
structure (void *aux) 和相应的 autoconf 节点 (struct cfdata *cf)
的指针。驱动程序期望在假定的位置(通常,所在位置和配置信息通过
attach tag 传递)找出设备。如果找到,探测程序返回 1。如果未发现设
备,返回 0。两种情况都不应该保留状态。
3. if probe returned success, autoconf allocates chunk of memory
sized as specified in device's *_ca and calls its attach
routine, passing it pointer to parent (struct device *parent),
pointer to the freshly allocated memory (struct device *self)
and the attach tag (void *aux). Driver is expected to find out
exact ports and memory, allocate resources and initialize its
internal structure accordingly. Preferably, all driver instance
specific information should be kept in the allocated memory.
如果探测程序返回成功,autoconf 分配一块内存,大小是设备的 *_ca
里面指定的,并调用 attach 程序,传入父设备 (struct device
*parent)、所分配内存 (struct device *self) 和 attach tag (void
*aux) 的指针。驱动程序期望找到正确的端口和内存,并同时分配资源和
初始化内部结构。所有驱动实例指定的信息应该都保存在所分配的内存中。 |
|