コード例 #1
0
ファイル: ldrv_mpcs.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPCS_create
 *
 *  @desc   This function creates and initializes an instance of the MPCS
 *          object.
 *          The memory for the object may or may not be provided by the user.
 *          If provided by the user, the memory for the object must be shared
 *          across the processors using the MPCS. It must also already be mapped
 *          into user space for OSes supporting user/kernel separation.
 *
 *  @modif  None.
 *  ============================================================================
 */
EXPORT_API
DSP_STATUS
LDRV_MPCS_create (IN     ProcessorId    dspId,
                  IN     MPCS_ShObj *   mpcsObj)
{
    DSP_STATUS status = DSP_SOK ;

    TRC_2ENTER ("LDRV_MPCS_create", dspId, mpcsObj) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;
    DBC_Require (mpcsObj != NULL) ;

    mpcsObj->turn                     = SELF  ;
#if defined (DDSP_PROFILE)
    mpcsObj->gppMpcsObj.conflicts     = 0 ;
    mpcsObj->gppMpcsObj.numCalls      = 0 ;
    mpcsObj->dspMpcsObj.conflicts     = 0 ;
    mpcsObj->dspMpcsObj.numCalls      = 0 ;
#endif

    status = LDRV_MPCS_OS_create (dspId, mpcsObj) ;

    mpcsObj->dspMpcsObj.localLock     = 0 ;
    mpcsObj->gppMpcsObj.flag          = (Uint16) MPCS_FREE  ;
    mpcsObj->dspMpcsObj.flag          = (Uint16) MPCS_FREE  ;
    mpcsObj->gppMpcsObj.freeObject    = (Uint16) FALSE  ;
    mpcsObj->dspMpcsObj.freeObject    = (Uint16) FALSE  ;
    mpcsObj->dspMpcsObj.mpcsEntryAddr = 0 ;
    mpcsObj->gppMpcsObj.mpcsEntryAddr = 0 ;

    TRC_1LEAVE ("LDRV_MPCS_create", status) ;

    return status ;
}
コード例 #2
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_exit
 *
 *  @desc   This function finalizes the LDRV MPLIST module for a particular DSP.
 *          Finalizing means no further services will be provided by this
 *          module for this particular DSP.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_MPLIST_exit (IN ProcessorId dspId)
{
    DSP_STATUS           status    = DSP_SOK ;
    LDRV_MPLIST_Object * mplistState ;

    TRC_1ENTER ("LDRV_MPLIST_exit", dspId) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;

    if (LDRV_MPLIST_IsInitialized [dspId] == TRUE) {
        mplistState = &(LDRV_MPLIST_State [dspId]) ;

        /*  --------------------------------------------------------------------
         *  Free shared memory allocated for the MPLIST component.
         *  --------------------------------------------------------------------
         */
        if (mplistState->ctrlPtr != NULL) {
            status = LDRV_SMM_free (dspId,
                                    mplistState->memEntry,
                                    mplistState->ctrlSize) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }

        LDRV_MPLIST_IsInitialized [dspId] = FALSE ;
    }

    TRC_1LEAVE ("LDRV_MPLIST_exit", status) ;

    return status ;
}
コード例 #3
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_isEmpty
 *
 *  @desc   check for an empty list.
 *
 *  @modif  None.
 *  ============================================================================
 */
EXPORT_API
Bool
LDRV_MPLIST_isEmpty (IN     ProcessorId dspId,
                     IN     List *      list )
{
    Bool                 retVal = FALSE ;
    LDRV_MPLIST_Object * mplistState ;
    Uint32               temp   ;

    TRC_2ENTER ("LDRV_MPLIST_isEmpty", dspId, list) ;

    DBC_Require (IS_VALID_PROCID(dspId)) ;
    DBC_Require (list != NULL) ;
    DBC_Assert  (LDRV_MPLIST_IsInitialized [dspId] == TRUE) ;

    mplistState = &(LDRV_MPLIST_State [dspId]) ;

    temp = SWAP_LONG (DSP_addrConvert (dspId,
                                       (Uint32) &((list)->head),
                                       GppToDsp),
                      mplistState->wordSwap) ;

    if ( ((Uint32) (list)->head.next) == temp) {
        retVal = TRUE ;
    }

    TRC_1LEAVE ("LDRV_MPLIST_isEmpty", retVal) ;

    return retVal ;
}
コード例 #4
0
ファイル: ldrv_mpcs.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPCS_exit
 *
 *  @desc   This function finalizes the LDRV MPCS module for a particular DSP.
 *          Finalizing means no further services will be provided by this
 *          module for this particular DSP.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_MPCS_exit (IN ProcessorId dspId)
{
    DSP_STATUS         status    = DSP_SOK ;
    DSP_STATUS         tmpStatus = DSP_SOK ;
    LDRV_MPCS_Object * mpcsState ;
    MPCS_Ctrl *        mpcsCtrl ;
    Uint32             i ;
    MPCS_Entry *       entry ;

    TRC_1ENTER ("LDRV_MPCS_exit", dspId) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;

    if (LDRV_MPCS_IsInitialized [dspId] == TRUE) {
        mpcsState = &(LDRV_MPCS_State [dspId]) ;
        mpcsCtrl  = mpcsState->ctrlPtr ;

        if (mpcsCtrl != NULL) {
            /* mpcsCtrl->entry is reset on user-side with user address, so it
             * is again set to kernel address.
             */
            entry = (MPCS_Entry *) (   (Uint32) (mpcsState->ctrlPtr)
                                              +  sizeof (MPCS_Ctrl)) ;

            status = LDRV_MPCS_delete (dspId, &(mpcsCtrl->lockObj)) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }

            /* Finalize the entries table. */
            for (i = 0 ; i < mpcsState->maxEntries ; i++) {
                entry [i].physAddress = NULL ;
                entry [i].name [0]    = '\0' ;
            }

            /*  ----------------------------------------------------------------
             *  Free shared memory allocated for the MPCS component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_SMM_free (dspId,
                                       mpcsState->memEntry,
                                       mpcsState->ctrlSize) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }

            mpcsCtrl->isInitialized = FALSE ;
        }

        LDRV_MPCS_IsInitialized [dspId] = FALSE ;
    }

    TRC_1LEAVE ("LDRV_MPCS_exit", status) ;

    return status ;
}
コード例 #5
0
ファイル: ldrv.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_init
 *
 *  @desc   Allocates resources and initializes the LDRV component for a DSP.
 *
 *  @modif  None
 *  ============================================================================
 */
EXPORT_API
DSP_STATUS
LDRV_init (IN ProcessorId procId, IN LINKCFG_DspConfig * dspCfg)
{
    DSP_STATUS  status  = DSP_SOK ;
    Char8 *     dspName = NULL    ;

    TRC_2ENTER ("LDRV_init", procId, dspCfg) ;

    DBC_Require (LDRV_LinkCfgPtr != NULL) ;
    DBC_Require (IS_VALID_PROCID (procId)) ;

    /*  ------------------------------------------------------------------------
     *  Get the pointer to kernel-side APUDRV configuration structure.
     *  ------------------------------------------------------------------------
     */
    if (dspCfg != NULL) {
        if (LDRV_LinkCfgPtr->dspConfigs [procId] != NULL) {
            /* First free the previously read config values */
            status = LDRV_freeLinkDspCfg (procId, LDRV_LinkCfgPtr) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }

        if (DSP_SUCCEEDED (status)) {
            status = LDRV_getLinkDspCfg (procId, dspCfg, LDRV_LinkCfgPtr) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
                LDRV_exit (procId) ;
            }
        }
    }
    else {
        if (LDRV_LinkCfgPtr->dspConfigs [procId] == NULL) {
            PRINT_Printf ("For multi-app support, Please pass valid DSP") ;
            PRINT_Printf ("Config values through PROC_attach.\n") ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
    }

    /*  ------------------------------------------------------------------------
     *  Plug the correct configuration mapping information for APU DRIVER.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        dspName = LDRV_LinkCfgPtr->dspConfigs [procId]->dspObject->name ;
        status = CFGMAP_attachObject (procId, dspName) ;
        if (DSP_FAILED (status)) {
            SET_FAILURE_REASON ;
            LDRV_exit (procId) ;
        }
    }

    TRC_1LEAVE ("LDRV_init", status) ;

    return status ;
}
コード例 #6
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_removeElement
 *
 *  @desc   Removes (unlinks) the given element from the list, if the list is
 *          not empty.  Does not free the list element. This function works on
 *          the list object and element fields in DSP address space.If the
 *          element is from pool memory, it does the  invalidate and writeback
 *          operations on the element. If the element is from a non pool shared
 *          memory, invalidate writeback operations  are not performed.
 *
 *  @modif  None.
 *  ============================================================================
 */
EXPORT_API
Void
LDRV_MPLIST_removeElement (IN     ProcessorId    dspId,
                           IN     List *         list,
                           IN     ListElement *  element )
{
    PoolId               poolId        = POOL_INVALIDID ;
    LDRV_MPLIST_Object * mplistState ;
    ListElement *        temp   ;

    TRC_4ENTER ("LDRV_MPLIST_removeElement", dspId, list, element, poolId) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;
    DBC_Require (list    != NULL) ;
    DBC_Require (element != NULL) ;
    DBC_Assert  (LDRV_MPLIST_IsInitialized [dspId] == TRUE) ;

    mplistState = &(LDRV_MPLIST_State [dspId]) ;

    if (LDRV_MPLIST_isEmpty (dspId, list) == FALSE) {
        temp = (ListElement *)
                  DSP_addrConvert (dspId,
                                   SWAP_LONG ((Uint32) (element->prev),
                                              mplistState->wordSwap),
                                   DspToGpp) ;

        LDRV_POOL_getPoolId (dspId,
                             temp,
                             AddrType_Knl,
                             &poolId );
        if (IS_VALID_POOLID (poolId)) {
            LDRV_POOL_invalidate (poolId, temp, sizeof (ListElement)) ;
        }
        temp->next = element->next ;
        if (IS_VALID_POOLID (poolId)) {
            LDRV_POOL_writeback (poolId, temp, sizeof (ListElement)) ;
        }

        temp = (ListElement *)
                  DSP_addrConvert (dspId,
                                   SWAP_LONG ((Uint32) (element->next),
                                              mplistState->wordSwap),
                                   DspToGpp) ;
        LDRV_POOL_getPoolId (dspId,
                             temp,
                             AddrType_Knl,
                             &poolId );
        if (IS_VALID_POOLID (poolId)) {
            LDRV_POOL_invalidate (poolId, temp, sizeof (ListElement)) ;
        }
        temp->prev = element->prev ;
        if (IS_VALID_POOLID (poolId)) {
            LDRV_POOL_writeback (poolId, temp, sizeof (ListElement)) ;
        }
    }

    TRC_0LEAVE ("LDRV_MPLIST_removeElement") ;
}
コード例 #7
0
ファイル: ldrv_mpcs.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPCS_delete
 *
 *  @desc   This function deletes the instance of the MPCS object.
 *
 *  @modif  None.
 *  ============================================================================
 */
EXPORT_API
DSP_STATUS
LDRV_MPCS_delete (IN     ProcessorId  dspId,
                  IN     MPCS_ShObj * mpcsObj)
{
    DSP_STATUS  status = DSP_SOK ;

    TRC_2ENTER ("LDRV_MPCS_delete", dspId, mpcsObj) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;
    DBC_Require (mpcsObj != NULL) ;

    DBC_Assert (mpcsObj->dspMpcsObj.flag != MPCS_BUSY) ;
    mpcsObj->dspMpcsObj.flag = (Uint16) MPCS_FREE ;
    mpcsObj->gppMpcsObj.flag = (Uint16) MPCS_FREE ;

    status = LDRV_MPCS_OS_delete (dspId, mpcsObj) ;

    TRC_1LEAVE ("LDRV_MPCS_delete", status) ;

    return status ;
}
コード例 #8
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_getMemInfo
 *
 *  @desc   This function returns the memory information for the MPLIST region.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_MPLIST_getMemInfo (IN OUT MPLIST_MemInfo * mplistMemInfo)
{
    DSP_STATUS           status = DSP_SOK ;
    LDRV_MPLIST_Object * mplistState ;

    TRC_1ENTER ("LDRV_MPLIST_getMemInfo", mplistMemInfo) ;

    DBC_Require (mplistMemInfo != NULL) ;
    DBC_Require (IS_VALID_PROCID (mplistMemInfo->procId)) ;
    DBC_Assert  (LDRV_MPLIST_IsInitialized [mplistMemInfo->procId] == TRUE) ;

    mplistState  = &(LDRV_MPLIST_State [mplistMemInfo->procId]) ;

    mplistMemInfo->kernAddr = (Uint32) mplistState->ctrlPtr ;
    mplistMemInfo->physAddr = mplistState->physCtrlAddr ;
    mplistMemInfo->size     = mplistState->ctrlSize ;

    TRC_1LEAVE ("LDRV_MPLIST_getMemInfo", status) ;

    return status ;
}
コード例 #9
0
ファイル: ldrv_ringio.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_RINGIO_getMemInfo
 *
 *  @desc   This function returns the memory information for the RINGIO region.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_RINGIO_getMemInfo (IN OUT RingIO_MemInfo * ringIoMemInfo)
{
    DSP_STATUS           status = DSP_SOK ;
    LDRV_RINGIO_Object * ringIoState ;

    TRC_1ENTER ("LDRV_RINGIO_getMemInfo", ringIoMemInfo) ;

    DBC_Require (ringIoMemInfo != NULL) ;
    DBC_Require (IS_VALID_PROCID (ringIoMemInfo->procId)) ;
    DBC_Assert  (LDRV_RINGIO_IsInitialized [ringIoMemInfo->procId] == TRUE) ;

    ringIoState  = &(LDRV_RINGIO_State [ringIoMemInfo->procId]) ;

    ringIoMemInfo->kernAddr = (Uint32) ringIoState->ctrlPtr ;
    ringIoMemInfo->physAddr = ringIoState->physCtrlAddr ;
    ringIoMemInfo->size     = ringIoState->ctrlSize ;

    TRC_1LEAVE ("LDRV_RINGIO_getMemInfo", status) ;

    return status ;
}
コード例 #10
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_clear
 *
 *  @desc   Clears a statically created list and translates its contents to
 *          work with DSP address space.
 *
 *  @modif  None.
 *  ============================================================================
 */
EXPORT_API
Void
LDRV_MPLIST_clear (IN     ProcessorId dspId,
                   IN     List *      list )
{
    LDRV_MPLIST_Object * mplistState ;

    TRC_2ENTER ("LDRV_MPLIST_clear", dspId, list) ;

    DBC_Require (IS_VALID_PROCID(dspId)) ;
    DBC_Require (list != NULL) ;
    DBC_Assert  (LDRV_MPLIST_IsInitialized [dspId] == TRUE) ;

    mplistState = &(LDRV_MPLIST_State [dspId]) ;

    list->head.next = (ListElement *)
                      SWAP_LONG (DSP_addrConvert (dspId,
                                                  (Uint32) &(list->head),
                                                  GppToDsp),
                                 mplistState->wordSwap) ;
    list->head.prev = list->head.next ;

    TRC_0LEAVE ("LDRV_MPLIST_clear") ;
}
コード例 #11
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_putTail
 *
 *  @desc   Adds the specified element to the tail of the list while working on
 *          the list object and element fields in DSP address space.If the
 *          element is from pool memory, it does the  invalidate and writeback
 *          operations on the element. If the element is from a non pool shared
 *          memory, invalidate writeback operations  are not performed.
 *
 *  @modif  None.
 *  ============================================================================
 */
EXPORT_API
Void
LDRV_MPLIST_putTail (IN     ProcessorId   dspId,
                     IN     List *        list,
                     IN     ListElement * element )
{
    PoolId               poolId         = POOL_INVALIDID ;
    LDRV_MPLIST_Object * mplistState ;
    ListElement *        temp   ;
    Uint32               intermediateState ;

    TRC_3ENTER ("LDRV_MPLIST_putTail", dspId, list, element) ;

    DBC_Require (IS_VALID_PROCID(dspId)) ;
    DBC_Require (list    != NULL) ;
    DBC_Require (element != NULL) ;
    DBC_Assert  (LDRV_MPLIST_IsInitialized [dspId] == TRUE) ;

    mplistState = &(LDRV_MPLIST_State [dspId]) ;

    element->prev   = list->head.prev ;
    element->next   = (ListElement *)
                          SWAP_LONG (DSP_addrConvert (dspId,
                                                      (Uint32) &(list->head),
                                                      GppToDsp),
                                     mplistState->wordSwap) ;
    /* Get the poolId of the element to do write back */
     LDRV_POOL_getPoolId (dspId,
                          element,
                          AddrType_Knl,
                          &poolId );

    if (IS_VALID_POOLID (poolId)) {
        LDRV_POOL_writeback (poolId, element, sizeof (ListElement)) ;
    }

    intermediateState = DSP_addrConvert (dspId,
                                         (Uint32) element,
                                         GppToDsp) ;
    if (IS_VALID_POOLID (poolId)) {
        LDRV_POOL_writeback (poolId, element, sizeof (ListElement)) ;
    }

    list->head.prev = (ListElement *) SWAP_LONG ((Uint32)intermediateState,
                                                 mplistState->wordSwap) ;
    temp = (ListElement *)
                  DSP_addrConvert (dspId,
                                   SWAP_LONG ((Uint32) (element->prev),
                                              mplistState->wordSwap),
                                   DspToGpp) ;
    /* Get the  poolId of temp, to be able to invalidate and write back
     * properly
     */
    LDRV_POOL_getPoolId (dspId,
                         temp,
                         AddrType_Knl,
                         &poolId );
    if (IS_VALID_POOLID (poolId)) {
        LDRV_POOL_invalidate (poolId, temp, sizeof (ListElement)) ;
    }
    temp->next = list->head.prev ;
    if (IS_VALID_POOLID (poolId)) {
        LDRV_POOL_writeback (poolId, temp, sizeof (ListElement)) ;
    }

    TRC_0LEAVE ("LDRV_MPLIST_putTail") ;
}
コード例 #12
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_getHead
 *
 *  @desc   Gets the head pointer from the list while working on the list object
 *          and element fields in DSP address space.If the head element is from
 *          pool memory, it does the  invalidate and writeback operations on the
 *          element. If the element is from a non pool shared memory, invalidate
 *          writeback operations  are not performed.
 *
 *  @modif  None.
 *  ============================================================================
 */
EXPORT_API
Void
LDRV_MPLIST_getHead (IN     ProcessorId    dspId,
                     IN     List *         list,
                     OUT    ListElement ** headElement )
{
    PoolId               poolId         = POOL_INVALIDID;
    LDRV_MPLIST_Object * mplistState ;
    ListElement *        temp   ;

    TRC_3ENTER ("LDRV_MPLIST_getHead", dspId, list, headElement) ;

    DBC_Require (IS_VALID_PROCID(dspId)) ;
    DBC_Require (list        != NULL) ;
    DBC_Require (headElement != NULL) ;
    DBC_Assert  (LDRV_MPLIST_IsInitialized [dspId] == TRUE) ;

    mplistState = &(LDRV_MPLIST_State [dspId]) ;

    if (LDRV_MPLIST_isEmpty (dspId, list) == TRUE) {
        *headElement = NULL ;
    }
    else {
        *headElement = (ListElement *)
                       DSP_addrConvert (dspId,
                                        SWAP_LONG (((Uint32) (list->head.next)),
                                                   mplistState->wordSwap),
                                        DspToGpp) ;
        /* Get the pool Id of the Head element */
        LDRV_POOL_getPoolId (dspId,
                             *headElement,
                             AddrType_Knl,
                             &poolId);

        if (IS_VALID_POOLID (poolId)) {
            LDRV_POOL_invalidate (poolId, *headElement, sizeof (ListElement)) ;
        }
        list->head.next = (ListElement *) (*headElement)->next ;
        temp = (ListElement *)
                 DSP_addrConvert (dspId,
                                  SWAP_LONG ((Uint32) ((*headElement)->next),
                                             mplistState->wordSwap),
                                  DspToGpp) ;

        LDRV_POOL_getPoolId (dspId,
                             temp,
                             AddrType_Knl,
                             &poolId );
        /* Invalidate only when (*headElement)->next is from  POOL memory*/
        if (IS_VALID_POOLID (poolId)) {
            LDRV_POOL_invalidate (poolId, temp, sizeof (ListElement)) ;
        }
        temp->prev = (ListElement *)
                     SWAP_LONG (DSP_addrConvert (dspId,
                                                 (Uint32) (&(list->head)),
                                                 GppToDsp),
                                                 mplistState->wordSwap) ;
        if (IS_VALID_POOLID (poolId)) {
            LDRV_POOL_writeback (poolId, temp, sizeof (ListElement)) ;
        }
    }

    TRC_0LEAVE ("LDRV_MPLIST_getHead") ;
}
コード例 #13
0
/*!
 *  @brief      Function to open a handle to an instance of this PwrMgr. This
 *              function is called when access to the PwrMgr is required from
 *              a different process.
 *
 *  @param      handlePtr   Handle to the PwrMgr instance
 *  @param      procId      Processor ID addressed by this PwrMgr instance.
 *
 *  @sa         DM8168DUCATIPWR_close
 */
Int
DM8168DUCATIPWR_open (DM8168DUCATIPWR_Handle * handlePtr, UInt16 procId)
{
    Int status = PWRMGR_SUCCESS;

    GT_2trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_open", handlePtr, procId);

    GT_assert (curTrace, (handlePtr != NULL));
    GT_assert (curTrace, IS_VALID_PROCID (procId));

    GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0));

#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    if (DM8168DUCATIPWR_state.refCount == 0) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_open",
                             DM8168DUCATIPWR_E_INVALIDSTATE,
                             "Module was not initialized!");
    }
    else if (handlePtr == NULL) {
        /*! @retval PWRMGR_E_HANDLE Invalid NULL handlePtr specified */
        status = PWRMGR_E_HANDLE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_open",
                             status,
                             "Invalid NULL handlePtr specified");
    }
    else if (!IS_VALID_PROCID (procId)) {
        /*! @retval PWRMGR_E_INVALIDARG Invalid procId specified */
        status = PWRMGR_E_INVALIDARG;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_open",
                             status,
                             "Invalid procId specified");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
        /* Initialize return parameter handle. */
        *handlePtr = NULL;

        /* Check if the PwrMgr exists and return the handle if found. */
        if (DM8168DUCATIPWR_state.pwrHandles [procId] == NULL) {
            /*! @retval PWRMGR_E_NOTFOUND Specified instance not found */
            status = PWRMGR_E_NOTFOUND;
            GT_setFailureReason (curTrace,
                              GT_4CLASS,
                              "DM8168DUCATIPWR_open",
                              status,
                              "Specified DM8168DUCATIPWR instance does not exist!");
        }
        else {
            *handlePtr = DM8168DUCATIPWR_state.pwrHandles [procId];
        }
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */

    GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_open", status);

    /*! @retval PWRMGR_SUCCESS Operation successful */
    return status;
}
コード例 #14
0
ファイル: ldrv_mplist.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPLIST_init
 *
 *  @desc   This function allocates and initializes resources used by this
 *          component.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_MPLIST_init (IN ProcessorId dspId, OUT Uint32 * shDspAddr)
{
    DSP_STATUS           status = DSP_SOK ;
    LINKCFG_MpList *     mplistObject ;
    LINKCFG_Dsp *        dspObj ;
    LINKCFG_DspConfig *  dspCfg ;
    LINKCFG_LinkDrv *    linkDrv ;
    LDRV_MPLIST_Object * mplistState ;

    TRC_2ENTER ("LDRV_MPLIST_init", dspId, shDspAddr) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;
    DBC_Require (shDspAddr != NULL) ;

    mplistState  = &(LDRV_MPLIST_State [dspId]) ;

    dspCfg    = LDRV_LinkCfgPtr->dspConfigs [dspId] ;
    dspObj    = dspCfg->dspObject ;
    linkDrv   = &(dspCfg->linkDrvObjects [dspObj->linkDrvId]) ;
    mplistObject = &(dspCfg->mplistObjects [linkDrv->mplistTableId]) ;

    *shDspAddr = (Uint32) NULL ;
    if (LDRV_MPLIST_IsInitialized [dspId] == FALSE) {
        /*  --------------------------------------------------------------------
         * Validate the setup configuration parameters for the link driver.
         *  --------------------------------------------------------------------
         */
        mplistState = &(LDRV_MPLIST_State [dspId]) ;

        /* Initialize the state object. */
        mplistState->ctrlPtr      = NULL ;
        mplistState->dspCtrlAddr  = (Uint32) NULL ;
        mplistState->physCtrlAddr = (Uint32) NULL ;
        mplistState->ctrlSize     = 0 ;
        mplistState->memEntry     = mplistObject->memEntry ;
        mplistState->wordSwap     = dspObj->wordSwap ;

        /* Check if the memEntry is in valid range. */
        if (    (mplistObject->memEntry != (Uint32) -1)
            &&  (mplistObject->memEntry >= dspObj->memEntries)) {
            PRINT_Printf ("<1>Configuration error:"
                          " Incorrect MPLIST memEntry specified [0x%x]\n",
                          mplistObject->memEntry) ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
        else if (    (mplistObject->ipsId != (Uint32) -1)
                 &&  (mplistObject->ipsId >= linkDrv->numIpsEntries)) {
            /* Check if the ipsId is in valid range. */
            PRINT_Printf ("<1>Configuration error:"
                          " Incorrect MPLIST ipsId specified [0x%x]\n",
                          mplistObject->ipsId) ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
        else if (    (mplistObject->ipsId      != (Uint32) -1)
                 &&  (mplistObject->ipsEventNo != (Uint32) -1)
                 &&  (   mplistObject->ipsEventNo
                      >= dspCfg->ipsTables [linkDrv->ipsTableId]
                                          [mplistObject->ipsId].numIpsEvents)) {
            /* Check if the ipsEventNo is in valid range. */
            PRINT_Printf ("<1>Configuration error:"
                          " Incorrect MPLIST ipsEventNo specified [0x%x]\n",
                          mplistObject->ipsEventNo) ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
        else {
            /* Added for MISRAC compliance */
        }
    }

    if (   (LDRV_MPLIST_IsInitialized [dspId] == FALSE)
        && (DSP_SUCCEEDED (status))) {
        /*  --------------------------------------------------------------------
         *  Allocate shared memory required for the MPLIST component.
         *  --------------------------------------------------------------------
         */
        mplistState->ctrlSize = sizeof (MPLIST_Ctrl)
                         +  (sizeof (MPLIST_Entry) * mplistObject->maxEntries) ;

        status = LDRV_SMM_alloc (dspId,
                                 mplistState->memEntry,
                                 &(mplistState->physCtrlAddr),
                                 &(mplistState->dspCtrlAddr),
                                 (Uint32 *) ((Pvoid) &(mplistState->ctrlPtr)),
                                 mplistState->ctrlSize) ;
        if (DSP_SUCCEEDED (status)) {
            *shDspAddr = mplistState->dspCtrlAddr ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPLIST Ctrl GPP address      [0x%x]\n",
                        mplistState->ctrlPtr) ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPLIST Ctrl DSP address      [0x%x]\n",
                        mplistState->dspCtrlAddr) ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPLIST Ctrl physical address [0x%x]\n",
                        mplistState->physCtrlAddr) ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPLIST Ctrl size             [0x%x]\n",
                        mplistState->ctrlSize) ;

            /* mplistState->ctrlPtr->entry is set on user-side with user
             * address.
             */
            mplistState->ctrlPtr->dspAddrEntry = (MPLIST_Entry *)
                                         (   (Uint32) (mplistState->dspCtrlAddr)
                                          +  sizeof (MPLIST_Ctrl)) ;
        }
        else {
            SET_FAILURE_REASON ;
        }

        LDRV_MPLIST_IsInitialized [dspId] = TRUE ;
        if (DSP_FAILED (status)) {
            /* LDRV_MPLIST_exit executes cleanup only if the initialized flag is
             * TRUE.
             */
            LDRV_MPLIST_exit (dspId) ;
            LDRV_MPLIST_IsInitialized [dspId] = FALSE ;
        }
    }

    TRC_1LEAVE ("LDRV_MPLIST_init", status) ;

    return status ;
}
コード例 #15
0
ファイル: ldrv_os.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_freeLinkCfg
 *
 *  @desc   Frees any memory allocated for the kernel-side APUDRV configuration
 *          structure.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_freeLinkDspCfg (IN  ProcessorId       procId,
                     IN  LINKCFG_Object *  knlLinkCfg)
{
    DSP_STATUS          status    = DSP_SOK ;
    DSP_STATUS          tmpStatus = DSP_SOK ;
    LINKCFG_DspConfig * dspCfg    = NULL    ;
    LINKCFG_Dsp *       dspObject     = NULL ;
#if !(defined (ONLY_PROC_COMPONENT))
    LINKCFG_LinkDrv *   linkDrvObject = NULL ;
#endif /* if !(defined (ONLY_PROC_COMPONENT)) */
    Uint32              tableId ;

    TRC_2ENTER ("LDRV_freeLinkDspCfg", procId, knlLinkCfg) ;

    DBC_Require (IS_VALID_PROCID (procId)) ;
    DBC_Require (knlLinkCfg != NULL) ;

    if (knlLinkCfg != NULL) {
        dspCfg        = knlLinkCfg->dspConfigs [procId] ;
        if (dspCfg != NULL && ((Pvoid) dspCfg >= KMEM_STARTADDRESS)) {
            dspObject     = dspCfg->dspObject ;
            if (dspObject != NULL && ((Pvoid) dspObject >= KMEM_STARTADDRESS)) {
#if !(defined (ONLY_PROC_COMPONENT))
                linkDrvObject = &dspCfg->linkDrvObjects [dspObject->linkDrvId] ;
                if (   (linkDrvObject != NULL)
                    && ((Pvoid) linkDrvObject >= KMEM_STARTADDRESS)) {
                }
                else {
                    status = DSP_EFAIL ;
                    SET_FAILURE_REASON ;
                }
#endif /* if !(defined (ONLY_PROC_COMPONENT)) */
            }
            else {
                status = DSP_EFAIL ;
                SET_FAILURE_REASON ;
            }
        }
        else {
            status = DSP_EFAIL ;
            SET_FAILURE_REASON ;
        }
    }
    else {
        status = DSP_EFAIL ;
        SET_FAILURE_REASON ;
    }

    if (DSP_SUCCEEDED (status)) {
#if defined (LOG_COMPONENT)
        /*  --------------------------------------------------------------------
         *  Free memory allocated for the LOG object.
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->logObject != NULL)
            && (dspCfg->logObject >= KMEM_STARTADDRESS)) {
            tmpStatus = FREE_PTR (dspCfg->logObject) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (LOG_COMPONENT) */

#if !(defined (ONLY_PROC_COMPONENT))
#if defined (MPCS_COMPONENT)
        /*  --------------------------------------------------------------------
         *  Free memory allocated for the MPCS objects
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->mpcsObjects != NULL)
            && ((Pvoid) dspCfg->mpcsObjects >= KMEM_STARTADDRESS)) {
            tmpStatus = FREE_PTR (dspCfg->mpcsObjects) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (MPCS_COMPONENT) */

#if defined (MPLIST_COMPONENT)
        /*  --------------------------------------------------------------------
         *  Free memory allocated for the MPLIST objects
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->mplistObjects != NULL)
            && ((Pvoid) dspCfg->mplistObjects >= KMEM_STARTADDRESS)) {
            tmpStatus = FREE_PTR (dspCfg->mplistObjects) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (MPLIST_COMPONENT) */

#if defined (RINGIO_COMPONENT)
        /*  --------------------------------------------------------------------
         *  Free memory allocated for the RingIO objects
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->ringIoObjects != NULL)
            && ((Pvoid) dspCfg->ringIoObjects >= KMEM_STARTADDRESS)) {
            tmpStatus = FREE_PTR (dspCfg->ringIoObjects) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (RINGIO_COMPONENT) */

#if defined (MSGQ_COMPONENT)
        /*  --------------------------------------------------------------------
         *  Free memory allocated for the MQT objects
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->mqtObjects != NULL)
            && ((Pvoid) dspCfg->mqtObjects >= KMEM_STARTADDRESS)) {
            tmpStatus = FREE_PTR (dspCfg->mqtObjects) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (MSGQ_COMPONENT) */

#if defined (CHNL_COMPONENT)
        /*  --------------------------------------------------------------------
         *  Free memory allocated for the Data driver tables
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->dataTables != NULL)
            && ((Pvoid) dspCfg->dataTables >= KMEM_STARTADDRESS)) {
            tableId   = linkDrvObject->dataTableId ;
            tmpStatus = FREE_PTR (dspCfg->dataTables [tableId]) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }

            tmpStatus = FREE_PTR (dspCfg->dataTables) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (CHNL_COMPONENT) */

#if defined (POOL_COMPONENT)
        /*  --------------------------------------------------------------------
         *  Free memory allocated for the Pool tables
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->poolTables != NULL)
            && ((Pvoid) dspCfg->poolTables >= KMEM_STARTADDRESS)) {
            tableId   = linkDrvObject->poolTableId ;
            tmpStatus = FREE_PTR (dspCfg->poolTables [tableId]) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }

            tmpStatus = FREE_PTR (dspCfg->poolTables) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (POOL_COMPONENT) */

        /*  --------------------------------------------------------------------
         *  Free memory allocated for the IPS tables
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->ipsTables != NULL)
            && ((Pvoid) dspCfg->ipsTables >= KMEM_STARTADDRESS)) {
            tableId   = linkDrvObject->ipsTableId ;
            tmpStatus = FREE_PTR (dspCfg->ipsTables [tableId]) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }

            tmpStatus = FREE_PTR (dspCfg->ipsTables) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if !(defined (ONLY_PROC_COMPONENT)) */

        /*  --------------------------------------------------------------------
         *  Free memory allocated for the Memory tables
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->memTables != NULL)
            && ((Pvoid) dspCfg->memTables >= KMEM_STARTADDRESS)) {
            tableId   = dspCfg->dspObject->memTableId ;
            tmpStatus = FREE_PTR (dspCfg->memTables [tableId]) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }

            tmpStatus = FREE_PTR (dspCfg->memTables) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }

        /*  --------------------------------------------------------------------
         *  Free memory allocated for the Link Driver objects
         *  --------------------------------------------------------------------
         */
#if !(defined (ONLY_PROC_COMPONENT))
        if (   (dspCfg->linkDrvObjects != NULL)
            && ((Pvoid) dspCfg->linkDrvObjects >= KMEM_STARTADDRESS)) {
            tmpStatus = FREE_PTR (dspCfg->linkDrvObjects) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }
#endif /* if !(defined (ONLY_PROC_COMPONENT)) */

        /*  --------------------------------------------------------------------
         *  Free memory allocated for the DSP objects
         *  --------------------------------------------------------------------
         */
        if (   (dspCfg->dspObject != NULL)
            && ((Pvoid) dspCfg->dspObject >= KMEM_STARTADDRESS)) {
            tmpStatus = FREE_PTR (dspCfg->dspObject) ;
            if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }

        /*  --------------------------------------------------------------------
         *  Free memory allocated for the global DSP Config object.
         *  --------------------------------------------------------------------
         */
        tmpStatus = FREE_PTR (dspCfg) ;
        if (DSP_FAILED (tmpStatus) && DSP_SUCCEEDED (status)) {
            status = tmpStatus ;
            SET_FAILURE_REASON ;
        }

        /* Delete the dspConfig anyway */
        knlLinkCfg->dspConfigs [procId] = NULL ;
    }

    TRC_1LEAVE ("LDRV_freeLinkDspCfg", status) ;

    return status ;
}
コード例 #16
0
/*!
 *  @brief      Function to delete an instance of this PwrMgr.
 *
 *              The user provided pointer to the handle is reset after
 *              successful completion of this function.
 *
 *  @param      handlePtr  Pointer to Handle to the PwrMgr instance
 *
 *  @sa         DM8168DUCATIPWR_create
 */
Int
DM8168DUCATIPWR_delete (DM8168DUCATIPWR_Handle * handlePtr)
{
    Int                  status = PWRMGR_SUCCESS;
    DM8168DUCATIPWR_Object * object = NULL;
    PwrMgr_Object *      handle;
    IArg                 key;

    GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_delete", handlePtr);

    GT_assert (curTrace, (handlePtr != NULL));
    GT_assert (curTrace, ((handlePtr != NULL) && (*handlePtr != NULL)));

    GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0));

#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    if (DM8168DUCATIPWR_state.refCount == 0) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_delete",
                             DM8168DUCATIPWR_E_INVALIDSTATE,
                             "Module was not initialized!");
    }
    else if (handlePtr == NULL) {
        /*! @retval PWRMGR_E_INVALIDARG Invalid NULL handlePtr specified*/
        status = PWRMGR_E_INVALIDARG;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_delete",
                             status,
                             "Invalid NULL handlePtr specified");
    }
    else if (*handlePtr == NULL) {
        /*! @retval PWRMGR_E_HANDLE Invalid NULL *handlePtr specified */
        status = PWRMGR_E_HANDLE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_delete",
                             status,
                             "Invalid NULL *handlePtr specified");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
        handle = (PwrMgr_Object *) (*handlePtr);
        /* Enter critical section protection. */
        key = IGateProvider_enter (DM8168DUCATIPWR_state.gateHandle);

        /* Reset handle in PwrMgr handle array. */
        GT_assert (curTrace, IS_VALID_PROCID (handle->procId));
        DM8168DUCATIPWR_state.pwrHandles [handle->procId] = NULL;

        object = (DM8168DUCATIPWR_Object *) handle->object;
        /* Free memory used for the DM8168DUCATIPWR object. */
        if (handle->object != NULL) {
            /* Free memory used for the clock handle */
#if defined (SYSLINK_BUILDOS_LINUX)
            LinuxClock_delete(((DM8168DUCATIPWR_Object *)handle->object)->clockHandle);
#endif /* #if defined (SYSLINK_BUILDOS_LINUX) */
#if defined (SYSLINK_BUILD_RTOS)
            DM8168CLOCK_delete(((DM8168DUCATIPWR_Object *)handle->object)->clockHandle);
#endif /* #if defined (SYSLINK_BUILD_RTOS) */
            Memory_free (NULL,
                         object,
                         sizeof (DM8168DUCATIPWR_Object));
            handle->object = NULL;
        }

        /* Free memory used for the PwrMgr object. */
        Memory_free (NULL, handle, sizeof (PwrMgr_Object));
        *handlePtr = NULL;

        /* Leave critical section protection. */
        IGateProvider_leave (DM8168DUCATIPWR_state.gateHandle, key);
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */

    GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_delete", status);

    /*! @retval PWRMGR_SUCCESS Operation successful */
    return (status);
}
コード例 #17
0
ファイル: ldrv_drv.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_DRV_init
 *
 *  @desc   This function allocates and initializes resources used by this
 *          component.
 *
 *  @modif  None.
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_DRV_init (IN ProcessorId dspId)
{
    DSP_STATUS              status  = DSP_SOK ;
    LDRV_DRV_Ctrl *         drvCtrl = NULL ;
    LINKCFG_DspConfig *     dspCfg ;
    LINKCFG_Dsp *           dspObj ;
    LINKCFG_LinkDrv *       linkDrv ;
    LDRV_DRV_Object *       drvState ;
    Int32                   strCmpResult ;
    Uint32                  mapId ;

    TRC_1ENTER ("LDRV_DRV_init", dspId) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;

    drvState = &(LDRV_DRV_State [dspId]) ;
    dspCfg   = LDRV_LinkCfgPtr->dspConfigs [dspId] ;
    dspObj   = dspCfg->dspObject ;
    linkDrv  = &(dspCfg->linkDrvObjects [dspObj->linkDrvId]) ;

    if (LDRV_DRV_IsInitialized [dspId] == FALSE) {
        /*  --------------------------------------------------------------------
         * Validate the setup configuration parameters for the link driver.
         *  --------------------------------------------------------------------
         */
        drvState = &(LDRV_DRV_State [dspId]) ;

        /* Initialize the state object. */
        drvState->linkDrvId   = dspObj->linkDrvId ;
        drvState->ctrlPtr     = NULL ;
        drvState->dspCtrlAddr = (Uint32) NULL ;
        drvState->interface   = NULL ;

        /* Check if the configured link driver is available and set the
         * interface table if the configuration is valid.
         */
        for (mapId = 0 ; mapId < CFGMAP_Config [dspId]->numLinkDrvs ; mapId++) {
            status = GEN_Strcmp (
                     dspCfg->linkDrvObjects [drvState->linkDrvId].name,
                     CFGMAP_Config [dspId]->linkDrvObjects [mapId].name,
                     &strCmpResult) ;
            DBC_Assert (DSP_SUCCEEDED (status)) ;
            if (strCmpResult == 0) {
                drvState->interface =
                       CFGMAP_Config [dspId]->linkDrvObjects [mapId].interface ;
                break ;
            }
        }

        if (mapId == CFGMAP_Config [dspId]->numLinkDrvs) {
            /* Configured link driver is not available. */
            PRINT_Printf ("<1>Configuration error:"
                   " Incorrect link driver name specified [%s]\n",
                   dspCfg->linkDrvObjects [drvState->linkDrvId].name) ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
        else {
            /* Check if the memEntry is in valid range. */
            if (    (linkDrv->memEntry != (Uint32) -1)
                &&  (linkDrv->memEntry >= dspObj->memEntries)) {
                PRINT_Printf ("<1>Configuration error:"
                           " Incorrect link driver memEntry specified [0x%x]\n",
                           linkDrv->memEntry) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
            else if (linkDrv->ipsTableId >= dspCfg->numIpsTables) {
                /* Check if the ipsTableId is in valid range. */
                PRINT_Printf ("<1>Configuration error:"
                         " Incorrect link driver ipsTableId specified [0x%x]\n",
                         linkDrv->ipsTableId) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
#if defined (POOL_COMPONENT)
            else if (linkDrv->poolTableId >= dspCfg->numPoolTables) {
                /* Check if the poolTableId is in valid range. */
                PRINT_Printf ("<1>Configuration error:"
                        " Incorrect link driver poolTableId specified [0x%x]\n",
                        linkDrv->poolTableId) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (POOL_COMPONENT) */
#if defined (CHNL_COMPONENT)
            else if (linkDrv->dataTableId >= dspCfg->numDataTables) {
                /* Check if the dataTableId is in valid range. */
                PRINT_Printf ("<1>Configuration error:"
                        " Incorrect link driver dataTableId specified [0x%x]\n",
                        linkDrv->dataTableId) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (CHNL_COMPONENT) */
#if defined (MSGQ_COMPONENT)
            else if (linkDrv->mqtId >= dspCfg->numMqts) {
                /* Check if the mqtId is in valid range. */
                PRINT_Printf ("<1>Configuration error:"
                              " Incorrect link driver mqtId specified [0x%x]\n",
                              linkDrv->mqtId) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (MSGQ_COMPONENT) */
#if defined (RINGIO_COMPONENT)
            else if (linkDrv->ringIoTableId >= dspCfg->numRingIo) {
                /* Check if the ringIoTableId is in valid range. */
                PRINT_Printf ("<1>Configuration error:"
                      " Incorrect link driver ringIoTableId specified [0x%x]\n",
                      linkDrv->ringIoTableId) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (RINGIO_COMPONENT) */
#if defined (MPLIST_COMPONENT)
            else if (linkDrv->mplistTableId >= dspCfg->numMpList) {
                /* Check if the mplistTableId is in valid range. */
                PRINT_Printf ("<1>Configuration error:"
                      " Incorrect link driver mplistTableId specified [0x%x]\n",
                      linkDrv->mplistTableId) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (MPLIST_COMPONENT) */
#if defined (MPCS_COMPONENT)
            else if (linkDrv->mpcsTableId >= dspCfg->numMpcs) {
                /* Check if the mpcsTableId is in valid range. */
                PRINT_Printf ("<1>Configuration error:"
                        " Incorrect link driver mpcsTableId specified [0x%x]\n",
                        linkDrv->mpcsTableId) ;
                status = DSP_ECONFIG ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (MPCS_COMPONENT) */
        }

        /*  --------------------------------------------------------------------
         *  Initialize the Shared Memory Manager component.
         *  --------------------------------------------------------------------
         */
        if (DSP_SUCCEEDED (status)) {
            status = LDRV_SMM_init (dspId) ;
        }
        else {
            SET_FAILURE_REASON ;
        }

        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Allocate shared memory required for the LDRV_DRV component.
             *  ----------------------------------------------------------------
             */
            status = LDRV_SMM_alloc (dspId,
                                     linkDrv->memEntry,
                                     NULL, /* Physical address not required. */
                                     &(drvState->dspCtrlAddr),
                                     (Uint32 *) ((Pvoid) &(drvState->ctrlPtr)),
                                     sizeof (LDRV_DRV_Ctrl)) ;
            if (DSP_SUCCEEDED (status)) {
                TRC_1PRINT (TRC_LEVEL4,
                            "LDRV_DRV Ctrl GPP address [0x%x]\n",
                            drvState->ctrlPtr) ;
                TRC_1PRINT (TRC_LEVEL4,
                            "LDRV_DRV Ctrl DSP address [0x%x]\n",
                            drvState->dspCtrlAddr) ;
                TRC_1PRINT (TRC_LEVEL4,
                            "LDRV_DRV Ctrl size        [0x%x]\n",
                            sizeof (LDRV_DRV_Ctrl)) ;

                drvCtrl = drvState->ctrlPtr ;
                DBC_Assert (drvCtrl != NULL) ;
            }
            else {
                SET_FAILURE_REASON ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }

        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize all fields of the shared memory control structure.
             *  ----------------------------------------------------------------
             */
            status = GEN_Strcpyn (drvCtrl->version,
                                  APUDRV_VERSION,
                                  DSP_MAX_STRLEN) ;
            if (DSP_SUCCEEDED (status)) {
                drvCtrl->linkAddr          = 0 ;
                drvCtrl->drvDspInitDone    = (Uint32) -1 ;
                drvCtrl->ipsAddr           = 0 ;
                drvCtrl->ipsDspInitDone    = (Uint32) -1 ;
                drvCtrl->poolAddr          = 0 ;
                drvCtrl->poolConfigured    = 0 ;
                drvCtrl->poolDspInitDone   = (Uint32) -1 ;
                drvCtrl->mpcsAddr          = 0 ;
                drvCtrl->mpcsConfigured    = 0 ;
                drvCtrl->mpcsDspInitDone   = (Uint32) -1 ;
                drvCtrl->mplistAddr        = 0 ;
                drvCtrl->mplistConfigured  = 0 ;
                drvCtrl->mplistDspInitDone = (Uint32) -1 ;
                drvCtrl->mqtAddr           = 0 ;
                drvCtrl->mqtConfigured     = 0 ;
                drvCtrl->mqtDspInitDone    = (Uint32) -1 ;
                drvCtrl->dataAddr          = 0 ;
                drvCtrl->dataConfigured    = 0 ;
                drvCtrl->dataDspInitDone   = (Uint32) -1 ;
                drvCtrl->ringIoAddr        = 0 ;
                drvCtrl->ringIoConfigured  = 0 ;
                drvCtrl->ringIoDspInitDone = (Uint32) -1 ;

                drvCtrl->config.numIpsEntries  = linkDrv->numIpsEntries ;
                drvCtrl->config.numPools       = linkDrv->numPools ;
                drvCtrl->config.numDataDrivers = linkDrv->numDataDrivers ;
                drvCtrl->config.cpuFreq        = dspObj->cpuFreq ;

            }
            else {
                SET_FAILURE_REASON ;
            }
        }

        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the link towards the DSP and get the address of its
             *  shared memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = (drvState->interface->init) (dspId,
                                                  drvState->linkDrvId,
                                                  &(drvCtrl->linkAddr)) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }

        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the IPS component and get the address of its
             *  shared memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = LDRV_IPS_init (dspId, &(drvCtrl->ipsAddr)) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }

#if defined (POOL_COMPONENT)
        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the POOL component and get the address of its shared
             *  memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = LDRV_POOL_init (dspId, &(drvCtrl->poolAddr)) ;
            if (DSP_SUCCEEDED (status)) {
                drvCtrl->poolConfigured = (Uint32) TRUE ;
            }
            else {
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (POOL_COMPONENT) */

#if defined (MPCS_COMPONENT)
        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the MPCS component and get the address of its shared
             *  memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = LDRV_MPCS_init (dspId, &(drvCtrl->mpcsAddr)) ;
            if (DSP_SUCCEEDED (status)) {
                drvCtrl->mpcsConfigured = (Uint32) TRUE ;
            }
            else {
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (MPCS_COMPONENT) */

#if defined (MPLIST_COMPONENT)
        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the MPLIST component and get the address of its
             *  shared memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = LDRV_MPLIST_init (dspId, &(drvCtrl->mplistAddr)) ;
            if (DSP_SUCCEEDED (status)) {
                drvCtrl->mplistConfigured = (Uint32) TRUE ;
            }
            else {
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (MPLIST_COMPONENT) */

#if defined (MSGQ_COMPONENT)
        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the MQT component and get the address of its shared
             *  memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = LDRV_MQT_init (dspId, &(drvCtrl->mqtAddr)) ;
            if (DSP_SUCCEEDED (status)) {
                drvCtrl->mqtConfigured = (Uint32) TRUE ;
            }
            else {
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (MSGQ_COMPONENT) */

#if defined (CHNL_COMPONENT)
        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the DATA component and get the address of its shared
             *  memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = LDRV_DATA_init (dspId, &(drvCtrl->dataAddr)) ;
            if (DSP_SUCCEEDED (status)) {
                drvCtrl->dataConfigured = (Uint32) TRUE ;
            }
            else {
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (CHNL_COMPONENT) */

#if defined (RINGIO_COMPONENT)
        if (DSP_SUCCEEDED (status)) {
            /*  ----------------------------------------------------------------
             *  Initialize the RINGIO component and get the address of its
             *  shared memory control region in DSP address space.
             *  ----------------------------------------------------------------
             */
            status = LDRV_RINGIO_init (dspId, &(drvCtrl->ringIoAddr)) ;
            if (DSP_SUCCEEDED (status)) {
                drvCtrl->ringIoConfigured = (Uint32) TRUE ;
            }
            else {
                SET_FAILURE_REASON ;
            }
        }
#endif /* if defined (RINGIO_COMPONENT) */

        LDRV_DRV_IsInitialized [dspId] = TRUE ;
        if (DSP_FAILED (status)) {
            /* LDRV_DRV_exit executes cleanup only if the initialized flag is
             * TRUE.
             */
            LDRV_DRV_exit (dspId) ;
            LDRV_DRV_IsInitialized [dspId] = FALSE ;
        }
    }

    TRC_1LEAVE ("LDRV_DRV_init", status) ;

    return status ;
}
コード例 #18
0
ファイル: ldrv_drv.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_DRV_exit
 *
 *  @desc   This function finalizes the LDRV DRV module for a particular DSP.
 *          Finalizing means no further services will be provided by this
 *          module for this particular DSP.
 *
 *  @modif  None.
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_DRV_exit (IN ProcessorId dspId)
{
    DSP_STATUS        status    = DSP_SOK ;
    DSP_STATUS        tmpStatus = DSP_SOK ;
    LDRV_DRV_Object * drvState ;
    LINKCFG_Dsp *     dspObj ;
    LINKCFG_LinkDrv * linkDrv ;
    LINKCFG_DspConfig * dspCfg ;

    TRC_1ENTER ("LDRV_DRV_exit", dspId) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;

    if (LDRV_DRV_IsInitialized [dspId] == TRUE) {
        if (LDRV_LinkCfgPtr != NULL) {
            dspCfg   = LDRV_LinkCfgPtr->dspConfigs [dspId] ;
            drvState = &(LDRV_DRV_State [dspId]) ;
            dspObj   = dspCfg->dspObject ;
            linkDrv  = &(dspCfg->linkDrvObjects [dspObj->linkDrvId]) ;

#if defined (RINGIO_COMPONENT)
            /*  ----------------------------------------------------------------
             *  Finalize the RINGIO component.
             *  ----------------------------------------------------------------
             */
            status = LDRV_RINGIO_exit (dspId) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
#endif /* if defined (RINGIO_COMPONENT) */

#if defined (CHNL_COMPONENT)
            /*  ----------------------------------------------------------------
             *  Finalize the DATA component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_DATA_exit (dspId) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (CHNL_COMPONENT) */

#if defined (MSGQ_COMPONENT)
            /*  ----------------------------------------------------------------
             *  Finalize the MQT component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_MQT_exit (dspId) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (MSGQ_COMPONENT) */

#if defined (MPLIST_COMPONENT)
            /*  ----------------------------------------------------------------
             *  Finalize the MPLIST component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_MPLIST_exit (dspId) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (MPLIST_COMPONENT) */

#if defined (MPCS_COMPONENT)
            /*  ----------------------------------------------------------------
             *  Finalize the MPCS component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_MPCS_exit (dspId) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (MPCS_COMPONENT) */

#if defined (POOL_COMPONENT)
            /*  ----------------------------------------------------------------
             *  Finalize the POOL component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_POOL_exit (dspId) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
#endif /* if defined (POOL_COMPONENT) */

            /*  ----------------------------------------------------------------
             *  Finalize the IPS component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_IPS_exit (dspId) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }

            /*  ----------------------------------------------------------------
             *  Finalize the link toward the DSP.
             *  ----------------------------------------------------------------
             */
            if (drvState->interface != NULL) {
                tmpStatus = (drvState->interface->exit) (dspId,
                                                         drvState->linkDrvId) ;
                if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                    status = tmpStatus ;
                    SET_FAILURE_REASON ;
                }
            }

            /*  ----------------------------------------------------------------
             *  Free shared memory allocated for the LDRV_DRV component.
             *  ----------------------------------------------------------------
             */
            if (drvState->ctrlPtr != NULL) {
                tmpStatus = LDRV_SMM_free (dspId,
                                           linkDrv->memEntry,
                                           sizeof (LDRV_DRV_Ctrl)) ;
                if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                    status = tmpStatus ;
                    SET_FAILURE_REASON ;
                }
            }

            /*  ----------------------------------------------------------------
             *  Finalize the Shared Memory Manager component.
             *  ----------------------------------------------------------------
             */
            tmpStatus = LDRV_SMM_exit (dspId) ;
            if (DSP_SUCCEEDED (status) && DSP_FAILED (tmpStatus)) {
                status = tmpStatus ;
                SET_FAILURE_REASON ;
            }
        }

        LDRV_DRV_IsInitialized [dspId] = FALSE ;
    }

    TRC_1LEAVE ("LDRV_DRV_exit", status) ;

    return status ;
}
コード例 #19
0
ファイル: ldrv_mpcs.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_MPCS_init
 *
 *  @desc   This function allocates and initializes resources used by this
 *          component.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_MPCS_init (IN ProcessorId dspId, OUT Uint32 * shDspAddr)
{
    DSP_STATUS         status = DSP_SOK ;
    LINKCFG_Mpcs *     mpcsObject ;
    LINKCFG_Dsp *      dspObj ;
    LINKCFG_DspConfig * dspCfg ;
    LINKCFG_LinkDrv *  linkDrv ;
    LDRV_MPCS_Object * mpcsState ;
    MPCS_Ctrl *        mpcsCtrl ;
    Uint32             i ;
    MPCS_Entry *       entry ;

    TRC_2ENTER ("LDRV_MPCS_init", dspId, shDspAddr) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;
    DBC_Require (shDspAddr != NULL) ;

    mpcsState  = &(LDRV_MPCS_State [dspId]) ;

    dspCfg    = LDRV_LinkCfgPtr->dspConfigs [dspId] ;
    dspObj    = dspCfg->dspObject ;
    linkDrv   = &(dspCfg->linkDrvObjects [dspObj->linkDrvId]) ;
    mpcsObject = &(dspCfg->mpcsObjects [linkDrv->mpcsTableId]) ;

    *shDspAddr = (Uint32) NULL ;
    if (LDRV_MPCS_IsInitialized [dspId] == FALSE) {
        /*  --------------------------------------------------------------------
         * Validate the setup configuration parameters for the link driver.
         *  --------------------------------------------------------------------
         */
        mpcsState = &(LDRV_MPCS_State [dspId]) ;

        /* Initialize the state object. */
        mpcsState->ctrlPtr      = NULL ;
        mpcsState->dspCtrlAddr  = (Uint32) NULL ;
        mpcsState->physCtrlAddr = (Uint32) NULL ;
        mpcsState->ctrlSize     = 0 ;
        mpcsState->memEntry     = mpcsObject->memEntry ;
        mpcsState->maxEntries   = mpcsObject->maxEntries ;

        /* Check if the memEntry is in valid range. */
        if (    (mpcsObject->memEntry != (Uint32) -1)
            &&  (mpcsObject->memEntry >= dspObj->memEntries)) {
            PRINT_Printf ("<1>Configuration error:"
                          " Incorrect MPCS memEntry specified [0x%x]\n",
                          mpcsObject->memEntry) ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
        else if (    (mpcsObject->ipsId != (Uint32) -1)
                 &&  (mpcsObject->ipsId >= linkDrv->numIpsEntries)) {
            /* Check if the ipsId is in valid range. */
            PRINT_Printf ("<1>Configuration error:"
                          " Incorrect MPCS ipsId specified [0x%x]\n",
                          mpcsObject->ipsId) ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
        else if (    (mpcsObject->ipsId      != (Uint32) -1)
                 &&  (mpcsObject->ipsEventNo != (Uint32) -1)
                 &&  (   mpcsObject->ipsEventNo
                      >= dspCfg->ipsTables [linkDrv->ipsTableId]
                                            [mpcsObject->ipsId].numIpsEvents)) {
            /* Check if the ipsEventNo is in valid range. */
            PRINT_Printf ("<1>Configuration error:"
                          " Incorrect MPCS ipsEventNo specified [0x%x]\n",
                          mpcsObject->ipsEventNo) ;
            status = DSP_ECONFIG ;
            SET_FAILURE_REASON ;
        }
        else {
            /*Added for MISRAC compliance */
        }
    }

    if (   (LDRV_MPCS_IsInitialized [dspId] == FALSE)
        && (DSP_SUCCEEDED (status))) {
        /*  --------------------------------------------------------------------
         *  Allocate shared memory required for the MPCS component.
         *  --------------------------------------------------------------------
         */
        mpcsState->ctrlSize =   sizeof (MPCS_Ctrl)
                             +  (sizeof (MPCS_Entry) * mpcsObject->maxEntries) ;
        status = LDRV_SMM_alloc (dspId,
                                 mpcsState->memEntry,
                                 &(mpcsState->physCtrlAddr),
                                 &(mpcsState->dspCtrlAddr),
                                 (Uint32 *) ((Pvoid) &(mpcsState->ctrlPtr)),
                                 mpcsState->ctrlSize) ;
        if (DSP_SUCCEEDED (status)) {
            *shDspAddr = mpcsState->dspCtrlAddr ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPCS Ctrl GPP address      [0x%x]\n",
                        mpcsState->ctrlPtr) ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPCS Ctrl DSP address      [0x%x]\n",
                        mpcsState->dspCtrlAddr) ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPCS Ctrl physical address [0x%x]\n",
                        mpcsState->physCtrlAddr) ;
            TRC_1PRINT (TRC_LEVEL4,
                        "MPCS Ctrl size             [0x%x]\n",
                        mpcsState->ctrlSize) ;

            mpcsCtrl = mpcsState->ctrlPtr ;
            DBC_Assert (mpcsCtrl != NULL) ;

            /* Initialize the control region. */
            mpcsCtrl->dspId      = dspId ;
            mpcsCtrl->maxEntries = mpcsState->maxEntries ;
            mpcsCtrl->ipsId      = mpcsObject->ipsId ;
            mpcsCtrl->ipsEventNo = mpcsObject->ipsEventNo ;
            entry = (MPCS_Entry *) (   (Uint32) (mpcsState->ctrlPtr)
                                              +  sizeof (MPCS_Ctrl)) ;
            mpcsCtrl->dspAddrEntry = (MPCS_Entry *)
                                           (   (Uint32) (mpcsState->dspCtrlAddr)
                                            +  sizeof (MPCS_Ctrl)) ;

            /* Initialize the entries table. */
            for (i = 0 ; i < mpcsState->maxEntries ; i++) {
                entry [i].physAddress = NULL ;
                entry [i].name [0]    = '\0' ;
            }

            /* Create the MPCS to be used for protecting the shared region. */
            status = LDRV_MPCS_create (dspId, &(mpcsCtrl->lockObj)) ;
            if (DSP_SUCCEEDED (status)) {
                mpcsCtrl->isInitialized = TRUE ;
            }
            else {
                SET_FAILURE_REASON ;
            }

            /* mpcsCtrl->entry is reset on user-side with user address */
        }
        else {
            SET_FAILURE_REASON ;
        }

        LDRV_MPCS_IsInitialized [dspId] = TRUE ;
        if (DSP_FAILED (status)) {
            /* LDRV_MPCS_exit executes cleanup only if the initialized flag is
             * TRUE.
             */
            LDRV_MPCS_exit (dspId) ;
            LDRV_MPCS_IsInitialized [dspId] = FALSE ;
        }
    }

    TRC_1LEAVE ("LDRV_MPCS_init", status) ;

    return status ;
}
コード例 #20
0
ファイル: ldrv_drv.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_DRV_debug
 *
 *  @desc   Prints the current status of this subcomponent.
 *
 *  @modif  None.
 *  ============================================================================
 */
NORMAL_API
Void
LDRV_DRV_debug (IN  ProcessorId dspId)
{
    LDRV_DRV_Object * drvState ;

    TRC_1ENTER ("LDRV_DRV_debug", dspId) ;

    DBC_Require (IS_VALID_PROCID (dspId)) ;

    drvState = &(LDRV_DRV_State [dspId]) ;

    if (LDRV_DRV_IsInitialized [dspId] == TRUE) {
        /*  --------------------------------------------------------------------
         *  Print the LDRV DRV component state information.
         *  --------------------------------------------------------------------
         */
        TRC_0PRINT (TRC_LEVEL4, "========================================.\n") ;
        TRC_1PRINT (TRC_LEVEL4,
                    "LDRV DRV component state information for DSP ID %d:\n",
                    dspId) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    ctrlPtr          = [0x%x].\n",
                    drvState->ctrlPtr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    dspCtrlAddr      = [0x%x].\n",
                    drvState->dspCtrlAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    interface        = [0x%x].\n",
                    drvState->interface) ;
        TRC_0PRINT (TRC_LEVEL4, "========================================.\n") ;

        /*  --------------------------------------------------------------------
         *  Print the information for the shared memory region.
         *  --------------------------------------------------------------------
         */
        TRC_0PRINT (TRC_LEVEL4, "Shared memory region information:\n") ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    version              = [%s]\n",
                    drvState->ctrlPtr->version) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    ProcId               = [%d]\n",
                    drvState->ctrlPtr->procId) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    linkAddr             = [%d]\n",
                    drvState->ctrlPtr->linkAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    drvDspInitDone       = [0x%x]\n",
                    drvState->ctrlPtr->drvDspInitDone) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    ipsAddr              = [0x%x]\n",
                    drvState->ctrlPtr->ipsAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    ipsDspInitDone       = [0x%x]\n",
                    drvState->ctrlPtr->ipsDspInitDone) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    poolAddr             = [0x%x]\n",
                    drvState->ctrlPtr->poolAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    poolConfigured       = [0x%x]\n",
                    drvState->ctrlPtr->poolConfigured) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    poolDspInitDone      = [0x%x]\n",
                    drvState->ctrlPtr->poolDspInitDone) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mpcsAddr             = [0x%x]\n",
                    drvState->ctrlPtr->mpcsAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mpcsConfigured       = [0x%x]\n",
                    drvState->ctrlPtr->mpcsConfigured) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mpcsDspInitDone      = [0x%x]\n",
                    drvState->ctrlPtr->mpcsDspInitDone) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mplistAddr           = [0x%x]\n",
                    drvState->ctrlPtr->mplistAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mplistConfigured     = [0x%x]\n",
                    drvState->ctrlPtr->mplistConfigured) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mplistDspInitDone    = [0x%x]\n",
                    drvState->ctrlPtr->mplistDspInitDone) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mqtAddr              = [0x%x]\n",
                    drvState->ctrlPtr->mqtAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mqtConfigured        = [0x%x]\n",
                    drvState->ctrlPtr->mqtConfigured) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    mqtDspInitDone       = [0x%x]\n",
                    drvState->ctrlPtr->mqtDspInitDone) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    dataAddr             = [0x%x]\n",
                    drvState->ctrlPtr->dataAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    dataConfigured       = [0x%x]\n",
                    drvState->ctrlPtr->dataConfigured) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    dataDspInitDone      = [0x%x]\n",
                    drvState->ctrlPtr->dataDspInitDone) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    ringIoAddr           = [0x%x]\n",
                    drvState->ctrlPtr->ringIoAddr) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    ringIoConfigured     = [0x%x]\n",
                    drvState->ctrlPtr->ringIoConfigured) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    ringIoDspInitDone    = [0x%x]\n",
                    drvState->ctrlPtr->ringIoDspInitDone) ;

        TRC_1PRINT (TRC_LEVEL4,
                    "    config.numIpsEntries  = [0x%x]\n",
                    drvState->ctrlPtr->config.numIpsEntries) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    config.numPools       = [0x%x]\n",
                    drvState->ctrlPtr->config.numPools) ;
        TRC_1PRINT (TRC_LEVEL4,
                    "    config.numDataDrivers = [0x%x]\n",
                    drvState->ctrlPtr->config.numDataDrivers) ;

        /*  --------------------------------------------------------------------
         *  Call the debug function for the specific link driver.
         *  --------------------------------------------------------------------
         */
        TRC_2PRINT (TRC_LEVEL4,
                    "Platform-specifc Link driver information for DSP ID %d"
                    " Link driver ID %d:\n",
                    dspId,
                    drvState->linkDrvId) ;
        drvState->interface->debug (dspId, drvState->linkDrvId) ;
    }
    else {
        TRC_1PRINT (TRC_LEVEL4,
                    "LDRV_DRV component for DSP ID %d is not initialized.\n",
                    dspId) ;
    }

    TRC_0LEAVE ("LDRV_DRV_debug") ;
}
コード例 #21
0
ファイル: ldrv_os.c プロジェクト: zp8001/STUDY_4.0.3
/** ============================================================================
 *  @func   LDRV_getLinkDspCfg
 *
 *  @desc   Gets the pointer to kernel configuration structure after creating
 *          it (if required). Copies only DSP structures.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
DSP_STATUS
LDRV_getLinkDspCfg (IN  ProcessorId         procId,
                    IN  LINKCFG_DspConfig * dspCfg,
                    OUT LINKCFG_Object *    knlLinkCfg)
{
    DSP_STATUS          status        = DSP_SOK ;
    LINKCFG_DspConfig * knlDspCfg     = NULL ;
    LINKCFG_Dsp *       dspObject     = NULL ;
#if !(defined (ONLY_PROC_COMPONENT))
    LINKCFG_LinkDrv *   linkDrvObject = NULL ;
#endif /* if !(defined (ONLY_PROC_COMPONENT)) */
    Void *              tmpUsrPtr ;
    Void *              tmpKnlPtr ;
    Uint32              size ;
    Uint32              tableId ;

    TRC_3ENTER ("LDRV_getLinkDspCfg",procId, dspCfg, knlLinkCfg) ;

    DBC_Require (knlLinkCfg != NULL) ;
    DBC_Require (IS_VALID_PROCID (procId)) ;

    if (DSP_SUCCEEDED (status)) {
        size = sizeof (LINKCFG_DspConfig) ;
        /* Allocate memory for the DSP object. */
        status = MEM_Alloc ((Void **) &(tmpKnlPtr),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the objects from user-space. */
            status = USER_copyFromUser ((Void *) tmpKnlPtr,
                                        (void *) dspCfg,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
            else {
                knlLinkCfg->dspConfigs [procId] = tmpKnlPtr ;
                knlDspCfg = tmpKnlPtr ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }

    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the DSP and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = knlDspCfg->dspObject ;
        size      = sizeof (LINKCFG_Dsp) ;
        /* Allocate memory for the DSP object. */
        status = MEM_Alloc ((Void **) &(knlDspCfg->dspObject),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the objects from user-space. */
            status = USER_copyFromUser ((Void *) knlDspCfg->dspObject,
                                        (void *) tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
            else {
                dspObject = knlDspCfg->dspObject ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }

    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the Link driver object array and initialize
     *  it.
     *  ------------------------------------------------------------------------
     */
#if !(defined (ONLY_PROC_COMPONENT))
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->linkDrvObjects ;
        size      = sizeof (LINKCFG_LinkDrv) *  knlDspCfg->numDrvs ;
        /* Allocate memory for the Link Driver object array. */
        status = MEM_Alloc ((Void **) &(knlDspCfg->linkDrvObjects),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the objects from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->linkDrvObjects),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
            else {
                linkDrvObject =
                             &knlDspCfg->linkDrvObjects [dspObject->linkDrvId] ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if !(defined (ONLY_PROC_COMPONENT)) */

    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the array of memory tables and initialize
     *  it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->memTables ;
        size = sizeof (LINKCFG_MemEntry *) * knlDspCfg->numMemTables ;
        /* Allocate memory for the array of pointers to memory tables. */
        status = MEM_Calloc ((Void **) &(knlDspCfg->memTables),
                             size,
                             MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the array of pointers from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->memTables),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
            else {
                tableId   = knlDspCfg->dspObject->memTableId ;
                tmpUsrPtr = (Void *) knlDspCfg->memTables [tableId] ;
                size =  sizeof (LINKCFG_MemEntry)
                      * knlDspCfg->dspObject->memEntries ;

                /* Allocate memory for the memory table. */
                status = MEM_Alloc ((Void **)
                                    &(knlDspCfg->memTables [tableId]),
                                    size,
                                    MEM_DEFAULT) ;
                if (DSP_SUCCEEDED (status)) {
                    /* Copy the contents of the objects from user-space. */
                    status = USER_copyFromUser (
                                      (Void *) (knlDspCfg->memTables [tableId]),
                                                tmpUsrPtr,
                                                size) ;
                    if (DSP_FAILED (status)) {
                        SET_FAILURE_REASON ;
                    }
                }
                else {
                    SET_FAILURE_REASON ;
                }
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }

#if !(defined (ONLY_PROC_COMPONENT))
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the array of IPS tables and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->ipsTables ;
        size      = sizeof (LINKCFG_Ips *) * knlDspCfg->numIpsTables ;
        /* Allocate memory for the array of pointers to IPS tables. */
        status = MEM_Calloc ((Void **) &(knlDspCfg->ipsTables),
                             size,
                             MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the array of pointers from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->ipsTables),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
            else {
                tableId   = linkDrvObject->ipsTableId;
                tmpUsrPtr = (Void *) knlDspCfg->ipsTables [tableId] ;
                size =   sizeof (LINKCFG_Ips) * linkDrvObject->numIpsEntries ;

                /* Allocate memory for the IPS table. */
                status = MEM_Alloc ((Void **)
                                    &(knlDspCfg->ipsTables [tableId]),
                                    size,
                                    MEM_DEFAULT) ;
                if (DSP_SUCCEEDED (status)) {
                    /* Copy the contents of the objects from user-space. */
                    status = USER_copyFromUser ((Void *)
                                      (knlDspCfg->ipsTables [tableId]),
                                      tmpUsrPtr,
                                      size) ;
                    if (DSP_FAILED (status)) {
                        SET_FAILURE_REASON ;
                    }
                }
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }

#if defined (POOL_COMPONENT)
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the array of Pool tables and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->poolTables ;
        size      = sizeof (LINKCFG_Pool *) * knlDspCfg->numPoolTables ;
        /* Allocate memory for the array of pointers to Pool tables. */
        status = MEM_Calloc ((Void **) &(knlDspCfg->poolTables),
                             size,
                             MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the array of pointers from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->poolTables),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
            else {
                tableId = linkDrvObject->poolTableId ;
                tmpUsrPtr = (Void *) knlDspCfg->poolTables [tableId] ;
                size = sizeof (LINKCFG_Pool) * linkDrvObject->numPools ;

                /* Allocate memory for the Pool table. */
                status = MEM_Alloc ((Void **)
                                   &(knlDspCfg->poolTables [tableId]),
                                   size,
                                   MEM_DEFAULT) ;
                if (DSP_SUCCEEDED (status)) {
                    /* Copy the contents of the objects from user-space. */
                    status = USER_copyFromUser (
                                     (Void *) (knlDspCfg->poolTables [tableId]),
                                     tmpUsrPtr,
                                     size) ;
                    if (DSP_FAILED (status)) {
                        SET_FAILURE_REASON ;
                    }
                }
                else {
                    SET_FAILURE_REASON ;
                }
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if defined (POOL_COMPONENT) */

#if defined (CHNL_COMPONENT)
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the array of Data driver tables and
     *  initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->dataTables ;
        size = sizeof (LINKCFG_DataDrv *) * knlDspCfg->numDataTables ;
        /* Allocate memory for the array of pointers to Data driver tables. */
        status = MEM_Calloc ((Void **) &(knlDspCfg->dataTables),
                             size,
                             MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the array of pointers from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->dataTables),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
            else {
                tableId = linkDrvObject->dataTableId ;
                tmpUsrPtr = (Void *) knlDspCfg->dataTables [tableId] ;
                size =  sizeof (LINKCFG_DataDrv)
                      * linkDrvObject->numDataDrivers ;

                /* Allocate memory for the Data driver table. */
                status = MEM_Alloc ((Void **)
                                   &(knlDspCfg->dataTables [tableId]),
                                   size,
                                   MEM_DEFAULT) ;
                if (DSP_SUCCEEDED (status)) {
                    /* Copy the contents of the objects from user-space. */
                    status = USER_copyFromUser (
                                     (Void *) (knlDspCfg->dataTables [tableId]),
                                     tmpUsrPtr,
                                     size) ;
                    if (DSP_FAILED (status)) {
                        SET_FAILURE_REASON ;
                    }
                }
                else {
                    SET_FAILURE_REASON ;
                }
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if defined (CHNL_COMPONENT) */

#if defined (MSGQ_COMPONENT)
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the MQT object array and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->mqtObjects ;
        size      = sizeof (LINKCFG_Mqt) * knlDspCfg->numMqts ;
        /* Allocate memory for the MQT object array. */
        status = MEM_Alloc ((Void **) &(knlDspCfg->mqtObjects),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the objects from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->mqtObjects),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if defined (MSGQ_COMPONENT) */

#if defined (RINGIO_COMPONENT)
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the RingIO object array and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->ringIoObjects ;
        size      = sizeof (LINKCFG_RingIo) * knlDspCfg->numRingIo ;
        /* Allocate memory for the RingIO object array. */
        status = MEM_Alloc ((Void **) &(knlDspCfg->ringIoObjects),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the objects from user-space. */
            status = USER_copyFromUser ((Void *)(knlDspCfg->ringIoObjects),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if defined (RINGIO_COMPONENT) */

#if defined (MPLIST_COMPONENT)
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the MPLIST object array and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->mplistObjects ;
        size      = sizeof (LINKCFG_MpList) * knlDspCfg->numMpList ;
        /* Allocate memory for the MPLIST object array. */
        status = MEM_Alloc ((Void **) &(knlDspCfg->mplistObjects),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the objects from user-space. */
            status = USER_copyFromUser ((Void *)(knlDspCfg->mplistObjects),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if defined (MPLIST_COMPONENT) */

#if defined (MPCS_COMPONENT)
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the MPCS object array and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->mpcsObjects ;
        size      = sizeof (LINKCFG_Mpcs) * knlDspCfg->numMpcs ;
        /* Allocate memory for the MPCS object array. */
        status = MEM_Alloc ((Void **) &(knlDspCfg->mpcsObjects),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the objects from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->mpcsObjects),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if defined (MPCS_COMPONENT) */

#if defined (LOG_COMPONENT)
    /*  ------------------------------------------------------------------------
     *  Allocate memory required for the LOG object and initialize it.
     *  ------------------------------------------------------------------------
     */
    if (DSP_SUCCEEDED (status)) {
        tmpUsrPtr = (Void *) knlDspCfg->logObject ;
        size      = sizeof (LINKCFG_Log) ;
        /* Allocate memory for the GPP object. */
        status = MEM_Alloc ((Void **) &(knlDspCfg->logObject),
                            size,
                            MEM_DEFAULT) ;
        if (DSP_SUCCEEDED (status)) {
            /* Copy the contents of the object from user-space. */
            status = USER_copyFromUser ((Void *) (knlDspCfg->logObject),
                                        tmpUsrPtr,
                                        size) ;
            if (DSP_FAILED (status)) {
                SET_FAILURE_REASON ;
            }
        }
        else {
            SET_FAILURE_REASON ;
        }
    }
#endif /* if defined (LOG_COMPONENT) */
#endif /* if !(defined (ONLY_PROC_COMPONENT)) */

    if (DSP_FAILED (status)) {
        LDRV_freeLinkDspCfg (procId, knlLinkCfg) ;
    }

    TRC_1LEAVE ("LDRV_getLinkDspCfg", status) ;

    return status ;
}
コード例 #22
0
/*!
 *  @brief      Function to create an instance of this PwrMgr.
 *
 *  @param      procId  Processor ID addressed by this PwrMgr instance.
 *  @param      params  Configuration parameters.
 *
 *  @sa         DM8168DUCATIPWR_delete
 */
DM8168DUCATIPWR_Handle
DM8168DUCATIPWR_create (      UInt16               procId,
                    const DM8168DUCATIPWR_Params * params)
{
    Int                  status = PWRMGR_SUCCESS;
    PwrMgr_Object *      handle = NULL;
    IArg                 key;

    GT_2trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_create", procId, params);

    GT_assert (curTrace, IS_VALID_PROCID (procId));
    GT_assert (curTrace, (params != NULL));
    GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0));

#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    if (DM8168DUCATIPWR_state.refCount == 0) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_create",
                             DM8168DUCATIPWR_E_INVALIDSTATE,
                             "Module was not initialized!");
    }
    else if (!IS_VALID_PROCID (procId)) {
        /* Not setting status here since this function does not return status.*/
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_create",
                             PWRMGR_E_INVALIDARG,
                             "Invalid procId specified");
    }
    else if (params == NULL) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_create",
                             PWRMGR_E_INVALIDARG,
                             "params passed is null!");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
        /* Enter critical section protection. */
        key = IGateProvider_enter (DM8168DUCATIPWR_state.gateHandle);
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
        /* Check if the PwrMgr already exists for specified procId. */
        if (DM8168DUCATIPWR_state.pwrHandles [procId] != NULL) {
            status = PWRMGR_E_ALREADYEXIST;
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "DM8168DUCATIPWR_create",
                                 status,
                                 "PwrMgr already exists for specified procId!");
        }
        else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
            /* Allocate memory for the handle */
            handle = (PwrMgr_Object *) Memory_calloc (NULL,
                                                      sizeof (PwrMgr_Object),
                                                      0,
                                                      NULL);
            if (handle == NULL) {
                GT_setFailureReason (curTrace,
                                     GT_4CLASS,
                                     "DM8168DUCATIPWR_create",
                                     PWRMGR_E_MEMORY,
                                     "Memory allocation failed for handle!");
            }
            else {
                /* Populate the handle fields */
                handle->pwrFxnTable.attach = &DM8168DUCATIPWR_attach;
                handle->pwrFxnTable.detach = &DM8168DUCATIPWR_detach;
                handle->pwrFxnTable.on     = &DM8168DUCATIPWR_on;
                handle->pwrFxnTable.off    = &DM8168DUCATIPWR_off;
                /* TBD: Other functions */

                /* Allocate memory for the DM8168DUCATIPWR handle */
                handle->object = Memory_calloc (NULL,
                                                sizeof (DM8168DUCATIPWR_Object),
                                                0,
                                                NULL);
                if (handle == NULL) {
                    status = PWRMGR_E_MEMORY;
                    GT_setFailureReason (curTrace,
                                        GT_4CLASS,
                                        "DM8168DUCATIPWR_create",
                                        status,
                                        "Memory allocation failed for handle!");
                }
                else {
#if defined (SYSLINK_BUILDOS_LINUX)
                    ((DM8168DUCATIPWR_Object *)handle->object)->clockHandle
                                       = (ClockOps_Handle) LinuxClock_create();
#endif/* #if defined (SYSLINK_BUILDOS_LINUX) */
#if defined (SYSLINK_BUILD_RTOS)
                    ((DM8168DUCATIPWR_Object *)handle->object)->clockHandle
                                       = (ClockOps_Handle) DM8168CLOCK_create();
#endif/* #if defined (SYSLINK_BUILD_RTOS) */
                    handle->procId = procId;
                    DM8168DUCATIPWR_state.pwrHandles [procId] =
                                                (DM8168DUCATIPWR_Handle) handle;
                }
            }
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
        }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
        /* Leave critical section protection. */
        IGateProvider_leave (DM8168DUCATIPWR_state.gateHandle, key);
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */

    if (status < 0) {
        if (handle !=  NULL) {
            if (handle->object != NULL) {
                Memory_free (NULL, handle->object, sizeof (DM8168DUCATIPWR_Object));
            }
            Memory_free (NULL, handle, sizeof (PwrMgr_Object));
        }
        /*! @retval NULL Function failed */
        handle = NULL;
    }

    GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_create", handle);

    /*! @retval Valid-Handle Operation successful */
    return (DM8168DUCATIPWR_Handle) handle;
}