Lines Matching +full:- +full:desc

2  * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
140 image_desc_t *desc; in new_image_desc() local
142 desc = xzalloc(sizeof(*desc), in new_image_desc()
144 memcpy(&desc->uuid, uuid, sizeof(uuid_t)); in new_image_desc()
145 desc->name = xstrdup(name, in new_image_desc()
147 desc->cmdline_name = xstrdup(cmdline_name, in new_image_desc()
149 desc->action = DO_UNSPEC; in new_image_desc()
150 return desc; in new_image_desc()
153 static void set_image_desc_action(image_desc_t *desc, int action, in set_image_desc_action() argument
156 assert(desc != NULL); in set_image_desc_action()
158 if (desc->action_arg != (char *)DO_UNSPEC) in set_image_desc_action()
159 free(desc->action_arg); in set_image_desc_action()
160 desc->action = action; in set_image_desc_action()
161 desc->action_arg = NULL; in set_image_desc_action()
163 desc->action_arg = xstrdup(arg, in set_image_desc_action()
167 static void free_image_desc(image_desc_t *desc) in free_image_desc() argument
169 free(desc->name); in free_image_desc()
170 free(desc->cmdline_name); in free_image_desc()
171 free(desc->action_arg); in free_image_desc()
172 if (desc->image) { in free_image_desc()
173 free(desc->image->buffer); in free_image_desc()
174 free(desc->image); in free_image_desc()
176 free(desc); in free_image_desc()
179 static void add_image_desc(image_desc_t *desc) in add_image_desc() argument
184 p = &(*p)->next; in add_image_desc()
187 *p = desc; in add_image_desc()
193 image_desc_t *desc = image_desc_head, *tmp; in free_image_descs() local
195 while (desc != NULL) { in free_image_descs()
196 tmp = desc->next; in free_image_descs()
197 free_image_desc(desc); in free_image_descs()
198 desc = tmp; in free_image_descs()
199 nr_image_descs--; in free_image_descs()
209 toc_entry->cmdline_name != NULL; in fill_image_descs()
211 image_desc_t *desc; in fill_image_descs() local
213 desc = new_image_desc(&toc_entry->uuid, in fill_image_descs()
214 toc_entry->name, in fill_image_descs()
215 toc_entry->cmdline_name); in fill_image_descs()
216 add_image_desc(desc); in fill_image_descs()
220 toc_entry->cmdline_name != NULL; in fill_image_descs()
222 image_desc_t *desc; in fill_image_descs() local
224 desc = new_image_desc(&toc_entry->uuid, in fill_image_descs()
225 toc_entry->name, in fill_image_descs()
226 toc_entry->cmdline_name); in fill_image_descs()
227 add_image_desc(desc); in fill_image_descs()
234 image_desc_t *desc; in lookup_image_desc_from_uuid() local
236 for (desc = image_desc_head; desc != NULL; desc = desc->next) in lookup_image_desc_from_uuid()
237 if (memcmp(&desc->uuid, uuid, sizeof(uuid_t)) == 0) in lookup_image_desc_from_uuid()
238 return desc; in lookup_image_desc_from_uuid()
244 image_desc_t *desc; in lookup_image_desc_from_opt() local
246 for (desc = image_desc_head; desc != NULL; desc = desc->next) in lookup_image_desc_from_opt()
247 if (strcmp(desc->cmdline_name, opt) == 0) in lookup_image_desc_from_opt()
248 return desc; in lookup_image_desc_from_opt()
257 "%02X%02X%02X%02X-%02X%02X-%02X%02X-%04X-%04X%04X%04X", in uuid_to_str()
258 u->time_low[0], u->time_low[1], u->time_low[2], u->time_low[3], in uuid_to_str()
259 u->time_mid[0], u->time_mid[1], in uuid_to_str()
260 u->time_hi_and_version[0], u->time_hi_and_version[1], in uuid_to_str()
261 (u->clock_seq_hi_and_reserved << 8) | u->clock_seq_low, in uuid_to_str()
262 (u->node[0] << 8) | u->node[1], in uuid_to_str()
263 (u->node[2] << 8) | u->node[3], in uuid_to_str()
264 (u->node[4] << 8) | u->node[5]); in uuid_to_str()
277 "%2hhx%2hhx%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", in uuid_from_str()
278 &u->time_low[0], &u->time_low[1], &u->time_low[2], &u->time_low[3], in uuid_from_str()
279 &u->time_mid[0], &u->time_mid[1], in uuid_from_str()
280 &u->time_hi_and_version[0], &u->time_hi_and_version[1], in uuid_from_str()
281 &u->clock_seq_hi_and_reserved, &u->clock_seq_low, in uuid_from_str()
282 &u->node[0], &u->node[1], in uuid_from_str()
283 &u->node[2], &u->node[3], in uuid_from_str()
284 &u->node[4], &u->node[5]); in uuid_from_str()
306 if (fstat(fileno(fp), &st) == -1) in parse_fip()
321 if (toc_header->name != TOC_HEADER_NAME) in parse_fip()
329 while ((char *)toc_entry + sizeof(*toc_entry) - 1 < bufend) { in parse_fip()
331 image_desc_t *desc; in parse_fip() local
334 if (memcmp(&toc_entry->uuid, &uuid_null, sizeof(uuid_t)) == 0) { in parse_fip()
345 image->toc_e = *toc_entry; in parse_fip()
346 image->buffer = xmalloc(toc_entry->size, in parse_fip()
349 if (toc_entry->size > (uint64_t)-1 - toc_entry->offset_address) in parse_fip()
351 if (toc_entry->size + toc_entry->offset_address > st.st_size) in parse_fip()
354 memcpy(image->buffer, buf + toc_entry->offset_address, in parse_fip()
355 toc_entry->size); in parse_fip()
358 desc = lookup_image_desc_from_uuid(&toc_entry->uuid); in parse_fip()
359 if (desc == NULL) { in parse_fip()
362 uuid_to_str(name, sizeof(name), &toc_entry->uuid); in parse_fip()
365 desc = new_image_desc(&toc_entry->uuid, name, "blob"); in parse_fip()
366 desc->action = DO_UNPACK; in parse_fip()
367 desc->action_arg = xstrdup(filename, in parse_fip()
369 add_image_desc(desc); in parse_fip()
372 assert(desc->image == NULL); in parse_fip()
373 desc->image = image; in parse_fip()
398 if (fstat(fileno(fp), &st) == -1) in read_image_from_file()
402 image->toc_e.uuid = *uuid; in read_image_from_file()
403 image->buffer = xmalloc(st.st_size, "failed to allocate image buffer"); in read_image_from_file()
404 if (fread(image->buffer, 1, st.st_size, fp) != st.st_size) in read_image_from_file()
406 image->toc_e.size = st.st_size; in read_image_from_file()
419 xfwrite(image->buffer, image->toc_e.size, fp, filename); in write_image_to_file()
441 image_desc_t *desc; in fill_common_opts() local
443 for (desc = image_desc_head; desc != NULL; desc = desc->next) in fill_common_opts()
444 opts = add_opt(opts, nr_opts, desc->cmdline_name, has_arg, in fill_common_opts()
459 image_desc_t *desc; in info_cmd() local
464 argc--, argv++; in info_cmd()
477 for (desc = image_desc_head; desc != NULL; desc = desc->next) { in info_cmd()
478 image_t *image = desc->image; in info_cmd()
482 printf("%s: offset=0x%llX, size=0x%llX, cmdline=\"--%s\"", in info_cmd()
483 desc->name, in info_cmd()
484 (unsigned long long)image->toc_e.offset_address, in info_cmd()
485 (unsigned long long)image->toc_e.size, in info_cmd()
486 desc->cmdline_name); in info_cmd()
491 SHA256(image->buffer, image->toc_e.size, md); in info_cmd()
511 image_desc_t *desc; in pack_images() local
518 for (desc = image_desc_head; desc != NULL; desc = desc->next) in pack_images()
519 if (desc->image != NULL) in pack_images()
530 toc_header->name = TOC_HEADER_NAME; in pack_images()
531 toc_header->serial_number = TOC_HEADER_SERIAL_NUMBER; in pack_images()
532 toc_header->flags = toc_flags; in pack_images()
537 for (desc = image_desc_head; desc != NULL; desc = desc->next) { in pack_images()
538 image_t *image = desc->image; in pack_images()
542 payload_size += image->toc_e.size; in pack_images()
543 entry_offset = (entry_offset + align - 1) & ~(align - 1); in pack_images()
544 image->toc_e.offset_address = entry_offset; in pack_images()
545 *toc_entry++ = image->toc_e; in pack_images()
546 entry_offset += image->toc_e.size; in pack_images()
555 toc_entry->offset_address = (entry_offset + align - 1) & ~(align - 1); in pack_images()
570 for (desc = image_desc_head; desc != NULL; desc = desc->next) { in pack_images()
571 image_t *image = desc->image; in pack_images()
575 if (fseek(fp, image->toc_e.offset_address, SEEK_SET)) in pack_images()
578 xfwrite(image->buffer, image->toc_e.size, fp, filename); in pack_images()
584 pad_size = toc_entry->offset_address - entry_offset; in pack_images()
585 while (pad_size--) in pack_images()
602 image_desc_t *desc; in update_fip() local
605 for (desc = image_desc_head; desc != NULL; desc = desc->next) { in update_fip()
608 if (desc->action != DO_PACK) in update_fip()
611 image = read_image_from_file(&desc->uuid, in update_fip()
612 desc->action_arg); in update_fip()
613 if (desc->image != NULL) { in update_fip()
616 desc->cmdline_name, in update_fip()
617 desc->action_arg); in update_fip()
619 free(desc->image); in update_fip()
620 desc->image = image; in update_fip()
624 desc->action_arg); in update_fip()
625 desc->image = image; in update_fip()
639 /* Platform ToC flags is a 16-bit field occupying bits [32-47]. */ in parse_plat_toc_flags()
645 return x && !(x & (x - 1)); in is_power_of_2()
687 opts = add_opt(opts, &nr_opts, "plat-toc-flags", required_argument, in create_cmd()
697 if (c == -1) in create_cmd()
702 image_desc_t *desc; in create_cmd() local
704 desc = lookup_image_desc_from_opt(opts[opt_index].name); in create_cmd()
705 set_image_desc_action(desc, DO_PACK, optarg); in create_cmd()
718 image_desc_t *desc; in create_cmd() local
727 desc = lookup_image_desc_from_uuid(&uuid); in create_cmd()
728 if (desc == NULL) { in create_cmd()
730 desc = new_image_desc(&uuid, name, "blob"); in create_cmd()
731 add_image_desc(desc); in create_cmd()
733 set_image_desc_action(desc, DO_PACK, filename); in create_cmd()
740 argc -= optind; in create_cmd()
760 printf(" --align <value>\t\tEach image is aligned to <value> (default: 1).\n"); in create_usage()
761 printf(" --blob uuid=...,file=...\tAdd an image with the given UUID pointed to by file.\n"); in create_usage()
762 …printf(" --plat-toc-flags <value>\t16-bit platform specific flag field occupying bits 32-47 in 64 in create_usage()
765 for (; toc_entry->cmdline_name != NULL; toc_entry++) in create_usage()
766 printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, in create_usage()
767 toc_entry->name); in create_usage()
770 for (; toc_entry->cmdline_name != NULL; toc_entry++) in create_usage()
771 printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, in create_usage()
772 toc_entry->name); in create_usage()
794 opts = add_opt(opts, &nr_opts, "plat-toc-flags", required_argument, in update_cmd()
802 if (c == -1) in update_cmd()
807 image_desc_t *desc; in update_cmd() local
809 desc = lookup_image_desc_from_opt(opts[opt_index].name); in update_cmd()
810 set_image_desc_action(desc, DO_PACK, optarg); in update_cmd()
821 image_desc_t *desc; in update_cmd() local
830 desc = lookup_image_desc_from_uuid(&uuid); in update_cmd()
831 if (desc == NULL) { in update_cmd()
833 desc = new_image_desc(&uuid, name, "blob"); in update_cmd()
834 add_image_desc(desc); in update_cmd()
836 set_image_desc_action(desc, DO_PACK, filename); in update_cmd()
849 argc -= optind; in update_cmd()
879 printf(" --align <value>\t\tEach image is aligned to <value> (default: 1).\n"); in update_usage()
880 …printf(" --blob uuid=...,file=...\tAdd or update an image with the given UUID pointed to by file.… in update_usage()
881 printf(" --out FIP_FILENAME\t\tSet an alternative output FIP file.\n"); in update_usage()
882 …printf(" --plat-toc-flags <value>\t16-bit platform specific flag field occupying bits 32-47 in 64 in update_usage()
885 for (; toc_entry->cmdline_name != NULL; toc_entry++) in update_usage()
886 printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, in update_usage()
887 toc_entry->name); in update_usage()
890 for (; toc_entry->cmdline_name != NULL; toc_entry++) in update_usage()
891 printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, in update_usage()
892 toc_entry->name); in update_usage()
902 image_desc_t *desc; in unpack_cmd() local
919 if (c == -1) in unpack_cmd()
924 image_desc_t *desc; in unpack_cmd() local
926 desc = lookup_image_desc_from_opt(opts[opt_index].name); in unpack_cmd()
927 set_image_desc_action(desc, DO_UNPACK, optarg); in unpack_cmd()
935 image_desc_t *desc; in unpack_cmd() local
944 desc = lookup_image_desc_from_uuid(&uuid); in unpack_cmd()
945 if (desc == NULL) { in unpack_cmd()
947 desc = new_image_desc(&uuid, name, "blob"); in unpack_cmd()
948 add_image_desc(desc); in unpack_cmd()
950 set_image_desc_action(desc, DO_UNPACK, filename); in unpack_cmd()
964 argc -= optind; in unpack_cmd()
974 if (chdir(outdir) == -1) in unpack_cmd()
978 for (desc = image_desc_head; desc != NULL; desc = desc->next) { in unpack_cmd()
980 image_t *image = desc->image; in unpack_cmd()
982 if (!unpack_all && desc->action != DO_UNPACK) in unpack_cmd()
986 if (desc->action_arg == NULL) in unpack_cmd()
988 desc->cmdline_name); in unpack_cmd()
991 desc->action_arg); in unpack_cmd()
1005 log_warnx("File %s already exists, use --force to overwrite it", in unpack_cmd()
1020 printf(" --blob uuid=...,file=...\tUnpack an image with the given UUID to file.\n"); in unpack_usage()
1021 printf(" --force\t\t\tIf the output file already exists, use --force to overwrite it.\n"); in unpack_usage()
1022 printf(" --out path\t\t\tSet the output directory path.\n"); in unpack_usage()
1025 for (; toc_entry->cmdline_name != NULL; toc_entry++) in unpack_usage()
1026 printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, in unpack_usage()
1027 toc_entry->name); in unpack_usage()
1030 for (; toc_entry->cmdline_name != NULL; toc_entry++) in unpack_usage()
1031 printf(" --%-16s FILENAME\t%s\n", toc_entry->cmdline_name, in unpack_usage()
1032 toc_entry->name); in unpack_usage()
1045 image_desc_t *desc; in remove_cmd() local
1063 if (c == -1) in remove_cmd()
1068 image_desc_t *desc; in remove_cmd() local
1070 desc = lookup_image_desc_from_opt(opts[opt_index].name); in remove_cmd()
1071 set_image_desc_action(desc, DO_REMOVE, NULL); in remove_cmd()
1080 image_desc_t *desc; in remove_cmd() local
1088 desc = lookup_image_desc_from_uuid(&uuid); in remove_cmd()
1089 if (desc == NULL) { in remove_cmd()
1091 desc = new_image_desc(&uuid, name, "blob"); in remove_cmd()
1092 add_image_desc(desc); in remove_cmd()
1094 set_image_desc_action(desc, DO_REMOVE, NULL); in remove_cmd()
1107 argc -= optind; in remove_cmd()
1115 log_errx("File %s already exists, use --force to overwrite it", in remove_cmd()
1123 for (desc = image_desc_head; desc != NULL; desc = desc->next) { in remove_cmd()
1124 if (desc->action != DO_REMOVE) in remove_cmd()
1127 if (desc->image != NULL) { in remove_cmd()
1130 desc->cmdline_name); in remove_cmd()
1131 free(desc->image); in remove_cmd()
1132 desc->image = NULL; in remove_cmd()
1135 desc->cmdline_name, argv[0]); in remove_cmd()
1150 printf(" --align <value>\tEach image is aligned to <value> (default: 1).\n"); in remove_usage()
1151 printf(" --blob uuid=...\tRemove an image with the given UUID.\n"); in remove_usage()
1152 printf(" --force\t\tIf the output FIP file already exists, use --force to overwrite it.\n"); in remove_usage()
1153 printf(" --out FIP_FILENAME\tSet an alternative output FIP file.\n"); in remove_usage()
1156 for (; toc_entry->cmdline_name != NULL; toc_entry++) in remove_usage()
1157 printf(" --%-16s\t%s\n", toc_entry->cmdline_name, in remove_usage()
1158 toc_entry->name); in remove_usage()
1161 for (; toc_entry->cmdline_name != NULL; toc_entry++) in remove_usage()
1162 printf(" --%-16s\t%s\n", toc_entry->cmdline_name, in remove_usage()
1163 toc_entry->name); in remove_usage()
1191 argc--, argv++; in help_cmd()
1205 printf("usage: fiptool [--verbose] <command> [<args>]\n"); in usage()
1207 printf(" --verbose\tEnable verbose output for all commands.\n"); in usage()
1232 * Set POSIX mode so getopt stops at the first non-option in main()
1236 if (c == -1) in main()
1247 argc -= optind; in main()