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

📄 ixdmaacc.c

📁 有关ARM开发板上的IXP400网络驱动程序的源码以。
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * @file    IxDmaAcc.c * * @date    18 October 2002 * * @brief   API of the IXP400 DMA Access Driver Component (IxDma) * * @par * IXP400 SW Release version 2.1 *  * -- Copyright Notice -- *  * @par * Copyright (c) 2001-2005, Intel Corporation. * All rights reserved. *  * @par * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. Neither the name of the Intel Corporation nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. *  *  * @par * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. *  *  * @par * -- End of Copyright Notice -- *//* * User defined include files listed below */#include "IxOsal.h"#include "IxDmaAcc.h"#include "IxDmaAcc_p.h"#include "IxNpeDl.h"#include "IxQMgr.h"#include "IxFeatureCtrl.h"/* * System defined include files listed below *//* *  Local Variables */static BOOL ixDmaAccInitDone = FALSE;  /* Flag is true once DmaIitialization                                          is done */static IxQMgrQId ixDmaQIdDmaDone;     /* Done Q Id    */static IxQMgrQId ixDmaQIdDmaRequest;  /* Request Q Id */static IxDmaAccStats dmaStats;     /* Instantiate statistics data structure *//*********************************************************************** * @fn IxDmaAccInit * @param npeId : The Id for NPE A, NPE B or NPE C * @brief Initialize the DMA Access Component * @return IX_SUCCESS : Initialization succeeded * @return IX_FAIL : Initialization Failed ***********************************************************************/PUBLIC IX_STATUSixDmaAccInit(IxNpeDlNpeId npeId){  #if CPU!=SIMSPARCSOLARIS     /* If not IXP42X A0 stepping, proceed to check for existence of coprocessors */     if ((IX_FEATURE_CTRL_SILICON_TYPE_A0 !=         (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))        || (IX_FEATURE_CTRL_DEVICE_TYPE_IXP42X != ixFeatureCtrlDeviceRead ()))    {      /*       * Check whether NPE is present        */      if (IX_NPEDL_NPEID_NPEA == npeId)	{              /* Check whether NPE A is present */             if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)== 	        IX_FEATURE_CTRL_COMPONENT_DISABLED)            {   	        /* NPE A does not present */	        ixOsalLog (IX_OSAL_LOG_LVL_WARNING,	        		   IX_OSAL_LOG_DEV_STDOUT,                        "Warning:NPEA does not present.\n",	                   0,0,0,0,0,0);            }        }        else if (IX_NPEDL_NPEID_NPEB == npeId)	 {  	    /* Check whether NPE B is present */             if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)== 	        IX_FEATURE_CTRL_COMPONENT_DISABLED)            {     	        /* NPE B does not present */	        ixOsalLog (IX_OSAL_LOG_LVL_WARNING,	        		   IX_OSAL_LOG_DEV_STDOUT,                       "Warning:NPEB does not present.\n",	                   0,0,0,0,0,0);            }         }       else if (IX_NPEDL_NPEID_NPEC == npeId)	{ 	    /* Check whether NPE C is present */             if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)== 	        IX_FEATURE_CTRL_COMPONENT_DISABLED)            {   	        /* NPE C does not present */	        ixOsalLog (IX_OSAL_LOG_LVL_WARNING,	        		   IX_OSAL_LOG_DEV_STDOUT,                        "Warning:NPEC does not present.\n",	                   0,0,0,0,0,0);	                    } 	}        else	  {             /* Invalid NPE ID */             ixOsalLog (IX_OSAL_LOG_LVL_WARNING,             		  	IX_OSAL_LOG_DEV_STDOUT,                        "ixDmaAccInit : invalid Npe ID.\n",                        0,0,0,0,0,0);                          return IX_FAIL;          }      }   #endif    /* Check if ixDmaInit has been initialized already*/    if( TRUE == ixDmaAccInitDone )    {        /* Log error message in debugging mode */        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,        		   IX_OSAL_LOG_DEV_STDERR,                   "\nixDmaAccInit : Dma initialization is performed more than once.",                   0,0,0,0,0,0);        return IX_FAIL;    }    /* Select the Queues based on the NPE to be used */    switch (npeId)    {        case IX_NPEDL_NPEID_NPEA:             /* Select the Queues for NPE A */             ixDmaQIdDmaDone = IX_DMA_NPE_A_DONE_QID;            /* NPE A Done Q Id    */             ixDmaQIdDmaRequest = IX_DMA_NPE_A_REQUEST_QID;      /* NPE A Request Q Id */             break;        case IX_NPEDL_NPEID_NPEB:             /* Select the Queues for NPE B */             ixDmaQIdDmaDone = IX_DMA_NPE_B_DONE_QID;            /* NPE B Done Q Id    */             ixDmaQIdDmaRequest = IX_DMA_NPE_B_REQUEST_QID;      /* NPE B Request Q Id */             break;        case IX_NPEDL_NPEID_NPEC:             /* Select the Queues for NPE C */             ixDmaQIdDmaDone = IX_DMA_NPE_C_DONE_QID;            /* NPE C Done Q Id    */             ixDmaQIdDmaRequest = IX_DMA_NPE_C_REQUEST_QID;      /* NPE C Request Q Id */             break;        default:             /* Invalid NPE ID */             ixOsalLog (IX_OSAL_LOG_LVL_ERROR,             			IX_OSAL_LOG_DEV_STDERR,                        "\nixDmaAccInit : invalid Npe ID.",                        0,0,0,0,0,0);             return IX_FAIL;     } /* end of switch (npeId) */    /* Configure the Dma Request Q */    if( IX_SUCCESS !=        ixQMgrQConfig ( "DMA Request Q",	                    ixDmaQIdDmaRequest,                        IX_QMGR_Q_SIZE16,	                    IX_QMGR_Q_ENTRY_SIZE1) )    {        /* Log error message in debugging mode */        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,        		   IX_OSAL_LOG_DEV_STDERR,                   "\nixDmaAccInit : DMA Request Q initialization failed.",                   0,0,0,0,0,0);        return (IX_FAIL);    }    /* Configure the Dma Done Q */    if( IX_SUCCESS !=        ixQMgrQConfig ( "DMA Done Q",                        ixDmaQIdDmaDone,                        IX_QMGR_Q_SIZE16,                        IX_QMGR_Q_ENTRY_SIZE1) )    {        /* Log error message in debugging mode */        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,        		   IX_OSAL_LOG_DEV_STDERR,                   "\nixDmaAccInit : DMA Done Q initialization failed.",                   0,0,0,0,0,0);        return (IX_FAIL);    }    /* Initialize Descriptor Pool */    if( IX_SUCCESS != ixDmaAccDescriptorPoolInit() )    {        /* Log error message in debugging mode */        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,        		   IX_OSAL_LOG_DEV_STDERR,                   "\nixDmaAccInit : Descriptor pool initialization failed.",                   0,0,0,0,0,0);        return (IX_FAIL);    }    if ( IX_SUCCESS !=         ixQMgrNotificationDisable(ixDmaQIdDmaDone))    {        /* Log error message in debugging mode */        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,        		   IX_OSAL_LOG_DEV_STDERR,                   "\nixDmaAccInit : DMA done Q manager notification disable failed.",                   0,0,0,0,0,0);        return (IX_FAIL);    }    /* set up the Dma done call back */    if ( IX_SUCCESS !=         ixQMgrNotificationCallbackSet(               ixDmaQIdDmaDone,               (IxQMgrCallback) ixDmaTransferDoneCallback,               IX_DMA_CALLBACK_ID_DMADONE ) )    {        /* Log error message in debugging mode */        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,        		   IX_OSAL_LOG_DEV_STDERR,                   "\nixDmaAccInit : Dma done callback registration failed.",                   0,0,0,0,0,0);        return (IX_FAIL);    }    if ( IX_SUCCESS !=         ixQMgrNotificationEnable(               ixDmaQIdDmaDone,               IX_QMGR_Q_SOURCE_ID_NOT_E) )    {        /* Log error message in debugging mode */        ixOsalLog (IX_OSAL_LOG_LVL_ERROR,        		   IX_OSAL_LOG_DEV_STDERR,                   "\nixDmaAccInit : Dma done Q manager enable failed.",                   0,0,0,0,0,0);        return (IX_FAIL);    }    /* Initialize dma statistics */    dmaStats.successCnt = 0;    dmaStats.failCnt = 0;    dmaStats.qOverflowCnt = 0;    dmaStats.qUnderflowCnt = 0;    dmaStats.qDescAddrInvalidCnt = 0;    ixDmaAccInitDone = TRUE;    return (IX_SUCCESS);}
/* Module - ixDmaAccUninit () */PUBLIC IX_STATUSixDmaAccUninit (IxNpeDlNpeId npeId){	IX_STATUS status;    /*Check wheather the NPE is present*/    #if CPU!=SIMSPARCSOLARIS        if (IX_FEATURE_CTRL_SILICON_TYPE_B0 ==            (ixFeatureCtrlProductIdRead() & IX_FEATURE_CTRL_SILICON_STEPPING_MASK))        {            if (IX_NPEDL_NPEID_NPEA == npeId)            {                /* Check whether NPE A is present */                if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEA)==                        IX_FEATURE_CTRL_COMPONENT_DISABLED)                {                    /* NPE A does not present */                    ixOsalLog (IX_OSAL_LOG_LVL_WARNING,                            IX_OSAL_LOG_DEV_STDOUT,                            "Warning:NPEA does not present.\n",                            0,0,0,0,0,0);                }            }            else if (IX_NPEDL_NPEID_NPEB == npeId)            {                /* Check whether NPE B is present */                if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEB)==                        IX_FEATURE_CTRL_COMPONENT_DISABLED)                {                    /* NPE B does not present */                    ixOsalLog (IX_OSAL_LOG_LVL_WARNING,                           IX_OSAL_LOG_DEV_STDOUT,                           "Warning:NPEB does not present.\n",                           0,0,0,0,0,0);                }            }            else if (IX_NPEDL_NPEID_NPEC == npeId)            {                /* Check whether NPE C is present */                if (ixFeatureCtrlComponentCheck(IX_FEATURECTRL_NPEC)==                        IX_FEATURE_CTRL_COMPONENT_DISABLED)                {                /* NPE C does not present */                        ixOsalLog (IX_OSAL_LOG_LVL_WARNING,                               IX_OSAL_LOG_DEV_STDOUT,                                "Warning:NPEC does not present.\n",                                0,0,0,0,0,0);                }            }            else            {                /* Invalid NPE ID */                ixOsalLog (IX_OSAL_LOG_LVL_WARNING,                        IX_OSAL_LOG_DEV_STDOUT,                        "ixDmaAccUninit : invalid Npe ID.\n",                        0,0,0,0,0,0);                return IX_FAIL;            }        }

⌨️ 快捷键说明

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