/**
 * Non-Require:
 *    - MMDSP could be sleep (Since we access it only through HSEM)
 */
void cm_delayedDestroyComponent(t_component_instance *component) {
    int i;

    if (osal_debug_ops.component_destroy)
	    osal_debug_ops.component_destroy(component);

    /*
     * Remove component from load map here
     */
    cm_DSPABI_RemoveLoadMap(
            component->domainId,
            component->Template->name,
            component->memories,
            component->pathname,
            component);

    // Generate XTI/STM trace
    cm_TRC_traceLoadMap(TRACE_COMPONENT_COMMAND_REMOVE, component);

    /*
     * disconnect interrupt handler if needed
     */
    for(i = 0; i < component->Template->provideNumber; i++)
    {
        if(component->Template->provides[i].interruptLine)
        {
            cm_unbindInterfaceStaticInterrupt(component->Template->dspId, component->Template->provides[i].interruptLine);
        }
    }

    /*
     * Update dsp stack size if needed
     */
    if (component->Template->minStackSize > MIN_STACK_SIZE)
    {
        if (cm_EEM_isStackUpdateNeed(component->Template->dspId, component->priority, FALSE, component->Template->minStackSize))
        {
            t_uint32 newStackValue;
            t_uint32 maxComponentStackSize;

            maxComponentStackSize = cm_getMaxStackValue(component);
            cm_EEM_UpdateStack(component->Template->dspId, component->priority, maxComponentStackSize, &newStackValue);
	    if (cm_DSP_GetState(component->Template->dspId)->state == MPC_STATE_BOOTED)
		    cm_COMP_UpdateStack(component->Template->dspId, newStackValue);
        }
    }

    cm_DestroyComponentMemory(component);
}
示例#2
0
static void cm_bindLowLevelInterfaceToConst(
        const t_interface_require_description *itfRequire,
        const t_dsp_address functionAddress,
        const t_component_instance* targetInstance) {
    const t_component_instance* client = itfRequire->client;
    t_interface_require *require = &client->Template->requires[itfRequire->requireIndex];
    int j, k;


    // If DSP is off/panic/... -> write nothing
    if(
            require->indexes != NULL
            && cm_DSP_GetState(client->Template->dspId)->state == MPC_STATE_BOOTED)
    {
        t_interface_require_index *requireindex = &require->indexes[itfRequire->collectionIndex];

        for(k = 0; k < requireindex->numberOfClient; k++) {
            t_uint32 *hostAddr;

            hostAddr = (t_uint32*)(
                    cm_DSP_GetHostLogicalAddress(client->memories[requireindex->memories[k].memory->id]) +
                    requireindex->memories[k].offset * requireindex->memories[k].memory->memEntSize);

            /*
             * Fill the interface references. We start by Methods then This in order to swith to
             * Unbinded panic as fast as possible and not used method with wrong This. This is
             * relevent only for optional since we must go in stop state before rebinding other
             * required interface.
             *
             * Direct write to DSP memory without go through DSP abstraction since we know we are in 24bits
             */
            /*
             * Write THIS reference into the Data field of the interface reference
             * Hack for simplifying debug just to keep THIS reference with caller one
             * (could be removed if __return_address MMDSP intrinsec provided by compiler).
             */
            // Write the interface methods reference

            if(((t_uint32)hostAddr & 0x7) == 0 && require->interface->methodNumber > 0)
            {
                // We are 64word byte aligned, combine this write with first method
                *(volatile t_uint64*)hostAddr =
                        ((t_uint64)client->thisAddress << 0) |
                        ((t_uint64)functionAddress << 32);
                hostAddr += 2;
                j = 1;
            }
            else
            {
                // We are not, write this which will align us
                *hostAddr++ = (t_uint32)client->thisAddress;
                j = 0;
            }

            // Word align copy
            for(; j < require->interface->methodNumber - 1; j+=2) {
                *(volatile t_uint64*)hostAddr =
                        ((t_uint64)functionAddress << 0) |
                        ((t_uint64)functionAddress << 32);
                hostAddr += 2;
            }

            // Last word align if required
            if(j < require->interface->methodNumber)
                *hostAddr = functionAddress;
        }
    }

    cm_registerLowLevelInterfaceToConst(itfRequire, targetInstance);
}