Exemplo n.º 1
0
static void do_next(client_ctx *cx)
{
	int new_state;

	ASSERT(cx->state != s_dead);
	switch (cx->state) {
	case s_read_size:
		new_state = do_read_size(cx);
		break;
	case s_read_request:
		new_state = do_read_request(cx);
		break;
	case s_process_request:
	case s_write_response:
		new_state = do_write_response(cx);
		break;
	case s_almost_dead_0:
	case s_almost_dead_1:
		new_state = do_almost_dead(cx);
		break;
	default:
		UNREACHABLE();
	}
	cx->state = new_state;

	if (cx->state == s_dead) {
		if (DEBUG_CHECKS) {
			memset(cx, -1, sizeof(*cx));
		}
		free(cx);
	}
}
Exemplo n.º 2
0
static int do_read_size(client_ctx *cx)
{
	conn *incoming;	
	uint8_t *data;
	size_t size;
	
	incoming = &cx->incoming;

	if (incoming->result < 0) {
		pr_err("read error: %s", uv_strerror(incoming->result));
		return do_kill(cx);
	}

	data = (uint8_t *)incoming->buf;
	size = (size_t)incoming->offset;

	if (size >= 2) {
		incoming->req_size = ntohs(*((uint16_t *)data));
		if (incoming->req_size > sizeof(incoming->buf)-2) {
			pr_err("read error: %d req size", incoming->req_size);
			return do_kill(cx);
		}
		return do_read_request(cx);
	}
	else {		
		conn_read(incoming);
	}

	return s_read_size;
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: giszo/urubu
// =====================================================================================================================
static int ps2_read(struct device* dev, struct device_request* req)
{
    // currently there is no data to be read
    if (s_avail_cnt == 0)
	return 0;

    do_read_request(req);

    return 0;
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: giszo/urubu
// =====================================================================================================================
static void ps2_handler(struct ipc_message* msg)
{
    switch (msg->data[0])
    {
	case 1 /* irq */ :
	    s_buffer[s_avail_cnt++] = inb(0x60);

	    if (s_ps2_dev->request)
		do_read_request(s_ps2_dev->request);

	    // finish the handling of the interrupt
	    irq_finished(msg->data[1] /* the IRQ number parameter */);

	    break;
    }
}