Exemplo n.º 1
0
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
{
    struct property *prop = prop_alloc(type, current_entry->sym);

    prop->menu = current_entry;
    prop->expr = expr;
    prop->visible.expr = menu_check_dep(dep);

    if (prompt) {
        if (isspace(*prompt)) {
            prop_warn(prop, "leading whitespace ignored");
            while (isspace(*prompt))
                prompt++;
        }
        if (current_entry->prompt && current_entry != &rootmenu)
            prop_warn(prop, "prompt redefined");

        /* Apply all upper menus' visibilities to actual prompts. */
        if(type == P_PROMPT) {
            struct menu *menu = current_entry;

            while ((menu = menu->parent) != NULL) {
                struct expr *dup_expr;

                if (!menu->visibility)
                    continue;
                /*
                 * Do not add a reference to the
                 * menu's visibility expression but
                 * use a copy of it.  Otherwise the
                 * expression reduction functions
                 * will modify expressions that have
                 * multiple references which can
                 * cause unwanted side effects.
                 */
                dup_expr = expr_copy(menu->visibility);

                prop->visible.expr
                    = expr_alloc_and(prop->visible.expr,
                                     dup_expr);
            }
        }

        current_entry->prompt = prop;
    }
    prop->text = prompt;

    return prop;
}
Exemplo n.º 2
0
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
{
    struct property *prop = prop_alloc(type, current_entry->sym);

    prop->menu = current_entry;
    prop->text = prompt;
    prop->expr = expr;
    prop->visible.expr = menu_check_dep(dep);

    if (prompt) {
        if (current_entry->prompt)
            menu_warn(current_entry, "prompt redefined\n");
        current_entry->prompt = prop;
    }

    return prop;
}
Exemplo n.º 3
0
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
{
	struct property *prop = prop_alloc(type, current_entry->sym);

	prop->menu = current_entry;
	prop->expr = expr;
	prop->visible.expr = menu_check_dep(dep);

	if (prompt) {
		/* For crostool-NG, a leading pipe followed with spaces
		 * means that pipe shall be removed, and the spaces should
		 * not be trimmed.
		 */
		if (*prompt == '|')
			prompt++;
		else if (isspace(*prompt)) {
			prop_warn(prop, "leading whitespace ignored");
			while (isspace(*prompt))
				prompt++;
		}
		if (current_entry->prompt && current_entry != &rootmenu)
			prop_warn(prop, "prompt redefined");

		/* Apply all upper menus' visibilities to actual prompts. */
		if(type == P_PROMPT) {
			struct menu *menu = current_entry;

			while ((menu = menu->parent) != NULL) {
				if (!menu->visibility)
					continue;
				prop->visible.expr
					= expr_alloc_and(prop->visible.expr,
							 menu->visibility);
			}
		}

		current_entry->prompt = prop;
	}
	prop->text = prompt;

	return prop;
}
Exemplo n.º 4
0
void menu_add_option(int token, char *arg)
{
	struct property *prop;

	switch (token) {
	case T_OPT_MODULES:
		prop = prop_alloc(P_DEFAULT, modules_sym);
		prop->expr = expr_alloc_symbol(current_entry->sym);
		break;
	case T_OPT_DEFCONFIG_LIST:
		if (!sym_defconfig_list)
			sym_defconfig_list = current_entry->sym;
		else if (sym_defconfig_list != current_entry->sym)
			zconf_error("trying to redefine defconfig symbol");
		break;
	case T_OPT_ENV:
		prop_add_env(arg);
		break;
	}
}
Exemplo n.º 5
0
Arquivo: menu.c Projeto: 274914765/C
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
{
    struct property *prop = prop_alloc(type, current_entry->sym);

    prop->menu = current_entry;
    prop->expr = expr;
    prop->visible.expr = menu_check_dep(dep);

    if (prompt) {
        if (isspace(*prompt)) {
            prop_warn(prop, "leading whitespace ignored");
            while (isspace(*prompt))
                prompt++;
        }
        if (current_entry->prompt)
            prop_warn(prop, "prompt redefined");
        current_entry->prompt = prop;
    }
    prop->text = prompt;

    return prop;
}
Exemplo n.º 6
0
Retcode
make_translations(Environ *e)
{
	Package *savepkg = e->currpkg;
	Cell saveinst = e->currinst;
	Retcode ret;
	Byte *prop;
	Int plen = 0;
	Int i;
	Translation *t = NULL;

	e->currpkg = e->mmu;
	e->currinst = (uPtr)NULL;

	for (i = 0, t = g_translations; t; t = t->next, i++)
		;

	prop = prop_alloc(e, i * 4 * sizeof (Int));

	for (t = g_translations; t; t = t->next)
	{
		/* first encode the single-cell virtual address */
		prop_encode_int(prop + plen, &plen, t->virt);

		/* second encode the size */
		prop_encode_int(prop + plen, &plen, t->size);

		/* third encode the single-cell physical address */
		prop_encode_int(prop + plen, &plen, t->phys);

		/* forth encode the mode */
		prop_encode_int(prop + plen, &plen, t->mode);
	}
	
	ret = add_property(e->mmu->props, "translations", CSTR, prop, plen);
	e->currpkg = savepkg;
	e->currinst = saveinst;
	return ret;
}
Exemplo n.º 7
0
static Retcode
make_reg_prop(Environ *e, Allocator *a, Byte *propname)
{
	Package *savepkg = e->currpkg;
	Cell saveinst = e->currinst;
	Retcode ret;
	Byte *prop;
	Int plen = 0;
	Int i;
	Allocator_block *b = NULL;
	uInt addr[1];
	uInt size[1];

	e->currpkg = e->mmu;
	e->currinst = (uPtr)NULL;

	alloc_info(a, &b, addr, size);
	
	for (i = 1; b; alloc_info(a, &b, addr, size), i++)
		;

	prop = prop_alloc(e, i * 2 * sizeof (Int));

	b = NULL;
	alloc_info(a, &b, addr, size);
	
	for (i = 1; b; alloc_info(a, &b, addr, size), i++)
	{
		/* first encode the single-cell virtual address */
		prop_encode_int(prop + plen, &plen, addr[0]);
		/* next encode the single-cell block size */
		prop_encode_int(prop + plen, &plen, size[0]);
	}
	
	ret = add_property(e->mmu->props, propname, CSTR, prop, plen);
	e->currpkg = savepkg;
	e->currinst = saveinst;
	return ret;
}
Exemplo n.º 8
0
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
{
    struct property *prop = prop_alloc(type, current_entry->sym);

    prop->menu = current_entry;
    prop->expr = expr;
    prop->visible.expr = menu_check_dep(dep);

    if (prompt) {
        if (isspace(*prompt)) {
            prop_warn(prop, "leading whitespace ignored");
            while (isspace(*prompt))
                prompt++;
        }
        if (current_entry->prompt && current_entry != &rootmenu)
            prop_warn(prop, "prompt redefined");

        /* Apply all upper menus' visibilities to actual prompts. */
        if(type == P_PROMPT) {
            struct menu *menu = current_entry;

            while ((menu = menu->parent) != NULL) {
                if (!menu->visibility)
                    continue;
                prop->visible.expr
                    = expr_alloc_and(prop->visible.expr,
                                     menu->visibility);
            }
        }

        current_entry->prompt = prop;
    }
    prop->text = prompt;

    return prop;
}
Exemplo n.º 9
0
void sym_add_default(struct symbol *sym, const char *def)
{
	struct property *prop = prop_alloc(P_DEFAULT, sym);

	prop->expr = expr_alloc_symbol(sym_lookup(def, 1));
}
Exemplo n.º 10
0
/**
* Read the properties file specified by <tt>filename</tt> 
* into the array of <tt>properties</tt>, 
* using the specified port library to allocate memory. 
* The array is terminated with null-keyed element, 
* though one can obtain number of elements directly
* via last argument.
*
* @param[in] portLibrary - The port library used to interact with the platform.
* @param[in] filename - The file from which to read data using hyfile* functions.
* @param[out] properties - An array that will contain property file entries.
* @param[out] number - Optional parameter, number of elements in the returned array.
*
* @return JNI_OK on success, or a JNI error code on failure.
*/
jint 
properties_load(HyPortLibrary * portLibrary, const char *filename, 
                          key_value_pair** properties, U_32 *number)
{
    PORT_ACCESS_FROM_PORT (portLibrary);    
    void *handle;
    I_64 seekResult;
    IDATA fileSize;
    char *scanCursor, *scanLimit;
    char *start, *delim, *end;
    key_value_pair *props;
    unsigned arraySize;
    unsigned count = 0;
    jint status = JNI_OK;

    /* Determine the file size, fail if > 2G */
    seekResult = hyfile_length (filename);
    if ((seekResult <= 0) || (seekResult > 0x7FFFFFFF))
    {
        return JNI_ERR;
    }
    scanCursor = hymmap_map_file(filename, &handle);
    if (!scanCursor) {
        return JNI_ERR;
    }

#ifdef ZOS
    /* Convert the scan buffer into ASCII */
    scanCursor = e2a(scanCursor, seekResult);
#endif

    fileSize = (IDATA) seekResult;
    arraySize = fileSize/50 + 1;
    props = hymem_allocate_memory(sizeof(key_value_pair)*(arraySize + 1));
    if (!props) {
        status = JNI_ENOMEM;
        goto finish;
    }

    start = end = scanCursor;
    delim = NULL;
    scanLimit = scanCursor + fileSize;

    do {
        while (scanCursor < scanLimit) {
            switch(*scanCursor) {
                case '\r': 
                case '\n': 
                    end = scanCursor;
                    goto read_line;
                case '=':
                    /* remember only first occurrence which is not key itself */
                    if (delim == NULL && scanCursor > start) {
                        delim = scanCursor;
                    }
                default:
                    ++scanCursor;
                    continue;
            }
        }

read_line:
        if (scanCursor > start && start != delim && *start != '#' && *start != '!')  
            /* line is not empty, well formed and not commented out */
        {
            if (end == start) {
                /* the last line ends with EOF */
                end = scanLimit;
            }
            if (count == arraySize) 
            {
                void* re_props;
                arraySize += arraySize/2 + 1;
                re_props = hymem_reallocate_memory(props, 
                    sizeof(key_value_pair)*(arraySize + 1));
                if (!re_props) {
                    status = JNI_ENOMEM;
                    goto finish;
                }
                props = re_props;
            }
            if (!prop_alloc(portLibrary, props + count, start, delim, end)) {
                status = JNI_ENOMEM;
                goto finish;
            }
            ++count;
        }   
        start = end = ++scanCursor;
        delim = NULL;
    }
    while (scanCursor < scanLimit);

    /*set terminating NULL*/
    props[count].key = NULL; 

finish:
    hymmap_unmap_file(handle);
    if (status != JNI_OK) 
    {
        properties_free(portLibrary, props);
    }
    else 
    {
        *properties = props;
        if (number){
            *number = count;
        }
    }
    return status;
}
Exemplo n.º 11
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;
}