Example #1
0
t_cm_error cm_bindInterfaceStaticInterrupt(
        const t_nmf_core_id coreId,
        const int interruptLine,
        const t_component_instance *server,
        const char* providedItfServerName
)
{
    char requiredItfClientName[CM_IT_NAME_MAX_LENGTH];
    t_component_instance *client = cm_EEM_getExecutiveEngine(coreId)->instance;
    t_interface_require_description itfRequire;
    t_interface_provide_description itfProvide;
    t_cm_error error;

    //build it[%d] name
    if (interruptLine < 0 || interruptLine > 255) {return CM_OUT_OF_LIMITS;}
    cm_fillItName(interruptLine, requiredItfClientName);

    //do binding
    if ((error = cm_getRequiredInterface(client,requiredItfClientName,&itfRequire)) !=  CM_OK) {return error;}
    if ((error = cm_getProvidedInterface(server,providedItfServerName,&itfProvide)) !=  CM_OK) {return error;}
    if((error = cm_bindInterface(&itfRequire, &itfProvide)) != CM_OK) {return error;}

    return CM_OK;
}
/*
 * Component binding wrapping.
 */
PUBLIC EXPORT_SHARED t_cm_error CM_ENGINE_BindComponent(
        const t_cm_instance_handle clientInstance,
        const char* requiredItfClientName,
        const t_cm_instance_handle serverInstance,
        const char* providedItfServerName,
        t_bool traced,
        t_nmf_client_id clientId,
        const char *dataFileTrace) {
    t_interface_require_description itfRequire;
    t_interface_provide_description itfProvide;
    t_bool bindable;
    t_cm_error error;
    t_component_instance *client, *server;
    t_elfdescription *elfhandleTrace = NULL;

    OSAL_LOCK_API();

    /*
     * Load Elf File
     */
    if(dataFileTrace != NULL &&
            (error = cm_ELF_CheckFile(
                    dataFileTrace,
                    TRUE,
                    &elfhandleTrace)) != CM_OK)
        goto out;

    client = cm_lookupComponent(clientInstance);
    server = cm_lookupComponent(serverInstance);
    // Sanity check
    if((error = cm_checkValidBinding(client, requiredItfClientName,
				     server, providedItfServerName,
				     &itfRequire, &itfProvide, &bindable)) != CM_OK)
        goto out;

    // Check that client and server component run on same DSP
    if (itfRequire.client->Template->dspId != itfProvide.server->Template->dspId)
    {
        error = CM_ILLEGAL_BINDING;
        goto out;
    }

    // Check if we really need to bind
    if(bindable)
    {
        if ((error = cm_EEM_ForceWakeup(itfRequire.client->Template->dspId)) != CM_OK)
            goto out;

        /*
         * Synchronous binding, so no binding component
         */
        if(traced)
            error = cm_bindInterfaceTrace(&itfRequire, &itfProvide, elfhandleTrace);
        else
            error = cm_bindInterface(&itfRequire, &itfProvide);

        cm_EEM_AllowSleep(itfRequire.client->Template->dspId);
    }

    cm_registerSingletonBinding(client, &itfRequire, &itfProvide, clientId);

out:
    cm_ELF_CloseFile(TRUE, elfhandleTrace);
    OSAL_UNLOCK_API();
    return error;
}