MCPcopy Create free account
hub / github.com/coreboot/coreboot / main

Function main

util/amdfwtool/amdfwread.c:729–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727}
728
729int main(int argc, char **argv)
730{
731 char *fw_file = NULL;
732 int mode_dump = 0;
733 ssize_t fw_size;
734
735 int selected_functions = 0;
736 while (1) {
737 int opt = getopt_long(argc, argv, optstring, long_options, NULL);
738
739 if (opt == -1) {
740 if (optind != (argc - 1)) {
741 /* Print usage if one and only one option i.e. filename is
742 not found. */
743 print_usage();
744 return 0;
745 }
746
747 fw_file = argv[optind];
748 break;
749 }
750
751 switch (opt) {
752 case AMDFW_OPT_HELP:
753 print_usage();
754 return 0;
755 case AMDFW_OPT_DUMP:
756 mode_dump = 1;
757 break;
758
759 case AMDFW_OPT_SOFT_FUSE:
760 case AMDFW_OPT_RO_LIST:
761 selected_functions |= opt;
762 break;
763
764 default:
765 break;
766 }
767 }
768
769 FILE *fw = fopen(fw_file, "rb");
770 if (!fw) {
771 ERR("Failed to open FW file %s\n", fw_file);
772 return 1;
773 }
774
775 /* Get file size */
776 fseek(fw, 0, SEEK_END);
777 if ((fw_size = ftell(fw)) == -1) {
778 ERR("Failed to get FW file size\n");
779 fclose(fw);
780 return -1;
781 }
782 if (fw_size > 128 * MiB) {
783 ERR("FW ROM size 0x%zx not supported\n", fw_size);
784 fclose(fw);
785 return -1;
786 }

Callers

nothing calls this directly

Calls 10

getopt_longFunction · 0.85
fopenFunction · 0.85
fseekFunction · 0.85
ftellFunction · 0.85
fcloseFunction · 0.85
read_fw_headerFunction · 0.85
dump_efwFunction · 0.85
read_soft_fuseFunction · 0.85
list_amdfw_roFunction · 0.85
print_usageFunction · 0.70

Tested by

no test coverage detected