Ejemplo n.º 1
0
/*
 * Locate the blob, fix it up and return its location.
 */
static int
fdt_fixup(void)
{
	int chosen, len;

	len = 0;

	debugf("fdt_fixup()\n");

	if (fdtp == NULL && fdt_setup_fdtp() != 0)
		return (0);

	/* Create /chosen node (if not exists) */
	if ((chosen = fdt_subnode_offset(fdtp, 0, "chosen")) ==
	    -FDT_ERR_NOTFOUND)
		chosen = fdt_add_subnode(fdtp, 0, "chosen");

	/* Value assigned to fixup-applied does not matter. */
	if (fdt_getprop(fdtp, chosen, "fixup-applied", NULL))
		return (1);

	fdt_platform_fixups();

	fdt_setprop(fdtp, chosen, "fixup-applied", NULL, 0);
	return (1);
}
Ejemplo n.º 2
0
int
uboot_autoload(void)
{
#if defined(LOADER_FDT_SUPPORT)
	int err;

	if ((err = fdt_setup_fdtp()) != 0)
		return (err);
#endif

	return(0);
}
Ejemplo n.º 3
0
int
uboot_autoload(void)
{
#if defined(LOADER_FDT_SUPPORT)
	int err;

	if ((err = fdt_setup_fdtp()) != 0) {
		printf("No valid device tree blob found!\n");
		return (err);
	}
#endif

	return(0);
}
Ejemplo n.º 4
0
int
command_fdt_internal(int argc, char *argv[])
{
	cmdf_t *cmdh;
	char *cmd;
	int i, err;

	if (argc < 2) {
		command_errmsg = "usage is 'fdt <command> [<args>]";
		return (CMD_ERROR);
	}

	/*
	 * Check if uboot env vars were parsed already. If not, do it now.
	 */
	fdt_fixup();

	/*
	 * Validate fdt <command>.
	 */
	cmd = strdup(argv[1]);
	i = 0;
	cmdh = NULL;
	while (!(commands[i].name == NULL)) {
		if (strcmp(cmd, commands[i].name) == 0) {
			/* found it */
			cmdh = commands[i].handler;
			break;
		}
		i++;
	}
	if (cmdh == NULL) {
		command_errmsg = "unknown command";
		return (CMD_ERROR);
	}

	if (!fdtp)
		if (fdt_setup_fdtp())
			return (CMD_ERROR);

	/*
	 * Call command handler.
	 */
	err = (*cmdh)(argc, argv);

	return (err);
}
Ejemplo n.º 5
0
/*
 * Copy DTB blob to specified location and return size
 */
int
fdt_copy(vm_offset_t va)
{
	int err;
	debugf("fdt_copy va 0x%08x\n", va);
	if (fdtp == NULL) {
		err = fdt_setup_fdtp();
		if (err) {
			printf("No valid device tree blob found!\n");
			return (0);
		}
	}

	if (fdt_fixup() == 0)
		return (0);

	if (fdtp_va != 0) {
		/* Overwrite the FDT with the fixed version. */
		/* XXX Is this really appropriate? */
		COPYIN(fdtp, fdtp_va, fdtp_size);
	}
	COPYIN(fdtp, va, fdtp_size);
	return (fdtp_size);
}
Ejemplo n.º 6
0
int
fdt_fixup(void)
{
	const char *env;
	char *ethstr;
	int chosen, err, eth_no, len;
	struct sys_info *si;

	env = NULL;
	eth_no = 0;
	ethstr = NULL;
	len = 0;

	if (!fdtp) {
		err = fdt_setup_fdtp();
		if (err) {
			sprintf(command_errbuf, "Could not perform blob "
			    "fixups. Error code: %d\n", err);
			return (err);
		}
	}

	/* Create /chosen node (if not exists) */
	if ((chosen = fdt_subnode_offset(fdtp, 0, "chosen")) ==
	    -FDT_ERR_NOTFOUND)
		chosen = fdt_add_subnode(fdtp, 0, "chosen");

	/* Value assigned to fixup-applied does not matter. */
	if (fdt_getprop(fdtp, chosen, "fixup-applied", NULL))
		return (CMD_OK);

	/* Acquire sys_info */
	si = ub_get_sys_info();

	while ((env = ub_env_enum(env)) != NULL) {
		if (strncmp(env, "eth", 3) == 0 &&
		    strncmp(env + (strlen(env) - 4), "addr", 4) == 0) {
			/*
			 * Handle Ethernet addrs: parse uboot env eth%daddr
			 */

			if (!eth_no) {
				/*
				 * Check how many chars we will need to store
				 * maximal eth iface number.
				 */
				len = strlen(STRINGIFY(TMP_MAX_ETH)) +
				    strlen("ethernet");

				/*
				 * Reserve mem for string "ethernet" and len
				 * chars for iface no.
				 */
				ethstr = (char *)malloc(len * sizeof(char));
				bzero(ethstr, len * sizeof(char));
				strcpy(ethstr, "ethernet0");
			}

			/* Modify blob */
			fixup_ethernet(env, ethstr, &eth_no, len);

		} else if (strcmp(env, "consoledev") == 0)
			fixup_stdout(env);
	}

	/* Modify cpu(s) and bus clock frequenties in /cpus node [Hz] */
	fixup_cpubusfreqs(si->clk_cpu, si->clk_bus);

	/* Fixup memory regions */
	fixup_memory(si);

	fdt_setprop(fdtp, chosen, "fixup-applied", NULL, 0);

	return (CMD_OK);
}