📄 plx9656regaccess.c
字号:
/* Included Files */
#include <vxWorks.h>
#include <stdio.h>
#include <logLib.h>
#include <taskLib.h>
#include "../../../include/drv/hF1394Pmc/hFCtlPmc.h"
#include "../../../include/drv/hF1394Pmc/plx9656.h"
#include "rs60x.h"
/* define some macro */
/* Global Variables */
extern HFCTL_DEV HFCtlPmcDev;
/* Forward Declaration */
/******************************************************************************
TITLE: pciReadTest
DESC: test routine to read data from PCI bus
PARAM: none
RETURN: OK - operation runs successfully
ERROR - operation runs failed
******************************************************************************/
STATUS pciReadTest(void)
{
int i;
int iPciAdrs;
unsigned long iAccessValue;
for(i = 0; i < 20; i++)
{
iPciAdrs = (0x80200000 + i * 4);
iAccessValue = pciReadLong(iPciAdrs);
printf("pciReadTest: No %d = 0x%.8x\n", i, iAccessValue);
}
return(OK);
}
/******************************************************************************
TITLE: pciReadByteTest
DESC: test routine for pciReadByte() function
PARAM: none
RETURN: OK - operation runs successfully
ERROR - operation runs failed
******************************************************************************/
STATUS pciReadByteTest(void)
{
int i;
int iPciAdrs;
unsigned char ucAccessValue;
for(i = 0; i < 4; i++)
{
iPciAdrs = (0x2000001 + i);
ucAccessValue = pciReadByte(iPciAdrs);
printf("pciReadByteTest: 0x%.8x = 0x%.2x\n", iPciAdrs, ucAccessValue);
}
return(OK);
}
STATUS pciReadWriteByteTest(unsigned char ucData)
{
int i;
int iPciAdrs;
unsigned char ucTempData = 0x12;
unsigned char ucAccessValue;
unsigned long *pHfCtlDevMemAdrs;
pHfCtlDevMemAdrs = (unsigned long *)PCI_MEM2LOCAL(HFCtlPmcDev.pciControllerSpace0);
for(i = 0; i < 4; i++)
{
iPciAdrs = (0x2000000 + i);
#if 0
pciWriteByte(iPciAdrs, (ucData + i * 5) & 0xff);
#endif /* if 0 */
pciWriteByte(iPciAdrs, (ucTempData + i * 5) & 0xff);
}
for(i = 0; i < 4; i++)
{
iPciAdrs = (0x2000000 + i);
ucAccessValue = pciReadByte(iPciAdrs);
printf("pciReadByteTest: 0x%.8x = 0x%.2x\n", iPciAdrs, ucAccessValue);
}
return(OK);
}
STATUS pciReadWriteByteTest1(unsigned char ucData)
{
int i;
int iPciAdrs;
unsigned char ucTempData = 0x12;
unsigned char ucAccessValue;
unsigned long *pHfCtlDevMemAdrs;
pHfCtlDevMemAdrs = (unsigned long *)PCI_MEM2LOCAL(HFCtlPmcDev.pciControllerSpace0);
for(i = 0; i < 4; i++)
{
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_RT_REG_MBOX0_PCI + i);
pciWriteByte(iPciAdrs, (ucTempData + i * 5) & 0xff);
}
for(i = 0; i < 4; i++)
{
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_RT_REG_MBOX0_PCI + i);
ucAccessValue = pciReadByte(iPciAdrs);
printf("pciReadByteTest: 0x%.8x = 0x%.2x\n", iPciAdrs, ucAccessValue);
}
return(OK);
}
STATUS pciReadWriteByteTest2(unsigned char ucData)
{
int i;
int iPciAdrs;
unsigned char ucTempData = 0x12;
unsigned char ucAccessValue;
unsigned long *pHfCtlDevMemAdrs;
printf("pciReadWriteByteTest2: before write, read 4 byte register\n");
pHfCtlDevMemAdrs = (unsigned long *)PCI_MEM2LOCAL(HFCtlPmcDev.pciControllerSpace0);
for(i = 0; i < 4; i++)
{
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_LOCAL_CFG_REG_BIGEND_PCI + i);
ucAccessValue = pciReadByte(iPciAdrs);
printf("pciReadWriteByteTest2: 0x%.8x = 0x%.2x\n", iPciAdrs, ucAccessValue);
}
#if 0
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_LOCAL_CFG_REG_BIGEND_PCI);
ucTempData = 0x00;
pciWriteByte(iPciAdrs, ucTempData);
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_LOCAL_CFG_REG_LMISC1_PCI);
ucTempData = 0x04;
pciWriteByte(iPciAdrs, ucTempData);
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_LOCAL_CFG_REG_PROT_AREA_PCI);
ucTempData = 0x30;
pciWriteByte(iPciAdrs, ucTempData);
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_LOCAL_CFG_REG_LMISC2_PCI);
ucTempData = 0x01;
pciWriteByte(iPciAdrs, ucTempData);
printf("pciReadWriteByteTest2: after write, read 4 byte register\n");
for(i = 0; i < 4; i++)
{
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_LOCAL_CFG_REG_BIGEND_PCI + i);
ucAccessValue = pciReadByte(iPciAdrs);
printf("pciReadWriteByteTest2: 0x%.8x = 0x%.2x\n", iPciAdrs, ucAccessValue);
}
#endif /* if 0 */
return(OK);
}
/******************************************************************************
TITLE: HfCtlDevStructShow
DESC: routine to show structure HFCTL_DEV detail
PARAM: none
RETURN: OK - operation runs successfully
ERROR - operation runs failed
******************************************************************************/
STATUS HfCtlDevStructShow(void)
{
int i;
int iPciAdrs;
unsigned long iAccessValue;
unsigned long *pHfCtlDevMemAdrs;
unsigned long *pHfCtlDevPciAdrs;
if (HFCtlPmcDev.devCreated == 0)
{
printf("HfCtlDevStructShow: HFCtl Dev not created.\n");
return(ERROR);
}
printf("HfCtlDevStructShow: HFCTL_DEV.devHdr = 0x%.8x\n", HFCtlPmcDev.devHdr);
printf("HfCtlDevStructShow: HFCTL_DEV.semLocalData = 0x%.8x\n", HFCtlPmcDev.semLocalData);
printf("HfCtlDevStructShow: HFCTL_DEV.semDmaDone = 0x%.8x\n", HFCtlPmcDev.semDmaDone);
printf("HfCtlDevStructShow: HFCTL_DEV.semMailBox = 0x%.8x\n", HFCtlPmcDev.semMailBox);
printf("HfCtlDevStructShow: HFCTL_DEV.semLocalData = 0x%.8x\n", HFCtlPmcDev.semLocalData);
printf("HfCtlDevStructShow: HFCTL_DEV.devCreated = 0x%d\n", HFCtlPmcDev.devCreated);
printf("HfCtlDevStructShow: HFCTL_DEV.devBusy = 0x%d\n", HFCtlPmcDev.devBusy);
printf("HfCtlDevStructShow: HFCTL_DEV.iPciBusNo = 0x%d\n", HFCtlPmcDev.iPciBusNo);
printf("HfCtlDevStructShow: HFCTL_DEV.iPciDevNo = 0x%d\n", HFCtlPmcDev.iPciDevNo);
printf("HfCtlDevStructShow: HFCTL_DEV.iPciFuncNo = 0x%d\n", HFCtlPmcDev.iPciFuncNo);
printf("HfCtlDevStructShow: HFCTL_DEV.pciControllerSpace0 = 0x%.8x\n", HFCtlPmcDev.pciControllerSpace0);
printf("HfCtlDevStructShow: HFCTL_DEV.pciControllerSpace1 = 0x%.8x\n", HFCtlPmcDev.pciControllerSpace1);
printf("HfCtlDevStructShow: HFCTL_DEV.boardDataSpace0 = 0x%.8x\n", HFCtlPmcDev.boardDataSpace0);
printf("HfCtlDevStructShow: HFCTL_DEV.boardDataSpace1 = 0x%.8x\n", HFCtlPmcDev.boardDataSpace1);
printf("HfCtlDevStructShow: HFCTL_DEV.iWhichSapce = 0x%d\n", HFCtlPmcDev.iWhichSapce);
#if 0
pHfCtlDevMemAdrs = (unsigned long *)PCI_MEM2LOCAL(HFCtlPmcDev.pciControllerSpace0);
pHfCtlDevPciAdrs = (unsigned long *)LOCAL2PCI_MEM(HFCtlPmcDev.pciControllerSpace0);
printf("HfCtlDevStructShow: pHfCtlDevMemAdrs = 0x%.8x\n", pHfCtlDevMemAdrs);
printf("HfCtlDevStructShow: pHfCtlDevPciAdrs = 0x%.8x\n", pHfCtlDevPciAdrs);
#endif /* if 0 */
pHfCtlDevMemAdrs = (unsigned long *)(HFCtlPmcDev.pciControllerSpace0);
printf("HfCtlDevStructShow: pHfCtlDevMemAdrs = 0x%.8x\n", pHfCtlDevMemAdrs);
/*
for(i = 0; i < 20; i++)
{
iPciAdrs = ((int)pHfCtlDevMemAdrs + i * 4);
iAccessValue = pciReadLong(iPciAdrs);
printf("pciReadTest: 0x%.8x = 0x%.8x\n", iPciAdrs, iAccessValue);
}
*/ /* comment by chenxuhao at 2004-11-24 */
iPciAdrs = ((int)pHfCtlDevMemAdrs + PLX9656_RT_REG_PCIHIDR_PCI);
iAccessValue = pciReadLong(iPciAdrs);
printf("pciReadTest: PLX9656_RT_REG_PCIHIDR_PCI 0x%.8x = 0x%.8x\n",
((int)pHfCtlDevMemAdrs + PLX9656_RT_REG_PCIHIDR_PCI), iAccessValue);
return(OK);
}
unsigned long pciAdrsToLocalAdrsPPC6(unsigned long ulPciAdrs)
{
unsigned long pHfCtlDevMemAdrs;
pHfCtlDevMemAdrs = (unsigned long)PCI_MEM2LOCAL(ulPciAdrs);
return(pHfCtlDevMemAdrs);
}
STATUS HfCtlDevPciCfgRegsList(void)
{
int i;
int iPciAdrs;
unsigned long iAccessValue;
unsigned long *pHfCtlDevMemAdrs;
pHfCtlDevMemAdrs = (unsigned long *)(HFCtlPmcDev.pciControllerSpace0);
printf("HfCtlDevPciCfgRegsList: pHfCtlDevMemAdrs = 0x%.8x\n", pHfCtlDevMemAdrs);
for(i = 0; i < 20; i++)
{
iPciAdrs = ((int)pHfCtlDevMemAdrs + i * 4);
iAccessValue = pciReadLong(iPciAdrs);
printf("HfCtlDevPciCfgRegsList: 0x%.8x = 0x%.8x\n", iPciAdrs, iAccessValue);
}
return(OK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -