static void bridge_load_firmware(void)
{
	struct PROCESS_CONTEXT pr_ctxt;
	DSP_STATUS status;
	const char *argv[2];
	argv[0] = firmware_file;
	argv[1] = NULL;

	pr_ctxt.hProcessor = NULL;
	status = PROC_Attach(0, NULL, &pr_ctxt.hProcessor, &pr_ctxt);
	if (DSP_FAILED(status))
		goto func_err;

	status = PROC_Stop(pr_ctxt.hProcessor);
	if (DSP_FAILED(status))
		goto func_err;

	status = PROC_Load(pr_ctxt.hProcessor, 1, argv, NULL);
	if (DSP_FAILED(status))
		goto func_err;

	status = PROC_Start(pr_ctxt.hProcessor);
	if (DSP_FAILED(status))
		goto func_err;

	status = PROC_Detach(&pr_ctxt);
	if (DSP_SUCCEEDED(status)) {
		pr_info("DSP recovery succeeded\n");
		return;
	}

func_err:
	pr_err("DSP could not be restarted, status = %x\n", status);
}
Beispiel #2
0
/*
 * ======== PROCWRAP_Attach ========
 */
u32 PROCWRAP_Attach(union Trapped_Args *args, void *pr_ctxt)
{
	DSP_HPROCESSOR processor;
	DSP_STATUS status = DSP_SOK;
	struct DSP_PROCESSORATTRIN attrIn, *pAttrIn = NULL;

	GT_3trace(WCD_debugMask, GT_ENTER,
		 "PROCWRAP_Attach: entered args:\n" "0x%x"
		 " uProcessor: 0x%x\tpAttrIn: 0x%x\tphProcessor \n",
		 args->ARGS_PROC_ATTACH.uProcessor,
		 args->ARGS_PROC_ATTACH.pAttrIn,
		 args->ARGS_PROC_ATTACH.phProcessor);
	/* Optional argument */
	if (args->ARGS_PROC_ATTACH.pAttrIn) {
		cp_fm_usr(&attrIn, args->ARGS_PROC_ATTACH.pAttrIn, status, 1);
		if (DSP_SUCCEEDED(status))
			pAttrIn = &attrIn;
		else
			goto func_end;


	}
	status = PROC_Attach(args->ARGS_PROC_ATTACH.uProcessor, pAttrIn,
			    &processor, pr_ctxt);
	cp_to_usr(args->ARGS_PROC_ATTACH.phProcessor, &processor, status, 1);
func_end:
	return status;
}
/** ============================================================================
 *  @func   RING_IO_getLinkAccess
 *
 *  @desc   Function  that allows the child  process to  use the link
 *          components.
 *
 *  @modif  None
 *  ============================================================================
 */
NORMAL_API
Int
RING_IO_getLinkAccess(Uint8 processorId)
{
	DSP_STATUS status = DSP_SOK;

	/* Call the Link APIs that allows child process to be able to use the
	 * Link components
	 */

	status = PROC_Attach (processorId, NULL);

	if (DSP_FAILED (status)) {
		RING_IO_1Print ("Attach Failed. Status = [0x%x]", status);
	}

	return (status);
}
Beispiel #4
0
/*
 *  ======== procCreate ========
 */
static Bool procCreate(Processor_Handle proc)
{
    DSP_STATUS      status = DSP_SOK;
    ZcpyMqtAttrs    mqtAttrs;
    Bool            retVal;

    GT_1trace(curTrace, GT_ENTER, "Processor_create_d> Enter(proc=0x%x)\n",
            proc);

    /* TODO:L ignoring cpuId string, using 0 for cpuId */
    proc->cpuId = 0;

    /* call power on function -- either the real one, or the empty
     * stub defined by Global.xdt if power is not used.
     */
    if (Power_on(&proc->powerHandle) == Power_EFAIL) {
        retVal = FALSE;
        GT_0trace(curTrace, GT_6CLASS,
            "Processor_create_d> Power_on failed.\n");
        goto procCreate_return;
    }

    /* if using LAD: connect to LAD, startup DSP, attach with Link */
    if (Global_useLinkArbiter) {

        /* connect to LAD */
        ladStatus = LAD_connect(&handle);
        GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "LAD_connect status = %x, handle = %x\n", ladStatus, handle);

        if (ladStatus != LAD_SUCCESS) {
            GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> "
               "LAD_connect FAILED, status = [0x%x]\n", ladStatus);
            goto ladfail;
        }

        /* startup the DSP (if it isn't already started) */
        GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "Loading %s on DSP, linkConfigName= %s ...\n", proc->imageName,
            proc->linkConfigName);
        ladStatus = LAD_startupDsp(handle, proc->cpuId, proc->linkConfigName,
            proc->imageName);
        GT_1trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "LAD_startupDsp status = %x\n", ladStatus);

        /* on success, continue */
        if ((ladStatus == LAD_SUCCESS) || (ladStatus == LAD_ALREADYRUNNING)) {
#ifndef WIN32
            /*
             *  Must still call PROC_Attach from this app's process. (For
             *  WinCE, LAD runs in the same process, so PROC_Attach() returns
             *  an error.)
             */
            status = PROC_Attach(proc->cpuId, NULL);
            if (!DSP_SUCCEEDED(status)) {
                GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> "
                    "PROC_Attach following LAD_startupDsp FAILED, "
                    "status=[0x%x]\n", (Uns) status);
                goto ladfail;
            }

            /* must still call POOL_Open from this app (NULL attributes) */
            status = POOL_Open (Global_cePoolId, NULL) ;
            if (!DSP_SUCCEEDED(status)) {
                GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> "
                    "POOL_Open following LAD_startupDsp FAILED, "
                    "status=[0x%x]\n", (Uns) status);
            }
#endif
        }
        /* else, on fail, abort */
        else {
            GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> "
                "LAD_startupDsp FAILED, status = [0x%x]\n", ladStatus);
            goto ladfail;
        }
    } /* end of 'if using LAD' */

    /* else, if no LAD, call Link's startup APIs directly */
    else {

        /*
         *  Create and initialize the PROC object.
         */
        GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "Initializing DSP PROC...\n");

        modifyDefaultLinkCfgObjectForCENeeds();
        modifyDefaultLinkCfgObjectBasedOnUserCfgData(proc->imageName);

    dumpLinkCfgObj(&ti_sdo_ce_ipc_Processor_linkcfg);

        status = PROC_setup( &ti_sdo_ce_ipc_Processor_linkcfg );

        if (!DSP_SUCCEEDED(status)) {
            goto fail;
        }

        /*
         *  Attach the Dsp.
         */
        GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "Attaching to DSP PROC...\n");

        status = PROC_Attach(proc->cpuId, NULL);
        if (!DSP_SUCCEEDED(status)) {
            goto fail;
        }

        /*
         *  Open a pool with buffers for both the control messages use by the
         *  transport and the application.
         */
        GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "Opening MSGQ pool...\n");

        status = POOL_Open(Global_cePoolId, &Global_cePoolAttrs);
        if (!DSP_SUCCEEDED(status)) {
            goto fail;
        }

        /*
         *  Load the executable on the DSP.
         */
        GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "Loading %s on DSP (%d args)...\n", proc->imageName,
            proc->attrs.argc);

        status = PROC_Load(proc->cpuId, proc->imageName,
            proc->attrs.argc, proc->attrs.argv);
        if (!DSP_SUCCEEDED(status)) {
            goto fail;
        }

        /*
         *  Start execution on DSP.
         */
        GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "Starting DSP PROC...\n");

        status = PROC_Start(proc->cpuId);
        if (!DSP_SUCCEEDED(status)) {
            goto fail;
        }

        /*
         *  Open the remote transport to the DSP.
         */
        GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> "
            "Opening remote transport...\n");
        /* tell the transport which open pool id to use for ctrl messages */
        mqtAttrs.poolId = Global_cePoolId;

        status = MSGQ_TransportOpen(proc->cpuId, &mqtAttrs);
        if (!DSP_SUCCEEDED(status)) {
            goto fail;
        }

    }  /* end of else to using LAD */

    /*
     *  Connect to the Power on the DSP
     */
    if (Power_connect(proc->powerHandle) == Power_EFAIL) {
        goto fail;
    }

    proc->connected = TRUE;

    if (Global_getenv("CE_DSPDEBUG") != NULL) {
        printf("Codec Engine system message (b/c CE_DSPDEBUG=1) : DSP image "
                "loaded and started, press Enter to continue: ");
        getchar();
    }

    retVal = TRUE;
    goto procCreate_return;

    /* TODO:[4] should try those asyncErrorHandlers that link supports?
     * (MSGQ_SetErrorHandler)
     */

fail:
    GT_4trace(curTrace, GT_7CLASS, "Processor_create_d> "
        "Loading and starting DSP server '%s' FAILED, status=[0x%x] "
        "(look for error code 'DSP_EBASE + 0x%x' in "
        "dsplink*/packages/dsplink/gpp/inc/usr/errbase.h) %s\n",
        proc->imageName, status,
        status & 0x7fff, status == DSP_ERANGE ?
            "This error code typically indicates a problem with the DSP memory "
            "map, i.e. it is different from what the Arm side specified; check "
            "the DSP server's memory map in your Arm application .cfg script, "
            "and make sure you have set 'armDspLinkConfig' "
            "configuration variable correctly (for details, refer to the "
            "documentation for ti.sdo.ce.Engine.xdc). Also, verify that "
            "the DSPLINKMEM segment on the DSP is large enough. "
            : ""
         );

ladfail:

    procDelete(proc);

    retVal = FALSE;

procCreate_return:

    GT_1trace(curTrace, GT_2CLASS, "Processor_create_d> return (%d)\n", retVal);

    return retVal;
}