📄 hfctlpmc.c
字号:
#endif /* if 0 */
}
#endif /* if 0 */
#else
semGive(pHfctlDev->semRxFifoRdy);
semGive(pHfctlDev->semLocalData);
#endif /* if 0 */
}
if ((ulIntCsrValue & DATA_BIT18) && (ulIntCsrValue & DATA_BIT21))
{
i9656DmaIntCount++;
semGive(pHfctlDev->semDmaDone);
}
}
/******************************************************************************
TITLE: PciBaseAddrRead
DESC: routine to search PCI card and get the PCI base address
PARAM: pHfctlDev - pointer to HFCTL_DEV device structure
instance - instance to search
RETURN: OK - find the PCI device and get the PCI base address
ERROR - cannot find the PCI device
******************************************************************************/
STATUS PciBaseAddrRead (HFCTL_DEV *pHfctlDev, int instance)
{
STATUS iStatus;
int iTempData;
int iPciBusNo; /* PCI bus number */
int iPciDevNo; /* PCI device number */
int iPciFuncNo; /* PCI function number */
unsigned short ulTemp;
/* Search for device on PCI Bus */
iPciBusNo = 0xFF; /* Set trap for empty PMC sites... */
iPciDevNo = 0xFF;
iPciFuncNo = 0xFF;
iStatus = pciFindDevice((HFCTL_PCI_ID & 0xFFFF), (HFCTL_PCI_ID >> 16) & 0xFFFF, instance,
&iPciBusNo, &iPciDevNo, &iPciFuncNo);
if ((iPciBusNo == 0xFF) && (iPciDevNo == 0xFF) && (iPciFuncNo == 0xFF))
{
logMsg("\n\rNo device found!!", 0, 0, 0, 0, 0, 0);
return(ERROR);
}
#if 0
if (HFCtl_Debug)
{
/* Show the configuration settings */
pciHeaderShow(iPciBusNo, iPciDevNo, iPciFuncNo);
}
#endif /* if 0 */
pHfctlDev->iPciBusNo = iPciBusNo;
pHfctlDev->iPciDevNo = iPciDevNo;
pHfctlDev->iPciFuncNo = iPciFuncNo;
#if 0
if (HFCtl_Debug)
{
logMsg("PciBaseAddrRead: pHfctlDev->iPciBusNo = %d\n", pHfctlDev->iPciBusNo, 0, 0, 0, 0, 0);
logMsg("PciBaseAddrRead: pHfctlDev->iPciBusNo = %d\n", pHfctlDev->iPciDevNo, 0, 0, 0, 0, 0);
logMsg("PciBaseAddrRead: pHfctlDev->iPciBusNo = %d\n", pHfctlDev->iPciFuncNo, 0, 0, 0, 0, 0);
}
#endif /* if 0 */
iTempData = 0;
pciConfigInLong(iPciBusNo, iPciDevNo, iPciFuncNo, PLX9656_PCI_CFG_REG_BAR0_PCI, &iTempData);
pHfctlDev->pciControllerSpace0 = (unsigned long)PCI_MEM2LOCAL(iTempData);
/*
pHfctlDev->pciControllerSpace0 = (unsigned long)iTempData;
*/ /* comment by chenxuhao at 2004-11-25 */
pciConfigInLong(iPciBusNo, iPciDevNo, iPciFuncNo, PLX9656_PCI_CFG_REG_BAR1_PCI, &iTempData);
pHfctlDev->pciControllerSpace1 = (unsigned long)PCI_IO2LOCAL(iTempData);
/*
pHfctlDev->pciControllerSpace1 = (unsigned long)iTempData;
*/ /* comment by chenxuhao at 2004-11-25 */
pciConfigInLong(iPciBusNo, iPciDevNo, iPciFuncNo, PLX9656_PCI_CFG_REG_BAR2_PCI, &iTempData);
pHfctlDev->boardDataSpace0 = (unsigned long)PCI_MEM2LOCAL(iTempData);
/*
pHfctlDev->boardDataSpace0 = (unsigned long)iTempData;
*/ /* comment by chenxuhao at 2004-11-25 */
pciConfigInLong(iPciBusNo, iPciDevNo, iPciFuncNo, PLX9656_PCI_CFG_REG_BAR3_PCI, &iTempData);
pHfctlDev->boardDataSpace1 = (unsigned long)PCI_MEM2LOCAL(iTempData);
/*
pHfctlDev->boardDataSpace1 = (unsigned long)iTempData;
*/ /* comment by chenxuhao at 2004-11-25 */
pciConfigInLong(iPciBusNo, iPciDevNo, iPciFuncNo, PLX9656_PCI_CFG_REG_INT_LINE_PCI, &iTempData);
pmcIntValue = iTempData & 0xff;
pciConfigInWord(iPciBusNo, iPciDevNo, iPciFuncNo, PLX9656_PCI_CFG_REG_PCI_CMD_PCI, &ulTemp);
ulTemp = ulTemp | DATA_BIT0 | DATA_BIT1 | DATA_BIT2 | DATA_BIT4 | DATA_BIT6;
pciConfigOutWord(iPciBusNo, iPciDevNo, iPciFuncNo, PLX9656_PCI_CFG_REG_PCI_CMD_PCI, ulTemp);
return(OK);
}
/******************************************************************************
TITLE: pciReadLong
DESC: routine to read Long data from a pci address
PARAM: iPciAddr - pci address to be read
RETURN: ulTemp - data read from specified PCI address
******************************************************************************/
unsigned long pciReadLong (int iPciAddr)
{
unsigned int * pPciAddr;
unsigned long ulData;
unsigned long ulTemp;
ulTemp = 0;
pPciAddr = ((unsigned int *)iPciAddr);
__asm__("eieio");
ulData = *pPciAddr;
#if 1
ulTemp = ulTemp | ((ulData << 24) & 0xFF000000);
ulTemp = ulTemp | ((ulData << 8) & 0x00FF0000);
ulTemp = ulTemp | ((ulData >> 8) & 0x0000FF00);
ulTemp = ulTemp | ((ulData >> 24) & 0x000000FF);
#else
ulTemp = ulData;
#endif /* if 0 */
return(ulTemp);
}
/******************************************************************************
TITLE: pciWriteLong
DESC: routine to write Long data to a pci address
PARAM: iPciAddr - pci address to be written
ulData - data to be written into the pci space
RETURN: none
******************************************************************************/
void pciWriteLong(int iPciAddr, unsigned long ulData)
{
unsigned int * pPciAddr;
unsigned long ulTemp;
#if 1
ulTemp = 0;
ulTemp = ulTemp | ((ulData << 24)& 0xFF000000);
ulTemp = ulTemp | ((ulData << 8)& 0x00FF0000);
ulTemp = ulTemp | ((ulData >> 8)& 0x0000FF00);
ulTemp = ulTemp | ((ulData >> 24)& 0x000000FF);
#else
ulTemp = ulData;
#endif /* if 0 */
pPciAddr = ((unsigned int *) iPciAddr);
*pPciAddr = ulTemp;
__asm__("eieio");
}
/******************************************************************************
TITLE: pciReadByte
DESC: routine to read byte data from a pci address
PARAM: iPciAddr - pci address to be read
RETURN: ulTemp - data read from specified PCI address
******************************************************************************/
unsigned char pciReadByte (int iPciAddr)
{
unsigned char *pPciAddr;
unsigned char ucData;
unsigned char ucTemp;
ucTemp = 0;
pPciAddr = ((unsigned char *)iPciAddr);
#if 0
logMsg("pciReadByte: pPciAddr = 0x%.8x\n", (int)pPciAddr, 0, 0, 0, 0, 0);
#endif /* if 0 */
/*
__asm__("eieio");
*/ /* comment by chenxuhao at 2004-11-24 */
ucData = *pPciAddr;
#if 0
logMsg("pciReadByte: ucData = 0x%.8x\n", (int)ucData, 0, 0, 0, 0, 0);
#endif /* if 0 */
ucTemp = ucData;
#if 0
logMsg("pciReadByte: ucTemp = 0x%.8x\n", (int)ucTemp, 0, 0, 0, 0, 0);
#endif /* if 0 */
return(ucTemp);
}
/******************************************************************************
TITLE: pciWriteByte
DESC: routine to write byte data to a pci address
PARAM: iPciAddr - pci address to be written
ulData - data to be written into the pci space
RETURN: none
******************************************************************************/
void pciWriteByte(int iPciAddr, unsigned char ucData)
{
unsigned char *pPciAddr;
unsigned char ucTemp;
ucTemp = ucData;
#if 0
logMsg("pciWriteByte: ucTemp = 0x%.2x\n", ucTemp, 0, 0, 0, 0, 0);
#endif /* if 0 */
pPciAddr = ((unsigned char *) iPciAddr);
#if 0
logMsg("pciWriteByte: pPciAddr = 0x%.8x\n", (int)pPciAddr, 0, 0, 0, 0, 0);
#endif /* if 0 */
*pPciAddr = ucTemp;
__asm__("eieio");
#if 0
logMsg("pciWriteByte: after write *pPciAddr = 0x%.2x\n", (int)*pPciAddr, 0, 0, 0, 0, 0);
#endif /* if 0 */
}
/******************************************************************************
TITLE: pciReadShort
DESC: routine to read Word(2 Byte) data from a pci address
PARAM: iPciAddr - pci address to be read
RETURN: usTemp - data read from specified PCI address
******************************************************************************/
unsigned short pciReadShort (int iPciAddr)
{
unsigned short *pPciAddr;
unsigned short usData;
unsigned short usTemp;
usTemp = 0;
pPciAddr = ((unsigned short *)iPciAddr);
logMsg("pciReadShort: pPciAddr = 0x%.4x\n", (int)pPciAddr, 0, 0, 0, 0, 0);
/*
__asm__("eieio");
*/ /* comment by chenxuhao at 2004-11-24 */
usData = *pPciAddr;
logMsg("pciReadShort: usData = 0x%.4x\n", (int)usData, 0, 0, 0, 0, 0);
usTemp = usData;
logMsg("pciReadShort: usTemp = 0x%.4x\n", (int)usTemp, 0, 0, 0, 0, 0);
return(usTemp);
}
/******************************************************************************
TITLE: pciWriteShort
DESC: routine to write Word(2 Byte) data to a pci address
PARAM: iPciAddr - pci address to be written
usData - data to be written into the pci space
RETURN: none
******************************************************************************/
void pciWriteShort(int iPciAddr, unsigned short usData)
{
unsigned short *pPciAddr;
unsigned short usTemp;
usTemp = usData;
logMsg("pciWriteShort: usTemp = 0x%.4x\n", usTemp, 0, 0, 0, 0, 0);
pPciAddr = ((unsigned short *)iPciAddr);
logMsg("pciWriteShort: pPciAddr = 0x%.8x\n", (int)pPciAddr, 0, 0, 0, 0, 0);
*pPciAddr = usTemp;
__asm__("eieio");
logMsg("pciWriteShort: after write *pPciAddr = 0x%.4x\n", (int)*pPciAddr, 0, 0, 0, 0, 0);
}
/******************************************************************************
TITLE: HFCtlDrvParmReset
DESC: routine to clear all driver specific parameter of hop freq control PMC Card
PARAM: none
RETURN: none
******************************************************************************/
void HFCtlDrvParmReset(void)
{
iPciIntCount = 0;
i9656LocalIntCount = 0;
i9656LintRxFifoRdyCount = 0;
i9656LintTxHFDataRdyCount = 0;
i9656DmaIntCount = 0;
pmcIntValue = 0;
DriverNumber = 0;
NumberOfDevices = 0;
}
/******************************************************************************
TITLE: HFCtlIntRemove
DESC: routine to remove installed ISR for HFCTL card
PARAM: none
RETURN: OK - routine runs successfully
ERROR - routine runs failed with error
******************************************************************************/
STATUS HFCtlIntRemove(void)
{
int iStatus;
int vec;
INT_HANDLER_DESC *handler = NULL;
#if 0
printf("HFCtlIntRemove: pmcIntValue = %d\n", pmcIntValue);
printf("HFCtlIntRemove: INUM_TO_IVEC(pmcIntValue) = %d\n", INUM_TO_IVEC(pmcIntValue));
printf("HFCtlIntRemove: HFCtlIntHandle = 0x%.8x\n", (int)HFCtlIntHandle);
#endif /* if 0 */
vec = (int)INUM_TO_IVEC(pmcIntValue);
handler = sysIntTbl[vec];
while (handler != NULL)
{
/* link the next ISR to system Interrupt table */
sysIntTbl[vec] = handler->next;
/* clear the installed ISR */
free(handler);
/* get next ISR */
handler = sysIntTbl[vec];
}
return(OK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -