linux 查看 pci 设备驱动,如何写linux pci设备驱动程序

PCI总线应用领域及其广泛并且令人惊奇。不同的pci设备有不同的需求以及不同的问题。因此,在linux内核中pci层支持就非常重要啦。本文档就是想为驱动程序设计开发人员解决pci处理中的各种问题。

0.Pci设备驱动程序的结构

现在有两种风格的的pci驱动程序结构:新风格的驱动(即让pci层来做大量设备探测

工作并且支持热插拔功能)和旧风格的驱动(即由驱动程序自己探测设备)。除非你有很好的理由,否则就不要用旧风格写驱动程序。当驱动程序找到所驱动的设备后,将执行以下步骤:

启用设备

访问设备配置空间

检测设备资源(如基地址和中断号)

分配设备资源

与设备通讯

下文将论述以上大部分步骤,其余部分请参考,它有不错的注释。

如果没有配置pci子系统(即CONFIG_PCI没有置位),以下介绍的大部分函数都被定义为内联函数,它们要么是空的,要么返回对应的错误代码以避免在驱动中出现过多的条件宏ifdefs。

1.新风格的驱动程序

新风格的驱动程序只是在初始化时调用pci_register_driver,调用时使用一个指向struct pci_driver的结构指针。该指针包含以下几个分量:

name驱动程序名称

id_table指向一个与驱动程序相关的设备ID表的指针。大多数驱动程序应当用MODULE_DEVICE_TABLE(pci,…)将该设备ID表导出。在调用prob( )时设成NULL以让系统检测到所有的pci设备。

probe指向设备检测函数prob( )的指针。该函数将在pci设备ID与设备ID表匹配且还没有被其它驱动程序处理时(一般在对已存在的设备执行pci_register_driver或以后又有新设备插入时)被调用。调用时传入一个指向struct pci_dri

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PCI8系列 PCI9系列 PCI9054 linux驱动程序 PLX SDK Samples ================================================================ ABOUT This document provides a brief description of the samples included in the PLX SDK. Please refer to the source code in each sample & the PLX SDK User's Manual for additional details. The PLX samples are intended to demonstrate use of the PLX API. The samples are not intended for debug or real world applications, although they can be extended to complex applications. They should be treated as a reference for writing custom software that utilizes the PLX API. Not all samples work with all PLX devices. The PLX API supports numerous PLX chip families in PCI/PCIe, including 6000-series PCI-to-PCI bridges, 9000-series PCI-to-Local bus bridges, & 8000-series PCI/PCIe bridges & switches. Some samples are provided only for specific chip families. SAMPLES - ApiTest Simple application that calls various PLX APIs for a selected device & verifies return codes & parameters. The API calls made depend upon the type of device selected. - DSlave Demonstrates how to read/write from a PLX 9000 PCI BAR space using the PLX API/driver to perform the data transer. This operation is often referred to as "Direct Slave". - DSlave_BypassApi Similar to the 'DSlave' sample, except this sample uses the PLX API only to map a PCI BAR space directly to the application's virtual space. The application can then directly access the space via simple memory dereferencing, bypassing the PLX API/driver & resulting in greater performance, especially for small transfers. The application is responsible for initializing the BAR space, such as setup of translation/remap registers. - LocalToPciInt [9000-series & 8311] Demonstrates how to wait for a generic Local-to-PCI interrupt using the PLX Notification API. - NT_DmaTest [8000-series switches with DMA & NT support] Demonstrates using the DMA engine in a PLX 8000 switch to transfer data through a PLX

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值