如何在VxWorks 653中的PCI设备上读/写内存?

时间:2010-12-28 22:28:52

标签: vxworks pci

我正在使用VxWorks 653,我的目标是wrSbc7457 Power PC。

我的wrSbc7457上有夹层卡,我正试图在夹层卡上写/读内存。

对于熟悉VxWorks的人,我在ModuleOS的usrAppInit()函数中有以下内容:

printf ( "Entering ModuleOS, usrAppInit() ...\n" ) ;
printf ( "sysModel() returns %s\n", sysModel() ) ;
pciDeviceShow ( 0 ) ;


{
int pciBus, pciDevice, pciFunc ;
UINT32  BAR_0_contents, BAR_1_contents ;

printf
    ( "\npciFindDevice returns STATUS %d\n",
            pciFindDevice ( my_VENDORID, my_PMC_DEVICEID, 0, &pciBus, &pciDevice, &pciFunc )
    ) ;
printf ( "\tand pciBus = %d, pciDevice = %d, pciFunc = %d\n", pciBus, pciDevice, pciFunc ) ;

printf ( "\npciConfigInLong returns STATUS %d\n",
        pciConfigInLong ( pciBus, pciDevice, pciFunc, PCI_CFG_BASE_ADDRESS_0, & BAR_0_contents ) ) ;
printf ( "\tand Base Address Register 0 contains 0x%X\n", BAR_0_contents ) ;
printf ( "\npciConfigInLong returns STATUS %d\n",
        pciConfigInLong ( pciBus, pciDevice, pciFunc, PCI_CFG_BASE_ADDRESS_1, & BAR_1_contents ) ) ;
printf ( "\tand Base Address Register 1 contains 0x%X\n", BAR_1_contents ) ;

我的目标在加载操作系统启动映像时输出以下内容:

Entering ModuleOS, usrAppInit() ...

sysModel() returns wrSbc7457 Power PC

Scanning function 0 of each PCI device on bus 0
Using configuration mechanism 0
bus       device    function  vendorID  deviceID  class
00000000  00000000  00000000  0000----  0000----  000-----
00000000  00000001  00000000  0000----  0000----  00--0000
00000000  00000002  00000000  0000----  0000----  000-----

pciFindDevice returns STATUS 0 (OK)
        and pciBus = 0, pciDevice = 1, pciFunc = 0

pciConfigInLong returns STATUS 0 (OK)
        and Base Address Register 0 contains 0x50000000

pciConfigInLong returns STATUS 0 (OK)
        and Base Address Register 1 contains 0x58000000

我的问题是:如何将夹层卡的内存映射到主机的地址空间,然后如何在夹层卡上写入/读取内存?

1 个答案:

答案 0 :(得分:1)

不幸的是,没有普遍的答案。您必须编程PCI桥。 其中一些取决于您是否使用PCI自动配置。

您应该查看pciConfig和/或pciAutoConfig的库引用。

您的设备看起来在0x50000000和0x58000000处有两个地址空间,但我相信这是PCI地址空间,而不是主机桥映射。

相关问题