⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pciconfiglib.c

📁 ge公司的dv4av4信号处理板的bsp源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
		{
		retStat = OK;
		}
            break;

	case PCI_MECHANISM_1:
	    PCI_OUT_LONG (pciConfigAddr0, 
		          pciConfigBdfPack (busNo, deviceNo, funcNo) |
		          (offset & 0xfc) | 0x80000000);
	    retval = PCI_IN_BYTE (pciConfigAddr1 + (offset & 0x3));
	    retStat = OK;
	    break;

	case PCI_MECHANISM_2:
	    PCI_OUT_BYTE (pciConfigAddr0, 0xf0 | (funcNo << 1));
	    PCI_OUT_BYTE (pciConfigAddr1, busNo);
	    retvallong =
		PCI_IN_LONG(pciConfigAddr2 | ((deviceNo & 0x000f) << 8) \
			| (offset & 0xfc));
	    PCI_OUT_BYTE (pciConfigAddr0, 0);
	    retvallong >>= (offset & 0x03) * 8;
	    retval = (UINT8)(retvallong & 0xff);
	    retStat = OK;
	    break;

	default:
	    break;
	}
#else
    bslPciConfigRead8(busNo, deviceNo, funcNo, offset, pData);
#endif

    intUnlock (key);				/* mutual exclusion stop */

#if 0
    *pData = retval;
    return (retStat);
#endif

    return (OK);
    }

/*******************************************************************************
*
* pciConfigInWord - read one word from the PCI configuration space
*
* This routine reads one word from the PCI configuration space
*
* RETURNS: OK, or ERROR if this library is not initialized
*/

STATUS pciConfigInWord
    (
    int	busNo,      /* bus number */
    int	deviceNo,   /* device number */
    int	funcNo,     /* function number */
    int	offset,     /* offset into the configuration space */
    UINT16 * pData  /* data read from the offset */
    )
    {
    int	key;

#if 0
    STATUS retStat = ERROR;
    UINT16 retval = 0;
    UINT32 retvallong = 0;

    /* check for library initialization or unaligned access */

#ifdef PCI_CONFIG_OFFSET_NOCHECK
    if (pciLibInitStatus != OK)
	{
        return (retStat);
	}
#else
    if ((pciLibInitStatus != OK) || ((offset & (int)0x1) > 0) )
	{
        return (retStat);
	}
#endif
#endif

    key = intLock ();				/* mutual exclusion start */

#if 0
    switch (pciConfigMech)
	{
        case PCI_MECHANISM_0:
            if (pciConfigRead (busNo, deviceNo, funcNo, offset, 2,
                                (void *)&retval) == ERROR)
		{
		retval = 0xffff;
		}
	    else
		{
		retStat = OK;
		}
            break;

	case PCI_MECHANISM_1:
	    PCI_OUT_LONG (pciConfigAddr0, 
		          pciConfigBdfPack (busNo, deviceNo, funcNo) |
		          (offset & 0xfc) | 0x80000000);
	    retval = PCI_IN_WORD (pciConfigAddr1 + (offset & 0x2));
	    retStat = OK;
	    break;

	case PCI_MECHANISM_2:
	    PCI_OUT_BYTE (pciConfigAddr0, 0xf0 | (funcNo << 1));
	    PCI_OUT_BYTE (pciConfigAddr1, busNo);
	    retvallong = PCI_IN_LONG (pciConfigAddr2 | \
		    ((deviceNo & 0x000f) << 8) | (offset & 0xfc));
	    PCI_OUT_BYTE (pciConfigAddr0, 0);
	    retvallong >>= (offset & 0x02) * 8;
	    retval = (UINT16)(retvallong & 0xffff);
	    retStat = OK;
	    break;

	default:
	    break;
	}
#else
    bslPciConfigRead16(busNo, deviceNo, funcNo, offset, pData);
#endif

    intUnlock (key);				/* mutual exclusion stop */

#if 0
    *pData = retval;

    return (retStat);
#endif
    return (OK);

    }

/*******************************************************************************
*
* pciConfigInLong - read one longword from the PCI configuration space
*
* This routine reads one longword from the PCI configuration space
*
* RETURNS: OK, or ERROR if this library is not initialized
*/

STATUS pciConfigInLong
    (
    int	busNo,     /* bus number */
    int	deviceNo,  /* device number */
    int	funcNo,    /* function number */
    int	offset,    /* offset into the configuration space */
    UINT32 * pData /* data read from the offset */
    )
    {
#if 0
    STATUS retStat = ERROR;
    UINT32 retval = 0;

    /* check for library initialization or unaligned access */

#ifdef PCI_CONFIG_OFFSET_NOCHECK
    if (pciLibInitStatus != OK)
	{
        return (retStat);
	}
#else
    if ((pciLibInitStatus != OK) || ((offset & (int)0x3) > 0) )
	{
        return (retStat);
	}
#endif
#endif

    int		 key;
    key = intLock ();				/* mutual exclusion start */

#if 0
    switch (pciConfigMech)
	{

        case PCI_MECHANISM_0:
            if (pciConfigRead (busNo, deviceNo, funcNo, offset, 4,
                                (void *)&retval) == ERROR)
		{
                retval = 0xffffffff;
		}
	    else
		{
		retStat = OK;
		}
            break;


	case PCI_MECHANISM_1:
	    PCI_OUT_LONG (pciConfigAddr0, 
		          pciConfigBdfPack (busNo, deviceNo, funcNo) |
		          (offset & 0xfc) | 0x80000000);
	    retval = PCI_IN_LONG (pciConfigAddr1);
	    retStat = OK;
	    break;

	case PCI_MECHANISM_2:
	    PCI_OUT_BYTE (pciConfigAddr0, 0xf0 | (funcNo << 1));
	    PCI_OUT_BYTE (pciConfigAddr1, busNo);
	    retval = PCI_IN_LONG (pciConfigAddr2 | ((deviceNo & 0x000f) << 8) |
				  (offset & 0xfc));
	    PCI_OUT_BYTE (pciConfigAddr0, 0);
	    retStat = OK;
	    break;

	default:
	    break;
	}
#else
    bslPciConfigRead32(busNo, deviceNo, funcNo, offset, pData);
#endif

    intUnlock (key);				/* mutual exclusion stop */

#if 0
    *pData = retval;

    return (retStat);
#endif

    return (OK);
    }

/*******************************************************************************
*
* pciConfigOutByte - write one byte to the PCI configuration space
*
* This routine writes one byte to the PCI configuration space.
*
* RETURNS: OK, or ERROR if this library is not initialized
*/

STATUS pciConfigOutByte
    (
    int	busNo,    /* bus number */
    int	deviceNo, /* device number */
    int	funcNo,   /* function number */
    int	offset,   /* offset into the configuration space */
    UINT8 data    /* data written to the offset */
    )
    {
#if 0
    UINT32	retval;
    int		mask	= 0x000000ff;

    if (pciLibInitStatus != OK)			/* sanity check */
        return (ERROR);
#endif

    int		key;
    key = intLock ();				/* mutual exclusion start */

#if 0
    switch (pciConfigMech)
	{
        case PCI_MECHANISM_0:
            pciConfigWrite (busNo, deviceNo, funcNo, offset, 1, data);
            break;

	case PCI_MECHANISM_1:
	    PCI_OUT_LONG (pciConfigAddr0, 
		          pciConfigBdfPack (busNo, deviceNo, funcNo) |
		          (offset & 0xfc) | 0x80000000);
	    PCI_OUT_BYTE ((pciConfigAddr1 + (offset & 0x3)), data);
	    break;

	case PCI_MECHANISM_2:
	    PCI_OUT_BYTE (pciConfigAddr0, 0xf0 | (funcNo << 1));
	    PCI_OUT_BYTE (pciConfigAddr1, busNo);
	    retval = PCI_IN_LONG (pciConfigAddr2 | ((deviceNo & 0x000f) << 8) |
				  (offset & 0xfc));
	    data = (data & mask) << ((offset & 0x03) * 8);
	    mask <<= (offset & 0x03) * 8;
	    retval = (retval & ~mask) | data;
	    PCI_OUT_LONG ((pciConfigAddr2 | ((deviceNo & 0x000f) << 8) |
			  (offset & 0xfc)), retval);
	    PCI_OUT_BYTE (pciConfigAddr0, 0);
	    break;

	default:
	    break;
	}
#else
    bslPciConfigWrite8(busNo, deviceNo, funcNo, offset, data);
#endif

    intUnlock (key);				/* mutual exclusion stop */

    return (OK);
    }

/*******************************************************************************
*
* pciConfigOutWord - write one 16-bit word to the PCI configuration space
*
* This routine writes one 16-bit word to the PCI configuration space.
*
* RETURNS: OK, or ERROR if this library is not initialized
*/

STATUS pciConfigOutWord
    (
    int	busNo,    /* bus number */
    int	deviceNo, /* device number */
    int	funcNo,   /* function number */
    int	offset,   /* offset into the configuration space */
    UINT16 data   /* data written to the offset */
    )
    {

#if 0
    UINT32	retval;
    int		mask	= 0x0000ffff;

    /* check for library initialization or unaligned access */

#ifdef PCI_CONFIG_OFFSET_NOCHECK
    if (pciLibInitStatus != OK)
	{
        return (ERROR);
	}
#else
    if ((pciLibInitStatus != OK) || ((offset & (int)0x1) > 0) )
	{
        return (ERROR);
	}
#endif
#endif

    int		key;
    key = intLock ();				/* mutual exclusion start */

#if 0
    switch (pciConfigMech)
	{

        case PCI_MECHANISM_0:
            pciConfigWrite (busNo, deviceNo, funcNo, offset, 2, data);
            break;

	case PCI_MECHANISM_1:
	    PCI_OUT_LONG (pciConfigAddr0, pciConfigBdfPack (busNo, deviceNo, funcNo) |
		          (offset & 0xfc) | 0x80000000);
	    PCI_OUT_WORD ((pciConfigAddr1 + (offset & 0x2)), data);
	    break;

	case PCI_MECHANISM_2:
	    PCI_OUT_BYTE (pciConfigAddr0, 0xf0 | (funcNo << 1));
	    PCI_OUT_BYTE (pciConfigAddr1, busNo);
	    retval = PCI_IN_LONG (pciConfigAddr2 | ((deviceNo & 0x000f) << 8) |
				  (offset & 0xfc));
	    data = (data & mask) << ((offset & 0x02) * 8);
	    mask <<= (offset & 0x02) * 8;
	    retval = (retval & ~mask) | data;
	    PCI_OUT_LONG ((pciConfigAddr2 | ((deviceNo & 0x000f) << 8) |
			  (offset & 0xfc)), retval);
	    PCI_OUT_BYTE (pciConfigAddr0, 0);
	    break;

	default:
	    break;
	}
#else
    bslPciConfigWrite16(busNo, deviceNo, funcNo, offset, data);
#endif

    intUnlock (key);				/* mutual exclusion stop */

    return (OK);
    }


/*******************************************************************************
*
* pciConfigOutLong - write one longword to the PCI configuration space
*
* This routine writes one longword to the PCI configuration space.
*
* RETURNS: OK, or ERROR if this library is not initialized
*/

STATUS pciConfigOutLong
    (
    int	busNo,    /* bus number */
    int	deviceNo, /* device number */
    int	funcNo,   /* function number */
    int	offset,   /* offset into the configuration space */
    UINT32 data   /* data written to the offset */
    )
    {
    int key;

#if 0
    /* check for library initialization or unaligned access */

#ifdef PCI_CONFIG_OFFSET_NOCHECK
    if (pciLibInitStatus != OK)
	{
        return (ERROR);
	}
#else
    if ((pciLibInitStatus != OK) || ((offset & (int)0x3) > 0) )
	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -