Beispiel #1
0
cfw_handle_t system_setup(T_QUEUE *q, handle_msg_cb_t cb, void *cb_data)
{
	cfw_handle_t handle;

	/* Initialize OS abstraction */
	os_init();

	/* Setup IPC and main queue */
	*q = ipc_setup();

	/* General hardware setup function, pass the ipc message handler if you
	 * want to use this feature. */
	soc_setup(ipc_handle_message);

	/* start Quark watchdog */
	wdt_start(WDT_MAX_TIMEOUT_MS);

	/* USB setup */
	usb_app_setup();

	/* Start log infrastructure */
	log_start(log_backend_uart);

	/* Enable test command engine async support through the main queue */
	tcmd_async_init(*q);
	/* Test commands will use the same port as the log system */
	set_tcmd_uart_port(CONFIG_UART_CONSOLE_INDEX);

	/* Component framework and services setup */
	handle = cfw_setup(*q, cb, NULL);
	pr_info(LOG_MODULE_MAIN, "cfw init done");

	/* Initialize ARC shared structure and start it. */
	shared_data->ports = port_get_port_table();
	shared_data->services = services;
	shared_data->service_mgr_port_id = cfw_get_service_mgr_port_id();
	start_arc(0);

	return handle;
}
	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;
	}