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

Function decode_mmap_arg

util/cbfstool/cbfstool.c:391–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389
390
391static int decode_mmap_arg(char *arg)
392{
393 if (arg == NULL)
394 return 1;
395
396 union {
397 unsigned long array[3];
398 struct {
399 unsigned long flash_base;
400 unsigned long mmap_base;
401 unsigned long mmap_size;
402 };
403 } mmap_args;
404 char *suffix = NULL;
405 char *substring = strtok(arg, ":");
406 for (size_t i = 0; i < ARRAY_SIZE(mmap_args.array); i++) {
407 if (!substring) {
408 ERROR("Invalid mmap arguments '%s'.\n",
409 arg);
410 return 1;
411 }
412 mmap_args.array[i] = strtol(substring, &suffix, 0);
413 if (suffix && *suffix) {
414 ERROR("Invalid mmap arguments '%s'.\n",
415 arg);
416 return 1;
417 }
418 substring = strtok(NULL, ":");
419 }
420
421 if (substring != NULL) {
422 ERROR("Invalid argument, too many substrings '%s'.\n",
423 arg);
424
425 return 1;
426 }
427
428 if (add_mmap_window(mmap_args.flash_base, mmap_args.mmap_base, mmap_args.mmap_size))
429 return 1;
430
431 return 0;
432}
433
434#define DEFAULT_DECODE_WINDOW_TOP (4ULL * GiB)
435#define DEFAULT_DECODE_WINDOW_MAX_SIZE (16 * MiB)

Callers 1

mainFunction · 0.85

Calls 3

add_mmap_windowFunction · 0.85
strtokFunction · 0.50
strtolFunction · 0.50

Tested by

no test coverage detected