Exemplo n.º 1
0
Arquivo: server.c Projeto: rongc5/test
static void child_work(int numth, Prolib_t *lib)
{
    while (1)
    {
        set_process_status(numth, lib, IDLE);
        p(lib[numth].semid, lib[numth].semid_index);
        set_process_status(numth, lib, RUNNING);
        lib[numth].func((void *)&lib[numth].sokFd);
        increase_job_times(lib + numth);
    }
}
Exemplo n.º 2
0
/**
 * @brief ioctl communicaton function
 *        communicaton with application
 * @param data passed from application memory space
 *
 * @return communicaton status
 */
static long driver_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
{
	int ret = 0;
	uint32_t mess;

	switch (cmd){
	case SET_IMAGE_STATUS:
		
		if (copy_from_user(&mess, (void __user *)arg, sizeof(unsigned int)))
			return COMMUNICATION_ERROR;

		/* Send message to nios */
		ret = mbox_send_message(chan_sender, (void *)&mess);
		pr_info("%s image is sent to nios, size: %d", __func__, mess);

		if (ret < 0)
			pr_info("Message 1 failure\n");

		set_process_status(PROCESS_START);
		if(__put_user(ret, (unsigned int __user *)arg))
				return COMMUNICATION_ERROR;
		break;

	case GET_IMAGE_STATUS:
		mess = get_process_status();
		/*
		 * Return image status
		 * If process_status is 0,
		 * Nios did not finish to process the last request
		 */
		if(__put_user(mess, (unsigned int __user *)arg))
			return COMMUNICATION_ERROR;
		break;
	default:
		break;
	}

	return ret;
}