LDD3学习笔记(15):PCI驱动

#include<linux/pci.h>

包含PCI寄存器的符号名和几个供应商和设备ID值的头文件.

structpci_dev;

表示内核中一个PCI设备的结构.

structpci_driver;

代表一个PCI驱动的结构.所有的PCI驱动必须定义这个.

structpci_device_id;

描述这个驱动支持的PCI设备类型的结构.

intpci_register_driver(structpci_driver*drv);

intpci_module_init(structpci_driver*drv);

voidpci_unregister_driver(structpci_driver*drv);

从内核注册或注销一个PCI驱动的函数.

structpci_dev*pci_find_device(unsignedintvendor,unsignedintdevice,structpci_dev*from);

structpci_dev*pci_find_device_reverse(unsignedintvendor,unsignedintdevice,conststructpci_dev

*from);

structpci_dev*pci_find_subsys(unsignedintvendor,unsignedintdevice,unsignedintss_vendor,unsigned

intss_device,conststructpci_dev*from);

structpci_dev*pci_find_class(unsignedintclass,structpci_dev*from);

在设备列表中搜寻带有一个特定签名的设备,或者属于一个特定类的.返回值是NULL如果

没找到.from用来继续一个搜索;在你第一次调用任一个函数时它必须是NULL,并且它必须

指向刚刚找到的设备如果你寻找更多的设备.这些函数不推荐使用,pci_get_变体来代替.

structpci_dev*pci_get_device(unsignedintvendor,unsignedintdevice,structpci_dev*from);

structpci_dev*pci_get_subsys(unsignedintvendor,unsignedintdevice,unsignedintss_vendor,unsigned

intss_device,structpci_dev*from);

structpci_dev*pci_get_slot(structpci_bus*bus,unsignedintdevfn);

在设备列表中搜索一个特定签名的设备,或者属于一个特定类.返回值是NULL如果没找到.

from用来继续一个搜索;在你第一次调用任一个函数时它必须是NULL,并且它必须指向刚

刚找到的设备如果你寻找更多的设备.返回的结构使它的引用计数递增,并且在调用者完成

,函数pci_dev_put必须被调用.

intpci_read_config_byte(structpci_dev*dev,intwhere,u8*val);

intpci_read_config_word(structpci_dev*dev,intwhere,u16*val);

intpci_read_config_dword(structpci_dev*dev,intwhere,u32*val);

intpci_write_config_byte(structpci_dev*dev,intwhere,u8*val);

intpci_write_config_word(structpci_dev*dev,intwhere,u16*val);

intpci_write_config_dword(structpci_dev*dev,intwhere,u32*val);

读或写PCI配置寄存器的函数.尽管Linux内核负责字节序,程序员必须小心字节序当从单

个字节组合多字节值时.PCI总线是小端.

intpci_enable_device(structpci_dev*dev);

使能一个PCI设备.

unsignedlongpci_resource_start(structpci_dev*dev,intbar);

unsignedlongpci_resource_end(structpci_dev*dev,intbar);

unsignedlongpci_resource_flags(structpci_dev*dev,intbar);

处理PCI设备资源的函数.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值