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

Function process_config

util/amdfwtool/data_parse.c:550–627  ·  view source on GitHub ↗

return value: 0: The config file can not be parsed correctly. 1: The config file can be parsed correctly. */

Source from the content-addressed store, hash-verified

548 1: The config file can be parsed correctly.
549 */
550uint8_t process_config(FILE *config, amd_cb_config *cb_config)
551{
552 char oneline[MAX_LINE_SIZE];
553 regmatch_t match[N_MATCHES];
554 char dir[MAX_LINE_SIZE] = {'\0'};
555 uint32_t dir_len;
556 char *platform_name = NULL;
557 int index;
558
559 for (index = 0; index < N_MATCHES; index++) {
560 match[index].rm_so = -1;
561 match[index].rm_eo = -1;
562 }
563
564 compile_reg_expr(REG_EXTENDED | REG_NEWLINE,
565 blank_or_comment_regex, &blank_or_comment_expr);
566 compile_reg_expr(REG_EXTENDED | REG_NEWLINE,
567 entries_line_regex, &entries_line_expr);
568
569 /* Get a line */
570 /* Get FIRMWARE_LOCATION in the first loop */
571 while (get_input_file_line(config, oneline, MAX_LINE_SIZE) == OK) {
572 /* get a line */
573 if (skip_comment_blank_line(oneline))
574 continue;
575 if (is_valid_entry(oneline, match)) {
576 if (strcmp(&(oneline[match[FW_TYPE].rm_so]), FW_LOCATION) == 0) {
577 dir_len = match[FW_FILE].rm_eo - match[FW_FILE].rm_so;
578 assert(dir_len < MAX_LINE_SIZE);
579 snprintf(dir, MAX_LINE_SIZE, "%.*s", dir_len,
580 &(oneline[match[FW_FILE].rm_so]));
581 } else if (strcmp(&(oneline[match[FW_TYPE].rm_so]), SOC_NAME) == 0) {
582 platform_name = strdup(&(oneline[match[FW_FILE].rm_so]));
583 cb_config->soc_id = platform_identify(platform_name);
584 }
585 }
586 }
587
588 if (!platform_name) {
589 fprintf(stderr, "AMDFWTOOL: Platform not specified in config\n");
590 return 0;
591 } else if (cb_config->soc_id == PLATFORM_UNKNOWN) {
592 fprintf(stderr, "AMDFWTOOL: Unknown platform '%s'\n", platform_name);
593 free(platform_name);
594 return 0;
595 }
596 free(platform_name);
597
598 if (platform_needs_ish(cb_config->soc_id))
599 cb_config->recovery_ab = true;
600
601 if (dir[0] == '\0') {
602 fprintf(stderr, "No line with FIRMWARE_LOCATION\n");
603 return 0;
604 }
605
606 fseek(config, 0, SEEK_SET);
607 /* Get a line */

Callers 1

open_process_configFunction · 0.85

Calls 13

skip_comment_blank_lineFunction · 0.85
is_valid_entryFunction · 0.85
platform_identifyFunction · 0.85
fprintfFunction · 0.85
platform_needs_ishFunction · 0.85
fseekFunction · 0.85
process_one_lineFunction · 0.85
compile_reg_exprFunction · 0.70
get_input_file_lineFunction · 0.70
strcmpFunction · 0.50
snprintfFunction · 0.50
strdupFunction · 0.50

Tested by

no test coverage detected