diff options
| author | Gerald Van Baren <vanbaren@cideas.com> | 2007-04-14 22:51:24 -0400 | 
|---|---|---|
| committer | Gerald Van Baren <vanbaren@cideas.com> | 2007-04-14 22:51:24 -0400 | 
| commit | c28abb9c614f65ce2096cc4a66fc886c77d0e5a4 (patch) | |
| tree | e5ac701063ae2b80e27e7a49c6d9cf2dc44e8f0c /common/fdt_support.c | |
| parent | 3f9f08cf91c8a6949a5d78a18bd3d8df7b86d888 (diff) | |
| download | olio-uboot-2014.01-c28abb9c614f65ce2096cc4a66fc886c77d0e5a4.tar.xz olio-uboot-2014.01-c28abb9c614f65ce2096cc4a66fc886c77d0e5a4.zip  | |
Improve the bootm command for CONFIG_OF_LIBFDT
In bootm, create the "/chosen" node only if it doesn't already exist
  (better matches the previous behavior).
Update for proper reserved memory map handling for initrd.
Diffstat (limited to 'common/fdt_support.c')
| -rw-r--r-- | common/fdt_support.c | 34 | 
1 files changed, 29 insertions, 5 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c index 14a4df5fa..91b729f37 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -55,9 +55,33 @@ int fdt_chosen(void *fdt, ulong initrd_start, ulong initrd_end, int force)  		return err;  	} -#warning "Don't double-add the reserved map"  	if (initrd_start && initrd_end) { -		err = fdt_add_reservemap_entry(fdt, +		struct fdt_reserve_entry *re; +		int  used; +		int  total; +		int  j; + +		err = fdt_num_reservemap(fdt, &used, &total); +		if (err < 0) { +			printf("libfdt: %s\n", fdt_strerror(err)); +			return err; +		} +		if (used >= total) { +			printf("fdt_chosen: no room in the reserved map (%d of %d)\n", +				used, total); +			return -1; +		} +		/* +		 * Look for an existing entry and update it.  If we don't find +		 * the entry, we will j be the next available slot. +		 */ +		for (j = 0; j < used; j++) { +			err = fdt_get_reservemap(fdt, j, &re); +			if (re->address == initrd_start) { +				break; +			} +		} +		err = fdt_replace_reservemap_entry(fdt, j,  			initrd_start, initrd_end - initrd_start + 1);  		if (err < 0) {  			printf("libfdt: %s\n", fdt_strerror(err)); @@ -202,13 +226,13 @@ int fdt_env(void *fdt)  			continue;  		err = fdt_setprop(fdt, nodeoffset, lval, rval, strlen(rval)+1);  		if (err < 0) { -			printf("libfdt: %s\n", lval, fdt_strerror(err)); +			printf("libfdt: %s\n", fdt_strerror(err));  			return err;  		}  	}  	return 0;  } -#endif /* CONFIG_OF_HAS_UBOOT_ENV */ +#endif /* ifdef CONFIG_OF_HAS_UBOOT_ENV */  /********************************************************************/ @@ -318,6 +342,6 @@ int fdt_bd_t(void *fdt)  	return 0;  } -#endif /* CONFIG_OF_HAS_BD_T */ +#endif /* ifdef CONFIG_OF_HAS_BD_T */  #endif /* CONFIG_OF_LIBFDT */  |