2 * Copyright (c) 2013, Google Inc.
4 * (C) Copyright 2008 Semihalf
6 * (C) Copyright 2000-2006
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * SPDX-License-Identifier: GPL-2.0+
21 DECLARE_GLOBAL_DATA_PTR
;
22 #endif /* !USE_HOSTCC*/
24 #include <bootstage.h>
25 #include <u-boot/crc.h>
26 #include <u-boot/md5.h>
27 #include <u-boot/sha1.h>
28 #include <u-boot/sha256.h>
30 /*****************************************************************************/
31 /* New uImage format routines */
32 /*****************************************************************************/
34 static int fit_parse_spec(const char *spec
, char sepc
, ulong addr_curr
,
35 ulong
*addr
, const char **name
)
42 sep
= strchr(spec
, sepc
);
45 *addr
= simple_strtoul(spec
, NULL
, 16);
55 * fit_parse_conf - parse FIT configuration spec
56 * @spec: input string, containing configuration spec
57 * @add_curr: current image address (to be used as a possible default)
58 * @addr: pointer to a ulong variable, will hold FIT image address of a given
60 * @conf_name double pointer to a char, will hold pointer to a configuration
63 * fit_parse_conf() expects configuration spec in the form of [<addr>]#<conf>,
64 * where <addr> is a FIT image address that contains configuration
65 * with a <conf> unit name.
67 * Address part is optional, and if omitted default add_curr will
71 * 1 if spec is a valid configuration string,
72 * addr and conf_name are set accordingly
75 int fit_parse_conf(const char *spec
, ulong addr_curr
,
76 ulong
*addr
, const char **conf_name
)
78 return fit_parse_spec(spec
, '#', addr_curr
, addr
, conf_name
);
82 * fit_parse_subimage - parse FIT subimage spec
83 * @spec: input string, containing subimage spec
84 * @add_curr: current image address (to be used as a possible default)
85 * @addr: pointer to a ulong variable, will hold FIT image address of a given
87 * @image_name: double pointer to a char, will hold pointer to a subimage name
89 * fit_parse_subimage() expects subimage spec in the form of
90 * [<addr>]:<subimage>, where <addr> is a FIT image address that contains
91 * subimage with a <subimg> unit name.
93 * Address part is optional, and if omitted default add_curr will
97 * 1 if spec is a valid subimage string,
98 * addr and image_name are set accordingly
101 int fit_parse_subimage(const char *spec
, ulong addr_curr
,
102 ulong
*addr
, const char **image_name
)
104 return fit_parse_spec(spec
, ':', addr_curr
, addr
, image_name
);
106 #endif /* !USE_HOSTCC */
108 static void fit_get_debug(const void *fit
, int noffset
,
109 char *prop_name
, int err
)
111 debug("Can't get '%s' property from FIT 0x%08lx, node: offset %d, name %s (%s)\n",
112 prop_name
, (ulong
)fit
, noffset
, fit_get_name(fit
, noffset
, NULL
),
117 * fit_get_subimage_count - get component (sub-image) count
118 * @fit: pointer to the FIT format image header
119 * @images_noffset: offset of images node
122 * number of image components
124 int fit_get_subimage_count(const void *fit
, int images_noffset
)
130 /* Process its subnodes, print out component images details */
131 for (ndepth
= 0, count
= 0,
132 noffset
= fdt_next_node(fit
, images_noffset
, &ndepth
);
133 (noffset
>= 0) && (ndepth
> 0);
134 noffset
= fdt_next_node(fit
, noffset
, &ndepth
)) {
143 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_FIT_SPL_PRINT)
145 * fit_print_contents - prints out the contents of the FIT format image
146 * @fit: pointer to the FIT format image header
147 * @p: pointer to prefix string
149 * fit_print_contents() formats a multi line FIT image contents description.
150 * The routine prints out FIT image properties (root node level) follwed by
151 * the details of each component image.
154 * no returned results
156 void fit_print_contents(const void *fit
)
169 /* Indent string is defined in header image.h */
170 p
= IMAGE_INDENT_STRING
;
172 /* Root node properties */
173 ret
= fit_get_desc(fit
, 0, &desc
);
174 printf("%sFIT description: ", p
);
176 printf("unavailable\n");
178 printf("%s\n", desc
);
180 if (IMAGE_ENABLE_TIMESTAMP
) {
181 ret
= fit_get_timestamp(fit
, 0, ×tamp
);
182 printf("%sCreated: ", p
);
184 printf("unavailable\n");
186 genimg_print_time(timestamp
);
189 /* Find images parent node offset */
190 images_noffset
= fdt_path_offset(fit
, FIT_IMAGES_PATH
);
191 if (images_noffset
< 0) {
192 printf("Can't find images parent node '%s' (%s)\n",
193 FIT_IMAGES_PATH
, fdt_strerror(images_noffset
));
197 /* Process its subnodes, print out component images details */
198 for (ndepth
= 0, count
= 0,
199 noffset
= fdt_next_node(fit
, images_noffset
, &ndepth
);
200 (noffset
>= 0) && (ndepth
> 0);
201 noffset
= fdt_next_node(fit
, noffset
, &ndepth
)) {
204 * Direct child node of the images parent node,
205 * i.e. component image node.
207 printf("%s Image %u (%s)\n", p
, count
++,
208 fit_get_name(fit
, noffset
, NULL
));
210 fit_image_print(fit
, noffset
, p
);
214 /* Find configurations parent node offset */
215 confs_noffset
= fdt_path_offset(fit
, FIT_CONFS_PATH
);
216 if (confs_noffset
< 0) {
217 debug("Can't get configurations parent node '%s' (%s)\n",
218 FIT_CONFS_PATH
, fdt_strerror(confs_noffset
));
222 /* get default configuration unit name from default property */
223 uname
= (char *)fdt_getprop(fit
, noffset
, FIT_DEFAULT_PROP
, NULL
);
225 printf("%s Default Configuration: '%s'\n", p
, uname
);
227 /* Process its subnodes, print out configurations details */
228 for (ndepth
= 0, count
= 0,
229 noffset
= fdt_next_node(fit
, confs_noffset
, &ndepth
);
230 (noffset
>= 0) && (ndepth
> 0);
231 noffset
= fdt_next_node(fit
, noffset
, &ndepth
)) {
234 * Direct child node of the configurations parent node,
235 * i.e. configuration node.
237 printf("%s Configuration %u (%s)\n", p
, count
++,
238 fit_get_name(fit
, noffset
, NULL
));
240 fit_conf_print(fit
, noffset
, p
);
246 * fit_image_print_data() - prints out the hash node details
247 * @fit: pointer to the FIT format image header
248 * @noffset: offset of the hash node
249 * @p: pointer to prefix string
250 * @type: Type of information to print ("hash" or "sign")
252 * fit_image_print_data() lists properies for the processed hash node
254 * This function avoid using puts() since it prints a newline on the host
255 * but does not in U-Boot.
258 * no returned results
260 static void fit_image_print_data(const void *fit
, int noffset
, const char *p
,
270 debug("%s %s node: '%s'\n", p
, type
,
271 fit_get_name(fit
, noffset
, NULL
));
272 printf("%s %s algo: ", p
, type
);
273 if (fit_image_hash_get_algo(fit
, noffset
, &algo
)) {
274 printf("invalid/unsupported\n");
278 keyname
= fdt_getprop(fit
, noffset
, "key-name-hint", NULL
);
279 required
= fdt_getprop(fit
, noffset
, "required", NULL
) != NULL
;
281 printf(":%s", keyname
);
283 printf(" (required)");
286 ret
= fit_image_hash_get_value(fit
, noffset
, &value
,
288 printf("%s %s value: ", p
, type
);
290 printf("unavailable\n");
292 for (i
= 0; i
< value_len
; i
++)
293 printf("%02x", value
[i
]);
297 debug("%s %s len: %d\n", p
, type
, value_len
);
299 /* Signatures have a time stamp */
300 if (IMAGE_ENABLE_TIMESTAMP
&& keyname
) {
303 printf("%s Timestamp: ", p
);
304 if (fit_get_timestamp(fit
, noffset
, ×tamp
))
305 printf("unavailable\n");
307 genimg_print_time(timestamp
);
312 * fit_image_print_verification_data() - prints out the hash/signature details
313 * @fit: pointer to the FIT format image header
314 * @noffset: offset of the hash or signature node
315 * @p: pointer to prefix string
317 * This lists properies for the processed hash node
320 * no returned results
322 static void fit_image_print_verification_data(const void *fit
, int noffset
,
328 * Check subnode name, must be equal to "hash" or "signature".
329 * Multiple hash/signature nodes require unique unit node
330 * names, e.g. hash@1, hash@2, signature@1, signature@2, etc.
332 name
= fit_get_name(fit
, noffset
, NULL
);
333 if (!strncmp(name
, FIT_HASH_NODENAME
, strlen(FIT_HASH_NODENAME
))) {
334 fit_image_print_data(fit
, noffset
, p
, "Hash");
335 } else if (!strncmp(name
, FIT_SIG_NODENAME
,
336 strlen(FIT_SIG_NODENAME
))) {
337 fit_image_print_data(fit
, noffset
, p
, "Sign");
342 * fit_image_print - prints out the FIT component image details
343 * @fit: pointer to the FIT format image header
344 * @image_noffset: offset of the component image node
345 * @p: pointer to prefix string
347 * fit_image_print() lists all mandatory properies for the processed component
348 * image. If present, hash nodes are printed out as well. Load
349 * address for images of type firmware is also printed out. Since the load
350 * address is not mandatory for firmware images, it will be output as
351 * "unavailable" when not present.
354 * no returned results
356 void fit_image_print(const void *fit
, int image_noffset
, const char *p
)
359 uint8_t type
, arch
, os
, comp
;
367 /* Mandatory properties */
368 ret
= fit_get_desc(fit
, image_noffset
, &desc
);
369 printf("%s Description: ", p
);
371 printf("unavailable\n");
373 printf("%s\n", desc
);
375 if (IMAGE_ENABLE_TIMESTAMP
) {
378 ret
= fit_get_timestamp(fit
, 0, ×tamp
);
379 printf("%s Created: ", p
);
381 printf("unavailable\n");
383 genimg_print_time(timestamp
);
386 fit_image_get_type(fit
, image_noffset
, &type
);
387 printf("%s Type: %s\n", p
, genimg_get_type_name(type
));
389 fit_image_get_comp(fit
, image_noffset
, &comp
);
390 printf("%s Compression: %s\n", p
, genimg_get_comp_name(comp
));
392 ret
= fit_image_get_data(fit
, image_noffset
, &data
, &size
);
395 printf("%s Data Start: ", p
);
397 printf("unavailable\n");
399 void *vdata
= (void *)data
;
401 printf("0x%08lx\n", (ulong
)map_to_sysmem(vdata
));
405 printf("%s Data Size: ", p
);
407 printf("unavailable\n");
409 genimg_print_size(size
);
411 /* Remaining, type dependent properties */
412 if ((type
== IH_TYPE_KERNEL
) || (type
== IH_TYPE_STANDALONE
) ||
413 (type
== IH_TYPE_RAMDISK
) || (type
== IH_TYPE_FIRMWARE
) ||
414 (type
== IH_TYPE_FLATDT
)) {
415 fit_image_get_arch(fit
, image_noffset
, &arch
);
416 printf("%s Architecture: %s\n", p
, genimg_get_arch_name(arch
));
419 if ((type
== IH_TYPE_KERNEL
) || (type
== IH_TYPE_RAMDISK
)) {
420 fit_image_get_os(fit
, image_noffset
, &os
);
421 printf("%s OS: %s\n", p
, genimg_get_os_name(os
));
424 if ((type
== IH_TYPE_KERNEL
) || (type
== IH_TYPE_STANDALONE
) ||
425 (type
== IH_TYPE_FIRMWARE
) || (type
== IH_TYPE_RAMDISK
)) {
426 ret
= fit_image_get_load(fit
, image_noffset
, &load
);
427 printf("%s Load Address: ", p
);
429 printf("unavailable\n");
431 printf("0x%08lx\n", load
);
434 if ((type
== IH_TYPE_KERNEL
) || (type
== IH_TYPE_STANDALONE
) ||
435 (type
== IH_TYPE_RAMDISK
)) {
436 ret
= fit_image_get_entry(fit
, image_noffset
, &entry
);
437 printf("%s Entry Point: ", p
);
439 printf("unavailable\n");
441 printf("0x%08lx\n", entry
);
444 /* Process all hash subnodes of the component image node */
445 for (ndepth
= 0, noffset
= fdt_next_node(fit
, image_noffset
, &ndepth
);
446 (noffset
>= 0) && (ndepth
> 0);
447 noffset
= fdt_next_node(fit
, noffset
, &ndepth
)) {
449 /* Direct child node of the component image node */
450 fit_image_print_verification_data(fit
, noffset
, p
);
455 #endif /* !defined(CONFIG_SPL_BUILD) || defined(CONFIG_FIT_SPL_PRINT) */
458 * fit_get_desc - get node description property
459 * @fit: pointer to the FIT format image header
460 * @noffset: node offset
461 * @desc: double pointer to the char, will hold pointer to the descrption
463 * fit_get_desc() reads description property from a given node, if
464 * description is found pointer to it is returened in third call argument.
470 int fit_get_desc(const void *fit
, int noffset
, char **desc
)
474 *desc
= (char *)fdt_getprop(fit
, noffset
, FIT_DESC_PROP
, &len
);
476 fit_get_debug(fit
, noffset
, FIT_DESC_PROP
, len
);
484 * fit_get_timestamp - get node timestamp property
485 * @fit: pointer to the FIT format image header
486 * @noffset: node offset
487 * @timestamp: pointer to the time_t, will hold read timestamp
489 * fit_get_timestamp() reads timestamp poperty from given node, if timestamp
490 * is found and has a correct size its value is retured in third call
495 * -1, on property read failure
496 * -2, on wrong timestamp size
498 int fit_get_timestamp(const void *fit
, int noffset
, time_t *timestamp
)
503 data
= fdt_getprop(fit
, noffset
, FIT_TIMESTAMP_PROP
, &len
);
505 fit_get_debug(fit
, noffset
, FIT_TIMESTAMP_PROP
, len
);
508 if (len
!= sizeof(uint32_t)) {
509 debug("FIT timestamp with incorrect size of (%u)\n", len
);
513 *timestamp
= uimage_to_cpu(*((uint32_t *)data
));
518 * fit_image_get_node - get node offset for component image of a given unit name
519 * @fit: pointer to the FIT format image header
520 * @image_uname: component image node unit name
522 * fit_image_get_node() finds a component image (withing the '/images'
523 * node) of a provided unit name. If image is found its node offset is
524 * returned to the caller.
527 * image node offset when found (>=0)
528 * negative number on failure (FDT_ERR_* code)
530 int fit_image_get_node(const void *fit
, const char *image_uname
)
532 int noffset
, images_noffset
;
534 images_noffset
= fdt_path_offset(fit
, FIT_IMAGES_PATH
);
535 if (images_noffset
< 0) {
536 debug("Can't find images parent node '%s' (%s)\n",
537 FIT_IMAGES_PATH
, fdt_strerror(images_noffset
));
538 return images_noffset
;
541 noffset
= fdt_subnode_offset(fit
, images_noffset
, image_uname
);
543 debug("Can't get node offset for image unit name: '%s' (%s)\n",
544 image_uname
, fdt_strerror(noffset
));
551 * fit_image_get_os - get os id for a given component image node
552 * @fit: pointer to the FIT format image header
553 * @noffset: component image node offset
554 * @os: pointer to the uint8_t, will hold os numeric id
556 * fit_image_get_os() finds os property in a given component image node.
557 * If the property is found, its (string) value is translated to the numeric
558 * id which is returned to the caller.
564 int fit_image_get_os(const void *fit
, int noffset
, uint8_t *os
)
569 /* Get OS name from property data */
570 data
= fdt_getprop(fit
, noffset
, FIT_OS_PROP
, &len
);
572 fit_get_debug(fit
, noffset
, FIT_OS_PROP
, len
);
577 /* Translate OS name to id */
578 *os
= genimg_get_os_id(data
);
583 * fit_image_get_arch - get arch id for a given component image node
584 * @fit: pointer to the FIT format image header
585 * @noffset: component image node offset
586 * @arch: pointer to the uint8_t, will hold arch numeric id
588 * fit_image_get_arch() finds arch property in a given component image node.
589 * If the property is found, its (string) value is translated to the numeric
590 * id which is returned to the caller.
596 int fit_image_get_arch(const void *fit
, int noffset
, uint8_t *arch
)
601 /* Get architecture name from property data */
602 data
= fdt_getprop(fit
, noffset
, FIT_ARCH_PROP
, &len
);
604 fit_get_debug(fit
, noffset
, FIT_ARCH_PROP
, len
);
609 /* Translate architecture name to id */
610 *arch
= genimg_get_arch_id(data
);
615 * fit_image_get_type - get type id for a given component image node
616 * @fit: pointer to the FIT format image header
617 * @noffset: component image node offset
618 * @type: pointer to the uint8_t, will hold type numeric id
620 * fit_image_get_type() finds type property in a given component image node.
621 * If the property is found, its (string) value is translated to the numeric
622 * id which is returned to the caller.
628 int fit_image_get_type(const void *fit
, int noffset
, uint8_t *type
)
633 /* Get image type name from property data */
634 data
= fdt_getprop(fit
, noffset
, FIT_TYPE_PROP
, &len
);
636 fit_get_debug(fit
, noffset
, FIT_TYPE_PROP
, len
);
641 /* Translate image type name to id */
642 *type
= genimg_get_type_id(data
);
647 * fit_image_get_comp - get comp id for a given component image node
648 * @fit: pointer to the FIT format image header
649 * @noffset: component image node offset
650 * @comp: pointer to the uint8_t, will hold comp numeric id
652 * fit_image_get_comp() finds comp property in a given component image node.
653 * If the property is found, its (string) value is translated to the numeric
654 * id which is returned to the caller.
660 int fit_image_get_comp(const void *fit
, int noffset
, uint8_t *comp
)
665 /* Get compression name from property data */
666 data
= fdt_getprop(fit
, noffset
, FIT_COMP_PROP
, &len
);
668 fit_get_debug(fit
, noffset
, FIT_COMP_PROP
, len
);
673 /* Translate compression name to id */
674 *comp
= genimg_get_comp_id(data
);
678 static int fit_image_get_address(const void *fit
, int noffset
, char *name
,
685 cell
= fdt_getprop(fit
, noffset
, name
, &len
);
687 fit_get_debug(fit
, noffset
, name
, len
);
691 if (len
> sizeof(ulong
)) {
692 printf("Unsupported %s address size\n", name
);
697 /* Use load64 to avoid compiling warning for 32-bit target */
699 load64
= (load64
<< 32) | uimage_to_cpu(*cell
);
702 *load
= (ulong
)load64
;
707 * fit_image_get_load() - get load addr property for given component image node
708 * @fit: pointer to the FIT format image header
709 * @noffset: component image node offset
710 * @load: pointer to the uint32_t, will hold load address
712 * fit_image_get_load() finds load address property in a given component
713 * image node. If the property is found, its value is returned to the caller.
719 int fit_image_get_load(const void *fit
, int noffset
, ulong
*load
)
721 return fit_image_get_address(fit
, noffset
, FIT_LOAD_PROP
, load
);
725 * fit_image_get_entry() - get entry point address property
726 * @fit: pointer to the FIT format image header
727 * @noffset: component image node offset
728 * @entry: pointer to the uint32_t, will hold entry point address
730 * This gets the entry point address property for a given component image
733 * fit_image_get_entry() finds entry point address property in a given
734 * component image node. If the property is found, its value is returned
741 int fit_image_get_entry(const void *fit
, int noffset
, ulong
*entry
)
743 return fit_image_get_address(fit
, noffset
, FIT_ENTRY_PROP
, entry
);
747 * fit_image_get_data - get data property and its size for a given component image node
748 * @fit: pointer to the FIT format image header
749 * @noffset: component image node offset
750 * @data: double pointer to void, will hold data property's data address
751 * @size: pointer to size_t, will hold data property's data size
753 * fit_image_get_data() finds data property in a given component image node.
754 * If the property is found its data start address and size are returned to
761 int fit_image_get_data(const void *fit
, int noffset
,
762 const void **data
, size_t *size
)
766 *data
= fdt_getprop(fit
, noffset
, FIT_DATA_PROP
, &len
);
768 fit_get_debug(fit
, noffset
, FIT_DATA_PROP
, len
);
778 * fit_image_hash_get_algo - get hash algorithm name
779 * @fit: pointer to the FIT format image header
780 * @noffset: hash node offset
781 * @algo: double pointer to char, will hold pointer to the algorithm name
783 * fit_image_hash_get_algo() finds hash algorithm property in a given hash node.
784 * If the property is found its data start address is returned to the caller.
790 int fit_image_hash_get_algo(const void *fit
, int noffset
, char **algo
)
794 *algo
= (char *)fdt_getprop(fit
, noffset
, FIT_ALGO_PROP
, &len
);
796 fit_get_debug(fit
, noffset
, FIT_ALGO_PROP
, len
);
804 * fit_image_hash_get_value - get hash value and length
805 * @fit: pointer to the FIT format image header
806 * @noffset: hash node offset
807 * @value: double pointer to uint8_t, will hold address of a hash value data
808 * @value_len: pointer to an int, will hold hash data length
810 * fit_image_hash_get_value() finds hash value property in a given hash node.
811 * If the property is found its data start address and size are returned to
818 int fit_image_hash_get_value(const void *fit
, int noffset
, uint8_t **value
,
823 *value
= (uint8_t *)fdt_getprop(fit
, noffset
, FIT_VALUE_PROP
, &len
);
824 if (*value
== NULL
) {
825 fit_get_debug(fit
, noffset
, FIT_VALUE_PROP
, len
);
835 * fit_image_hash_get_ignore - get hash ignore flag
836 * @fit: pointer to the FIT format image header
837 * @noffset: hash node offset
838 * @ignore: pointer to an int, will hold hash ignore flag
840 * fit_image_hash_get_ignore() finds hash ignore property in a given hash node.
841 * If the property is found and non-zero, the hash algorithm is not verified by
842 * u-boot automatically.
845 * 0, on ignore not found
846 * value, on ignore found
848 static int fit_image_hash_get_ignore(const void *fit
, int noffset
, int *ignore
)
853 value
= (int *)fdt_getprop(fit
, noffset
, FIT_IGNORE_PROP
, &len
);
854 if (value
== NULL
|| len
!= sizeof(int))
862 ulong
fit_get_end(const void *fit
)
864 return map_to_sysmem((void *)(fit
+ fdt_totalsize(fit
)));
868 * fit_set_timestamp - set node timestamp property
869 * @fit: pointer to the FIT format image header
870 * @noffset: node offset
871 * @timestamp: timestamp value to be set
873 * fit_set_timestamp() attempts to set timestamp property in the requested
874 * node and returns operation status to the caller.
878 * -ENOSPC if no space in device tree, -1 for other error
880 int fit_set_timestamp(void *fit
, int noffset
, time_t timestamp
)
885 t
= cpu_to_uimage(timestamp
);
886 ret
= fdt_setprop(fit
, noffset
, FIT_TIMESTAMP_PROP
, &t
,
889 printf("Can't set '%s' property for '%s' node (%s)\n",
890 FIT_TIMESTAMP_PROP
, fit_get_name(fit
, noffset
, NULL
),
892 return ret
== -FDT_ERR_NOSPACE
? -ENOSPC
: -1;
899 * calculate_hash - calculate and return hash for provided input data
900 * @data: pointer to the input data
901 * @data_len: data length
902 * @algo: requested hash algorithm
903 * @value: pointer to the char, will hold hash value data (caller must
904 * allocate enough free space)
905 * value_len: length of the calculated hash
907 * calculate_hash() computes input data hash according to the requested
909 * Resulting hash value is placed in caller provided 'value' buffer, length
910 * of the calculated hash is returned via value_len pointer argument.
914 * -1, when algo is unsupported
916 int calculate_hash(const void *data
, int data_len
, const char *algo
,
917 uint8_t *value
, int *value_len
)
919 if (IMAGE_ENABLE_CRC32
&& strcmp(algo
, "crc32") == 0) {
920 *((uint32_t *)value
) = crc32_wd(0, data
, data_len
,
922 *((uint32_t *)value
) = cpu_to_uimage(*((uint32_t *)value
));
924 } else if (IMAGE_ENABLE_SHA1
&& strcmp(algo
, "sha1") == 0) {
925 sha1_csum_wd((unsigned char *)data
, data_len
,
926 (unsigned char *)value
, CHUNKSZ_SHA1
);
928 } else if (IMAGE_ENABLE_SHA256
&& strcmp(algo
, "sha256") == 0) {
929 sha256_csum_wd((unsigned char *)data
, data_len
,
930 (unsigned char *)value
, CHUNKSZ_SHA256
);
931 *value_len
= SHA256_SUM_LEN
;
932 } else if (IMAGE_ENABLE_MD5
&& strcmp(algo
, "md5") == 0) {
933 md5_wd((unsigned char *)data
, data_len
, value
, CHUNKSZ_MD5
);
936 debug("Unsupported hash alogrithm\n");
942 static int fit_image_check_hash(const void *fit
, int noffset
, const void *data
,
943 size_t size
, char **err_msgp
)
945 uint8_t value
[FIT_MAX_HASH_LEN
];
954 if (fit_image_hash_get_algo(fit
, noffset
, &algo
)) {
955 *err_msgp
= "Can't get hash algo property";
960 if (IMAGE_ENABLE_IGNORE
) {
961 fit_image_hash_get_ignore(fit
, noffset
, &ignore
);
968 if (fit_image_hash_get_value(fit
, noffset
, &fit_value
,
970 *err_msgp
= "Can't get hash value property";
974 if (calculate_hash(data
, size
, algo
, value
, &value_len
)) {
975 *err_msgp
= "Unsupported hash algorithm";
979 if (value_len
!= fit_value_len
) {
980 *err_msgp
= "Bad hash value len";
982 } else if (memcmp(value
, fit_value
, value_len
) != 0) {
983 *err_msgp
= "Bad hash value";
991 * fit_image_verify - verify data intergity
992 * @fit: pointer to the FIT format image header
993 * @image_noffset: component image node offset
995 * fit_image_verify() goes over component image hash nodes,
996 * re-calculates each data hash and compares with the value stored in hash
1000 * 1, if all hashes are valid
1001 * 0, otherwise (or on error)
1003 int fit_image_verify(const void *fit
, int image_noffset
)
1012 /* Get image data and data length */
1013 if (fit_image_get_data(fit
, image_noffset
, &data
, &size
)) {
1014 err_msg
= "Can't get image data/size";
1018 /* Verify all required signatures */
1019 if (IMAGE_ENABLE_VERIFY
&&
1020 fit_image_verify_required_sigs(fit
, image_noffset
, data
, size
,
1021 gd_fdt_blob(), &verify_all
)) {
1022 err_msg
= "Unable to verify required signature";
1026 /* Process all hash subnodes of the component image node */
1027 fdt_for_each_subnode(fit
, noffset
, image_noffset
) {
1028 const char *name
= fit_get_name(fit
, noffset
, NULL
);
1031 * Check subnode name, must be equal to "hash".
1032 * Multiple hash nodes require unique unit node
1033 * names, e.g. hash@1, hash@2, etc.
1035 if (!strncmp(name
, FIT_HASH_NODENAME
,
1036 strlen(FIT_HASH_NODENAME
))) {
1037 if (fit_image_check_hash(fit
, noffset
, data
, size
,
1041 } else if (IMAGE_ENABLE_VERIFY
&& verify_all
&&
1042 !strncmp(name
, FIT_SIG_NODENAME
,
1043 strlen(FIT_SIG_NODENAME
))) {
1044 ret
= fit_image_check_sig(fit
, noffset
, data
,
1045 size
, -1, &err_msg
);
1048 * Show an indication on failure, but do not return
1049 * an error. Only keys marked 'required' can cause
1050 * an image validation failure. See the call to
1051 * fit_image_verify_required_sigs() above.
1060 if (noffset
== -FDT_ERR_TRUNCATED
|| noffset
== -FDT_ERR_BADSTRUCTURE
) {
1061 err_msg
= "Corrupted or truncated tree";
1068 printf(" error!\n%s for '%s' hash node in '%s' image node\n",
1069 err_msg
, fit_get_name(fit
, noffset
, NULL
),
1070 fit_get_name(fit
, image_noffset
, NULL
));
1075 * fit_all_image_verify - verify data intergity for all images
1076 * @fit: pointer to the FIT format image header
1078 * fit_all_image_verify() goes over all images in the FIT and
1079 * for every images checks if all it's hashes are valid.
1082 * 1, if all hashes of all images are valid
1083 * 0, otherwise (or on error)
1085 int fit_all_image_verify(const void *fit
)
1092 /* Find images parent node offset */
1093 images_noffset
= fdt_path_offset(fit
, FIT_IMAGES_PATH
);
1094 if (images_noffset
< 0) {
1095 printf("Can't find images parent node '%s' (%s)\n",
1096 FIT_IMAGES_PATH
, fdt_strerror(images_noffset
));
1100 /* Process all image subnodes, check hashes for each */
1101 printf("## Checking hash(es) for FIT Image at %08lx ...\n",
1103 for (ndepth
= 0, count
= 0,
1104 noffset
= fdt_next_node(fit
, images_noffset
, &ndepth
);
1105 (noffset
>= 0) && (ndepth
> 0);
1106 noffset
= fdt_next_node(fit
, noffset
, &ndepth
)) {
1109 * Direct child node of the images parent node,
1110 * i.e. component image node.
1112 printf(" Hash(es) for Image %u (%s): ", count
,
1113 fit_get_name(fit
, noffset
, NULL
));
1116 if (!fit_image_verify(fit
, noffset
))
1125 * fit_image_check_os - check whether image node is of a given os type
1126 * @fit: pointer to the FIT format image header
1127 * @noffset: component image node offset
1128 * @os: requested image os
1130 * fit_image_check_os() reads image os property and compares its numeric
1131 * id with the requested os. Comparison result is returned to the caller.
1134 * 1 if image is of given os type
1135 * 0 otherwise (or on error)
1137 int fit_image_check_os(const void *fit
, int noffset
, uint8_t os
)
1141 if (fit_image_get_os(fit
, noffset
, &image_os
))
1143 return (os
== image_os
);
1147 * fit_image_check_arch - check whether image node is of a given arch
1148 * @fit: pointer to the FIT format image header
1149 * @noffset: component image node offset
1150 * @arch: requested imagearch
1152 * fit_image_check_arch() reads image arch property and compares its numeric
1153 * id with the requested arch. Comparison result is returned to the caller.
1156 * 1 if image is of given arch
1157 * 0 otherwise (or on error)
1159 int fit_image_check_arch(const void *fit
, int noffset
, uint8_t arch
)
1163 if (fit_image_get_arch(fit
, noffset
, &image_arch
))
1165 return (arch
== image_arch
) ||
1166 (arch
== IH_ARCH_I386
&& image_arch
== IH_ARCH_X86_64
);
1170 * fit_image_check_type - check whether image node is of a given type
1171 * @fit: pointer to the FIT format image header
1172 * @noffset: component image node offset
1173 * @type: requested image type
1175 * fit_image_check_type() reads image type property and compares its numeric
1176 * id with the requested type. Comparison result is returned to the caller.
1179 * 1 if image is of given type
1180 * 0 otherwise (or on error)
1182 int fit_image_check_type(const void *fit
, int noffset
, uint8_t type
)
1186 if (fit_image_get_type(fit
, noffset
, &image_type
))
1188 return (type
== image_type
);
1192 * fit_image_check_comp - check whether image node uses given compression
1193 * @fit: pointer to the FIT format image header
1194 * @noffset: component image node offset
1195 * @comp: requested image compression type
1197 * fit_image_check_comp() reads image compression property and compares its
1198 * numeric id with the requested compression type. Comparison result is
1199 * returned to the caller.
1202 * 1 if image uses requested compression
1203 * 0 otherwise (or on error)
1205 int fit_image_check_comp(const void *fit
, int noffset
, uint8_t comp
)
1209 if (fit_image_get_comp(fit
, noffset
, &image_comp
))
1211 return (comp
== image_comp
);
1215 * fit_check_format - sanity check FIT image format
1216 * @fit: pointer to the FIT format image header
1218 * fit_check_format() runs a basic sanity FIT image verification.
1219 * Routine checks for mandatory properties, nodes, etc.
1225 int fit_check_format(const void *fit
)
1227 /* mandatory / node 'description' property */
1228 if (fdt_getprop(fit
, 0, FIT_DESC_PROP
, NULL
) == NULL
) {
1229 debug("Wrong FIT format: no description\n");
1233 if (IMAGE_ENABLE_TIMESTAMP
) {
1234 /* mandatory / node 'timestamp' property */
1235 if (fdt_getprop(fit
, 0, FIT_TIMESTAMP_PROP
, NULL
) == NULL
) {
1236 debug("Wrong FIT format: no timestamp\n");
1241 /* mandatory subimages parent '/images' node */
1242 if (fdt_path_offset(fit
, FIT_IMAGES_PATH
) < 0) {
1243 debug("Wrong FIT format: no images parent node\n");
1252 * fit_conf_find_compat
1253 * @fit: pointer to the FIT format image header
1254 * @fdt: pointer to the device tree to compare against
1256 * fit_conf_find_compat() attempts to find the configuration whose fdt is the
1257 * most compatible with the passed in device tree.
1266 * |-o configurations
1274 * |-compatible = "foo,bar", "bim,bam"
1277 * |-compatible = "foo,bar",
1280 * |-compatible = "bim,bam", "baz,biz"
1282 * Configuration 1 would be picked because the first string in U-Boot's
1283 * compatible list, "foo,bar", matches a compatible string in the root of fdt1.
1284 * "bim,bam" in fdt2 matches the second string which isn't as good as fdt1.
1287 * offset to the configuration to use if one was found
1290 int fit_conf_find_compat(const void *fit
, const void *fdt
)
1293 int noffset
, confs_noffset
, images_noffset
;
1294 const void *fdt_compat
;
1296 int best_match_offset
= 0;
1297 int best_match_pos
= 0;
1299 confs_noffset
= fdt_path_offset(fit
, FIT_CONFS_PATH
);
1300 images_noffset
= fdt_path_offset(fit
, FIT_IMAGES_PATH
);
1301 if (confs_noffset
< 0 || images_noffset
< 0) {
1302 debug("Can't find configurations or images nodes.\n");
1306 fdt_compat
= fdt_getprop(fdt
, 0, "compatible", &fdt_compat_len
);
1308 debug("Fdt for comparison has no \"compatible\" property.\n");
1313 * Loop over the configurations in the FIT image.
1315 for (noffset
= fdt_next_node(fit
, confs_noffset
, &ndepth
);
1316 (noffset
>= 0) && (ndepth
> 0);
1317 noffset
= fdt_next_node(fit
, noffset
, &ndepth
)) {
1319 const char *kfdt_name
;
1321 const char *cur_fdt_compat
;
1329 kfdt_name
= fdt_getprop(fit
, noffset
, "fdt", &len
);
1331 debug("No fdt property found.\n");
1334 kfdt_noffset
= fdt_subnode_offset(fit
, images_noffset
,
1336 if (kfdt_noffset
< 0) {
1337 debug("No image node named \"%s\" found.\n",
1342 * Get a pointer to this configuration's fdt.
1344 if (fit_image_get_data(fit
, kfdt_noffset
, &kfdt
, &size
)) {
1345 debug("Failed to get fdt \"%s\".\n", kfdt_name
);
1349 len
= fdt_compat_len
;
1350 cur_fdt_compat
= fdt_compat
;
1352 * Look for a match for each U-Boot compatibility string in
1353 * turn in this configuration's fdt.
1355 for (i
= 0; len
> 0 &&
1356 (!best_match_offset
|| best_match_pos
> i
); i
++) {
1357 int cur_len
= strlen(cur_fdt_compat
) + 1;
1359 if (!fdt_node_check_compatible(kfdt
, 0,
1361 best_match_offset
= noffset
;
1366 cur_fdt_compat
+= cur_len
;
1369 if (!best_match_offset
) {
1370 debug("No match found.\n");
1374 return best_match_offset
;
1378 * fit_conf_get_node - get node offset for configuration of a given unit name
1379 * @fit: pointer to the FIT format image header
1380 * @conf_uname: configuration node unit name
1382 * fit_conf_get_node() finds a configuration (withing the '/configurations'
1383 * parant node) of a provided unit name. If configuration is found its node
1384 * offset is returned to the caller.
1386 * When NULL is provided in second argument fit_conf_get_node() will search
1387 * for a default configuration node instead. Default configuration node unit
1388 * name is retrieved from FIT_DEFAULT_PROP property of the '/configurations'
1392 * configuration node offset when found (>=0)
1393 * negative number on failure (FDT_ERR_* code)
1395 int fit_conf_get_node(const void *fit
, const char *conf_uname
)
1397 int noffset
, confs_noffset
;
1400 confs_noffset
= fdt_path_offset(fit
, FIT_CONFS_PATH
);
1401 if (confs_noffset
< 0) {
1402 debug("Can't find configurations parent node '%s' (%s)\n",
1403 FIT_CONFS_PATH
, fdt_strerror(confs_noffset
));
1404 return confs_noffset
;
1407 if (conf_uname
== NULL
) {
1408 /* get configuration unit name from the default property */
1409 debug("No configuration specified, trying default...\n");
1410 conf_uname
= (char *)fdt_getprop(fit
, confs_noffset
,
1411 FIT_DEFAULT_PROP
, &len
);
1412 if (conf_uname
== NULL
) {
1413 fit_get_debug(fit
, confs_noffset
, FIT_DEFAULT_PROP
,
1417 debug("Found default configuration: '%s'\n", conf_uname
);
1420 noffset
= fdt_subnode_offset(fit
, confs_noffset
, conf_uname
);
1422 debug("Can't get node offset for configuration unit name: '%s' (%s)\n",
1423 conf_uname
, fdt_strerror(noffset
));
1429 int fit_conf_get_prop_node(const void *fit
, int noffset
,
1430 const char *prop_name
)
1435 /* get kernel image unit name from configuration kernel property */
1436 uname
= (char *)fdt_getprop(fit
, noffset
, prop_name
, &len
);
1440 return fit_image_get_node(fit
, uname
);
1444 * fit_conf_print - prints out the FIT configuration details
1445 * @fit: pointer to the FIT format image header
1446 * @noffset: offset of the configuration node
1447 * @p: pointer to prefix string
1449 * fit_conf_print() lists all mandatory properies for the processed
1450 * configuration node.
1453 * no returned results
1455 void fit_conf_print(const void *fit
, int noffset
, const char *p
)
1460 int loadables_index
;
1462 /* Mandatory properties */
1463 ret
= fit_get_desc(fit
, noffset
, &desc
);
1464 printf("%s Description: ", p
);
1466 printf("unavailable\n");
1468 printf("%s\n", desc
);
1470 uname
= (char *)fdt_getprop(fit
, noffset
, FIT_KERNEL_PROP
, NULL
);
1471 printf("%s Kernel: ", p
);
1473 printf("unavailable\n");
1475 printf("%s\n", uname
);
1477 /* Optional properties */
1478 uname
= (char *)fdt_getprop(fit
, noffset
, FIT_RAMDISK_PROP
, NULL
);
1480 printf("%s Init Ramdisk: %s\n", p
, uname
);
1482 uname
= (char *)fdt_getprop(fit
, noffset
, FIT_FDT_PROP
, NULL
);
1484 printf("%s FDT: %s\n", p
, uname
);
1486 /* Print out all of the specified loadables */
1487 for (loadables_index
= 0;
1488 fdt_get_string_index(fit
, noffset
,
1491 (const char **)&uname
) == 0;
1494 if (loadables_index
== 0) {
1495 printf("%s Loadables: ", p
);
1499 printf("%s\n", uname
);
1503 static int fit_image_select(const void *fit
, int rd_noffset
, int verify
)
1505 fit_image_print(fit
, rd_noffset
, " ");
1508 puts(" Verifying Hash Integrity ... ");
1509 if (!fit_image_verify(fit
, rd_noffset
)) {
1510 puts("Bad Data Hash\n");
1519 int fit_get_node_from_config(bootm_headers_t
*images
, const char *prop_name
,
1526 debug("* %s: using config '%s' from image at 0x%08lx\n",
1527 prop_name
, images
->fit_uname_cfg
, addr
);
1529 /* Check whether configuration has this property defined */
1530 fit_hdr
= map_sysmem(addr
, 0);
1531 cfg_noffset
= fit_conf_get_node(fit_hdr
, images
->fit_uname_cfg
);
1532 if (cfg_noffset
< 0) {
1533 debug("* %s: no such config\n", prop_name
);
1537 noffset
= fit_conf_get_prop_node(fit_hdr
, cfg_noffset
, prop_name
);
1539 debug("* %s: no '%s' in config\n", prop_name
, prop_name
);
1547 * fit_get_image_type_property() - get property name for IH_TYPE_...
1549 * @return the properly name where we expect to find the image in the
1552 static const char *fit_get_image_type_property(int type
)
1555 * This is sort-of available in the uimage_type[] table in image.c
1556 * but we don't have access to the sohrt name, and "fdt" is different
1557 * anyway. So let's just keep it here.
1560 case IH_TYPE_FLATDT
:
1561 return FIT_FDT_PROP
;
1562 case IH_TYPE_KERNEL
:
1563 return FIT_KERNEL_PROP
;
1564 case IH_TYPE_RAMDISK
:
1565 return FIT_RAMDISK_PROP
;
1566 case IH_TYPE_X86_SETUP
:
1567 return FIT_SETUP_PROP
;
1568 case IH_TYPE_LOADABLE
:
1569 return FIT_LOADABLE_PROP
;
1575 int fit_image_load(bootm_headers_t
*images
, ulong addr
,
1576 const char **fit_unamep
, const char **fit_uname_configp
,
1577 int arch
, int image_type
, int bootstage_id
,
1578 enum fit_load_op load_op
, ulong
*datap
, ulong
*lenp
)
1580 int cfg_noffset
, noffset
;
1581 const char *fit_uname
;
1582 const char *fit_uname_config
;
1587 ulong load
, data
, len
;
1589 const char *prop_name
;
1592 fit
= map_sysmem(addr
, 0);
1593 fit_uname
= fit_unamep
? *fit_unamep
: NULL
;
1594 fit_uname_config
= fit_uname_configp
? *fit_uname_configp
: NULL
;
1595 prop_name
= fit_get_image_type_property(image_type
);
1596 printf("## Loading %s from FIT Image at %08lx ...\n", prop_name
, addr
);
1598 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_FORMAT
);
1599 if (!fit_check_format(fit
)) {
1600 printf("Bad FIT %s image format!\n", prop_name
);
1601 bootstage_error(bootstage_id
+ BOOTSTAGE_SUB_FORMAT
);
1604 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_FORMAT_OK
);
1606 /* get FIT component image node offset */
1607 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_UNIT_NAME
);
1608 noffset
= fit_image_get_node(fit
, fit_uname
);
1611 * no image node unit name, try to get config
1612 * node first. If config unit node name is NULL
1613 * fit_conf_get_node() will try to find default config node
1615 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_NO_UNIT_NAME
);
1616 if (IMAGE_ENABLE_BEST_MATCH
&& !fit_uname_config
) {
1617 cfg_noffset
= fit_conf_find_compat(fit
, gd_fdt_blob());
1619 cfg_noffset
= fit_conf_get_node(fit
,
1622 if (cfg_noffset
< 0) {
1623 puts("Could not find configuration node\n");
1624 bootstage_error(bootstage_id
+
1625 BOOTSTAGE_SUB_NO_UNIT_NAME
);
1628 fit_uname_config
= fdt_get_name(fit
, cfg_noffset
, NULL
);
1629 printf(" Using '%s' configuration\n", fit_uname_config
);
1630 if (image_type
== IH_TYPE_KERNEL
) {
1631 /* Remember (and possibly verify) this config */
1632 images
->fit_uname_cfg
= fit_uname_config
;
1633 if (IMAGE_ENABLE_VERIFY
&& images
->verify
) {
1634 puts(" Verifying Hash Integrity ... ");
1635 if (fit_config_verify(fit
, cfg_noffset
)) {
1636 puts("Bad Data Hash\n");
1637 bootstage_error(bootstage_id
+
1638 BOOTSTAGE_SUB_HASH
);
1643 bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG
);
1646 noffset
= fit_conf_get_prop_node(fit
, cfg_noffset
,
1648 fit_uname
= fit_get_name(fit
, noffset
, NULL
);
1651 puts("Could not find subimage node\n");
1652 bootstage_error(bootstage_id
+ BOOTSTAGE_SUB_SUBNODE
);
1656 printf(" Trying '%s' %s subimage\n", fit_uname
, prop_name
);
1658 ret
= fit_image_select(fit
, noffset
, images
->verify
);
1660 bootstage_error(bootstage_id
+ BOOTSTAGE_SUB_HASH
);
1664 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_CHECK_ARCH
);
1665 #if !defined(USE_HOSTCC) && !defined(CONFIG_SANDBOX)
1666 if (!fit_image_check_target_arch(fit
, noffset
)) {
1667 puts("Unsupported Architecture\n");
1668 bootstage_error(bootstage_id
+ BOOTSTAGE_SUB_CHECK_ARCH
);
1672 if (image_type
== IH_TYPE_FLATDT
&&
1673 !fit_image_check_comp(fit
, noffset
, IH_COMP_NONE
)) {
1674 puts("FDT image is compressed");
1675 return -EPROTONOSUPPORT
;
1678 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_CHECK_ALL
);
1679 type_ok
= fit_image_check_type(fit
, noffset
, image_type
) ||
1680 (image_type
== IH_TYPE_KERNEL
&&
1681 fit_image_check_type(fit
, noffset
,
1682 IH_TYPE_KERNEL_NOLOAD
));
1684 os_ok
= image_type
== IH_TYPE_FLATDT
||
1685 fit_image_check_os(fit
, noffset
, IH_OS_LINUX
) ||
1686 fit_image_check_os(fit
, noffset
, IH_OS_OPENRTOS
);
1689 * If either of the checks fail, we should report an error, but
1690 * if the image type is coming from the "loadables" field, we
1691 * don't care what it is
1693 if ((!type_ok
|| !os_ok
) && image_type
!= IH_TYPE_LOADABLE
) {
1694 fit_image_get_os(fit
, noffset
, &os
);
1695 printf("No %s %s %s Image\n",
1696 genimg_get_os_name(os
),
1697 genimg_get_arch_name(arch
),
1698 genimg_get_type_name(image_type
));
1699 bootstage_error(bootstage_id
+ BOOTSTAGE_SUB_CHECK_ALL
);
1703 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_CHECK_ALL_OK
);
1705 /* get image data address and length */
1706 if (fit_image_get_data(fit
, noffset
, &buf
, &size
)) {
1707 printf("Could not find %s subimage data!\n", prop_name
);
1708 bootstage_error(bootstage_id
+ BOOTSTAGE_SUB_GET_DATA
);
1713 /* verify that image data is a proper FDT blob */
1714 if (image_type
== IH_TYPE_FLATDT
&& fdt_check_header(buf
)) {
1715 puts("Subimage data is not a FDT");
1719 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_GET_DATA_OK
);
1722 * Work-around for eldk-4.2 which gives this warning if we try to
1723 * cast in the unmap_sysmem() call:
1724 * warning: initialization discards qualifiers from pointer target type
1727 void *vbuf
= (void *)buf
;
1729 data
= map_to_sysmem(vbuf
);
1732 if (load_op
== FIT_LOAD_IGNORED
) {
1734 } else if (fit_image_get_load(fit
, noffset
, &load
)) {
1735 if (load_op
== FIT_LOAD_REQUIRED
) {
1736 printf("Can't get %s subimage load address!\n",
1738 bootstage_error(bootstage_id
+ BOOTSTAGE_SUB_LOAD
);
1741 } else if (load_op
!= FIT_LOAD_OPTIONAL_NON_ZERO
|| load
) {
1742 ulong image_start
, image_end
;
1747 * move image data to the load address,
1748 * make sure we don't overwrite initial image
1751 image_end
= addr
+ fit_get_size(fit
);
1753 load_end
= load
+ len
;
1754 if (image_type
!= IH_TYPE_KERNEL
&&
1755 load
< image_end
&& load_end
> image_start
) {
1756 printf("Error: %s overwritten\n", prop_name
);
1760 printf(" Loading %s from 0x%08lx to 0x%08lx\n",
1761 prop_name
, data
, load
);
1763 dst
= map_sysmem(load
, len
);
1764 memmove(dst
, buf
, len
);
1767 bootstage_mark(bootstage_id
+ BOOTSTAGE_SUB_LOAD
);
1772 *fit_unamep
= (char *)fit_uname
;
1773 if (fit_uname_configp
)
1774 *fit_uname_configp
= (char *)fit_uname_config
;
1779 int boot_get_setup_fit(bootm_headers_t
*images
, uint8_t arch
,
1780 ulong
*setup_start
, ulong
*setup_len
)
1787 addr
= map_to_sysmem(images
->fit_hdr_os
);
1788 noffset
= fit_get_node_from_config(images
, FIT_SETUP_PROP
, addr
);
1792 ret
= fit_image_load(images
, addr
, NULL
, NULL
, arch
,
1793 IH_TYPE_X86_SETUP
, BOOTSTAGE_ID_FIT_SETUP_START
,
1794 FIT_LOAD_REQUIRED
, setup_start
, &len
);