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

Function main

util/cbfstool/fmaptool.c:161–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161int main(int argc, char **argv)
162{
163 struct {
164 // Mandatory
165 const char *fmd_filename;
166 const char *fmap_filename;
167
168 // Optional
169 const char *header_filename;
170 const char *region_filename;
171 } args = {NULL, NULL, NULL, NULL};
172
173 bool show_usage = false;
174 int each_arg;
175 while (!show_usage && (each_arg = getopt(argc, argv, ":h:R:")) != -1) {
176 switch (each_arg) {
177 case 'h':
178 args.header_filename = optarg;
179 break;
180 case 'R':
181 args.region_filename = optarg;
182 break;
183 case ':':
184 fprintf(stderr, "-%c: Expected an accompanying value\n",
185 optopt);
186 show_usage = true;
187 break;
188 default:
189 fprintf(stderr, "-%c: Unexpected command-line switch\n",
190 optopt);
191 show_usage = true;
192 }
193 }
194
195 if (show_usage || argc - optind != 2) {
196 usage(argv[0]);
197 return FMAPTOOL_EXIT_BAD_ARGS;
198 }
199 args.fmd_filename = argv[optind];
200 args.fmap_filename = argv[optind + 1];
201
202 FILE *fmd_file = stdin;
203 if (strcmp(args.fmd_filename, STDIN_FILENAME_SENTINEL) != 0) {
204 fmd_file = fopen(args.fmd_filename, "r");
205 if (!fmd_file) {
206 fprintf(stderr, "FATAL: Unable to open file '%s'\n",
207 args.fmd_filename);
208 return FMAPTOOL_EXIT_BAD_INPUT_PATH;
209 }
210 }
211
212 struct flashmap_descriptor *descriptor = fmd_create(fmd_file);
213 fclose(fmd_file);
214 if (!descriptor) {
215 fputs("FATAL: Failed while processing provided descriptor\n",
216 stderr);
217 full_fmd_cleanup(&descriptor);
218 return FMAPTOOL_EXIT_FAILED_DESCRIPTOR;

Callers

nothing calls this directly

Calls 15

getoptFunction · 0.85
fprintfFunction · 0.85
fopenFunction · 0.85
fmd_createFunction · 0.85
fcloseFunction · 0.85
full_fmd_cleanupFunction · 0.85
fmd_find_nodeFunction · 0.85
fmap_from_fmdFunction · 0.85
fmap_sizeFunction · 0.85
fmap_destroyFunction · 0.85
fwriteFunction · 0.85

Tested by

no test coverage detected