コード例 #1
0
ファイル: fit_image.c プロジェクト: AccretionD/u-boot
/**
 * fit_write_images() - Write out a list of images to the FIT
 *
 * We always include the main image (params->datafile). If there are device
 * tree files, we include an fdt@ node for each of those too.
 */
static int fit_write_images(struct image_tool_params *params, char *fdt)
{
	struct content_info *cont;
	const char *typename;
	char str[100];
	int upto;
	int ret;

	fdt_begin_node(fdt, "images");

	/* First the main image */
	typename = genimg_get_type_short_name(params->fit_image_type);
	snprintf(str, sizeof(str), "%s@1", typename);
	fdt_begin_node(fdt, str);
	fdt_property_string(fdt, "description", params->imagename);
	fdt_property_string(fdt, "type", typename);
	fdt_property_string(fdt, "arch", genimg_get_arch_name(params->arch));
	fdt_property_string(fdt, "os", genimg_get_os_short_name(params->os));
	fdt_property_string(fdt, "compression",
			    genimg_get_comp_short_name(params->comp));
	fdt_property_u32(fdt, "load", params->addr);
	fdt_property_u32(fdt, "entry", params->ep);

	/*
	 * Put data last since it is large. SPL may only load the first part
	 * of the DT, so this way it can access all the above fields.
	 */
	ret = fdt_property_file(params, fdt, "data", params->datafile);
	if (ret)
		return ret;
	fdt_end_node(fdt);

	/* Now the device tree files if available */
	upto = 0;
	for (cont = params->content_head; cont; cont = cont->next) {
		if (cont->type != IH_TYPE_FLATDT)
			continue;
		snprintf(str, sizeof(str), "%s@%d", FIT_FDT_PROP, ++upto);
		fdt_begin_node(fdt, str);

		get_basename(str, sizeof(str), cont->fname);
		fdt_property_string(fdt, "description", str);
		ret = fdt_property_file(params, fdt, "data", cont->fname);
		if (ret)
			return ret;
		fdt_property_string(fdt, "type", typename);
		fdt_property_string(fdt, "arch",
				    genimg_get_arch_short_name(params->arch));
		fdt_property_string(fdt, "compression",
				    genimg_get_comp_short_name(IH_COMP_NONE));
		fdt_end_node(fdt);
	}

	fdt_end_node(fdt);

	return 0;
}
コード例 #2
0
ファイル: efi-dom0.c プロジェクト: fdario/xen
/* Create /hypervisor/uefi node for efi properties. */
int __init acpi_make_efi_nodes(void *fdt, struct membank tbl_add[])
{
    int res;

    res = fdt_begin_node(fdt, "uefi");
    if ( res )
        return res;

    res = fdt_property_u64(fdt, "xen,uefi-system-table",
                           tbl_add[TBL_EFIT].start);
    if ( res )
        return res;

    res = fdt_property_u64(fdt, "xen,uefi-mmap-start",
                           tbl_add[TBL_MMAP].start);
    if ( res )
        return res;

    res = fdt_property_u32(fdt, "xen,uefi-mmap-size",
                           tbl_add[TBL_MMAP].size);
    if ( res )
        return res;

    res = fdt_property_u32(fdt, "xen,uefi-mmap-desc-size",
                           sizeof(EFI_MEMORY_DESCRIPTOR));
    if ( res )
        return res;

    res = fdt_property_u32(fdt, "xen,uefi-mmap-desc-ver", 1);
    if ( res )
        return res;

    res = fdt_end_node(fdt);

    return res;
}
コード例 #3
0
ファイル: region_tree.c プロジェクト: sglass68/dtc
/**
 * build_tree() - Build a tree
 *
 * @fdt:	Pointer to place to put tree, assumed to be large enough
 * @flags:	Flags to control the tree creation (FDT_REG_...)
 * @space:	Amount of space to create for later tree additions
 *
 * This creates a tree modelled on a U-Boot FIT image, with various nodes
 * and properties which are useful for testing the hashing features of
 * fdt_find_regions().
 *
 * See h_include() below for a list of the nodes we later search for.
 */
static void build_tree(void *fdt, int flags, int space)
{
	int direct_subnodes = flags & FDT_REG_DIRECT_SUBNODES;
	int all_subnodes = flags & FDT_REG_ALL_SUBNODES;
	int supernodes = flags & FDT_REG_SUPERNODES;
	int either = !all_subnodes && (direct_subnodes || supernodes);
	int err;

	CHECK(fdt_create(fdt, SPACE));

	CHECK(fdt_add_reservemap_entry(fdt, TEST_ADDR_1, TEST_SIZE_1));
	CHECK(fdt_add_reservemap_entry(fdt, TEST_ADDR_2, TEST_SIZE_2));
	CHECK(fdt_finish_reservemap(fdt));

	/*
	 * This is the start of a new region because in the fdt_xxx_region()
	 * call, we pass "/" as one of the nodes to find.
	 */
	start(fdt);	/* region 0 */
	CHECK(fdt_begin_node(fdt, ""));
	CHECK(fdt_property_string(fdt, "description", "kernel image"));
	CHECK(fdt_property_u32(fdt, "#address-cells", 1));

	/* /images */
	if (!either && !all_subnodes)
		stop(fdt);
	CHECK(fdt_begin_node(fdt, "images"));
	if (either)
		stop(fdt);
	CHECK(fdt_property_u32(fdt, "image-prop", 1));

	/* /images/kernel@1 */
	if (!all_subnodes)
		start(fdt);	/* region 1 */
	CHECK(fdt_begin_node(fdt, "kernel@1"));
	CHECK(fdt_property_string(fdt, "description", "exynos kernel"));
	stop(fdt);
	CHECK(fdt_property_string(fdt, "data", "this is the kernel image"));
	start(fdt);	/* region 2 */

	/* /images/kernel/hash@1 */
	CHECK(fdt_begin_node(fdt, "hash@1"));
	CHECK(fdt_property_string(fdt, "algo", "sha1"));
	CHECK(fdt_end_node(fdt));

	/* /images/kernel/hash@2 */
	if (!direct_subnodes)
		stop(fdt);
	CHECK(fdt_begin_node(fdt, "hash@2"));
	if (direct_subnodes)
		stop(fdt);
	CHECK(fdt_property_string(fdt, "algo", "sha1"));
	if (direct_subnodes)
		start(fdt);	/* region 3 */
	CHECK(fdt_end_node(fdt));
	if (!direct_subnodes)
		start(fdt);	/* region 3 */

	CHECK(fdt_end_node(fdt));

	/* /images/fdt@1 */
	CHECK(fdt_begin_node(fdt, "fdt@1"));
	CHECK(fdt_property_string(fdt, "description", "snow FDT"));
	if (!all_subnodes)
		stop(fdt);
	CHECK(fdt_property_string(fdt, "data", "FDT data"));
	if (!all_subnodes)
		start(fdt);	/* region 4 */

	/* /images/kernel/hash@1 */
	CHECK(fdt_begin_node(fdt, "hash@1"));
	CHECK(fdt_property_string(fdt, "algo", "sha1"));
	CHECK(fdt_end_node(fdt));

	CHECK(fdt_end_node(fdt));

	if (!either && !all_subnodes)
		stop(fdt);
	CHECK(fdt_end_node(fdt));

	/* /configurations */
	CHECK(fdt_begin_node(fdt, "configurations"));
	if (either)
		stop(fdt);
	CHECK(fdt_property_string(fdt, "default", "conf@1"));

	/* /configurations/conf@1 */
	if (!all_subnodes)
		start(fdt);	/* region 6 */
	CHECK(fdt_begin_node(fdt, "conf@1"));
	CHECK(fdt_property_string(fdt, "kernel", "kernel@1"));
	CHECK(fdt_property_string(fdt, "fdt", "fdt@1"));
	CHECK(fdt_end_node(fdt));
	if (!all_subnodes)
		stop(fdt);

	/* /configurations/conf@2 */
	CHECK(fdt_begin_node(fdt, "conf@2"));
	CHECK(fdt_property_string(fdt, "kernel", "kernel@1"));
	CHECK(fdt_property_string(fdt, "fdt", "fdt@2"));
	CHECK(fdt_end_node(fdt));

	if (either)
		start(fdt);	/* region 7 */
	CHECK(fdt_end_node(fdt));
	if (!either && !all_subnodes)
		start(fdt);	/* region 7 */

	CHECK(fdt_end_node(fdt));

	CHECK(fdt_finish(fdt));
	stop(fdt);

	/* Add in the strings */
	if (flags & FDT_REG_ADD_STRING_TAB) {
		expect[expect_count].offset = fdt_off_dt_strings(fdt);
		expect[expect_count].size = fdt_size_dt_strings(fdt);
		expect_count++;
	}

	/* Make a bit of space */
	if (space)
		CHECK(fdt_open_into(fdt, fdt, fdt_totalsize(fdt) + space));

	verbose_printf("Completed tree, totalsize = %d\n", fdt_totalsize(fdt));
}
コード例 #4
0
ファイル: fit_image.c プロジェクト: Xilinx/u-boot-xlnx
/**
 * fit_write_images() - Write out a list of images to the FIT
 *
 * We always include the main image (params->datafile). If there are device
 * tree files, we include an fdt- node for each of those too.
 */
static int fit_write_images(struct image_tool_params *params, char *fdt)
{
	struct content_info *cont;
	const char *typename;
	char str[100];
	int upto;
	int ret;

	fdt_begin_node(fdt, "images");

	/* First the main image */
	typename = genimg_get_type_short_name(params->fit_image_type);
	snprintf(str, sizeof(str), "%s-1", typename);
	fdt_begin_node(fdt, str);
	fdt_property_string(fdt, FIT_DESC_PROP, params->imagename);
	fdt_property_string(fdt, FIT_TYPE_PROP, typename);
	fdt_property_string(fdt, FIT_ARCH_PROP,
			    genimg_get_arch_short_name(params->arch));
	fdt_property_string(fdt, FIT_OS_PROP,
			    genimg_get_os_short_name(params->os));
	fdt_property_string(fdt, FIT_COMP_PROP,
			    genimg_get_comp_short_name(params->comp));
	fdt_property_u32(fdt, FIT_LOAD_PROP, params->addr);
	fdt_property_u32(fdt, FIT_ENTRY_PROP, params->ep);

	/*
	 * Put data last since it is large. SPL may only load the first part
	 * of the DT, so this way it can access all the above fields.
	 */
	ret = fdt_property_file(params, fdt, FIT_DATA_PROP, params->datafile);
	if (ret)
		return ret;
	fdt_end_node(fdt);

	/* Now the device tree files if available */
	upto = 0;
	for (cont = params->content_head; cont; cont = cont->next) {
		if (cont->type != IH_TYPE_FLATDT)
			continue;
		snprintf(str, sizeof(str), "%s-%d", FIT_FDT_PROP, ++upto);
		fdt_begin_node(fdt, str);

		get_basename(str, sizeof(str), cont->fname);
		fdt_property_string(fdt, FIT_DESC_PROP, str);
		ret = fdt_property_file(params, fdt, FIT_DATA_PROP,
					cont->fname);
		if (ret)
			return ret;
		fdt_property_string(fdt, FIT_TYPE_PROP, typename);
		fdt_property_string(fdt, FIT_ARCH_PROP,
				    genimg_get_arch_short_name(params->arch));
		fdt_property_string(fdt, FIT_COMP_PROP,
				    genimg_get_comp_short_name(IH_COMP_NONE));
		fdt_end_node(fdt);
	}

	/* And a ramdisk file if available */
	if (params->fit_ramdisk) {
		fdt_begin_node(fdt, FIT_RAMDISK_PROP "-1");

		fdt_property_string(fdt, FIT_TYPE_PROP, FIT_RAMDISK_PROP);
		fdt_property_string(fdt, FIT_OS_PROP,
				    genimg_get_os_short_name(params->os));

		ret = fdt_property_file(params, fdt, FIT_DATA_PROP,
					params->fit_ramdisk);
		if (ret)
			return ret;

		fdt_end_node(fdt);
	}

	fdt_end_node(fdt);

	return 0;
}