/* * ======== MpuRcmServerTest ======== */ Int MpuRcmServerTest (Int testCase) { Int status = 0; Osal_printf ("MpuRcmServerTest: Testing RCM server on MPU\n"); status = ipcSetup1 (testCase); if (status < 0) { Osal_printf ("MpuRcmServerTest: ipcSetup failed, status [0x%x]\n"); goto exit; } StartRcmServerTestThread (testCase); /* Wait until signaled to delete the rcm server */ Osal_printf ("MpuRcmServerTest: Wait for server thread completion.\n"); sem_wait (&mainThreadWait); pthread_join (thread, NULL); status = RcmServerCleanup (testCase); if (status < 0) Osal_printf ("MpuRcmServerTest: Error in RcmServerCleanup \n"); exit: Osal_printf ("MpuRcmServerTest: Leaving MpuRcmServerTest()\n"); 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; }
/*! * @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; }
/** print usage and exit */ static Void printUsageExit (Char * app) { Osal_printf ("%s: [-h] [-l logfile] [-f]\n", app); Osal_printf (" -h Show this help message.\n"); Osal_printf (" -l Select log file to write. (\"stdout\" can be used for" "terminal output.)\n"); Osal_printf (" -f Run in foreground. (Do not fork daemon process.)\n"); exit (EXIT_SUCCESS); }
/** ============================================================================ * Functions * ============================================================================ */ Void printUsage (Void) { Osal_printf ("Usage: ./slpmresources.out [<TestNo>]\n"); Osal_printf ("\tValid Values:\n\t\tTestNo: 1 or 2 (default = 1)\n"); Osal_printf ("\tExamples:\n"); Osal_printf ("\t\t./slpmresources.out 1: MessageQ sample with SysM3\n"); Osal_printf ("\t\t./slpmresources.out 2: MessageQ sample with AppM3\n"); return; }
/*! * @brief Linux driver function to finalize the driver module. */ static void __exit SyslinkMemMgrDrv_finalizeModule (void) { Osal_printf ("Entered SyslinkMemMgrDrv_finalizeModule\n"); SyslinkMemMgrDrv_unregisterDriver (&(SyslinkMemMgrDrv_osalDrvHandle)); /* Finalize the OsalDriver */ OsalDriver_destroy (); Osal_printf ("Leaving SyslinkMemMgrDrv_finalizeModule\n"); }
/*! * @brief Linux driver function to finalize the driver module. */ static void __exit NameServerDrv_finalizeModule (void) { Osal_printf ("Entered NameServerDrv_finalizeModule\n"); NameServerDrv_unregisterDriver (&(NameServerDrv_osalDrvHandle)); /* Finalize the OsalDriver */ OsalDriver_destroy (); Osal_printf ("Leaving NameServerDrv_finalizeModule\n"); }
/* * ======== signal_handler ======== */ static Void signal_handler (Int sig) { pthread_t self = pthread_self (); if (pthread_equal (self, sysM3EvtHandlerThrd)) { Osal_printf ("\n** SysLink Daemon: SysM3 thread exiting...\n "); } else if (pthread_equal (self, appM3EvtHandlerThrd)) { Osal_printf ("\n** SysLink Daemon: AppM3 thread exiting...\n "); } else { Osal_printf ("\n** SysLink Daemon: Exiting due to KILL command...\n"); sem_post (&semDaemonWait); } }
/*! * @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; }
/* * ======== sysM3EventHandler ======== */ static Void sysM3EventHandler (Void) { Int status = PROCMGR_E_FAIL; UInt index; Int size; ProcMgr_EventType eventList [] = {PROC_MMU_FAULT, PROC_ERROR, PROC_WATCHDOG}; size = (sizeof (eventList)) / (sizeof (ProcMgr_EventType)); status = ProcMgr_waitForMultipleEvents (PROC_SYSM3, eventList, size, -1, &index); if (status == PROCMGR_SUCCESS) { if (eventList [index] == PROC_MMU_FAULT) { Osal_printf ("\nMMU Fault occured on the M3 subsystem. See crash " "dump for more details...\n"); } else if (eventList [index] == PROC_ERROR) { Osal_printf ("\nSysError occured on SysM3. See crash dump for more " "details...\n"); } else { Osal_printf ("\nWatchDog fired on the M3 subsystem.\n"); } if ((eventList [index] == PROC_MMU_FAULT) || (eventList [index] == PROC_ERROR)) { /* Dump Crash Info */ exceptionDumpRegisters (); } /* Initiate cleanup */ isSysM3Event = TRUE; restart = TRUE; sem_post (&semDaemonWait); } else { if (errno == EINTR) { Osal_printf ("SysM3 Event Handler Thread %s\n", strerror(errno)); } else { Osal_printf ("SysM3 Event Handler Thread block failed 0x%x\n", status); isSysM3Event = TRUE; /* Post the semaphore to terminate the parent process */ sem_post (&semDaemonWait); } } }
/*! * @brief Function to execute the startup for loader sample application * * @sa */ Int loader_startup (Void) { Int i; Int status = 0; for (i = 0; i < loader_numProcessors; i++) { Osal_printf ("Loading and starting procId [%d] with [%s]\n", loader_procId[i] , loader_filePath[i] ); status = ProcMgrApp_startup (loader_procId[i], loader_filePath[i]); Osal_printf ("ProcMgrApp_startup status [%d]\n", status); } return (status); }
int main (int argc, char ** argv) { Int status = 0; //ServiceMgr_Config serviceMgrConfig; Int i, j; /* * Must be at least one set of procId and outfile. So argc cannot be odd */ if ((argc < 3) || (argc / 2 * 2 == argc) || (argc > 7)) { Osal_printf ("uiaDemo <procId> <outfile> [<procId> <outfile>] [<procId> <outfile>]\n"); return (-1); } for (i = 0, j = 1 ; i < argc/2; i++, j = j + 2) { uiaDemo_procId[i] = strtol (argv [j], NULL, 16); uiaDemo_filePath[i] = argv [j + 1]; uiaDemo_numProcessors++; } Osal_printf ("Running on %d processors\n", uiaDemo_numProcessors); Osal_printf ("Calling SysLink_setup\n"); SysLink_setup (); Osal_printf ("Calling uiaDemo_startup\n"); status = uiaDemo_startup (); /* write to a binary file instead of sending out over Ethernet */ //ServiceMgr_getConfig (&serviceMgrConfig); //strcpy(serviceMgrConfig.fileName, "eventDump"); //status = ServiceMgr_setConfig (&serviceMgrConfig); //Osal_printf ("ServiceMgr_setConfig status = [0x%x]\n", status); Osal_printf ("Calling ServiceMgr_start\n"); ServiceMgr_start(); Osal_printf ("Calling uiaDemo_execute\n"); status = uiaDemo_execute (); Osal_printf ("Calling ServiceMgr_stop\n"); ServiceMgr_stop(); Osal_printf ("Calling uiaDemo_shutdown\n"); status = uiaDemo_shutdown (); Osal_printf ("Calling SysLink_destroy\n"); SysLink_destroy (); return (0); }
/*! * @brief Function to execute the shutdown for loader sample application * * @sa */ Int loader_shutdown (Void) { Int i; Int status = 0; for (i = 0; i < loader_numProcessors; i++) { status = Notify_sendEvent(loader_procId[i], 0, SHUTDOWN, 0, FALSE); Osal_printf ("Notify_sendEvent status [%d]\n", status); } for (i = 0; i < loader_numProcessors; i++) { /* shutdown the logic one by one for each processor */ status = ProcMgrApp_shutdown(loader_procId[i]); Osal_printf ("ProcMgrApp_shutdown status [%d]\n", status); } return (status); }
/* * ======== fxnExit ======== */ Int32 fxnExit (UInt32 dataSize, UInt32 *data) { Int status = 0; Osal_printf ("Executing Remote Function fxnExit \n"); sem_post (&serverThreadSync); return status; }
Int loader_execute (Void) { Int status = 0; Char ch; Osal_printf ("\nOpen DVT and start getting events! [hit enter to shutdown the demo]\n"); ch = getchar(); return (status); }
/* * ======== RunServerTestThread ======== * RCM server test thread function */ Void StartRcmServerTestThread (Int testCase) { sem_init (&mainThreadWait, 0, 0); /* Create the server thread */ Osal_printf ("StartRcmServerThread: Create server thread.\n"); pthread_create (&thread, NULL, (Void *)&RcmServerThreadFxn, (Void *) testCase); return; }
/* * ======== TestExec ======== */ Int TestExec (Void) { Int status = 0; Int loop; RcmClient_Message * rcmMsg = NULL; RcmClient_Message * returnMsg = NULL; UInt rcmMsgSize; RCM_Remote_FxnArgs * fxnDoubleArgs; Osal_printf ("\nTestExec: Testing exec API\n"); for (loop = 1; loop <= LOOP_COUNT; loop++) { /* Allocate a remote command message */ rcmMsgSize = sizeof(RCM_Remote_FxnArgs); Osal_printf ("TestExec: calling RcmClient_alloc \n"); rcmMsg = NULL; status = RcmClient_alloc (rcmClientHandle, rcmMsgSize, &rcmMsg); if (status < 0) { Osal_printf ("TestExec: Error allocating RCM message\n"); goto exit; } /* Fill in the remote command message */ rcmMsg->fxnIdx = fxnDoubleIdx; fxnDoubleArgs = (RCM_Remote_FxnArgs *)(&rcmMsg->data); fxnDoubleArgs->a = loop; /* Execute the remote command message */ Osal_printf ("TestExec: calling RcmClient_exec \n"); status = RcmClient_exec (rcmClientHandle, rcmMsg, &returnMsg); if (status < 0) { Osal_printf ("TestExec: RcmClient_exec error, status = " "[0x%x].\n", status); goto exit; } fxnDoubleArgs = (RCM_Remote_FxnArgs *)(&(returnMsg->data)); Osal_printf ("TestExec: called fxnDouble(%d)), result = %d\n", fxnDoubleArgs->a, returnMsg->result); /* Return message to the heap */ Osal_printf ("TestExec: calling RcmClient_free \n"); RcmClient_free (rcmClientHandle, returnMsg); returnMsg = NULL; } exit: Osal_printf ("TestExec: Leaving TestExec()\n"); return status; }
/* * ======== GetSymbolIndex ======== */ Int GetSymbolIndex (Void) { Int status = 0; /* Get remote function index */ Osal_printf ("\nGetSymbolIndex: Querying server for fxnDouble() function " "index \n"); status = RcmClient_getSymbolIndex (rcmClientHandle, "fxnDouble", &fxnDoubleIdx); if (status < 0) Osal_printf ("GetSymbolIndex: Error getting fxnDouble symbol index" "[0x%x]\n", status); else Osal_printf ("GetSymbolIndex: fxnDouble() symbol index [0x%x]\n", fxnDoubleIdx); Osal_printf ("GetSymbolIndex: Querying server for fxnExit() function " "index \n"); status = RcmClient_getSymbolIndex (rcmClientHandle, "fxnExit", &fxnExitIdx); if (status < 0) Osal_printf ("GetSymbolIndex: Error getting fxnExit symbol index" " [0x%x]\n", status); else Osal_printf ("GetSymbolIndex: fxnExit() symbol index [0x%x]\n", fxnExitIdx); return status; }
/* * ======== main ======== */ Int main (Int argc, Char * argv []) { Int status = 0; Int testNo; Int subTestNo; Osal_printf ("\n== RCM Client or Server Sample ==\n"); if (argc < 3) { printUsage (); goto exit; } testNo = atoi (argv[1]); subTestNo = atoi (argv[2]); if ((testNo < 1 || testNo > 3) || (subTestNo != 1 && subTestNo != 2)) { printUsage (); goto exit; } /* Run RCM client test */ if(subTestNo == 1) { Osal_printf ("RCM Client sample invoked\n"); status = MpuRcmClientTest (testNo); if (status < 0) { Osal_printf ("Error in RCM Client sample\n"); } } /* Run RCM server test */ if(subTestNo == 2) { Osal_printf ("RCM Server sample invoked\n"); status = MpuRcmServerTest (testNo); if (status < 0) Osal_printf ("Error in RCM Server sample\n"); } exit: Osal_printf ("\n== Sample End ==\n"); /* Trace for TITAN support */ if (status < 0) Osal_printf ("test_case_status=%d\n", status); else Osal_printf ("test_case_status=0\n"); return status; }
/* * ======== fxnDouble ======== */ Int32 fxnDouble (UInt32 dataSize, UInt32 *data) { RCM_Remote_FxnDoubleArgs * args; Int a; Int result; args = (RCM_Remote_FxnDoubleArgs *)data; a = args->a; result = a * 2; Osal_printf ("Executed Remote Function fxnDouble, result = %d\n", result); return result; }
static Void printUsage (Void) { Osal_printf ("\nInvalid arguments!\n" "Usage: ./syslink_daemon.out [-f] <[-s] <SysM3 image file>> " "[<[-a] <AppM3 image file>>]\n" "Rules: - Full paths must be provided for image files.\n" " - Use '-f' option to run as a regular process.\n" " - Images can be specified in any order as long as\n" " the corresponding option is specified.\n" " - All images not preceded by an option are applied\n" " to the cores whose images are not already\n" " specified in the order of SysM3, AppM3\n\n"); exit (EXIT_FAILURE); }
/*! * @brief This is the worker thread which polls for events. * * @param attrs module attributes * * @sa */ Void _NotifyDrvUsr_eventWorker (Void * arg) { Int32 status = Notify_S_SUCCESS; UInt32 nRead = 0; NotifyDrv_EventPacket packet; sigset_t blockSet; GT_1trace (curTrace, GT_ENTER, "_NotifyDrvUsr_eventWorker", arg); if (sigfillset (&blockSet) != 0) { perror ("Event worker thread error in sigfillset"); pthread_exit (NULL); } if (pthread_sigmask (SIG_BLOCK, &blockSet, NULL) != 0) { perror ("Event worker thread error in setting sigmask"); pthread_exit (NULL); } while (status >= 0) { memset (&packet, 0, sizeof (NotifyDrv_EventPacket)); packet.pid = getpid (); nRead = read (IpcDrv_handle, &packet, sizeof (NotifyDrv_EventPacket)); if (nRead == sizeof (NotifyDrv_EventPacket)) { /* check for termination packet */ if (packet.isExit == TRUE) { pthread_exit (NULL); } if (packet.func != NULL) { packet.func (packet.procId, packet.lineId, packet.eventId, packet.param, packet.data); } } else if (nRead == -1) { Osal_printf("_NotifyDrvUsr_eventWorker: nRead returned -1\n"); break; } } GT_0trace (curTrace, GT_LEAVE, "_NotifyDrvUsr_eventWorker"); }
/* * ======== MpuRcmClientTest ======== */ Int MpuRcmClientTest(Int testCase) { Int status = 0; Osal_printf ("MpuRcmClientTest: Testing RCM Client on MPU\n"); status = ipcSetup (testCase); if (status < 0) { Osal_printf ("MpuRcmClientTest: ipcSetup failed, status [0x%x]\n"); goto exit; } status = CreateRcmClient (testCase); if (status < 0) { Osal_printf ("MpuRcmClientTest: Error in creating RcmClient \n"); goto exit; } status = GetSymbolIndex (); if (status < 0) { Osal_printf ("MpuRcmClientTest: Error in GetSymbolIndex \n"); goto exit; } status = TestExec (); if (status < 0) { Osal_printf ("MpuRcmClientTest: Error in TestExec \n"); goto exit; } /* status = TestExecDpc (); if (status < 0) { Osal_printf ("MpuRcmClientTest: Error in TestExecDpc \n"); goto exit; } status = TestExecNoWait (); if (status < 0) { Osal_printf ("MpuRcmClientTest: Error in TestExecNoWait \n"); goto exit; } */ status = RcmClientCleanup (testCase); if (status < 0) Osal_printf ("MpuRcmClientTest: Error in RcmClientCleanup \n"); exit: Osal_printf ("MpuRcmClientTest: Leaving MpuRcmClientTest()\n"); return status; }
/*! * @brief Function to retrieve physical address of given a remote * Processor's virtual address. * * Return value of less than or equal to zero * indicates the translation failure * * @param remoteAddr The slave's address * @param physAddr Translated physical address. * @param procId Remote Processor Id. * * @sa SysLinkMemUtils_virtToPhysPages */ Int SysLinkMemUtils_virtToPhys (UInt32 remoteAddr, UInt32 * physAddr, ProcMgr_ProcId procId) { /* FIX ME: Hack for Tiler */ if (remoteAddr >= TILER_ADDRESS_START && remoteAddr <= TILER_ADDRESS_END) { *physAddr = remoteAddr; printf("Translated Address = 0x%x\n", remoteAddr); return PROCMGR_SUCCESS; } else { Osal_printf("NON-TILER ADDRESS TRANSLATIONS NOT SUPPORTED" "remoteAddr = 0x%x\n",remoteAddr ); return PROCMGR_E_FAIL; } }
/*! * ======== VirtQueue_create ======== */ VirtQueue_Handle VirtQueue_create (VirtQueue_callback callback, UInt16 procId, UInt16 id, UInt32 vaddr, UInt32 paddr, UInt32 num, UInt32 align, Void *arg) { VirtQueue_Object *vq = NULL; vq = Memory_alloc(NULL, sizeof(VirtQueue_Object), 0, NULL); if (!vq) { return (NULL); } vq->callback = callback; vq->id = id; numQueues++; vq->procId = procId; vq->intId = coreIntId[procId]; vq->last_avail_idx = 0; vq->arg = arg; /* init the vring */ vring_init(&(vq->vring), num, (void *)vaddr, align); vq->num_free = num; vq->last_used_idx = 0; vq->vaddr = vaddr; vq->paddr = paddr; vq->vring.avail->idx = 0; vq->vring.used->idx = 0; /* Initialize the flags */ vq->vring.avail->flags = 0; vq->vring.used->flags = 0; /* Store the VirtQueue locally */ if (queueRegistry[procId][vq->id%2] == NULL) queueRegistry[procId][vq->id%2] = vq; else { Osal_printf ("VirtQueue ID %d already created", id); Memory_free(NULL, vq, sizeof(VirtQueue_Object)); vq = NULL; } return (vq); }
Void printUsage (Void) { Osal_printf ("Usage: ./rcm_singletest.out <Test#> <Sub Test#>\n" "Options:\n"); Osal_printf ("\t./rcm_singletest.out 1 1 : " "MPU RCM Client <--> SysM3 RCM Server\n"); Osal_printf ("\t./rcm_singletest.out 1 2 : " "MPU RCM Server <--> SysM3 RCM Client\n"); Osal_printf ("\t./rcm_singletest.out 2 1 : " "MPU RCM Client <--> AppM3 RCM Server\n"); Osal_printf ("\t./rcm_singletest.out 2 2 : " "MPU RCM Server <--> AppM3 RCM Client\n"); Osal_printf ("\t./rcm_singletest.out 3 1 : " "MPU RCM Client <--> Tesla RCM Server\n"); Osal_printf ("\t./rcm_singletest.out 3 2 : " "MPU RCM Server <--> Tesla RCM Client\n"); return; }
int main (int argc, char ** argv) { Int status = 0; Int i, j; /* * Must be at least one set of procId and outfile. So argc cannot be odd */ if ((argc < 3) || (argc / 2 * 2 == argc) || (argc > 7)) { Osal_printf ("uiaDaemon <procId> <outfile> [<procId> <outfile>] [<procId> <outfile>]\n"); return (-1); } for (i = 0, j = 1 ; i < argc/2; i++, j = j + 2) { loader_procId[i] = strtol (argv [j], NULL, 16); loader_filePath[i] = argv [j + 1]; loader_numProcessors++; } Osal_printf ("Running on %d processors\n", loader_numProcessors); Osal_printf ("Calling SysLink_setup\n"); SysLink_setup (); Osal_printf ("Calling loader_startup\n"); status = loader_startup (); Osal_printf ("Calling loader_execute\n"); status = loader_execute (); Osal_printf ("Calling loader_shutdown\n"); status = loader_shutdown (); Osal_printf ("Calling SysLink_destroy\n"); SysLink_destroy (); return (0); }
/*! * @brief Module initialization function for Linux driver. */ static int __init SyslinkMemMgrDrv_initializeModule (Void) { int result = 0; /* Display the version info and created date/time */ Osal_printf ("SyslinkMemMgr sample module created on Date:%s Time:%s\n", __DATE__, __TIME__); Osal_printf ("SyslinkMemMgrDrv_initializeModule\n"); /* Enable/disable levels of tracing. */ if (TRACE != NULL) { Osal_printf ("Trace enable %s\n", TRACE) ; SyslinkMemMgrDrv_enableTrace = simple_strtol (TRACE, NULL, 16); if ( (SyslinkMemMgrDrv_enableTrace != 0) && (SyslinkMemMgrDrv_enableTrace != 1)) { Osal_printf ("Error! Only 0/1 supported for TRACE\n") ; } else if (SyslinkMemMgrDrv_enableTrace == TRUE) { curTrace = GT_TraceState_Enable; } else if (SyslinkMemMgrDrv_enableTrace == FALSE) { curTrace = GT_TraceState_Disable; } } if (TRACEENTER != NULL) { Osal_printf ("Trace entry/leave prints enable %s\n", TRACEENTER) ; SyslinkMemMgrDrv_enableTraceEnter = simple_strtol (TRACEENTER, NULL, 16); if ( (SyslinkMemMgrDrv_enableTraceEnter != 0) && (SyslinkMemMgrDrv_enableTraceEnter != 1)) { Osal_printf ("Error! Only 0/1 supported for TRACEENTER\n") ; } else if (SyslinkMemMgrDrv_enableTraceEnter == TRUE) { curTrace |= GT_TraceEnter_Enable; } } if (TRACEFAILURE != NULL) { Osal_printf ("Trace SetFailureReason enable %s\n", TRACEFAILURE) ; SyslinkMemMgrDrv_enableTraceFailure = simple_strtol (TRACEFAILURE, NULL, 16); if ( (SyslinkMemMgrDrv_enableTraceFailure != 0) && (SyslinkMemMgrDrv_enableTraceFailure != 1)) { Osal_printf ("Error! Only 0/1 supported for TRACEENTER\n") ; } else if (SyslinkMemMgrDrv_enableTraceFailure == TRUE) { curTrace |= GT_TraceSetFailure_Enable; } } if (TRACECLASS != NULL) { Osal_printf ("Trace class %s\n", TRACECLASS) ; SyslinkMemMgrDrv_traceClass = simple_strtol (TRACECLASS, NULL, 16); if ( (SyslinkMemMgrDrv_enableTraceFailure != 1) && (SyslinkMemMgrDrv_enableTraceFailure != 2) && (SyslinkMemMgrDrv_enableTraceFailure != 3)) { Osal_printf ("Error! Only 1/2/3 supported for TRACECLASS\n") ; } else { SyslinkMemMgrDrv_traceClass = SyslinkMemMgrDrv_traceClass << (32 - GT_TRACECLASS_SHIFT); curTrace |= SyslinkMemMgrDrv_traceClass; } } Osal_printf ("curTrace value: 0x%x\n", curTrace); /* Initialize the OsalDriver */ OsalDriver_setup (); SyslinkMemMgrDrv_osalDrvHandle = SyslinkMemMgrDrv_registerDriver (); if (SyslinkMemMgrDrv_osalDrvHandle == NULL) { /*! @retval MEMMGR_E_OSFAILURE Failed to register SyslinkMemMgr driver with OS! */ result = -EFAULT; GT_setFailureReason (curTrace, GT_4CLASS, "SyslinkMemMgrDrv_initializeModule", MEMMGR_E_OSFAILURE, "Failed to register SyslinkMemMgr driver with OS!"); } Osal_printf ("SyslinkMemMgrDrv_initializeModule 0x%x\n", result); return result; }
/* * ======== CreateRcmClient ======== */ Int CreateRcmClient(Int testCase) { RcmClient_Params rcmClientParams; Int count = 0; Int status = 0; /* Size (in bytes) of RCM header including the messageQ header */ /* RcmClient_Message member data[1] is the start of the payload */ Osal_printf ("CreateRcmClient: Size of RCM header in bytes = %d \n", RcmClient_getHeaderSize()); /* Rcm client module setup*/ Osal_printf ("CreateRcmClient: RCM Client module setup.\n"); RcmClient_init (); /* Rcm client module params init*/ Osal_printf ("CreateRcmClient: RCM Client module params init.\n"); status = RcmClient_Params_init (&rcmClientParams); if (status < 0) { Osal_printf ("CreateRcmClient: Error in RCM Client instance params " "init \n"); goto exit; } Osal_printf ("CreateRcmClient: RCM Client instance params init " "passed \n"); /* Create an rcm client instance */ Osal_printf ("CreateRcmClient: Creating RcmClient instance \n"); rcmClientParams.callbackNotification = 0; /* disable asynchronous exec */ rcmClientParams.heapId = RCM_MSGQ_HEAPID; while ((rcmClientHandle == NULL) && (count++ < MAX_CREATE_ATTEMPTS)) { status = RcmClient_create (remoteServerName, &rcmClientParams, &rcmClientHandle); if (status < 0) { if (status == RcmClient_E_SERVERNOTFOUND) { Osal_printf ("CreateRcmClient: Unable to open remote" "server %d time \n", count); } else { Osal_printf ("CreateRcmClient: Error in RCM Client " "create \n"); goto exit; } } } if (MAX_CREATE_ATTEMPTS <= count) { Osal_printf ("CreateRcmClient: Timeout... could not connect with" "remote server\n"); } else { Osal_printf ("CreateRcmClient: RCM Client create passed \n"); } exit: Osal_printf ("CreateRcmClient: Leaving CreateRcmClient() \n"); return status; }
/* * ======== RcmClientCleanup ======== */ Int RcmClientCleanup (Int testCase) { Int status = 0; RcmClient_Message * rcmMsg = NULL; RcmClient_Message * returnMsg = NULL; UInt rcmMsgSize; RCM_Remote_FxnArgs * fxnExitArgs; #if !defined(SYSLINK_USE_DAEMON) ProcMgr_StopParams stopParams; #endif Osal_printf ("\nRcmClientCleanup: Entering RcmClientCleanup()\n"); /* Send terminate message */ /* Allocate a remote command message */ rcmMsgSize = sizeof(RCM_Remote_FxnArgs); status = RcmClient_alloc (rcmClientHandle, rcmMsgSize, &rcmMsg); if (status < 0) { Osal_printf ("RcmClientCleanup: Error allocating RCM message\n"); goto exit; } /* Fill in the remote command message */ rcmMsg->fxnIdx = fxnExitIdx; fxnExitArgs = (RCM_Remote_FxnArgs *)(&rcmMsg->data); fxnExitArgs->a = 0xFFFF; #if !defined(SYSLINK_USE_DAEMON) /* Execute the remote command message */ Osal_printf ("RcmClientCleanup: calling RcmClient_execDpc \n"); status = RcmClient_execDpc (rcmClientHandle, rcmMsg, &returnMsg); if (status < 0) { Osal_printf ("RcmClientCleanup: RcmClient_execDpc error [0x%x]\n", status); goto exit; } #endif /* !defined(SYSLINK_USE_DAEMON) */ /* Return message to the heap */ Osal_printf ("RcmClientCleanup: Calling RcmClient_free \n"); RcmClient_free (rcmClientHandle, returnMsg); /* Delete the rcm client */ Osal_printf ("RcmClientCleanup: Delete RCM client instance \n"); status = RcmClient_delete (&rcmClientHandle); if (status < 0) Osal_printf ("RcmClientCleanup: Error in RCM Client instance delete" " [0x%x]\n", status); else Osal_printf ("RcmClientCleanup: RcmClient_delete status: [0x%x]\n", status); /* Rcm client module destroy */ Osal_printf ("RcmClientCleanup: Destroy RCM client module \n"); RcmClient_exit (); /* Finalize modules */ #if !defined(SYSLINK_USE_DAEMON) // Do not call ProcMgr_stop if using daemon status = MessageQ_unregisterHeap (RCM_MSGQ_HEAPID); if (status < 0) Osal_printf ("RcmClientCleanup: Error in MessageQ_unregisterHeap" " [0x%x]\n", status); else Osal_printf ("RcmClientCleanup: MessageQ_unregisterHeap status:" " [0x%x]\n", status); if (heapHandle) { status = HeapBufMP_delete (&heapHandle); if (status < 0) Osal_printf ("RcmClientCleanup: Error in HeapBufMP_delete [0x%x]\n", status); else Osal_printf ("RcmClientCleanup: HeapBufMP_delete status: [0x%x]\n", status); } if (heapBufPtr) { Memory_free (srHeap, heapBufPtr, heapSize); } stopParams.proc_id = remoteIdClient; if (testCase == 2) { status = ProcMgr_stop(procMgrHandleClient1, &stopParams); if (status < 0) Osal_printf ("RcmClientCleanup: Error in ProcMgr_stop [0x%x]\n", status); else Osal_printf ("RcmClientCleanup: ProcMgr_stop status: [0x%x]\n", status); stopParams.proc_id = MultiProc_getId (SYSM3_PROC_NAME); } status = ProcMgr_stop(procMgrHandleClient, &stopParams); if (status < 0) Osal_printf ("RcmClientCleanup: Error in ProcMgr_stop [0x%x]\n", status); else Osal_printf ("RcmClientCleanup: ProcMgr_stop status: [0x%x]\n", status); #endif if (testCase == 2) { status = ProcMgr_detach (procMgrHandleClient1); Osal_printf ("RcmClientCleanup: ProcMgr_detach status [0x%x]\n", status); status = ProcMgr_close (&procMgrHandleClient1); if (status < 0) Osal_printf ("RcmClientCleanup: Error in ProcMgr_close [0x%x]\n", status); else Osal_printf ("RcmClientCleanup: ProcMgr_close status: [0x%x]\n", status); } status = ProcMgr_detach (procMgrHandleClient); Osal_printf ("RcmClientCleanup: ProcMgr_detach status [0x%x]\n", status); status = ProcMgr_close (&procMgrHandleClient); if (status < 0) Osal_printf ("RcmClientCleanup: Error in ProcMgr_close [0x%x]\n", status); else Osal_printf ("RcmClientCleanup: ProcMgr_close status: [0x%x]\n", status); status = Ipc_destroy (); if (status < 0) Osal_printf("RcmClientCleanup: Error in Ipc_destroy [0x%x]\n", status); else Osal_printf("RcmClientCleanup: Ipc_destroy status: [0x%x]\n", status); exit: Osal_printf ("RcmClientCleanup: Leaving RcmClientCleanup()\n"); return status; }