示例#1
0
/*
 *  ======== 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;
}
示例#2
0
static Int dvsdk_grapx_display_rpc_remote_mode_init ()
{
   RcmClient_Params  rcmClientParams;
   IArg key;
   Bool doInit = FALSE;
   Int status = 0;
   
   key = Gate_enterSystem();
   if (FALSE == g_RemoteStubContext.bRemoteInitDone) {
     doInit = TRUE;
   }
   Gate_leaveSystem(key);
  
   if (TRUE == doInit) {
       GateThread_Params gtParams;
    
    GateThread_Params_init (&gtParams);
       g_RemoteStubContext.hGate = GateThread_Handle_upCast(GateThread_create(&gtParams, NULL));
    key = GateH_enter (g_RemoteStubContext.hGate);
    
    MessageQ_registerHeap(SharedRegion_getHeap(0),Global_GrpxDssMsgHeapId);
    RcmClient_Params_init (&rcmClientParams);
    rcmClientParams.heapId = Global_GrpxDssMsgHeapId;
    do {
      status = RcmClient_create(DVSDK_DSS_GRPX_SERVER_NAME,
                      &rcmClientParams,
                  &g_RemoteStubContext.hRcmClient);
    if (status < 0) {
      Thread_yield(NULL);
    }
       } while (status < 0);
       if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_INIT_FXN_NAME,
                                          &g_RemoteStubContext.nInitFxnIdx);
    }
       if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_START_FXN_NAME,
                                          &g_RemoteStubContext.nStartFxnIdx);
    }
       if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_STOP_FXN_NAME,
                                          &g_RemoteStubContext.nStopFxnIdx);
    }
    if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_DEINIT_FXN_NAME,
                                          &g_RemoteStubContext.nDeinitFxnIdx);
    }
    if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_DISPLAYTOGGLE_FXN_NAME,
                                          &g_RemoteStubContext.nDisplayToggelFxnIdx);
    }
    g_RemoteStubContext.bRemoteInitDone = TRUE;
    GateH_leave(g_RemoteStubContext.hGate, key);
   }
   return status;   
}
	Int main(Int argc, Char * argv[])
	{
		pid_t child_pid, child_sid;
		int status;
		RcmClient_Config cfgParams;
		RcmClient_Params rcmParams;
		char cServerName[] = { "RSrv_Ducati1" };
		RcmClient_Handle rcmHndl = NULL;


		cfgParams.maxNameLen = 20;
		cfgParams.defaultHeapIdArrayLength = 4;

		printf("Spawning TILER server daemon...\n");

		/* Fork off the parent process */
		child_pid = fork();
		if (child_pid < 0)
		{
			printf("Spawn daemon failed!\n");
			exit(EXIT_FAILURE);	/* Failure */
		}
		/* If we got a good PID, then we can exit the parent process. */
		if (child_pid > 0)
		{
			exit(EXIT_SUCCESS);	/* Succeess */
		}

		/* Change file mode mask */
		umask(0);

		/* Create a new SID for the child process */
		child_sid = setsid();
		if (child_sid < 0)
			exit(EXIT_FAILURE);	/* Failure */

		/* Change the current working directory */
		if ((chdir("/")) < 0)
		{
			exit(EXIT_FAILURE);	/* Failure */
		}

		status = ipc_setup();
		if (status < 0)
		{
			printf("\nipc_setup failed\n");
			goto leave;
		}
		//Create default RCM client.
		RcmClient_getConfig(&cfgParams);
		printf("\nPrinting Config Parameters\n");
		printf("\nMaxNameLen %d\nHeapIdArrayLength %d\n",
		    cfgParams.maxNameLen, cfgParams.defaultHeapIdArrayLength);

		printf("\nRPC_InstanceInit: creating rcm instance\n");

		RcmClient_Params_init(NULL, &rcmParams);

		rcmParams.heapId = 1;
		printf("\n Heap ID configured : %d\n", rcmParams.heapId);

		printf("\nCalling client setup\n");
		status = RcmClient_setup(&cfgParams);
		printf("\nClient setup done\n");
		if (status < 0)
		{
			printf("Client  exist.Error Code:%d\n", status);
			goto leave;
		}

		while (rcmHndl == NULL)
		{
			printf
			    ("\nCalling client create with server name = %s\n",
			    cServerName);
			status =
			    RcmClient_create(cServerName, &rcmParams,
			    &rcmHndl);
			printf("\nClient create done\n");

			if (status < 0)
			{
				printf("\nCannot Establish the connection\n");
				goto leave;
			} else
			{
				printf("\nConnected to Server\n");
			}

		}
		//To ensure that it is always running
		while (1)
		{
		}
	      leave:
		return 0;
	}
/*
 *  ======== Hello_exec ========
 */
Int Hello_exec(Void)
{
    RcmClient_Params    rcmP;
    RcmClient_Handle    rcmH;
    RcmClient_Message * msg;
    UInt32              size;
    Int                 status;


    /* must initialize the module before using it */
    RcmClient_init();

    /* create an rcm client instance */
    RcmClient_Params_init(&rcmP);
    rcmP.heapId = Global_RcmClientHeapId;

    /* retry in case the slave is still booting */
    do {
        status = RcmClient_create(Global_RcmServerName, &rcmP, &rcmH);
    } while (status == RcmClient_E_SERVERNOTFOUND);

    if (status < 0) {
        Log_error0("Hello_exec: RcmClient create failed");
        goto leave;
    }

    /* allocate a remote command message */
    size = sizeof(RcmClient_Message) + sizeof(UInt32[32]);
    status = RcmClient_alloc(rcmH, size, &msg);

    if (status < 0) {
        msg = NULL;
        Log_error1("Hello_exec: RcmClient_alloc() returned error %d",
            (IArg)status);
        goto leave;
    }

    /* fill in the remote command message */
    msg->fxnIdx = Global_Hello_idx;
    msg->data[0] = (UInt32)0xFFFFFFFF;
    System_sprintf((Char *)(&msg->data[1]), "@@@@"); 

    /* execute the remote command message */
    status = RcmClient_exec(rcmH, msg, &msg);

    if (status < 0) {
        Log_error1("Hello_exec: RcmClient_exec() returned error %d",
            (IArg)status);
        goto leave;
    }

    /* unmarshal return value */
    System_printf("%s\n", (Char *)(&msg->data[1]));

leave:
    /* return message to the heap */
    if (msg != NULL) {
        RcmClient_free(rcmH, msg);
        msg = NULL;
    }

    /* delete the rcm client instance */
    if (rcmH != NULL) {
        RcmClient_delete(&rcmH);
    }

    /* finalize the module to support clean shutdown */
    RcmClient_exit();

    return(status);
}