diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Makefile | 1 | ||||
| -rw-r--r-- | lib/display_options.c | 20 | ||||
| -rw-r--r-- | lib/fdtdec.c | 29 | ||||
| -rw-r--r-- | lib/initcall.c | 39 | 
4 files changed, 78 insertions, 11 deletions
diff --git a/lib/Makefile b/lib/Makefile index 86ca1a6ec..1bfd3ee12 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -44,6 +44,7 @@ COBJS-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o  COBJS-$(CONFIG_GZIP) += gunzip.o  COBJS-$(CONFIG_GZIP_COMPRESSED) += gzip.o  COBJS-y += hashtable.o +COBJS-y += initcall.o  COBJS-$(CONFIG_LMB) += lmb.o  COBJS-y += ldiv.o  COBJS-$(CONFIG_MD5) += md5.o diff --git a/lib/display_options.c b/lib/display_options.c index 0339970e7..e6d684bd6 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -115,14 +115,15 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,  		linelen = DEFAULT_LINE_LENGTH_BYTES / width;  	while (count) { +		uint thislinelen = linelen;  		printf("%08lx:", addr);  		/* check for overflow condition */ -		if (count < linelen) -			linelen = count; +		if (count < thislinelen) +			thislinelen = count;  		/* Copy from memory into linebuf and print hex values */ -		for (i = 0; i < linelen; i++) { +		for (i = 0; i < thislinelen; i++) {  			uint32_t x;  			if (width == 4)  				x = lb.ui[i] = *(volatile uint32_t *)data; @@ -134,8 +135,15 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,  			data += width;  		} +		while (thislinelen < linelen) { +			/* fill line with whitespace for nice ASCII print */ +			for (i=0; i<width*2+1; i++) +				puts(" "); +			linelen--; +		} +  		/* Print data in ASCII characters */ -		for (i = 0; i < linelen * width; i++) { +		for (i = 0; i < thislinelen * width; i++) {  			if (!isprint(lb.uc[i]) || lb.uc[i] >= 0x80)  				lb.uc[i] = '.';  		} @@ -143,8 +151,8 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,  		printf("    %s\n", lb.uc);  		/* update references */ -		addr += linelen * width; -		count -= linelen; +		addr += thislinelen * width; +		count -= thislinelen;  		if (ctrlc())  			return -1; diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 43f29f5c6..e17dd001c 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -50,6 +50,7 @@ static const char * const compat_names[COMPAT_COUNT] = {  	COMPAT(NVIDIA_TEGRA20_SDMMC, "nvidia,tegra20-sdhci"),  	COMPAT(NVIDIA_TEGRA20_SFLASH, "nvidia,tegra20-sflash"),  	COMPAT(NVIDIA_TEGRA20_SLINK, "nvidia,tegra20-slink"), +	COMPAT(NVIDIA_TEGRA114_SPI, "nvidia,tegra114-spi"),  	COMPAT(SMSC_LAN9215, "smsc,lan9215"),  	COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"),  	COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"), @@ -58,7 +59,10 @@ static const char * const compat_names[COMPAT_COUNT] = {  	COMPAT(SAMSUNG_EXYNOS_SPI, "samsung,exynos-spi"),  	COMPAT(SAMSUNG_EXYNOS_EHCI, "samsung,exynos-ehci"),  	COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"), +	COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"),  	COMPAT(MAXIM_MAX77686_PMIC, "maxim,max77686_pmic"), +	COMPAT(GENERIC_SPI_FLASH, "spi-flash"), +	COMPAT(MAXIM_98095_CODEC, "maxim,max98095-codec"),  };  const char *fdtdec_get_compatible(enum fdt_compat_id id) @@ -68,25 +72,40 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id)  	return compat_names[id];  } -fdt_addr_t fdtdec_get_addr(const void *blob, int node, -		const char *prop_name) +fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, +		const char *prop_name, fdt_size_t *sizep)  {  	const fdt_addr_t *cell;  	int len;  	debug("%s: %s: ", __func__, prop_name);  	cell = fdt_getprop(blob, node, prop_name, &len); -	if (cell && (len == sizeof(fdt_addr_t) || -			len == sizeof(fdt_addr_t) * 2)) { +	if (cell && ((!sizep && len == sizeof(fdt_addr_t)) || +		     len == sizeof(fdt_addr_t) * 2)) {  		fdt_addr_t addr = fdt_addr_to_cpu(*cell); +		if (sizep) { +			const fdt_size_t *size; -		debug("%p\n", (void *)addr); +			size = (fdt_size_t *)((char *)cell + +					sizeof(fdt_addr_t)); +			*sizep = fdt_size_to_cpu(*size); +			debug("addr=%p, size=%p\n", (void *)addr, +			      (void *)*sizep); +		} else { +			debug("%p\n", (void *)addr); +		}  		return addr;  	}  	debug("(not found)\n");  	return FDT_ADDR_T_NONE;  } +fdt_addr_t fdtdec_get_addr(const void *blob, int node, +		const char *prop_name) +{ +	return fdtdec_get_addr_size(blob, node, prop_name, NULL); +} +  s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,  		s32 default_val)  { diff --git a/lib/initcall.c b/lib/initcall.c new file mode 100644 index 000000000..fc91bf641 --- /dev/null +++ b/lib/initcall.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <initcall.h> + +int initcall_run_list(init_fnc_t init_sequence[]) +{ +	init_fnc_t *init_fnc_ptr; + +	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { +		debug("initcall: %p\n", *init_fnc_ptr); +		if ((*init_fnc_ptr)()) { +			debug("initcall sequence %p failed at call %p\n", +			      init_sequence, *init_fnc_ptr); +			return -1; +		} +	} +	return 0; +}  |