Exemplo n.º 1
0
int
fdt_setup_fdtp()
{
	struct preloaded_file *bfp;
	vm_offset_t va;
	
	debugf("fdt_setup_fdtp()\n");

	/* If we already loaded a file, use it. */
	if ((bfp = file_findfile(NULL, "dtb")) != NULL) {
		if (fdt_load_dtb(bfp->f_addr) == 0) {
			printf("Using DTB from loaded file '%s'.\n", 
			    bfp->f_name);
			return (0);
		}
	}

	/* If we were given the address of a valid blob in memory, use it. */
	if (fdt_to_load != NULL) {
		if (fdt_load_dtb_addr(fdt_to_load) == 0) {
			printf("Using DTB from memory address 0x%08X.\n",
			    (unsigned int)fdt_to_load);
			return (0);
		}
	}

	if (fdt_platform_load_dtb() == 0)
		return (0);

	/* If there is a dtb compiled into the kernel, use it. */
	if ((va = fdt_find_static_dtb()) != 0) {
		if (fdt_load_dtb(va) == 0) {
			printf("Using DTB compiled into kernel.\n");
			return (0);
		}
	}
	
	command_errmsg = "No device tree blob found!\n";
	return (1);
}
Exemplo n.º 2
0
static int
fdt_setup_fdtp()
{
	struct preloaded_file *bfp;
	int err;

	/*
	 * Find the device tree blob.
	 */
	bfp = file_findfile(NULL, "dtb");
	if (bfp == NULL) {
		if ((fdtp = (struct fdt_header *)fdt_find_static_dtb()) == 0) {
			command_errmsg = "no device tree blob found!";
			return (CMD_ERROR);
		}
	} else {
		/* Dynamic blob has precedence over static. */
		fdtp = (struct fdt_header *)bfp->f_addr;
	}

	/*
	 * Validate the blob.
	 */
	err = fdt_check_header(fdtp);
	if (err < 0) {
		if (err == -FDT_ERR_BADVERSION)
			sprintf(command_errbuf,
			    "incompatible blob version: %d, should be: %d",
			    fdt_version(fdtp), FDT_LAST_SUPPORTED_VERSION);

		else
			sprintf(command_errbuf, "error validating blob: %s",
			    fdt_strerror(err));
		return (CMD_ERROR);
	}
	return (CMD_OK);
}