- 论坛徽章:
- 0
|
Linux的设备驱动程序与外界的接口可以分为三个部分:
1.驱动程序与操作系统内核的接口。这是通过include/linux/fs.h中的file_operations数据结构来完成
的,通过实例化其中的open close....函数;
2.驱动程序与系统引导的接口。这部分利用驱动程序对设备进行初始化,probe函数;
3.驱动程序与设备的接口,通过例化struct ???_device数据结构中的函数实现;
Example:在YC-2440-SBC中的cs8900.cpp文件中有以下函数
1.
static struct file_operations cs8900_eeprom_fops = {
owner: THIS_MODULE,
open: cs8900_eeprom_fopen,
release: cs8900_eeprom_frelease,
llseek: cs8900_eeprom_fllseek,
read: cs8900_eeprom_fread,
write: cs8900_eeprom_fwrite,
};
2.
int cs8900_probe (struct net_device *dev);
static struct net_device cs8900_dev =
{
init: cs8900_probe
};
3.
int __init cs8900_probe (struct net_device *dev)
{
static cs8900_t priv;
int i,result;
u16 value;
printk (VERSION_STRING"\n");
memset (&priv,0,sizeof (cs8900_t));
__raw_writel(0x2211d110,S3C2410_BWSCON);
__raw_writel(0x1f7c,S3C2410_BANKCON3);
ether_setup (dev);
dev->open = cs8900_start;
dev->stop = cs8900_stop;
dev->hard_start_xmit = cs8900_send_start;
dev->get_stats = cs8900_get_stats;
dev->set_multicast_list = cs8900_set_receive_mode;
dev->tx_timeout = cs8900_transmit_timeout;
.
.
.
}
probe探测例程将负责完成对硬件的检测工作。他在注册的时候调用。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/20871/showart_284644.html |
|