diff options
| author | Marian Balakowicz <m8@semihalf.com> | 2008-02-21 17:20:20 +0100 | 
|---|---|---|
| committer | Marian Balakowicz <m8@semihalf.com> | 2008-02-21 17:20:20 +0100 | 
| commit | f50433d670ec2ee9e96abac67cdc6e5e061a810d (patch) | |
| tree | 290a9d5e658517593dd659f6846be56d48e39319 | |
| parent | fff888a1997ff7de9b29e24050fc4a0fd403ba16 (diff) | |
| download | olio-uboot-2014.01-f50433d670ec2ee9e96abac67cdc6e5e061a810d.tar.xz olio-uboot-2014.01-f50433d670ec2ee9e96abac67cdc6e5e061a810d.zip | |
[new uImage] Add fit_parse_conf() and fit_parse_subimage() routines
Introducing routines for parsing new uImage format bootm arguments:
[<addr>]#<conf>		- configuration specification
[<addr>]:<subimg>	- subimage specification
New format images can contain multiple subimages of the same type. For example
a single new format image file can contain three kernels, two ramdisks and a
couple of FDT blobs. Subimage and configuration specifications are extensions
to bootm (and other image-related commands) arguments' syntax that allow to
specify which particular subimage should be operated on.
Subimage specification is used to denote a particular subimage. Configurations
are a bit more complex -- they are used to define a particualr booting setup,
for example a (kernel, fdt blob) pair, or a (kernel, ramdisk, fdt blob) tuple,
etc.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
| -rw-r--r-- | common/image.c | 78 | ||||
| -rw-r--r-- | include/image.h | 10 | 
2 files changed, 88 insertions, 0 deletions
| diff --git a/common/image.c b/common/image.c index ab6b8e65a..736232867 100644 --- a/common/image.c +++ b/common/image.c @@ -774,4 +774,82 @@ ulong get_boot_kbd (ulong alloc_current, bd_t **kbd)  }  #endif /* CONFIG_PPC || CONFIG_M68K */ +#if defined(CONFIG_FIT) +/*****************************************************************************/ +/* New uImage format routines */ +/*****************************************************************************/ +static int fit_parse_spec (const char *spec, char sepc, ulong addr_curr, +		ulong *addr, const char **name) +{ +	const char *sep; + +	*addr = addr_curr; +	*name = NULL; + +	sep = strchr (spec, sepc); +	if (sep) { +		if (sep - spec > 0) +			*addr = simple_strtoul (spec, NULL, 16); + +		*name = sep + 1; +		return 1; +	} + +	return 0; +} + +/** + * fit_parse_conf - parse FIT configuration spec + * @spec: input string, containing configuration spec + * @add_curr: current image address (to be used as a possible default) + * @addr: pointer to a ulong variable, will hold FIT image address of a given + * configuration + * @conf_name double pointer to a char, will hold pointer to a configuration + * unit name + * + * fit_parse_conf() expects configuration spec in the for of [<addr>]#<conf>, + * where <addr> is a FIT image address that contains configuration + * with a <conf> unit name. + * + * Address part is optional, and if omitted default add_curr will + * be used instead. + * + * returns: + *     1 if spec is a valid configuration string, + *     addr and conf_name are set accordingly + *     0 otherwise + */ +inline int fit_parse_conf (const char *spec, ulong addr_curr, +		ulong *addr, const char **conf_name) +{ +	return fit_parse_spec (spec, '#', addr_curr, addr, conf_name); +} + +/** + * fit_parse_subimage - parse FIT subimage spec + * @spec: input string, containing subimage spec + * @add_curr: current image address (to be used as a possible default) + * @addr: pointer to a ulong variable, will hold FIT image address of a given + * subimage + * @image_name: double pointer to a char, will hold pointer to a subimage name + * + * fit_parse_subimage() expects subimage spec in the for of + * [<addr>]:<subimage>, where <addr> is a FIT image address that contains + * subimage with a <subimg> unit name. + * + * Address part is optional, and if omitted default add_curr will + * be used instead. + * + * returns: + *     1 if spec is a valid subimage string, + *     addr and image_name are set accordingly + *     0 otherwise + */ +inline int fit_parse_subimage (const char *spec, ulong addr_curr, +		ulong *addr, const char **image_name) +{ +	return fit_parse_spec (spec, ':', addr_curr, addr, image_name); +} +#endif /* CONFIG_FIT */ +  #endif /* USE_HOSTCC */ diff --git a/include/image.h b/include/image.h index b4de49d6b..49236124c 100644 --- a/include/image.h +++ b/include/image.h @@ -367,6 +367,16 @@ ulong get_boot_cmdline (ulong alloc_current, ulong *cmd_start, ulong *cmd_end);  ulong get_boot_kbd (ulong alloc_current, bd_t **kbd);  #endif /* CONFIG_PPC || CONFIG_M68K */ +#if defined(CONFIG_FIT) +/* + * New uImage format + */ +inline int fit_parse_conf (const char *spec, ulong addr_curr, +		ulong *addr, const char **conf_name); +inline int fit_parse_subimage (const char *spec, ulong addr_curr, +		ulong *addr, const char **image_name); +#endif /* CONFIG_FIT */ +  #endif /* USE_HOSTCC */  #endif	/* __IMAGE_H__ */ |