基于PLX_SDK的Linux下的PCI9054驱动程序的开发

来公司也有一段,一直是让我负责做9054驱动程序的开发。这段时间终于差不多了,趁着还熟悉,就整理下。

         既然是9054这种广为流传的芯片,自然有官方的模板代码,再从头开发一套肯定是不划算的。

        于是就有了本文描述的基于PLX_SDK的9054驱动程序的开发。

         首先是安装PLX_SDK的系统要求:

                   1. 内核版本不能高于2.7,即不能是3.0版本的内核

                   2.编译驱动的时候,必须有内核版本对应的内核源代码的支持

         如果以上没有问题,那OK,我们继续。

       第一步:  下官网下载PLX_SDK,有WINDOWS版的,也有Linux版的,这里使用的版本是PLX_SDK_Linux_v6_50_Final_2011-09-30.zip。

     

       第二步: 解压,打开Documentation\PLX_Linux_Release_Notes.htm,查看具体的安装步骤和要求。

                   To install the Linux support files, use the following steps:

1.    Copy the PLX Linux TAR file to the desired working directory, e.g. the user’s home directory or/usr/linux/src.

                     拷贝PLX Linux 压缩包至工作目录,例如/usr/linux/src,这里我的工作目录是/usr/src

2.    If the PLX file contains a .gz extension, the file must first be unzipped, as follows:
            gunzip PlxSdk.tar.gz

     如果是gz压缩包,那么使用gunzip命令解压。我们使用的是zip压缩包,所以使用unzip命令解压。

3.    Use a TAR file extractor or open a terminal window and type the following command:
            tar -xvf  PlxSdk.tar

                使用tar -xvf  PlxSdk.tar  解压压缩包

4.    This will create a folder called PlxSdk with all PLX supplied files and folders inside.

5.    In order to build the files supplied, the shell environment variable PLX_SDK_DIR must be set.  This should be set to the root location of where thePlxSdk folder is created.  This can be set with the export command and may be placed in the shell initialization script (e.g. “.bashrc”) so that it is automatically set when a new terminal session is started.

   Examples:  export PLX_SDK_DIR=$HOME/PlxSdk
                     export PLX_SDK_DIR=/usr/src/PlxSdk

       配置PLX_SDK_DIR环境变量,并且导出。这里我导出的步骤是:

       #sudo vi /etc/enviroment       编译环境变量配置文件,也可以选择其他的文件,

       #export PLX_SDK_DIR=/usr/src/PlxSdk  在文件末尾输入这一行导出命令

      #source /etc/enviroment                  退出之后source使能环境变量配置文件

 

       第三步: 配置硬件架构有关的环境变量参数:

                       

PLX only tests the Linux package for Intel x86 compatible platforms.  By default, the PLX Linux package is set for 32-bit Little Endian CPU platforms.  If this package is to be used with a Big Endian CPU (e.g. PPC or MIPS core), follow the steps below before building PLX drivers or applications.  The PLX package is currently not able to auto-detect whether the end platform is Big Endian.

1.     In the environment, add an entry for PLX_CPU_BIG_ENDIAN as follows:
export PLX_CPU_BIG_ENDIAN=1

         必须清楚当前的CPU是大端存储还是小端存储的,如果是大端就必须配置PLX_CPU_BIG_ENDIAN环境变量。而我用的平台是Intel的CPU,Intel的CPU都是

        小端存储,所以不需要配置。如果这个参数配置错误,驱动编译出来的肯定不正确,会出莫名其妙的错误,一定要认真的确认是否正确配置!

2.     For 64-bit, define PLX_CPU_BITS as 64:
export PLX_CPU_BITS=64

         配置CPU位数,如果是64位,就必须配置PLX_CPU_BITS环境变量。

 #sudocat /proc/cpuinfo | more clflush

  #clflush size =64       如果返回结果为clflush size =64,则为64位CPU。

          我这里的CPU是64的,因此还是在/etc/enviroment环境变量配置文件中导出了PLX_CPU_BITS环境变量。

3.     To build applications & libraries in a cross-complier environment (embedded target platform)
- Modify the Assembler (AS), Compiler (CC), Archiver (AR), and Linker (LD) variables in the filePlxSdk\Linux\Makefiles\Gcc.def to match the GCC names of the target platform
- Modify the PLX_INC_DIR variable in PlxSdk\Linux\Makefiles\Common.def to add any additional include directories needed for the build

        配置CC,AS,等编译器选项。我这里采用的是GCC,默认的选项就可以了。

       第四步: 编译库函数和测试程序

                     PLX_SDK提供了一组API函数供开发者使用,同样的给出了一些测试程序用来测试API函数的正确性。下面编译:

                   编译API函数库:

                     #cd /usr/src/PlxSdk/PlxApi

                     跳转到PLX_SDK的安装目录

                    #make PLX_DEBUG=1

                    使用默认的makefile编译即可。加入了PLX_DEBUG参数,意思是编译调试版API函数。这里是为了后面调试驱动方便,调试驱动必须是编译有调试版的API函数。

                    不想调试也可以去掉PLX_DEBUG参数,直接make即可。

                    编译测试程序:

                    #cd /usr/src/PlxSdk/Linux/Samples/ApiTest

                    #make PLX_DEBUG=1

                     同样加入PLX_DEBUG参数,编译为调试版的测试程序。这样可以方便的使用gdb调试代码的执行流程以及是否有错误。

       第五步: 编译驱动程序

                   PLX_SDK中提供了自动编译的工具,即builddriver工具(其实是一个脚本,后面会分析具体代码)。利用builddriver工具可以方便的选择需要编译的驱动程序并进行编译。

                    #cd /usr/src/PlxSdk/Linux/Driver

                     #./builddriver 9054 d

                    9054指定了芯片号,d则是说明编译为可调试的驱动程序。

                  

        至此一个完整的PLX 9054的驱动程序已经编译完成了。可以进行后续的测试调整了。

        未完待续--------------

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值