wordstar
驱动牛犊
驱动牛犊
  • 注册日期2003-03-18
  • 最后登录2003-08-15
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:4278回复:0

菜鸟的设备驱动开发之路2003-0407

楼主#
更多 发布于:2003-04-09 06:40
11:02 2003-4-7
没有什么好看的了。
我们看看PLXMON的说明书对上面的理解有什么说法。不要急于编程,编程有的是机会呢。
直接看9054寄存器设置。
好像里面没有什么有新意的地方,连新名词都没有。只是一些界面说明。废话。
再看看9054RDKLITE的资料,两页纸,打印出来就是了。
Based on the powerful PLX PCI 9054, the PLX PCI 9054RDK-LITE (RDK-LITE) provides
a low cost development environment for PCI 9054 embedded application designs.
At the heart of the RDK-LITE is the PLX PCI 9054 I/O Accelerator which supports
a 32-bit, 33MHz PCI bus and a 50MHz local bus. It provides a complete PCI v2.2
specification implementation enabling burst transfers up to 132 Mbytes/second. The
PCI 9054 incorporates PLX’s industry leading advanced Data Pipe ArchitectureTM
technology including dual DMA engines, programmable PCI Initiator and Target data
transfer modes and PCI messaging functions.
There are various sizes of QFP footprints and through hole matrixes on the PCI
board which support industry standard embedded CPUs, DSPs and PLCC packaging,
including the IBM PPC, Motorola MPC and Coldfire, Hitachi MCU and MPU, TI DSP,
Analog Device DSP and many others. The 100-pin PLX Option Module (POM) J-Bus
connector can be used to connect to any POM. Also there is a 30 x 25 0.1” through
hole grid spacing for expansion purposes.
The RDK-LITE comes with PLXMon99TM, a comprehensive GUI utility for
monitoring, debugging, configuration and code download. When used with the PLX
PCI SDK, which can be purchased separately from PLX, the PCI 9054RDK-LITE will
allow customers to quickly and easily add PCI to a variety of embedded applications
in telecommunications, data communications, and many others.

n A PCI prototype adapter
board design based on the
PLX PCI 9054 32-bit I/O
Accelerator chip
n Surface mount footprints on
the board support industry
standard embedded CPUs,
DSPs and PLCC packaging
including the IBM PPC,
Motorola MPC and Coldfire,
Hitachi MCU and MPU, TI
DSP, Analog Device DSP and
many others
n 30 x 25 0.1” through hole grid
space for expansion purpose
n PLXMon 99, a comprehensive
GUI utility for debugging,
configuration and code
download

首先可以看出的是,PCI9054RDK-LITE是一个基于32位IO加速芯片PLXPCI9054的原型版。
PCI9054 支持32为,33MPCI总线和50M局部总线。
提供PCI2.2版的能力,突发传输速度132M,然后是广告,
支持最多64MSDRAM,板载128KSRAM,上面的16M内存一直不可用,不知道什么原因。既然如此,我们先使用这128K的静态
RAM吧。

再看9054 的广告。产品说明书700多页,对出学者很困难,广告总是容易一点。
广告中只能提供一个简单的概念性的东东。大致的数据通道是可以想像的。9054一方面挂接在局部总线上,另一方面挂接
在PCI总线上,然后为局部内存到计算机内存提供传输加速。

再看看9054的说明资料,这是个700多页的大东东。实在不想看。
直接看看9054的SDK说明书。
首先是软件体系构架。
最上层当然是应用程序。SDK提供了PLXMON的源代码,可以参照实现。
然后是API的动态链接库。
然后是设备驱动,
PCI总线
9054
本地API,BSP,BEM,这些东东大多只提供到PowerPC的芯片用。可能不需要软件根它们打交道。
本地应用程序。
设备驱动和DLL都是SDK提供了的,当然设备驱动有源代码,DLL有没有我不清楚。
我们直接看应用层的一个例子。

又死机了。写了好多东东都丢了。看了一下9054本地寄存器的配置
Register 11-39. (LAS0BA; PCI:04h, LOC:84h) Local Address Space 0 Local Base Address (Remap)
Bit Description Read Write
Value after
Reset
0
Space 0 Enable. Writing a 1 enables decoding of PCI addresses for PCI
Target access to Local Bus Space 0. Writing a 0 disables decoding.
Yes Yes 0
1 Reserved. Yes No 0
3:2
If Local Bus Space 0 is mapped into Memory space, bits are not used. When
mapped into I/O space, included with bits [31:4] for remapping.
Yes Yes 00
31:4
Remap PCI Address to Local Address Space 0 into Local Address Space.
Bits in this register remap (replace) PCI Address bits used in decode as Local
Address bits.
Note: Remap Address value must be a multiple of the Range (not the Range
register).
Yes Yes 0h

上面一堆乱七八糟的东东是从PDF文件的表格里拷贝下来的。中心思想是Remap这个寄存器怎样设置
Space 0 Enable. Writing a 1 enables decoding of PCI addresses for PCI
Target access to Local Bus Space 0. Writing a 0 disables decoding.
是说空间0 的允许。填1表示使能PCI地址译码操作局部总线的0空间。乱七八糟,我都不知道在说什么,总之,试验的结果,
填1就好了。

然后我想可以写程序了吧。
首先当然是吧PLXAPI.h 包含到工程里。这没有任何问题。
其次我想应该是去寻找PLXAPI.lib或者干脆把这个库弄进来。
简单起见,我把它弄到工程里算了。
然后可以开始编程了。
步骤1:初始化PLX卡。
S8
SelectDevice(
    DEVICE_LOCATION *pDevice
    )
{
    U32  i;
    U32  DeviceNum;


    pDevice->BusNumber  = (U8)-1;
    pDevice->SlotNumber = (U8)-1;
    pDevice->VendorId   = (U16)-1;
    pDevice->DeviceId   = (U16)-1;
    strcpy(pDevice->SerialNumber, \"\");

    DeviceNum = FIND_AMOUNT_MATCHED;
    if (PlxPciDeviceFind(
            pDevice,
            &DeviceNum
            ) != ApiSuccess)
    {
        return 0;
    }

    if (DeviceNum == 0)
        return 0;

    PlxPrintf(\"\\n\");
    for (i=0; i<DeviceNum; i++)
    {
        pDevice->BusNumber  = (U8)-1;
        pDevice->SlotNumber = (U8)-1;
        pDevice->VendorId   = (U16)-1;
        pDevice->DeviceId   = (U16)-1;
        strcpy(pDevice->SerialNumber, \"\");

        PlxPciDeviceFind(
            pDevice,
            &i
            );

        PlxPrintf(
            \"\\t\\t    %u. %.4x %.4x  [%04x - bus %.2x  slot %.2x]\\n\",
            i+1, pDevice->DeviceId, pDevice->VendorId,
            DetermineChipType(pDevice), pDevice->BusNumber, pDevice->SlotNumber
            );
    }

    PlxPrintf(\"\\t\\t    0. Cancel\\n\\n\");
    PlxPrintf(\"\\t  Device Selection --> \");

    while ((i = Plx_getch()-\'0\') > DeviceNum);

    PlxPrintf(\"%u\\n\\n\", i);

    if (i == 0)
        return -1;

    pDevice->BusNumber  = (U8)-1;
    pDevice->SlotNumber = (U8)-1;
    pDevice->VendorId   = (U16)-1;
    pDevice->DeviceId   = (U16)-1;
    strcpy(pDevice->SerialNumber, \"\");

    i--;
    PlxPciDeviceFind(
        pDevice,
        &i
        );

    return (S8)DeviceNum;
}

这里核心的函数是PlxPciDeviceFind,
我们从SDK的文档中去查找这个函数:
PLX SDK Programmer’s Reference Manual v3.2
3-90 ? 2001 PLX Technology, Inc. All rights reserved.

PlxPciDeviceFind
Syntax:
RETURN_CODE
PlxPciDeviceFind(
DEVICE_LOCATION *device,
U32 *requestLimit
);

看这个原型,返回值的类型为S8,这个类型在Win32系统中被定义为signed char ,是一个有符号的字符。
参数为一个类型为DEVICE_LOCATION 的指针,和一个返回设备数量的指针。U32的类型当然应该是32位无符号数。



PLX Chip Support:All
Description:Finds PLX devices on the PCI bus given a combination of bus number, slot number; vendor ID, and/or
device ID, or by the Serial number.
Parameters:
device:A pointer to a DEVICE_LOCATION structure containing the search criteria and/or to contain device
information once it is found.
requestLimit:A pointer to a 32-bit buffer. Refer to the Notes section.
Return Codes:
ApiSuccess :The function returned successfully
ApiNullParam :One or more parameters is NULL
ApiInvalidDeviceInfo :The device information did not match any device in the system
ApiNoActiveDriver: There is no device driver installed into the system
Notes:
If requestLimit contains the value FIND_AMOUNT_MATCHED, the DEVICE_LOCATION structure should
contain the search criteria
If requestLimit contains a value other than FIND_AMOUNT_MATCHED, the DEVICE_LOCATION
structure will be filled in with information about the device indexed at requestLimit (numbering starts at 0).
Set items not to be used as search criteria to

最新喜欢:

lyjyjjlyjyjj juventusjuvent...
游客

返回顶部