Ejemplo n.º 1
0
/*
  one child operation
 */
static void child_op(struct child_struct *child, const char *opname,
		     const char *fname, const char *fname2, 
		     char **params, const char *status)
{
	static struct dbench_op prev_op;
	struct dbench_op op;
	unsigned i;

	child->lasttime = timeval_current();

	ZERO_STRUCT(op);
	op.child = child;
	op.op = opname;
	op.fname = fname;
	op.fname2 = fname2;
	op.status = status;
	for (i=0;i<sizeof(op.params)/sizeof(op.params[0]);i++) {
		switch (params[i][0]) {
		case '*':
		case '+':
			op.params[i] = parse_special(params[i], prev_op.params[i]);
			break;
		default:
			op.params[i] = params[i]?ival(params[i]):0;
		}
	}

	prev_op = op;

	if (strcasecmp(op.op, "Sleep") == 0) {
		nb_sleep(op.params[0]);
		return;
	}

	for (i=0;nb_ops->ops[i].name;i++) {
		if (strcasecmp(op.op, nb_ops->ops[i].name) == 0) {
			nb_ops->ops[i].fn(&op);
			finish_op(child, &child->ops[i]);
			return;
		}
	}

	printf("[%u] Unknown operation %s in pid %u\n", 
	       child->line, op.op, (unsigned)getpid());
}
Ejemplo n.º 2
0
void i2cman_handler()
{
	ROM_I2CMasterIntClear(I2C_PORT);
	
	if(current_op == end || current_op == 0)
		return; // do absolutely nothing (irq may be called after aborting)
	
	uint32_t error = finish_op(current_op);
	if(error != I2C_MASTER_ERR_NONE)
	{
		stop();
		if(error & I2C_MASTER_ERR_ARB_LOST)
		{
			if(error_func)
				error_func(I2C_ARBLOST);
		}
		else
		{
			// error, abort completely
			//kill_op(current_op);
			// bad bad bad!
			if(error_func)
				error_func(I2C_NOACK);
		}
		return;
	}
	
	current_op ++;
	
	if(current_op == end)
	{
		stop(); // all done
		if(success_func)
			success_func();
		return;
	}
	
	// otherwise, process the next op
	start_op(current_op);
}