Ejemplo n.º 1
0
Int FirmwareLoad_shutdown (UInt16 procId)
{
    Int             status = 0;
    ProcMgr_Handle  handle = NULL;
    UInt32          fileId;

    if(status>=0)
        status = FirmwareLoad_ipcStop(procId);    

    if(status>=0)    
        status = ProcMgr_open (&handle, procId);

    if (status >= 0) {
        status = ProcMgr_stop (handle);
        printf ("Stopped slave procId %d.\n", procId);

        fileId = ProcMgr_getLoadedFileId (handle);
        status = ProcMgr_unload (handle, fileId) ;

        printf ("Unloaded slave procId %d.\n", procId);
        status = ProcMgr_detach (handle);

        printf ("Detached from slave procId %d.\n", procId);

        status = ProcMgr_close (&handle);
    }

    return status;
}
/*!
 *  @brief      Function to unmap
 *
 *
 *  @param      mappedAddr       The remote address to unmap
 *  @param      procId                 The remote Processor ID
 *
 *  @sa         SysLinkMemUtils_map
 */
Int
SysLinkMemUtils_unmap (UInt32 mappedAddr, ProcMgr_ProcId procId)
{
    ProcMgr_Handle procMgrHandle;
    Int32          status = PROCMGR_SUCCESS;

    /* Open a handle to the ProcMgr instance. */
    if (procId == PROC_APPM3) {
        procId = PROC_SYSM3;
    }

    /* Open a handle to the ProcMgr instance. */
    status = ProcMgr_open (&procMgrHandle, procId);
    if (status < 0) {
        Osal_printf ("Error in ProcMgr_open [0x%x]\n", status);
    }
    else {
        status = ProcMgr_unmap (procMgrHandle, mappedAddr, procId);
        /* FIX ME: Add Proc unreserve call */
        if (status < 0) {
            Osal_printf ("Error in ProcMgr_unmap [0x%x]\n", status);
        }
        else {
            status = ProcMgr_close (&procMgrHandle);
        }
    }

    return status;
}
Ejemplo n.º 3
0
Void Audio_systemProcInit (Void)
{
    Int32   status;
    Int16   procId;
    Int16   state;

    /* 
     * SysLink_setup is the first APIs needs to be called by user side
     * application to use any SysLink functionality 
     */
    SysLink_setup ();

    procId = MultiProc_getId ("DSP");

    status = ProcMgr_open (&procMgrHandle, procId);
    if (0 > status) {
        AUDIO_ERROR_PRINT(("AUDIO: ProcMgr_open() Failed \n"));
        goto EXIT;
    }

    state = ProcMgr_getState (procMgrHandle);

EXIT:
    return;
}
Ejemplo n.º 4
0
/*!
 *  @brief  Function to execute the shutdown for ProcMgrApp sample application
 */
Int
ProcMgrApp_shutdown (UInt16 procId)
{
    Int                          status = 0;
    ProcMgr_Handle               handle = NULL;
    ProcMgr_State                state;

    PRINTF ("Entered ProcMgrApp_shutdown\n");

    status = ProcMgr_open (&handle, procId);

    if (status >= 0) {
        status = Ipc_control (procId, Ipc_CONTROLCMD_STOPCALLBACK, NULL);
        PRINTF ("Ipc_control Ipc_CONTROLCMD_STOPCALLBACK status: [0x%x]\n",
                     status);

        status = ProcMgr_detach (handle);
        PRINTF ("ProcMgr_detach status: [0x%x]\n", status);

        state = ProcMgr_getState (handle);
        PRINTF ("After detach: ProcMgr_getState\n"
                     "    state [0x%x]\n",
                     state);

        status = ProcMgr_close (&handle);
        PRINTF ("ProcMgr_close status: [0x%x]\n", status);
    }

    PRINTF ("Leaving ProcMgrApp_shutdown\n");

    return 0;
}
Ejemplo n.º 5
0
Int FirmwareLoad_startup (UInt16 procId, String filePath)
{
    Int                          status = 0;
    ProcMgr_Handle               handle = NULL;
    ProcMgr_AttachParams         attachParams;
    ProcMgr_StartParams          startParams;
    //String                       args [NUM_ARGS];
    UInt32                       fileId;

    status = ProcMgr_open (&handle, procId);

    if (status >= 0) {

        ProcMgr_getAttachParams (NULL, &attachParams);
        
        /* Default params will be used if NULL is passed. */
        status = ProcMgr_attach (handle, &attachParams);
        if (status < 0) 
            printf ("ProcMgr_attach failed [0x%x]\n", status);
        else 
            printf ("Attached to slave procId %d.\n", procId);

        if(status >= 0)
        {
            /* Send filePath as the args to the slave to demonstrate how args
             * are used.
             */
            //args [0] = filePath;
            status = ProcMgr_load (handle,
                                   filePath,
                                   0,
                                   NULL,
                                   NULL,
                                   &fileId);
            if (status < 0) 
                printf ("Error in ProcMgr_load [0x%x]\n", status);
            else 
                printf ("Loaded file %s on slave procId %d.\n", filePath, procId);
        }

        if (status >= 0)
        {
            ProcMgr_getStartParams (handle, &startParams);
            status = ProcMgr_start (handle, &startParams);
            if (status < 0) 
                printf ("ProcMgr_start failed [0x%x]\n", status);
            else 
                printf ("Started slave procId %d.\n", procId);
        }

        status = ProcMgr_close (&handle);
    }

    if(status>=0)    
        status = FirmwareLoad_ipcStart(procId);    

    return status;
}
/*!
 *  @brief      Function to retrieve physical entries given a remote
 *              Processor's virtual address.
 *
 *              This function returns success state of this function
 *
 *  @param      remoteAddr  The slave's address
 *  @param      size        size of buffer
 *  @param      physEntries Translated physical addresses of each Page.
 *  @param      procId      Remote Processor Id.
 *  @param      flags       Used to pass any custom information for optimization.
 *
 *  @sa         SysLinkMemUtils_virtToPhys
 */
Int
SysLinkMemUtils_virtToPhysPages (UInt32         remoteAddr,
                                 UInt32         numOfPages,
                                 UInt32         physEntries[],
                                 ProcMgr_ProcId procId)
{
    Int             i;
    Int32           status = PROCMGR_SUCCESS;
    ProcMgr_Handle  procMgrHandle;

    GT_1trace (curTrace, GT_ENTER, "SysLinkMemUtils_virtToPhys: remote Addr",
                    remoteAddr);

    if (physEntries == NULL || (numOfPages == 0)) {
        Osal_printf("SysLinkMemUtils_virtToPhys: ERROR:Input arguments invalid:"
                    "physEntries = 0x%x, numOfPages = %d\n",
                    (UInt32)physEntries, numOfPages);
        return PROCMGR_E_FAIL;
    }

    if (procId == PROC_APPM3) {
        procId = PROC_SYSM3;
    }

    Osal_printf ("testing with ProcMgr_virtToPhysPages\n");

    /* Open a handle to the ProcMgr instance. */
    status = ProcMgr_open (&procMgrHandle, procId);
    if (status < 0) {
        Osal_printf ("Error in ProcMgr_open [0x%x]\n", status);
        return PROCMGR_E_FAIL;
    }
    /* TODO: Hack for tiler */
    if(remoteAddr >= TILER_ADDRESS_START && remoteAddr < TILER_ADDRESS_END) {
        for (i = 0; i < numOfPages; i++) {
            physEntries[i] = Page_ALIGN_LOW(remoteAddr, Page_SIZE_4K) + \
                                                                    (4096 * i);
        }
    }
    else {
        status = ProcMgr_virtToPhysPages (procMgrHandle, remoteAddr,
                    numOfPages, physEntries, procId);
    }

    if (status < 0) {
        Osal_printf ("Error in ProcMgr_virtToPhysPages [0x%x]\n", status);
    }
    else {
        for (i = 0; i < numOfPages; i++) {
            Osal_printf("physEntries[%d] = 0x%x\n", i, physEntries[i]);
        }
    }

    status = ProcMgr_close (&procMgrHandle);

    return status;
}
Ejemplo n.º 7
0
Void FirmwareLoad_printStatus (Void)
{
    Int             status = 0;
    ProcMgr_Handle  handle = NULL;
    UInt16          numProcs;
    UInt16          i;
    ProcMgr_State   state;
    Char            strState [32u];

    printf ("Current status of slave cores:\n");
    numProcs = MultiProc_getNumProcessors ();
    for (i = 0 ; (i < numProcs) && (i != MultiProc_self ()) ; i++) {
        {
            status = ProcMgr_open (&handle, i);
            if (status >= 0) {
                state = ProcMgr_getState (handle);
                switch (state)
                {
                    case ProcMgr_State_Unknown:
                        strncpy (strState, "Unknown", 32u);
                        break;
                    case ProcMgr_State_Powered:
                        strncpy (strState, "Powered", 32u);
                        break;
                    case ProcMgr_State_Reset:
                        strncpy (strState, "Reset", 32u);
                        break;
                    case ProcMgr_State_Loaded:
                        strncpy (strState, "Loaded", 32u);
                        break;
                    case ProcMgr_State_Running:
                        strncpy (strState, "Running", 32u);
                        break;
                    case ProcMgr_State_Unavailable:
                        strncpy (strState, "Unavailable", 32u);
                        break;
                    case ProcMgr_State_EndValue:
                        /* Not a valid value. */
                        break;
                }
                printf ("Slave core %d: %8s [%s]\n",
                             i,
                             MultiProc_getName (i),
                             strState);
                status = ProcMgr_close (&handle);
            }
        }
    }
}
/*!
 *  @brief      Function to Map Host processor to Remote processors
 *              module
 *
 *              This function can be called by the application to map their
 *              address space to remote slave's address space.
 *
 *  @param      MpuAddr
 *
 *  @sa         SysLinkMemUtils_unmap
 */
Int
SysLinkMemUtils_map (SyslinkMemUtils_MpuAddrToMap   mpuAddrList [],
                     UInt32                         numOfBuffers,
                     UInt32 *                       mappedAddr,
                     ProcMgr_MapType                memType,
                     ProcMgr_ProcId                 procId)
{
    ProcMgr_Handle  procMgrHandle;
    UInt32          mappedSize;
    Int32           status = PROCMGR_SUCCESS;

    if (numOfBuffers > 1) {
        status = PROCMGR_E_INVALIDARG;
        Osal_printf ("SysLinkMemUtils_map numBufError [0x%x]\n", status);
        return status;
    }

    if (procId == PROC_APPM3) {
        procId = PROC_SYSM3;
    }

    if (memType == ProcMgr_MapType_Tiler) {
        /* TILER addresses are pre-mapped, so just return the TILER ssPtr */
        *mappedAddr = TilerMem_VirtToPhys ((Void *)mpuAddrList [0].mpuAddr);
        return status;
    }

    /* Open a handle to the ProcMgr instance. */
    status = ProcMgr_open (&procMgrHandle, procId);
    if (status < 0) {
        Osal_printf ("Error in ProcMgr_open [0x%x]\n", status);
    }
    else {
        /* FIX ME: Add Proc reserve call */
        status = ProcMgr_map (procMgrHandle, (UInt32)mpuAddrList [0].mpuAddr,
                        (UInt32)mpuAddrList [0].size, mappedAddr, &mappedSize,
                        memType, procId);
         /* FIX ME: Add the table that keeps the C-D translations */
        if (status < 0) {
            Osal_printf ("Error in ProcMgr_map [0x%x]\n", status);
        }
        else {
            status = ProcMgr_close (&procMgrHandle);
        }
    }

    return status;
}
Ejemplo n.º 9
0
/*
 *  ======== ipcSetup ========
 */
Int ipcSetup (Int testCase)
{
    Int                             status          = 0;
    Char *                          procName;
    UInt16                          procId;
    ProcMgr_AttachParams            attachParams;
    ProcMgr_State                   state;
#if !defined(SYSLINK_USE_DAEMON)
    UInt32                          entryPoint      = 0;
    ProcMgr_StartParams             startParams;
    Char                            uProcId;
    HeapBufMP_Params                heapbufmpParams;
#if defined(SYSLINK_USE_LOADER)
    Char                          * imageName;
    UInt32                          fileId;
#endif
#endif
    Ipc_Config                      config;
    Int                             i;
    UInt32                          srCount;
    SharedRegion_Entry              srEntry;

    Osal_printf ("ipcSetup: Setup IPC componnets \n");

    switch(testCase) {
    case 0:
        Osal_printf ("ipcSetup: Local RCM test\n");
        remoteServerName = RCMSERVER_NAME;
        procName = MPU_PROC_NAME;
        break;
    case 1:
        Osal_printf ("ipcSetup: RCM test with RCM client and server on "
                     "Sys M3\n\n");
        remoteServerName = SYSM3_SERVER_NAME;
        procName = SYSM3_PROC_NAME;
        break;
    case 2:
        Osal_printf ("ipcSetup: RCM test with RCM client and server on "
                     "App M3\n\n");
        remoteServerName = APPM3_SERVER_NAME;
        procName = APPM3_PROC_NAME;
        break;
    case 3:
        Osal_printf ("ipcSetup: RCM test with RCM client and server on "
                     "Tesla\n\n");
        remoteServerName = DSP_SERVER_NAME;
        procName = DSP_PROC_NAME;
        break;
    default:
        Osal_printf ("ipcSetup: Please pass valid arg "
                     "(0-local, 1-Sys M3, 2-App M3, 3-Tesla) \n");
        goto exit;
        break;
    }

    Ipc_getConfig (&config);
    status = Ipc_setup (&config);
    if (status < 0) {
        Osal_printf ("ipcSetup: Error in Ipc_setup [0x%x]\n", status);
        goto exit;
    }
    Osal_printf("Ipc_setup status [0x%x]\n", status);

    procId = ((testCase == 3) ? MultiProc_getId (DSP_PROC_NAME) : \
                                MultiProc_getId (SYSM3_PROC_NAME));
    remoteIdClient = MultiProc_getId (procName);

    /* Open a handle to the ProcMgr instance. */
    status = ProcMgr_open (&procMgrHandleClient, procId);
    if (status < 0) {
        Osal_printf ("ipcSetup: Error in ProcMgr_open [0x%x]\n", status);
        goto exit;
    }
    if (status >= 0) {
        Osal_printf ("ipcSetup: ProcMgr_open Status [0x%x]\n", status);
        ProcMgr_getAttachParams (NULL, &attachParams);
        /* Default params will be used if NULL is passed. */
        status = ProcMgr_attach (procMgrHandleClient, &attachParams);
        if (status < 0) {
            Osal_printf ("ipcSetup: ProcMgr_attach failed [0x%x]\n", status);
        }
        else {
            Osal_printf ("ipcSetup: ProcMgr_attach status: [0x%x]\n", status);
            state = ProcMgr_getState (procMgrHandleClient);
            Osal_printf ("ipcSetup: After attach: ProcMgr_getState\n"
                         "    state [0x%x]\n", state);
        }
    }

    if ((status >= 0) && (testCase == 2)) {
        status = ProcMgr_open (&procMgrHandleClient1, remoteIdClient);
        if (status < 0) {
            Osal_printf ("ipcSetup: Error in ProcMgr_open [0x%x]\n", status);
            goto exit;
        }
        if (status >= 0) {
            Osal_printf ("ipcSetup: ProcMgr_open Status [0x%x]\n", status);
            ProcMgr_getAttachParams (NULL, &attachParams);
            /* Default params will be used if NULL is passed. */
            status = ProcMgr_attach (procMgrHandleClient1, &attachParams);
            if (status < 0) {
                Osal_printf ("ipcSetup: ProcMgr_attach failed [0x%x]\n",
                                status);
            }
            else {
                Osal_printf ("ipcSetup: ProcMgr_attach status: [0x%x]\n",
                                status);
                state = ProcMgr_getState (procMgrHandleClient1);
                Osal_printf ("ipcSetup: After attach: ProcMgr_getState\n"
                             "    state [0x%x]\n", state);
            }
        }
    }

#if !defined(SYSLINK_USE_DAEMON) /* Daemon sets this up */
#if defined(SYSLINK_USE_LOADER)
    if (testCase == 1)
        imageName = RCM_MPUCLIENT_SYSM3ONLY_IMAGE;
    else if (testCase == 2)
        imageName = RCM_MPUCLIENT_SYSM3_IMAGE;
    else if (testCase == 3)
        imageName = RCM_MPUCLIENT_DSP_IMAGE;

    if (testCase != 0) {
        status = ProcMgr_load (procMgrHandleClient, imageName, 2, &imageName,
                                &entryPoint, &fileId, procId);
        if (status < 0) {
            Osal_printf ("ipcSetup: Error in ProcMgr_load %s image [0x%x]\n",
                            procName, status);
            goto exit;
        }
        Osal_printf ("ipcSetup: ProcMgr_load %s image Status [0x%x]\n",
                        procName, status);
    }
#endif /* defined(SYSLINK_USE_LOADER) */
    if (testCase != 0) {
        startParams.proc_id = procId;
        status = ProcMgr_start (procMgrHandleClient, entryPoint, &startParams);
        if (status < 0) {
            Osal_printf ("ipcSetup: Error in ProcMgr_start %s [0x%x]\n",
                            procName, status);
            goto exit;
        }
        Osal_printf ("ipcSetup: ProcMgr_start %s Status [0x%x]\n", procName,
                        status);
    }

    if (testCase == 2) {
#if defined(SYSLINK_USE_LOADER)
        imageName = RCM_MPUCLIENT_APPM3_IMAGE;
        uProcId = MultiProc_getId (APPM3_PROC_NAME);
        status = ProcMgr_load (procMgrHandleClient1, imageName, 2, &imageName,
                                &entryPoint, &fileId, uProcId);
        if (status < 0) {
            Osal_printf ("ipcSetup: Error in ProcMgr_load AppM3 image: "
                "[0x%x]\n", status);
            goto exit;
        }
        Osal_printf ("ipcSetup: AppM3: ProcMgr_load Status [0x%x]\n", status);
#endif /* defined(SYSLINK_USE_LOADER) */
        startParams.proc_id = MultiProc_getId (APPM3_PROC_NAME);
        status = ProcMgr_start (procMgrHandleClient1, entryPoint, &startParams);
        if (status < 0) {
            Osal_printf ("ipcSetup: Error in ProcMgr_start AppM3 [0x%x]\n",
                        status);
            goto exit;
        }
        Osal_printf ("ipcSetup: ProcMgr_start AppM3 Status [0x%x]\n", status);
    }
#endif /* defined(SYSLINK_USE_DAEMON) */

    srCount = SharedRegion_getNumRegions();
    Osal_printf ("SharedRegion_getNumRegions = %d\n", srCount);
    for (i = 0; i < srCount; i++) {
        status = SharedRegion_getEntry (i, &srEntry);
        Osal_printf ("SharedRegion_entry #%d: base = 0x%x len = 0x%x "
                        "ownerProcId = %d isValid = %d cacheEnable = %d "
                        "cacheLineSize = 0x%x createHeap = %d name = %s\n",
                        i, srEntry.base, srEntry.len, srEntry.ownerProcId,
                        (Int)srEntry.isValid, (Int)srEntry.cacheEnable,
                        srEntry.cacheLineSize, (Int)srEntry.createHeap,
                        srEntry.name);
    }

#if !defined(SYSLINK_USE_DAEMON) /* Daemon sets this up */
    /* Create Heap and register it with MessageQ */
    if (status >= 0) {
        HeapBufMP_Params_init (&heapbufmpParams);
        heapbufmpParams.sharedAddr = NULL;
        heapbufmpParams.align      = 128;
        heapbufmpParams.numBlocks  = 4;
        heapbufmpParams.blockSize  = MSGSIZE;
        heapSize = HeapBufMP_sharedMemReq (&heapbufmpParams);
        Osal_printf ("ipcSetup: heapSize = 0x%x\n", heapSize);

        srHeap = SharedRegion_getHeap (RCM_HEAP_SR);
        if (srHeap == NULL) {
            status = MEMORYOS_E_FAIL;
            Osal_printf ("ipcSetup: SharedRegion_getHeap failed for srHeap:"
                         " [0x%x]\n", srHeap);
        }
        else {
            Osal_printf ("ipcSetup: Before Memory_alloc = 0x%x\n", srHeap);
            heapBufPtr = Memory_alloc (srHeap, heapSize, 0);
            if (heapBufPtr == NULL) {
                status = MEMORYOS_E_MEMORY;
                Osal_printf ("ipcSetup: Memory_alloc failed for ptr: [0x%x]\n",
                             heapBufPtr);
            }
            else {
                heapbufmpParams.name           = RCM_MSGQ_HEAPNAME;
                heapbufmpParams.sharedAddr     = heapBufPtr;
                Osal_printf ("ipcSetup: Before HeapBufMP_Create: [0x%x]\n",
                                heapBufPtr);
                heapHandle = HeapBufMP_create (&heapbufmpParams);
                if (heapHandle == NULL) {
                    status = HeapBufMP_E_FAIL;
                    Osal_printf ("ipcSetup: HeapBufMP_create failed for Handle:"
                                 "[0x%x]\n", heapHandle);
                }
                else {
                    /* Register this heap with MessageQ */
                    status = MessageQ_registerHeap (heapHandle,
                                                    RCM_MSGQ_HEAPID);
                    if (status < 0) {
                        Osal_printf ("ipcSetup: MessageQ_registerHeap "
                                     "failed!\n");
                    }
                }
            }
        }
    }
#endif /* defined(SYSLINK_USE_DAEMON) */

exit:
    Osal_printf ("ipcSetup: Leaving ipcSetup()\n");
    return status;
}
Ejemplo n.º 10
0
/*
 *  ======== ipc_setup ========
 */
	Int ipc_setup()
	{
		SysMgr_Config config;
		ProcMgr_StopParams stopParams;
		ProcMgr_StartParams start_params;
		ProcMgr_Handle procMgrHandle_server;
		UInt32 entry_point = 0;
		UInt16 remoteIdSysM3;
		UInt16 remoteIdAppM3;
		UInt32 shAddrBase;
		UInt32 shAddrBase1;
		UInt16 procId;
#if defined (SYSLINK_USE_LOADER)
		Char uProcId;
		UInt32 fileId;
#endif
		Int status = 0;
		Bool appM3Client = FALSE;

		  SysMgr_getConfig(&config);
		  status = SysMgr_setup(&config);
		if (status < 0)
		{
			printf("Error in SysMgr_setup [0x%x]\n", status);
			goto exit;
		}

		/* Get MultiProc IDs by name. */
		remoteIdSysM3 = MultiProc_getId(SYSM3_PROC_NAME);
		printf("MultiProc_getId remoteId: [0x%x]\n", remoteIdSysM3);
		remoteIdAppM3 = MultiProc_getId(APPM3_PROC_NAME);
		printf("MultiProc_getId remoteId: [0x%x]\n", remoteIdAppM3);
		procId = remoteIdSysM3;
		printf("MultiProc_getId procId: [0x%x]\n", procId);

		printf("RCM procId= %d\n", procId);
		/* Open a handle to the ProcMgr instance. */
		status = ProcMgr_open(&procMgrHandle_server, procId);
		if (status < 0)
		{
			printf("Error in ProcMgr_open [0x%x]\n", status);
			goto exit_sysmgr_destroy;
		} else
		{
			printf("ProcMgr_open status [0x%x]\n", status);
			/* Get the address of the shared region in kernel space. */
			status = ProcMgr_translateAddr(procMgrHandle_server,
			    (Ptr) & shAddrBase,
			    ProcMgr_AddrType_MasterUsrVirt,
			    (Ptr) SHAREDMEM, ProcMgr_AddrType_SlaveVirt);
			if (status < 0)
			{
				printf
				    ("Error in ProcMgr_translateAddr [0x%x]\n",
				    status);
				goto exit_procmgr_close;
			} else
			{
				printf
				    ("Virt address of shared address base #1:"
				    " [0x%x]\n", shAddrBase);
			}

			if (status >= 0)
			{
				/* Get the address of the shared region in kernel space. */
				status =
				    ProcMgr_translateAddr
				    (procMgrHandle_server,
				    (Ptr) & shAddrBase1,
				    ProcMgr_AddrType_MasterUsrVirt,
				    (Ptr) SHAREDMEM1,
				    ProcMgr_AddrType_SlaveVirt);
				if (status < 0)
				{
					printf
					    ("Error in ProcMgr_translateAddr [0x%x]\n",
					    status);
					goto exit_procmgr_close;
				} else
				{
					printf
					    ("Virt address of shared address base #2:"
					    " [0x%x]\n", shAddrBase1);
				}
			}
		}
		if (status >= 0)
		{
			/* Add the region to SharedRegion module. */
			status = SharedRegion_add(SHAREDMEMNUMBER,
			    (Ptr) shAddrBase, SHAREDMEMSIZE);
			if (status < 0)
			{
				printf("Error in SharedRegion_add [0x%x]\n",
				    status);
				goto exit_procmgr_close;
			}
		}

		if (status >= 0)
		{
			/* Add the region to SharedRegion module. */
			status = SharedRegion_add(SHAREDMEMNUMBER1,
			    (Ptr) shAddrBase1, SHAREDMEMSIZE1);
			if (status < 0)
			{
				printf("Error in SharedRegion_add1 [0x%x]\n",
				    status);
				goto exit_procmgr_close;
			}
		}

		printf("IPC setup completed successfully!\n");
		return 0;

	      exit_procmgr_close:
		status = ProcMgr_close(&procMgrHandle_server);
		if (status < 0)
		{
			printf("Error in ProcMgr_close: status = 0x%x\n",
			    status);
		}

	      exit_sysmgr_destroy:
		status = SysMgr_destroy();
		if (status < 0)
		{
			printf("Error in SysMgr_destroy: status = 0x%x\n",
			    status);
		}
	      exit:
		return (-1);
	}
Ejemplo n.º 11
0
/*
 *  ======== ipcSetup ========
 */
static Int ipcSetup (Char * sysM3ImageName, Char * appM3ImageName)
{
    Ipc_Config                      config;
    ProcMgr_StopParams              stopParams;
    ProcMgr_StartParams             startParams;
    UInt32                          entryPoint = 0;
    UInt16                          procId;
    Int                             status = 0;
    ProcMgr_AttachParams            attachParams;
    ProcMgr_State                   state;
    HeapBufMP_Params                heapbufmpParams;
    Int                             i;
    UInt32                          srCount;
    SharedRegion_Entry              srEntry;

    if(appM3ImageName != NULL)
        appM3Client = TRUE;
    else
        appM3Client = FALSE;

    Ipc_getConfig (&config);
    status = Ipc_setup (&config);
    if (status < 0) {
        Osal_printf ("Error in Ipc_setup [0x%x]\n", status);
        goto exit;
    }

    /* Get MultiProc IDs by name. */
    remoteIdSysM3 = MultiProc_getId (SYSM3_PROC_NAME);
    Osal_printf ("MultiProc_getId remoteId: [0x%x]\n", remoteIdSysM3);
    remoteIdAppM3 = MultiProc_getId (APPM3_PROC_NAME);
    Osal_printf ("MultiProc_getId remoteId: [0x%x]\n", remoteIdAppM3);
    procId = remoteIdSysM3;
    Osal_printf ("MultiProc_getId procId: [0x%x]\n", procId);

    /* Temporary fix to account for a timing issue during recovery. */
    usleep(FAULT_RECOVERY_DELAY);

    printf("RCM procId= %d\n", procId);
    /* Open a handle to the ProcMgr instance. */
    status = ProcMgr_open (&procMgrHandleSysM3, procId);
    if (status < 0) {
        Osal_printf ("Error in ProcMgr_open [0x%x]\n", status);
        goto exit_ipc_destroy;
    }
    else {
        Osal_printf ("ProcMgr_open Status [0x%x]\n", status);
        ProcMgr_getAttachParams (NULL, &attachParams);
        /* Default params will be used if NULL is passed. */
        status = ProcMgr_attach (procMgrHandleSysM3, &attachParams);
        if (status < 0) {
            Osal_printf ("ProcMgr_attach failed [0x%x]\n", status);
        }
        else {
            Osal_printf ("ProcMgr_attach status: [0x%x]\n", status);
            state = ProcMgr_getState (procMgrHandleSysM3);
            Osal_printf ("After attach: ProcMgr_getState\n"
                         "    state [0x%x]\n", status);
        }
    }

    if (status >= 0 && appM3Client) {
        procId = remoteIdAppM3;
        Osal_printf ("MultiProc_getId procId: [0x%x]\n", procId);

        /* Open a handle to the ProcMgr instance. */
        status = ProcMgr_open (&procMgrHandleAppM3, procId);
        if (status < 0) {
            Osal_printf ("Error in ProcMgr_open [0x%x]\n", status);
            goto exit_ipc_destroy;
        }
        else {
            Osal_printf ("ProcMgr_open Status [0x%x]\n", status);
            ProcMgr_getAttachParams (NULL, &attachParams);
            /* Default params will be used if NULL is passed. */
            status = ProcMgr_attach (procMgrHandleAppM3, &attachParams);
            if (status < 0) {
                Osal_printf ("ProcMgr_attach failed [0x%x]\n", status);
            }
            else {
                Osal_printf ("ProcMgr_attach status: [0x%x]\n", status);
                state = ProcMgr_getState (procMgrHandleAppM3);
                Osal_printf ("After attach: ProcMgr_getState\n"
                             "    state [0x%x]\n", status);
            }
        }
    }

#if defined(SYSLINK_USE_LOADER)
    Osal_printf ("SysM3 Load: loading the SysM3 image %s\n",
                sysM3ImageName);

    status = ProcMgr_load (procMgrHandleSysM3, sysM3ImageName, 2,
                            &sysM3ImageName, &entryPoint, &fileIdSysM3,
                            remoteIdSysM3);
    if(status < 0) {
        Osal_printf ("Error in ProcMgr_load, status [0x%x]\n", status);
        goto exit_procmgr_close_sysm3;
    }
#endif
    startParams.proc_id = remoteIdSysM3;
    Osal_printf ("Starting ProcMgr for procID = %d\n", startParams.proc_id);
    status  = ProcMgr_start(procMgrHandleSysM3, entryPoint, &startParams);
    if(status < 0) {
        Osal_printf ("Error in ProcMgr_start, status [0x%x]\n", status);
        goto exit_procmgr_close_sysm3;
    }

    if(appM3Client) {
#if defined(SYSLINK_USE_LOADER)
        Osal_printf ("AppM3 Load: loading the AppM3 image %s\n",
                    appM3ImageName);
        status = ProcMgr_load (procMgrHandleAppM3, appM3ImageName, 2,
                              &appM3ImageName, &entryPoint, &fileIdAppM3,
                              remoteIdAppM3);
        if(status < 0) {
            Osal_printf ("Error in ProcMgr_load, status [0x%x]\n", status);
            goto exit_procmgr_stop_sysm3;
        }
#endif
        startParams.proc_id = remoteIdAppM3;
        Osal_printf ("Starting ProcMgr for procID = %d\n", startParams.proc_id);
        status  = ProcMgr_start(procMgrHandleAppM3, entryPoint,
                                &startParams);
        if(status < 0) {
            Osal_printf ("Error in ProcMgr_start, status [0x%x]\n", status);
            goto exit_procmgr_stop_sysm3;
        }
    }

    Osal_printf ("SysM3: Creating Ducati DMM pool of size 0x%x\n",
                DUCATI_DMM_POOL_0_SIZE);
    status = ProcMgr_createDMMPool (DUCATI_DMM_POOL_0_ID,
                                    DUCATI_DMM_POOL_0_START,
                                    DUCATI_DMM_POOL_0_SIZE,
                                    remoteIdSysM3);
    if(status < 0) {
        Osal_printf ("Error in ProcMgr_createDMMPool, status [0x%x]\n", status);
        goto exit_procmgr_stop_sysm3;
    }

    srCount = SharedRegion_getNumRegions();
    Osal_printf ("SharedRegion_getNumRegions = %d\n", srCount);
    for (i = 0; i < srCount; i++) {
        status = SharedRegion_getEntry (i, &srEntry);
        Osal_printf ("SharedRegion_entry #%d: base = 0x%x len = 0x%x "
                        "ownerProcId = %d isValid = %d cacheEnable = %d "
                        "cacheLineSize = 0x%x createHeap = %d name = %s\n",
                        i, srEntry.base, srEntry.len, srEntry.ownerProcId,
                        (Int)srEntry.isValid, (Int)srEntry.cacheEnable,
                        srEntry.cacheLineSize, (Int)srEntry.createHeap,
                        srEntry.name);
    }

    /* Create the heap to be used by RCM and register it with MessageQ */
    /* TODO: Do this dynamically by reading from the IPC config from the
     *       baseimage using Ipc_readConfig() */
    if (status >= 0) {
        HeapBufMP_Params_init (&heapbufmpParams);
        heapbufmpParams.sharedAddr = NULL;
        heapbufmpParams.align      = RCM_MSGQ_TILER_HEAP_ALIGN;
        heapbufmpParams.numBlocks  = RCM_MSGQ_TILER_HEAP_BLOCKS;
        heapbufmpParams.blockSize  = RCM_MSGQ_TILER_MSGSIZE;
        heapSize = HeapBufMP_sharedMemReq (&heapbufmpParams);
        Osal_printf ("heapSize = 0x%x\n", heapSize);

        srHeap = SharedRegion_getHeap (RCM_MSGQ_HEAP_SR);
        if (srHeap == NULL) {
            status = MEMORYOS_E_FAIL;
            Osal_printf ("SharedRegion_getHeap failed for srHeap:"
                         " [0x%x]\n", srHeap);
            goto exit_procmgr_stop_sysm3;
        }
        else {
            Osal_printf ("Before Memory_alloc = 0x%x\n", srHeap);
            heapBufPtr = Memory_alloc (srHeap, heapSize, 0);
            if (heapBufPtr == NULL) {
                status = MEMORYOS_E_MEMORY;
                Osal_printf ("Memory_alloc failed for ptr: [0x%x]\n",
                             heapBufPtr);
                goto exit_procmgr_stop_sysm3;
            }
            else {
                heapbufmpParams.name           = RCM_MSGQ_TILER_HEAPNAME;
                heapbufmpParams.sharedAddr     = heapBufPtr;
                Osal_printf ("Before HeapBufMP_Create: [0x%x]\n", heapBufPtr);
                heapHandle = HeapBufMP_create (&heapbufmpParams);
                if (heapHandle == NULL) {
                    status = HeapBufMP_E_FAIL;
                    Osal_printf ("HeapBufMP_create failed for Handle:"
                                 "[0x%x]\n", heapHandle);
                    goto exit_procmgr_stop_sysm3;
                }
                else {
                    /* Register this heap with MessageQ */
                    status = MessageQ_registerHeap (heapHandle,
                                                    RCM_MSGQ_TILER_HEAPID);
                    if (status < 0) {
                        Osal_printf ("MessageQ_registerHeap failed!\n");
                        goto exit_procmgr_stop_sysm3;
                    }
                }
            }
        }
    }

    if (status >= 0) {
        HeapBufMP_Params_init (&heapbufmpParams);
        heapbufmpParams.sharedAddr = NULL;
        heapbufmpParams.align      = RCM_MSGQ_DOMX_HEAP_ALIGN;
        heapbufmpParams.numBlocks  = RCM_MSGQ_DOMX_HEAP_BLOCKS;
        heapbufmpParams.blockSize  = RCM_MSGQ_DOMX_MSGSIZE;
        heapSize1 = HeapBufMP_sharedMemReq (&heapbufmpParams);
        Osal_printf ("heapSize1 = 0x%x\n", heapSize1);

        heapBufPtr1 = Memory_alloc (srHeap, heapSize1, 0);
        if (heapBufPtr1 == NULL) {
            status = MEMORYOS_E_MEMORY;
            Osal_printf ("Memory_alloc failed for ptr: [0x%x]\n",
                         heapBufPtr1);
            goto exit_procmgr_stop_sysm3;
        }
        else {
            heapbufmpParams.name           = RCM_MSGQ_DOMX_HEAPNAME;
            heapbufmpParams.sharedAddr     = heapBufPtr1;
            Osal_printf ("Before HeapBufMP_Create: [0x%x]\n", heapBufPtr1);
            heapHandle1 = HeapBufMP_create (&heapbufmpParams);
            if (heapHandle1 == NULL) {
                status = HeapBufMP_E_FAIL;
                Osal_printf ("HeapBufMP_create failed for Handle:"
                             "[0x%x]\n", heapHandle1);
                goto exit_procmgr_stop_sysm3;
            }
            else {
                /* Register this heap with MessageQ */
                status = MessageQ_registerHeap (heapHandle1,
                                                RCM_MSGQ_DOMX_HEAPID);
                if (status < 0) {
                    Osal_printf ("MessageQ_registerHeap failed!\n");
                    goto exit_procmgr_stop_sysm3;
                }
            }
        }
    }

    Osal_printf ("=== SysLink-IPC setup completed successfully!===\n");
    return 0;

exit_procmgr_stop_sysm3:
    stopParams.proc_id = remoteIdSysM3;
    status = ProcMgr_stop (procMgrHandleSysM3, &stopParams);
    if (status < 0) {
        Osal_printf ("Error in ProcMgr_stop(%d): status = 0x%x\n",
            stopParams.proc_id, status);
    }

exit_procmgr_close_sysm3:
    status = ProcMgr_close (&procMgrHandleSysM3);
    if (status < 0) {
        Osal_printf ("Error in ProcMgr_close: status = 0x%x\n", status);
    }
exit_ipc_destroy:
    status = Ipc_destroy ();
    if (status < 0) {
        Osal_printf ("Error in Ipc_destroy: status = 0x%x\n", status);
    }

exit:
    return (-1);
}
/*
 *  ======== procCreate ========
 */
static Bool procCreate(Processor_Handle proc)
{
    Int status = 0;
    Bool retVal;
    ProcMgr_AttachParams attachParams;
    ProcMgr_StartParams  startParams;
    ProcMgr_State        state;
    ProcMgr_AddrInfo     CMEMAddrInfo;
    HeapBufMP_Params heapP;
    CMEM_BlockAttrs cmemBlockAttrs;
    Int blockNum;
    Int nCMEMBlocks;
    Bool createAndRegisterHeap;
    Int16 heapId;
    UInt16 regionId;
    UInt32 numMsgs;
    UInt32 msgSize;
    Char heapName[32];

    Log_print1(Diags_ENTRY, "[+E] Processor_create_d> Enter(proc=0x%x)",
            (IArg)proc);

    /* Create and initialize the PROC object */
    Log_print1(Diags_USER2, "[+2] Processor_create_d> "
    "Retrieving CPU ID for '%s'...", (IArg)(proc->attrs.cpuId));

    proc->cpuId = Processor_getCoreId(proc->attrs.cpuId);
    if (proc->cpuId < 0) {
        Log_print1(Diags_USER7, "[+7] Processor_create_d> "
               "Processor_getCoreId() failed: %d", proc->cpuId);
        goto fail;
    }

    /* Open DSP ProcMgr */
    Log_print2(Diags_USER2, "[+2] Processor_create_d> "
           "Opening %s ProcMgr for cpuId %d...",
           (IArg)proc->attrs.cpuId, proc->cpuId);
    status = ProcMgr_open(&proc->procMgrH, proc->cpuId);

    if (status < 0) {
        Log_print1(Diags_USER7, "[+7] Processor_create_d> "
               "ProcMgr_open() failed: %d", (IArg)status);
        goto fail;
    }

    /* Attach the DSP */
    Log_print1(Diags_USER2, "[+2] Processor_create_d> "
           "Attaching to %s...", (IArg)proc->attrs.cpuId);

    if (proc->useExtLoader == FALSE) {
        /* We load the slave */
        ProcMgr_getAttachParams(NULL, &attachParams);
        status = ProcMgr_attach(proc->procMgrH, &attachParams);
        if (status < 0) {
            Log_print1(Diags_USER7, "[+7] Processor_create_d> "
                    "ProcMgr_attach() failed: %d", (IArg)status);
            goto fail;
        }

        /* Map slave memory */
        if (!mapByFile(proc->procMgrH, proc->memMapName, proc->cpuId, TRUE)) {
            Log_print0(Diags_USER6, "Processor_create_d> mapByFile() failed!");
        }

        /* Load the executable on the DSP */
        Log_print3(Diags_USER2, "[+2] Processor_create_d> "
                "Loading %s on %s (%d args)...",
                (IArg)(proc->imageName), (IArg)(proc->attrs.cpuId),
                (IArg)(proc->attrs.argc));

        status = ProcMgr_load(proc->procMgrH, proc->imageName,
                proc->attrs.argc, proc->attrs.argv, NULL, &proc->fileId);
        if (status < 0) {
            Log_print1(Diags_USER7, "[+7] Processor_create_d> "
                    "ProcMgr_load() failed: %d", status);
            goto fail;
        }

        /* temporary: to be done by SysLink in the future */
        Log_print0(Diags_USER1, "[+2] Processor_create_d> "
                "calling Ipc_control(LOADCALLBACK)...");
        status = Ipc_control(proc->cpuId, Ipc_CONTROLCMD_LOADCALLBACK, NULL);
        Log_print1(Diags_USER1, "[+2] Processor_create_d> "
                "Ipc_control(LOADCALLBACK) status: %d", (IArg)status);

        /* Start execution on DSP */
        Log_print1(Diags_USER2, "[+2] Processor_create_d> Starting %s ...",
                (IArg)proc->attrs.cpuId);

        ProcMgr_getStartParams(proc->procMgrH, &startParams);
        status = ProcMgr_start(proc->procMgrH, &startParams);
        if (status < 0) {
            Log_print1(Diags_USER7, "Processor_create_d> "
                    "ProcMgr_start() failed: %d", status);
            goto fail;
        }
    } // if (proc->useExtLoader == FALSE)
    else {
        /* Check the state of the processor to make sure it's really running */
        state = ProcMgr_getState(proc->procMgrH);
        if (state != ProcMgr_State_Running) {
            Log_print1(Diags_USER7, "Processor_create_d> Invalid processor "
                    "state [%d].", state);
            goto fail;
        }

        Log_print0(Diags_USER1, "[+2] Processor_create_d> "
                "calling Ipc_control(LOADCALLBACK)...");
        status = Ipc_control(proc->cpuId, Ipc_CONTROLCMD_LOADCALLBACK, NULL);
        proc->loadCallBackStatus = status;
        Log_print1(Diags_USER1, "[+2] Processor_create_d> "
                "Ipc_control(LOADCALLBACK) status: %d", (IArg)status);

        if (status < 0) {
            Log_print1(Diags_USER7, "Processor_create_d> "
                    "Ipc_control(LOADCALLBACK) failed: %d", status);
            goto fail;
        }
    }

    status = Ipc_control(proc->cpuId, Ipc_CONTROLCMD_STARTCALLBACK, NULL);
    proc->startCallBackStatus = status;
    Log_print1(Diags_USER1, "[+2] Processor_create_d> "
            "Ipc_control(STARTCALLBACK) status: %d", (IArg)status);
    if (status < 0) {
        Log_print1(Diags_USER7, "Processor_create_d> "
                "Ipc_control(STARTCALLBACK) failed: %d", status);
        goto fail;
    }


    /* get user-specified heapId */
    heapId = perCoreHeapId(proc->cpuId);
    createAndRegisterHeap = FALSE;

    if (heapId == Processor_INVALID) {
        /* runtime validation of user configuration */
        if (perCoreUserCreatedHeapFlag(proc->cpuId) == TRUE ||
                perCoreNumMsgs(proc->cpuId) != Processor_INVALID ||
                perCoreMsgSize(proc->cpuId) != Processor_INVALID ||
                perCoreSharedRegionId(proc->cpuId) != Processor_INVALID) {

            Log_print1(Diags_USER7, "[+7] Processor_create_d> "
                    "Invalid heap configuration for core %d: "
                    "attempting to set other Processor_CommDesc "
                    "elements while Processor_CommDesc.heapId is "
                    "undefined",
                    proc->cpuId);

            goto fail;
        }

        /* will return default heapId since user didn't specify */
        heapId = Processor_getHeapId(proc->cpuId);

        if (defaultHeapRefCount++ == 0) {
            createAndRegisterHeap = TRUE;

            /* tell code below to record heapH in defaultHeapH */
            defaultHeapH = (HeapBufMP_Handle)-1;
        }
    }
    else {
        if (perCoreUserCreatedHeapFlag(proc->cpuId) == FALSE) {
            createAndRegisterHeap = TRUE;
        }
    }

    if (createAndRegisterHeap) {
        /* create a heap for message queue usage */

        /* get either user-config'ed or module default */
        numMsgs = Processor_getNumMsgs(proc->cpuId);
        msgSize = Processor_getMsgSize(proc->cpuId);
        regionId = Processor_getSharedRegionId(proc->cpuId);

        HeapBufMP_Params_init(&heapP);
        heapP.numBlocks = numMsgs;
        heapP.blockSize = msgSize;
        heapP.sharedAddr = NULL;
        heapP.regionId = regionId;
        if (defaultHeapH == (HeapBufMP_Handle)-1) {
            sprintf(heapName, "CE-default");
        }
        else {
            sprintf(heapName, "CE<->Svr%d", proc->cpuId);
        }
        heapP.name = heapName;

        Log_print2(Diags_USER1, "[+2] Processor_create_d> "
                "calling HeapBufMP_create(): nblocks %d, blocksize 0x%x",
                heapP.numBlocks, heapP.blockSize);

        proc->heapH = HeapBufMP_create(&heapP);

        if (proc->heapH == NULL) {
            Log_print0(Diags_USER7, "[+7] Processor_create_d> "
                    "HeapBufMP_create failed");
            goto fail;
        }

        if (defaultHeapH == (HeapBufMP_Handle)-1) {
            /* we've just created the module default heap singleton */
            defaultHeapH = proc->heapH;
        }

        /* register this heap with MessageQ */
        Log_print2(Diags_USER1, "[+2] Processor_create_d> "
                "MessageQ_registerHeap(heapH: 0x%x, heapId: %d)",
                (IArg)(proc->heapH), (IArg)heapId);

        if (MessageQ_registerHeap((Ptr)(proc->heapH), heapId) !=
                    MessageQ_S_SUCCESS) {
        Log_print1(Diags_USER7, "[+7] Processor_create_d> "
                "MessageQ_registerHeap() failed for heapId %d", heapId);

        goto fail;
        }
    }
    else {
        /*
         *  createAndRegisterHeap == FASLE
         *  If using the default heap, need to set proc->heapH for use by
         *  procDelete().
         */
        if (heapId == Processor_defaultHeapId) {
            proc->heapH = defaultHeapH;
        }
    }

    proc->heapId = heapId;

    blockNum = 0;
    nCMEMBlocks = 0;
    status = CMEM_getNumBlocks(&nCMEMBlocks);
    if (status != 0) {
        Log_print1(Diags_USER2, "[+2] Processor_create_d> "
                "CMEM_getNumBlocks() failed, not registering: %d",
                status);
    }

    while (blockNum < nCMEMBlocks) {
        status = CMEM_getBlockAttrs(blockNum, &cmemBlockAttrs);
        if (status != 0) {
            Log_print2(Diags_USER7, "[+7] Processor_create_d> "
                    "CMEM_getBlockAttrs(%d) failed: %d",
                    blockNum, status);

            goto fail;
        }

        CMEMAddrInfo.addr[ProcMgr_AddrType_MasterPhys] =
                cmemBlockAttrs.phys_base;
        CMEMAddrInfo.addr[ProcMgr_AddrType_SlaveVirt] =
                cmemBlockAttrs.phys_base;
        CMEMAddrInfo.size = cmemBlockAttrs.size;
        CMEMAddrInfo.isCached = FALSE;

        Log_print3(Diags_USER1, "[+1] Processor_create_d> CMEM block "
                "#%d found, doing ProcMgr_map(0x%x, 0x%x)...", blockNum,
                (IArg)cmemBlockAttrs.phys_base,
                (IArg)cmemBlockAttrs.size);

        status = ProcMgr_map(proc->procMgrH, ProcMgr_SLAVEVIRT, &CMEMAddrInfo,
                ProcMgr_AddrType_MasterPhys);
        if (status < 0) {
            Log_print1(Diags_USER7, "[+7] Processor_create_d> "
                    "ProcMgr_map() failed: %d", status);
            goto fail;
        }

        if (CMEMAddrInfo.addr[ProcMgr_AddrType_SlaveVirt] !=
                cmemBlockAttrs.phys_base) {
            Log_print2(Diags_USER1, "[+2] Processor_create_d> "
                    "mapped CMEM slave virtual address 0x%x doesn't "
                    "match expected value 0x%x",
                    CMEMAddrInfo.addr[ProcMgr_AddrType_SlaveVirt],
                    cmemBlockAttrs.phys_base);
        }

        blockNum++;
    }

    if (Global_getenv("CE_DSPDEBUG") != NULL) {
        printf("Codec Engine system message (b/c CE_DSPDEBUG=1) : %s image "
               "loaded and started, press Enter to continue: ",
               proc->attrs.cpuId);
        getchar();
    }

    retVal = TRUE;
    goto procCreate_return;

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

fail:
    Log_print3(Diags_USER7, "[+7] Processor_create_d> "
            "Loading and starting %s server '%s' FAILED, status=[0x%x]",
            (IArg)proc->attrs.cpuId, (IArg)proc->imageName, status);

    procDelete(proc);

    retVal = FALSE;

procCreate_return:

    Log_print1(Diags_USER2, "[+2] Processor_create_d> return (%d)",
            (IArg)retVal);

    return (retVal);
}
Ejemplo n.º 13
0
/*!
 *  @brief  Function to execute the startup for ProcMgrApp sample application
 */
Int
ProcMgrApp_startup (UInt16 procId)
{
    Int                          status = 0;
    ProcMgr_Handle               handle = NULL;
    ProcMgr_AttachParams         attachParams;
    ProcMgr_State                state;
    UInt32 resetVector = 0x00800000;

    PRINTF ("Entered ProcMgrApp_startup\n");

    status = ProcMgr_open (&handle, procId);

    if (status >= 0) {
        ProcMgr_getAttachParams (NULL, &attachParams);
        /* Default params will be used if NULL is passed. */

        attachParams.bootMode = ProcMgr_BootMode_NoBoot;
        /* set the boot mode */
        status = ProcMgr_attach (handle, &attachParams);
        if (status < 0) {
        	PRINTF ("ProcMgr_attach failed [0x%x]\n", status);
        }
        else {
            PRINTF ("ProcMgr_attach status: [0x%x]\n", status);
            state = ProcMgr_getState (handle);
            PRINTF ("After attach: ProcMgr_getState\n"
                         "    state [0x%x]\n",
                         state);

			/* Call Ipc_control for ProcMgr_BootMode_NoLoad_Pwr, ProcMgr_BootMode_NoLoad_NoPwr
			   and ProcMgr_BootMode_NoBoot modes */
			status = Ipc_control (procId,
								  Ipc_CONTROLCMD_LOADCALLBACK,
								  (Ptr)&resetVector);

            if (status < 0) {
                PRINTF ("Error in Ipc_control "
                             "Ipc_CONTROLCMD_LOADCALLBACK [0x%x]\n",
                             status);
            }
            else {
                state = ProcMgr_getState (handle);
                PRINTF ("After Ipc_loadcallback: ProcMgr_getState\n"
                             "    state [0x%x]\n",
                             state);
            }
        }

        if (status >= 0) {

            status = Ipc_control (procId,
                                  Ipc_CONTROLCMD_STARTCALLBACK,
                                  NULL);
            if (status < 0) {
                PRINTF ("Error in Ipc_control "
                             "Ipc_CONTROLCMD_STARTCALLBACK[0x%x]\n",
                             status);
            }
            else {
                state = ProcMgr_getState (handle);
                PRINTF ("After Ipc_startcallback: ProcMgr_getState\n"
                             "    state [0x%x]\n",
                             state);
            }
        }

        status = ProcMgr_close (&handle);
        PRINTF ("ProcMgr_close status: [0x%x]\n", status);
    }

    PRINTF ("Leaving ProcMgrApp_startup\n");

    return 0;
}
Ejemplo n.º 14
0
/*!
 *  @brief      This function implements the interrupt service routine for the
 *              interrupt received from the remote cores.
 *
 *  @param      refData       object to be handled in ISR
 *
 *  @sa         VirtQueue_cb
 */
static
Bool
VirtQueue_ISR (UInt32 msg, Void * arg)
{
    UInt32 procId = (UInt32)arg;
    ProcMgr_Handle handle = NULL;
    Int status = 0;

    GT_2trace (curTrace, GT_ENTER, "_VirtQueue_ISR", msg, arg);

        /* Interrupt clear is done by ArchIpcInt. */

        switch(msg) {
            case (UInt)RP_MBOX_ECHO_REPLY:
                Osal_printf ("Echo reply from %s",
                             MultiProc_getName(procId));
                break;

            case (UInt)RP_MBOX_CRASH:
                Osal_printf ("Crash notification for %s",
                             MultiProc_getName(procId));
                status = ProcMgr_open(&handle, procId);
                if (status >= 0) {
                    ProcMgr_setState(handle, ProcMgr_State_Error);
                    ProcMgr_close(&handle);
                }
                else {
                    Osal_printf("Failed to open ProcMgr handle");
                }
                break;

            case (UInt)RP_MBOX_BOOTINIT_DONE:
                Osal_printf ("Got BootInit done from %s",
                             MultiProc_getName(procId));
                // TODO: What to do with this message?
                break;

            case (UInt)RP_MBOX_HIBERNATION_ACK:
                Osal_printf ("Got Hibernation ACK from %s",
                             MultiProc_getName(procId));
                break;

            case (UInt)RP_MBOX_HIBERNATION_CANCEL:
                Osal_printf ("Got Hibernation CANCEL from %s",
                             MultiProc_getName(procId));
                break;

            default:
                /*
                 *  If the message isn't one of the above, it's a virtqueue
                 *  message
                 */
                if (msg%2 < NUM_QUEUES) {
                    /* This message is for us! */
                    VirtQueue_cb((void *)msg, queueRegistry[procId][msg%2]);
                }
            break;
        }

    return TRUE;
}