Ejemplo n.º 1
0
int MainMenu::popup(int X, int Y, int W, int H)
{
    if(Fl::event_button()==1) {
        m_open = true;
        init_entries();
        int newy=Y-calculate_height()-h()-1;
        // mainmenu is inside a group:
        if (parent()->parent()->y()+newy<1) newy=Y;
        int ret = Fl_Menu_::popup(X, newy, W, H);
        clear();
        m_open = false;
        return ret;
    }
    return 0;
}
Ejemplo n.º 2
0
Retcode
usb_install_keyboard_driver(Environ *e, Package *pkg, USB_self *usb,
		usb_device_descriptor_t *dev, usb_config_descriptor_t *cfg,
		usb_interface_descriptor_t *ifc)
{
	Retcode ret;
	Byte name[STR_SIZE];

	DPRINTF(("usb_install_keyboard_driver: addr=%d interface=%d\n",
			usb->addr, usb->interface));

	ret = prop_set_str(pkg->props, "device_type", CSTR, "keyboard", CSTR);

	if (ret == NO_ERROR)
		ret = init_entries(e, pkg->dict, usb_kbd_methods);


	/* make keyboard aliases if none already exist */
	if (ret == NO_ERROR)
		(void)get_device_name(e, pkg, name);

	if (ret == NO_ERROR &&
			find_table(e->aliases->props, "keyboard", CSTR) == NULL)
		ret = make_devalias(e, "keyboard", CSTR, name, CSTR);

	if (ret == NO_ERROR &&
			find_table(e->aliases->props, "usbkeyboard", CSTR) == NULL)
		ret = make_devalias(e, "usbkeyboard", CSTR, name, CSTR);


	/* set config descriptor 0 to turn on keyboard */
	ret = usb_setup(e, usb, usb->addr, USB_CONTROL_ENDPOINT,
			UT_WRITE_DEVICE, UR_SET_CONFIG,
			0, cfg->configuration_value, 0, 0, NULL);

	/* set keyboard to boot protocol (0) */
	if (ret == NO_ERROR)
		ret = usb_setup(e, usb, usb->addr, USB_CONTROL_ENDPOINT,
				UT_WRITE_CLASS_INTERFACE, UR_SET_PROTOCOL,
				0, 0, usb->interface, 0, NULL);

	if (ret == NO_ERROR)
		ret = usb_setup(e, usb, usb->addr, USB_CONTROL_ENDPOINT,
				UT_WRITE_CLASS_INTERFACE, UR_SET_IDLE,
				0, 0, usb->interface, 0, NULL);

	return ret;
}
Ejemplo n.º 3
0
void
init_dictionary(cell *up)
{
    /* reserve space for an array of tokens to the cfa of prim headers */
    V(DP) += (MAXPRIM * sizeof(token_t));

#if 0
    // Make a temporary vocabulary structure so header will have
    // a place to put its various links

    tokstore(CT_FROM_XT((xt_t)V(DP), up), &V(CONTEXT));
    tokstore(CT_FROM_XT((xt_t)V(DP), up), &V(CURRENT));

    linkcomma(DOVOC);
    linkcomma(CT_FROM_XT(V(TORIGIN), up));
    linkcomma(CT_FROM_XT(V(TORIGIN), up));

    /* Make the initial dictionary entry */
    header("forth", sizeof("forth")-1);
#else
    place_name("forth", sizeof("forth")-1, CT_FROM_XT((xt_t)V(TORIGIN), up), up);
#endif

    // Install the new vocabulary in the search order and the vocabulary list
    tokstore(CT_FROM_XT((xt_t)V(DP), up), (xt_t)&V(CONTEXT));
    tokstore(CT_FROM_XT((xt_t)V(DP), up), (xt_t)&V(CURRENT));
    tokstore(CT_FROM_XT((xt_t)V(DP), up), (xt_t)&V(VOC_LINK));

    compile((token_t)DOVOC);  // Code field

#ifdef RELOCATE
    set_relocation_bit(V(DP));
#endif
#if 0
    linkcomma(T(LASTP));    // last-word field
#else
    unumcomma(0);           // Forth voc threads are first thing in user area
    *(xt_t)(&up[0]) = T(LASTP);
#endif

    linkcomma(CT_FROM_XT((xt_t)V(TORIGIN), up));  // voc-link field

    init_variables(sizeof(cell), up);    // arg is first avail user number
    init_entries(up);
}
Ejemplo n.º 4
0
/*
 * initialize all devices in set
 */
static int
init_all(
	mdsetname_t	**spp,
	mdcmdopts_t	options,
	bool_t		called_thru_rpc,
	md_error_t	*ep
)
{
	md_tab_t	*tabp = NULL;
	size_t		setlen;
	uint_t		more;
	int		done;
	int		eval = -1;

	/*
	 * Only take the lock if this is not a MN set
	 * We can only enter this code for a MN set if we are the initiator
	 * and in this case, we don't want to take locks.
	 */
	if (meta_is_mn_set((*spp), ep) == 0) {
		/* grab set lock */
		if (meta_lock(*spp, TRUE, ep)) {
			mde_perror(ep, "");
			mdclrerror(ep);
			return (eval);
		}

		/* check for ownership */
		if (meta_check_ownership(*spp, ep) != 0) {
			mde_perror(ep, "");
			mdclrerror(ep);
			return (eval);
		}

		/* lock is held across init_entries */
		options |= MDCMD_NOLOCK;
	}

	/* get md.tab, preen entries */
	if ((tabp = meta_tab_parse(NULL, ep)) == NULL) {
		mde_perror(ep, "");
		mdclrerror(ep);
		return (eval);
	}

	setlen = strlen((*spp)->setname);
	for (more = 0; (more < tabp->nlines); ++more) {
		md_tab_line_t	*linep = &tabp->lines[more];
		char		*cname = linep->cname;
		char		*p;
		size_t		len;

		/* better have args */
		assert((linep->argc > 0) && (linep->argv[0] != NULL));

		/* only do metadevices and hotspare pools in set */
		if (linep->type & TAB_MD_HSP) {
			if ((p = strrchr(cname, '/')) == NULL) {
				len = 0;
			} else {
				len = p - cname;
			}
			if ((len == setlen) &&
			    (strncmp(cname, (*spp)->setname, len) == 0)) {
				linep->flags = DO_AGAIN;
			} else {
				linep->flags = DONT_DO;
			}

		} else {
			linep->flags = DONT_DO;
		}
	}

	eval = 1;

	/* while more devices get made */
	do {
		done = init_entries(spp, tabp, options,
		    MD_IGNORE_STDERR|MD_RETRY_BUSY, called_thru_rpc, ep);
	} while (done > 0);

	/* now do it and report errors */
	if (init_entries(spp, tabp, options, MD_RETRY_BUSY,
	    called_thru_rpc, ep) >= 0)
		eval = 0;	/* success */
	mdclrerror(ep);

	/* cleanup, return success */
out:
	meta_tab_free(tabp);
	return (eval);
}
Ejemplo n.º 5
0
Retcode
generic_install_flash(Environ *e, Flash_methods *methods)
{
	Retcode ret;
	Package *pkg;
	Byte *prop;
	Flash *f;
	Int plen = 0;
	Self self;
	int i;

	DPRINTF(("generic_install_flash: e=%#x\n", e));

	memset(&self, 0, sizeof self);
	self.meths = methods;
	self.width = methods->width;
	self.buf = (uByte *)malloc(4 * self.width);

	if (self.buf == NULL)
		return NO_ERROR;

	for (i = methods->unitcells - 1; i >= 0; i--)
		PUSH(e, methods->unit[i]);

	PUSH(e, methods->size);
	DPRINTF(("generic_install_flash: about to map-in\n", ret));
	ret = execute_static_method_name(e, e->root, "map-in", CSTR);
	DPRINTF(("generic_install_flash: map-in returns %d\n", ret));

	if (ret != NO_ERROR)
		return ret;

	POPT(e, self.addr, void *);
	DPRINTF(("generic_install_flash: self.addr %p\n", self.addr));

	if (self.addr == (void *)0)
	{
		DPRINTF(("generic_install_flash: unable to map-in\n"));
		return E_NO_DEVICE;
	}

	/* show the mapping */
	//PUSH(e, (Cell)self.addr);
	//f_mapq(e);

	f = flash_probe(e, &self);
	DPRINTF(("flash_probe: ret=%p\n", f));
	free((void *)self.buf);
	PUSH(e, self.addr);
	PUSH(e, methods->size);
	ret = execute_static_method_name(e, e->root, "map-out", CSTR);
	DPRINTF(("generic_install_flash: map-out returns %d\n", ret));

	if (!f)
		return E_NO_DEVICE;

	IFCKSP(e, 0, 3);
	pkg = new_pkg_name(e->currpkg, "flash");

	if (pkg == NULL)
		return E_OUT_OF_MEMORY;

	pkg->self = (struct pself*)methods;

	/* set the type of this device */
	prop_set_str(pkg->props, "device_type", CSTR, "block", CSTR);

	/* encode "reg" property for unit address */
	prop = prop_alloc(e, methods->unitcells * 2 * sizeof (Int));

	if (prop == NULL)
		return E_OUT_OF_MEMORY;

	for (i = 0; i < methods->unitcells; i++)
		prop_encode_int(prop + plen, &plen, methods->unit[i]);

	for (i = 0; i < methods->unitcells - 1; i++)
		prop_encode_int(prop + plen, &plen, 0);

	prop_encode_int(prop + plen, &plen, f->size * (methods->width / f->width));

	ret = add_property(pkg->props, "reg", CSTR, prop, plen);

	/* add device specific information */
	prop_set_str(pkg->props, "manufacture", CSTR, f->manufname, CSTR);
	prop_set_str(pkg->props, "device", CSTR, f->devname, CSTR);
	prop_set_int(pkg->props, "id", CSTR, (f->manufid << 16) | f->devid);
	prop_set_int(pkg->props, "bias", CSTR, methods->bias);

	if (ret == NO_ERROR)
		ret = init_entries(e, pkg->dict, flash_methods);

	return ret;
}