Пример #1
0
static void mat_mul_demo(void)
{
	while (1) {
		void *data;
		int len;

		/* wait for data... */
		buffer_pull(&data, &len);

		/* Process incoming message/data */
		if (*(int *)data == SHUTDOWN_MSG) {
			/* disable interrupts and free resources */
			remoteproc_resource_deinit(proc);

			break;
		} else {
			env_memcpy(matrix_array, data, len);

			/* Process received data and multiple matrices. */
			Matrix_Multiply(&matrix_array[0], &matrix_array[1], &matrix_result);

			/* Send result back */
			if (RPMSG_SUCCESS != rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix))) {
				xil_printf("Error: rpmsg_send failed\n");
			}
		}
	}
}
Пример #2
0
static void mat_mul_demo(void *unused_arg)
{
	int status = 0;

	(void)unused_arg;

	/* Create buffer to send data between RPMSG callback and processing task */
	buffer_create();

	/* Initialize HW and SW components/objects */
	init_system();

	/* Resource table needs to be provided to remoteproc_resource_init() */
	rsc_info.rsc_tab = (struct resource_table *)&resources;
	rsc_info.size = sizeof(resources);

	/* Initialize OpenAMP framework */
	status = remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
								 rpmsg_channel_deleted, rpmsg_read_cb,
								 &proc);
	if (RPROC_SUCCESS != status) {
		xil_printf("Error: initializing OpenAMP framework\n");
		return;
	}

	/* Stay in data processing loop until we receive a 'shutdown' message */
	while (1) {
		void *data;
		int len;

		/* wait for data... */
		buffer_pull(&data, &len);

		/* Process incoming message/data */
		if (*(int *)data == SHUTDOWN_MSG) {
			/* disable interrupts and free resources */
			remoteproc_resource_deinit(proc);

			/* Terminate this task */
			vTaskDelete(NULL);
			break;
		} else {
			env_memcpy(matrix_array, data, len);

			/* Process received data and multiple matrices. */
			Matrix_Multiply(&matrix_array[0], &matrix_array[1], &matrix_result);

			/* Send result back */
			if (RPMSG_SUCCESS != rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix))) {
				xil_printf("Error: rpmsg_send failed\n");
			}
		}
	}
}
Пример #3
0
/**
 * Entry point into dsui logging thread. The parameter
 * must be a struct logging_thread
 *
 * @param param void by pthread convention, but must be an
 * initialized struct logging_thread
 * @retval NULL in all cases
 */
static void *logging_thread_run(void *param)
{
	struct logging_thread *self;
	int retval;
	sigset_t mask;

	/* Calling function in dsui.c and we pass the pid of this thread
	 * we do this so that when we do discovery we would be able to
	 * identify the logging thread that is being forked off by DSUI
	 */

	// FIXME: 
	// Bad way to get the thread id.
	set_logging_thread_pid(syscall(SYS_gettid));
	
	self = (struct logging_thread *)param;
//	task_alias_add_alias(0, "dskid");

	/* We don't want to handle signals */
	sigfillset(&mask);
	if ((retval = pthread_sigmask(SIG_BLOCK, &mask, NULL))) {
		kusp_errno("pthread_sigmask", retval);
	}

	log_debug("Logging thread started, PID=%d\n", gettid());
	log_debug("Logging entities to file '%s'.\n", self->filename);

	while (1) {
		struct dstrm_buffer *buffer;
		size_t size;
		void *data;

		km_mutex_lock(&self->queue.lock);

		while (self->queue.num_buffers == 0) {

			if (!self->running) {
				km_mutex_unlock(&self->queue.lock);
				goto finished;
			}
			log_debug("logging thread going to sleep\n");
			km_cond_wait(&self->queue.cond, &self->queue.lock);
			log_debug("logging thread woke up, %d buffers to write\n",
					self->queue.num_buffers);
		}
		buffer = __buffer_queue_dequeue(&self->queue);

		km_mutex_unlock(&self->queue.lock);

		size = buffer_size(buffer);
		data = buffer_pull(buffer, size);

		log_debug("Pulling %d bytes of data off buffer %d\n",
				size, buffer->page_num);

		logging_thread_write(self, data, size);

		release_buffer(buffer);

	}
finished:


	if (close(self->fd)) {
		kusp_errno("close", errno);
	}

	self->fd = -1;

	log_debug("Logging thread exiting.\n");


	return NULL;
}