Exemplo n.º 1
0
static void cb_call_write_done(struct libusb_transfer *transfer)
{
	struct aura_node *node = transfer->user_data;
	struct usb_dev_info *inf = aura_get_transportdata(node);

	if (0 != check_control(transfer)) { 
		/* Put it back to queue. Core will deal with it later */
		goto requeue;
	}

	if (transfer->actual_length - LIBUSB_CONTROL_SETUP_SIZE < transfer->length) { 
		slog(0, SLOG_ERROR, "usb: short-write on call packet want %d got %d  (API mismatch?)",
		     transfer->length, transfer->actual_length);
		usb_panic_and_reset_state(node);
		goto requeue;
	}

	aura_buffer_release(node, inf->current_buffer);
	inf->current_buffer = NULL;
	slog(4, SLOG_DEBUG, "Call write done");
	return;
requeue:
	aura_requeue_buffer(&node->outbound_buffers, inf->current_buffer);
	inf->current_buffer = NULL;
}
Exemplo n.º 2
0
static void cb_parse_object(struct libusb_transfer *transfer)
{
	struct aura_node *node = transfer->user_data;
	struct usb_dev_info *inf = aura_get_transportdata(node);
	char is_method;
	char *name, *afmt, *rfmt;

	check_control(transfer);
	name = (char *) libusb_control_transfer_get_data(transfer);

	is_method = *name++;
	afmt = next(name);
	rfmt = next(afmt);

	slog(4, SLOG_DEBUG, "usb: got %s %s / '%s' '%s'", 
	     is_method ? "method" : "event",
	     name, afmt, rfmt);

	aura_etable_add(inf->etbl, name, 
			is_method ? afmt : NULL, 
			rfmt);

	if (inf->current_object == inf->num_objects) { 
		slog(4, SLOG_DEBUG, "etable becomes active");
		aura_etable_activate(inf->etbl);
		aura_set_status(node, AURA_STATUS_ONLINE);
		inf->state = AUSB_DEVICE_OPERATIONAL;
		itransfer_enable(node, true);
		return;
	}

	slog(4, SLOG_DEBUG, "Requesting info about obj %d", inf->current_object);
	/* Resubmit the transfer for the next round */
	request_object(node, inf->current_object++);
}
Exemplo n.º 3
0
static int group_setchild( lua_State* L )
{
	uiGroup* g = (uiGroup*) check_object( L, 1, uiGroupSignature );
	uiControl* c = check_control( L, 2, 0 );
	uiGroupSetChild( g, c );
	lua_pushvalue( L, 1 );
	return 1;
}
Exemplo n.º 4
0
static int window_setchild( lua_State* L )
{
	uiWindow* w = (uiWindow*) check_object( L, 1, uiWindowSignature );
	uiControl* c = (uiControl*) check_control( L, 2, 0 );
	uiWindowSetChild( w, c );
	lua_pushvalue( L, 1 );
	return 1;
}
Exemplo n.º 5
0
static int tab_insert( lua_State* L )
{
	uiTab* t = (uiTab*) check_object( L, 1, uiTabSignature );
	uiControl* c = check_control( L, 4, 0 );
	uiTabInsertAt( t, luaL_checkstring( L, 3 ), luaL_checkinteger( L, 2 ), c );
	lua_pushvalue( L, 1 );
	return 1;
}
Exemplo n.º 6
0
static int l_uiBoxAppend( lua_State* L )
{
	uiBox* b = (uiBox*) check_object( L, 1, uiBoxSignature );
	uiControl* o = (uiControl*) check_control( L, 2, 0 );
	uiBoxAppend( b, o, lua_toboolean( L, 3 ) );
	lua_pushvalue( L, 1 );
	return 1;
}
Exemplo n.º 7
0
int l_uiFormAppend( lua_State* L )
{
	uiFormAppend( 
		(uiForm*) check_object( L, 1, uiFormSignature ),
		luaL_checkstring( L, 2 ),
		check_control( L, 3, 0 ),
		lua_toboolean( L, 4 ) );
	lua_pushvalue( L, 1 );
	return 1;
}
Exemplo n.º 8
0
static int tab_append( lua_State* L )
{
	uiTab* t = (uiTab*) check_object( L, 1, uiTabSignature );
	uiControl* c = check_control( L, 3, 0 );
	uiTabAppend( t, luaL_checkstring( L, 2 ), c );
	if( lua_isboolean( L, 4 ) )
	{
		uiTabSetMargined( t, uiTabNumPages( t ) - 1, lua_toboolean( L, 4 ) );
	}
	lua_pushvalue( L, 1 );
	return 1;
}
Exemplo n.º 9
0
static void cb_call_done(struct libusb_transfer *transfer)
{
	struct aura_node *node = transfer->user_data;
	struct usb_dev_info *inf = aura_get_transportdata(node);
	struct aura_buffer *buf;

	/* Put the buffer pointer at the start of the data we've got */
	/* It only makes sense when we succeed */
	if (0 == check_control(transfer)) {
		slog(4, SLOG_DEBUG, "Requeuing!");
		buf = aura_node_read(node);
		aura_node_write(node, buf);
		inf->current_buffer = NULL;
	}
}
Exemplo n.º 10
0
int l_uiGridAppend( lua_State* L )
{
	uiGrid* g = (uiGrid*) check_object( L, 1, uiGridSignature );
	uiControl* c = check_control( L, 2, 0 );
	int left = luaL_checkinteger( L, 3 );
	int top = luaL_checkinteger( L, 4 );
	int xspan = luaL_optinteger( L, 5, 1 );
	int yspan = luaL_optinteger( L, 6, 1 );
	int hexpand = luaL_optinteger( L, 7, 1 );
	uiAlign halign = luaL_optinteger( L, 8, uiAlignFill );
	int vexpand = luaL_optinteger( L, 9, 1 );
	uiAlign valign = luaL_optinteger( L, 10, uiAlignFill );
	uiGridAppend( g, c, left, top, xspan, yspan, hexpand, halign, vexpand, valign );
	lua_pushvalue( L, 1 );
	return 1;
}
Exemplo n.º 11
0
static void cb_got_dev_info(struct libusb_transfer *transfer)
{
	struct aura_node *node = transfer->user_data;
	struct usb_dev_info *inf = aura_get_transportdata(node);
	struct usb_info_packet *pck; 
	int newbufsize; 
	char *tmp; 

	check_control(transfer);
	slog(4, SLOG_DEBUG, "usb: Got info packet from device");

	if (transfer->actual_length < sizeof(struct usb_info_packet)) { 
		slog(0, SLOG_ERROR, "usb: short-read on info packet want %d got %d  (API mismatch?)",
		     sizeof(struct usb_info_packet), transfer->actual_length);
		usb_panic_and_reset_state(node);
		return; 
	}

	pck = (struct usb_info_packet *)libusb_control_transfer_get_data(transfer);	
	aura_set_node_endian(node, usbdev_is_be(pck) ? 
			     AURA_ENDIAN_BIG : AURA_ENDIAN_LITTLE);

	newbufsize = pck->io_buf_size + LIBUSB_CONTROL_SETUP_SIZE;
	inf->num_objects = pck->num_objs;

	if (newbufsize > inf->io_buf_size) { 
		slog(4, SLOG_DEBUG, "usb: adjusting control buffer size: %d->%d bytes", 
		     inf->io_buf_size, newbufsize);
		tmp = realloc(inf->ctrlbuf, newbufsize);
		if (!tmp) { 
			slog(0, SLOG_ERROR, "Allocation error while adjusting control buffer size");
			aura_panic(node);
		}
		inf->io_buf_size = newbufsize;
		inf->ctrlbuf = (unsigned char *)tmp;
	}
	slog(4, SLOG_DEBUG, "usb: Device has %d objects, now running discovery", inf->num_objects);
	inf->etbl = aura_etable_create(node, inf->num_objects);
	if (!inf->etbl) 
	{
		slog(0, SLOG_ERROR, "usb: etable creation failed");
		aura_panic(node);
	}

	inf->current_object = 0; 
	request_object(node, inf->current_object++);
}
Exemplo n.º 12
0
static void cb_event_readout_done(struct libusb_transfer *transfer)
{
	struct aura_node *node = transfer->user_data;
	struct usb_dev_info *inf = aura_get_transportdata(node);
	struct usb_event_packet *evt; 
	struct aura_buffer *buf = inf->current_buffer;
	struct aura_object *o; 
 
	if (0 != check_control(transfer))
		goto ignore;

	if (transfer->actual_length < sizeof(struct usb_event_packet))
		goto ignore;
	
	evt = (struct usb_event_packet *) libusb_control_transfer_get_data(transfer);
	o = aura_etable_find_id(node->tbl, evt->id); 
	if (!o) {
		slog(0, SLOG_ERROR, "usb: got bogus event id from device %d, resetting", evt->id);
		goto panic;
	}
	
	if ((transfer->actual_length - LIBUSB_CONTROL_SETUP_SIZE) < 
	    (sizeof(struct usb_event_packet) + o->retlen)) {
		slog(0, SLOG_ERROR, "usb: short read for evt %d: %d bytes expected %d got",
		     evt->id, o->retlen + sizeof(struct usb_event_packet), 
		     transfer->actual_length);
		goto panic;
	}
	
	inf->pending--;
	slog(4, SLOG_DEBUG, "Event readout completed, %d bytes, %d evt left", 
	     transfer->actual_length, inf->pending);
	buf->object = o; 
	/* Position the buffer at the start of the responses */
	buf->pos = LIBUSB_CONTROL_SETUP_SIZE + sizeof(struct usb_event_packet);
	aura_queue_buffer(&node->inbound_buffers, buf);
	return; 

panic: 
	usb_panic_and_reset_state(node);
ignore:
	aura_buffer_release(node, buf);
	inf->current_buffer = NULL;
	return;
}
Exemplo n.º 13
0
int main() {
    self[0] = 0b00000100;
    self[1] = 0b00000100;

    self[2] = 0b00000011;
    self[3] = 0b00000100;

    self[4] = 0b00000010;
    self[5] = 0b00000100;
   /* 
    self[6] = 0b00000001;
    self[7] = 0b00000100;
    
    self[8] = 0b00000000;
    self[9] = 0b00000100;
    
    self[10] = 0b00000000;
    self[11] = 0b00000101;

    self[12] = 0b00000000;
    self[13] = 0b00000110;
*/

    generate_food();
    while(1) {
        check_control();
        move();
        update_fb();

        draw_food();
        draw();
        delay();
        undraw_food();
        draw();
        delay();
    }

    return 0;
}
Exemplo n.º 14
0
int perfctr_cpu_update_control(struct perfctr_cpu_state *state, int is_global)
{
    int err;

    // since we updated the control, we invalidate the cpu id in the state
    // so that we can force reload of control registers
    clear_isuspend_cpu(state);
    state->cstatus = 0;

    /* disallow i-mode counters if we cannot catch the interrupts */
    if (!(perfctr_info.cpu_features & PERFCTR_FEATURE_PCINT)
        && state->control.nrictrs) {
        
        return -EPERM;
    }

    err = check_ireset(state);
    if (err < 0) {
        return err;
    }
    err = check_control(state); /* may initialise state->cstatus */
    if (err < 0) {
        return err;
    }

    // Ok, while the map values and the start values for i-mode counters
    // are updated in the above function check_control() and the following
    // function setup_imode_start_values(), the 'cstatus' values is set here

    // how do u ensure that all i-mode registers are specified beyond a-mode
    // registers
    state->cstatus |= perfctr_mk_cstatus(state->control.tsc_on,
                         state->control.nractrs,
                         state->control.nrictrs);
    setup_imode_start_values(state);
    return 0;
}
Exemplo n.º 15
0
static int pmc_cpu_check_control(const struct pmc_control *control)
{
	return check_control(control);
}