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

📄 edma3resmgr.c

📁 vicp做为dm6446上的硬件加速器
💻 C
📖 第 1 页 / 共 5 页
字号:
                EDMA3_DVT_DESC(EDMA3_DVT_eFUNC_START,
                EDMA3_DVT_dCOUNTER,
                EDMA3_DVT_dNONE,
                EDMA3_DVT_dNONE));
#endif /* EDMA3_INSTRUMENTATION_ENABLED */

    if ((hEdmaResMgr == NULL) || (resObj == NULL))
        {
        result = (EDMA3_RM_E_INVALID_PARAM);
        }
    else
        {
        rmInstance = (EDMA3_RM_Instance *)hEdmaResMgr;
        rmObj = rmInstance->pResMgrObjHandle;

        if ((rmObj == NULL) ||
            (rmObj->gblCfgParams.globalRegs == NULL))
            {
            result = (EDMA3_RM_E_INVALID_PARAM);
            }
        else
            {
            gblRegs = (volatile EDMA3_CCRL_Regs *)(rmObj->gblCfgParams.globalRegs);

            resId = resObj->resId;

            resIdClr = (unsigned int)(~(1u << (resId%32u)));
            resIdSet = (1u << (resId%32u));

            /**
              * Take the instance specific semaphore, to prevent simultaneous
              * access to the shared resources.
              */
            semResult = edma3OsSemTake(rmInstance->initParam.rmSemHandle,
                                    EDMA3_OSSEM_NO_TIMEOUT);
            if (EDMA3_RM_SOK == semResult)
                {
                switch (resObj->type)
                    {
                    case EDMA3_RM_RES_DMA_CHANNEL :
                            {
                            if (resId == EDMA3_RM_RES_ANY)
                                {
                                for (avlblIdx=0u;
                                     avlblIdx <
                                            rmObj->gblCfgParams.numDmaChannels;
                                     ++avlblIdx)
                                    {
                                    if (((rmInstance->initParam.rmInstInitConfig->ownDmaChannels[avlblIdx/32u])
                                          &
                                          (rmInstance->avlblDmaChannels[avlblIdx/32u])
                                          &
                                          ~(rmInstance->initParam.rmInstInitConfig->resvdDmaChannels[avlblIdx/32u])
                                          &
                                          (1u << (avlblIdx%32u))) != FALSE)
                                        {
                                        /*
                                         * Match found.
                                         * A resource which is owned by this instance of the
                                         * Resource Manager and which is presently available
                                         * and which has not been reserved - is found.
                                         */
                                        resObj->resId = avlblIdx;
                                        /*
                                         * Mark the 'match found' resource as "Not Available"
                                         * for future requests
                                         */
                                        rmInstance->avlblDmaChannels[avlblIdx/32u] &= (unsigned int)(~(1u << (avlblIdx%32u)));

                                        /**
                                         * Check if the register modification flag is 
                                         * set or not.
                                         */
                                        if (TRUE == rmInstance->regModificationRequired)
                                            {
                                            /**
                                             * Enable the DMA channel in the
                                             * DRAE/DRAEH registers also.
                                             */
                                            if (avlblIdx < 32u)
                                                {
                                                gblRegs->DRA[rmInstance->initParam.regionId].DRAE
                                                    |= (0x1u << avlblIdx);
                                                }
                                            else
                                                {
                                                gblRegs->DRA[rmInstance->initParam.regionId].DRAEH
                                                    |= (0x1u << (avlblIdx - 32u));
                                                }
                                            }

                                        result = EDMA3_RM_SOK;
                                        break;
                                        }
                                    }
                                /*
                                 * If none of the owned resources of this type is available
                                 * then report "All Resources of this type not available" error
                                 */
                                if (avlblIdx == rmObj->gblCfgParams.numDmaChannels)
                                    {
                                    result = EDMA3_RM_E_ALL_RES_NOT_AVAILABLE;
                                    }
                                }
                            else
                                {
                                if (resId < rmObj->gblCfgParams.numDmaChannels)
                                    {
                                    /*
                                     * Check if specified resource is owned
                                     * by this instance of the resource manager
                                     */
                                    if (((rmInstance->initParam.rmInstInitConfig->ownDmaChannels[resId/32u])&(resIdSet))!=FALSE)
                                       {
                                        /* Now check if specified resource is available presently*/
                                        if (((rmInstance->avlblDmaChannels[resId/32u])&(resIdSet))!=FALSE)
                                            {
                                            /*
                                             * Mark the specified channel as "Not Available"
                                             * for future requests
                                             */
                                            rmInstance->avlblDmaChannels[resId/32u] &= resIdClr;

                                            /**
                                             * Check if the register modification flag is 
                                             * set or not.
                                             */
                                            if (TRUE == rmInstance->regModificationRequired)
                                                {
                                                if (resId < 32u)
                                                    {
                                                    rmInstance->shadowRegs->EECR = (1UL << resId);

                                                    /**
                                                     * Enable the DMA channel in the
                                                     * DRAE registers also.
                                                     */
                                                    gblRegs->DRA[rmInstance->initParam.regionId].DRAE
                                                        |= (0x1u << resId);
                                                    }
                                                else
                                                    {
                                                    rmInstance->shadowRegs->EECRH = (1UL << resId);

                                                    /**
                                                     * Enable the DMA channel in the
                                                     * DRAEH registers also.
                                                     */
                                                    gblRegs->DRA[rmInstance->initParam.regionId].DRAEH
                                                        |= (0x1u << (resId - 32u));
                                                    }
                                                }
                                            
                                            result = EDMA3_RM_SOK;
                                            }
                                        else
                                            {
                                            /* Specified resource is owned but is already booked */
                                            result = EDMA3_RM_E_SPECIFIED_RES_NOT_AVAILABLE;
                                            }
                                        }
                                    else
                                        {
                                        /*
                                         * Specified resource is not owned by this instance
                                         * of the Resource Manager
                                         */
                                        result = EDMA3_RM_E_RES_NOT_OWNED;
                                        }
                                    }
                                else
                                    {
                                    result = EDMA3_RM_E_INVALID_PARAM;
                                    }
                                }
                        }
                        break;

                    case EDMA3_RM_RES_QDMA_CHANNEL :
                        {
                        if (resId == EDMA3_RM_RES_ANY)
                            {
                            for (avlblIdx=0u; avlblIdx<rmObj->gblCfgParams.numQdmaChannels; ++avlblIdx)
                                {
                                if (((rmInstance->initParam.rmInstInitConfig->ownQdmaChannels[avlblIdx/32u])
                                          &
                                          (rmInstance->avlblQdmaChannels[avlblIdx/32u])
                                          &
                                          ~(rmInstance->initParam.rmInstInitConfig->resvdQdmaChannels[avlblIdx/32u])
                                          &
                                          (1u << (avlblIdx%32u))) != FALSE)
                                    {
                                    resObj->resId = avlblIdx;
                                    rmInstance->avlblQdmaChannels[avlblIdx/32u] &= (unsigned int)(~(1u << (avlblIdx%32u)));

                                    /**
                                     * Check if the register modification flag is 
                                     * set or not.
                                     */
                                    if (TRUE == rmInstance->regModificationRequired)
                                        {
                                        /**
                                         * Enable the QDMA channel in the
                                         * QRAE register also.
                                         */
                                        gblRegs->QRAE[rmInstance->initParam.regionId]
                                            |= (0x1u << avlblIdx);
                                        }

                                    result = EDMA3_RM_SOK;
                                    break;
                                    }
                                }
                            /*
                             * If none of the owned resources of this type is available
                             * then report "All Resources of this type not available" error
                             */
                            if (avlblIdx == rmObj->gblCfgParams.numQdmaChannels)
                                {
                                result = EDMA3_RM_E_ALL_RES_NOT_AVAILABLE;
                                }
                            }
                        else
                            {
                            if (resId < rmObj->gblCfgParams.numQdmaChannels)
                                {
                                if (((rmInstance->initParam.rmInstInitConfig->ownQdmaChannels [resId/32u])&(resIdSet))!=FALSE)
                                    {
                                    if (((rmInstance->avlblQdmaChannels [resId/32u])&(resIdSet))!=FALSE)
                                        {
                                        rmInstance->avlblQdmaChannels [resId/32u] &= resIdClr;

                                        /**
                                         * Check if the register modification flag is 
                                         * set or not.
                                         */
                                        if (TRUE == rmInstance->regModificationRequired)
                                            {
                                            /**
                                             * Enable the QDMA channel in the
                                             * QRAE register also.
                                             */
                                            gblRegs->QRAE[rmInstance->initParam.regionId]
                                                |= (0x1u << resId);
                                            }

                                        result = EDMA3_RM_SOK;
                                        }
                                    else
                                        {
                                        /* Specified resource is owned but is already booked */
                                        result = EDMA3_RM_E_SPECIFIED_RES_NOT_AVAILABLE;
                                       }
                                    }
                                else
                                    {
                                    /*
                                     * Specified resource is not owned by this instance
                                     * of the Resource Manager
                                     */
                                    result = EDMA3_RM_E_RES_NOT_OWNED;
                                    }
                                }
                            else
                                {
                                result = EDMA3_RM_E_INVALID_PARAM;
                                }
                            }
                        }
                        break;

                    case EDMA3_RM_RES_TCC :
                        {
                        if (resId == EDMA3_RM_RES_ANY)
                            {
                            for (avlblIdx=0u; avlblIdx<rmObj->gblCfgParams.numTccs; ++avlblIdx)
                                {
                                if (((rmInstance->initParam.rmInstInitConfig->ownTccs [avlblIdx/32u])
                                    & (rmInstance->avlblTccs [avlblIdx/32u])
                                    & ~(rmInstance->initParam.rmInstI

⌨️ 快捷键说明

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