Vladimir Serbinenko (phcoder@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/7076
-gerrit
commit 2e8df1ec6ec53208c1baa23f21cce2fc9807329c Author: Vladimir Serbinenko phcoder@gmail.com Date: Thu Oct 16 16:49:07 2014 +0200
cmos: Allow compiling several files together
Change-Id: Idd66a522623466c9aee35d941ba1f05beb912104 Signed-off-by: Vladimir Serbinenko phcoder@gmail.com --- Makefile.inc | 2 +- src/arch/x86/Makefile.inc | 10 ++++--- util/nvramtool/accessors/layout-text.c | 50 ++++++++++++++++++---------------- util/nvramtool/accessors/layout-text.h | 2 +- util/nvramtool/cli/nvramtool.c | 6 ++-- util/nvramtool/cli/opts.c | 10 +++++-- util/nvramtool/cli/opts.h | 1 + 7 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc index daf4cf4..dba923e 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -163,7 +163,7 @@ endef # arg2: binary file name cbfs-files-processor-nvramtool= \ $(eval $(2): $(1) $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout | $(objutil)/nvramtool/nvramtool ; \ - printf " CREATE $(2) (from $(1))\n"; $(objutil)/nvramtool/nvramtool -y $(src)/mainboard/$(MAINBOARDDIR)/cmos.layout -D $(2).tmp -p $(1) && mv $(2).tmp $(2)) + printf " CREATE $(2) (from $(1))\n"; $(objutil)/nvramtool/nvramtool -y $(cmos-layout-y) -D $(2).tmp -p $(1) && mv $(2).tmp $(2))
####################################################################### # Link VSA binary to ELF-ish stage diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index 1480a66..952348d 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -60,13 +60,15 @@ endif # i386 specific tools NVRAMTOOL:=$(objutil)/nvramtool/nvramtool
-$(OPTION_TABLE_H): $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout +cmos-layout-y += $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout + +$(OPTION_TABLE_H): $(NVRAMTOOL) $(cmos-layout-y) @printf " OPTION $(subst $(obj)/,,$(@))\n" - $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -H $@ + $(NVRAMTOOL) -y $(cmos-layout-y) -H $@
-$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout +$(obj)/cmos_layout.bin: $(NVRAMTOOL) $(cmos-layout-y) @printf " OPTION $(subst $(obj)/,,$(@))\n" - $(NVRAMTOOL) -y $(top)/src/mainboard/$(MAINBOARDDIR)/cmos.layout -L $@ + $(NVRAMTOOL) -y $(cmos-layout-y) -L $@
############################################################################### diff --git a/util/nvramtool/accessors/layout-text.c b/util/nvramtool/accessors/layout-text.c index a06f560..5f78700 100644 --- a/util/nvramtool/accessors/layout-text.c +++ b/util/nvramtool/accessors/layout-text.c @@ -189,17 +189,18 @@ static regex_t checksum_line_expr; static const int LINE_BUF_SIZE = 256;
static int line_num; +static int max_enum_id = 0, enum_id_offset = 0;
-static const char *layout_filename = NULL; +static const char **layout_filenames = NULL;
/**************************************************************************** * set_layout_filename * * Set the name of the file we will obtain CMOS layout information from. ****************************************************************************/ -void set_layout_filename(const char filename[]) +void set_layout_filenames(const char *filenames[]) { - layout_filename = filename; + layout_filenames = filenames; }
/**************************************************************************** @@ -209,19 +210,24 @@ void set_layout_filename(const char filename[]) ****************************************************************************/ void get_layout_from_file(void) { - FILE *f; + int i;
- assert(layout_filename != NULL); + assert(layout_filenames != NULL);
- if ((f = fopen(layout_filename, "r")) == NULL) { - fprintf(stderr, - "%s: Can not open CMOS layout file %s for reading: " - "%s\n", prog_name, layout_filename, strerror(errno)); - exit(1); - } + for (i = 0; layout_filenames[i]; i++) { + FILE *f; + enum_id_offset = max_enum_id + 1; + f = fopen(layout_filenames[i], "r"); + if (f == NULL) { + fprintf(stderr, + "%s: Can not open CMOS layout file %s for reading: " + "%s\n", prog_name, layout_filenames[i], strerror(errno)); + exit(1); + }
- process_layout_file(f); - fclose(f); + process_layout_file(f); + fclose(f); + } }
void write_cmos_layout_header(const char *header_filename) @@ -498,11 +504,7 @@ static int process_enum(FILE * f, int skip_add)
for (;; line_num++) { if (get_layout_file_line(f, line, LINE_BUF_SIZE)) { - fprintf(stderr, - "%s: Unexpected end of CMOS layout file reached while " - "reading "enumerations" section.\n", - prog_name); - exit(1); + break; }
if (!regexec(&blank_or_comment_expr, line, 0, NULL, 0)) @@ -550,10 +552,7 @@ static void process_checksum_info(FILE * f)
for (;; line_num++) { if (get_layout_file_line(f, line, LINE_BUF_SIZE)) { - fprintf(stderr, - "%s: Unexpected end of CMOS layout file reached while " - "reading "checksums" section.\n", prog_name); - exit(1); + break; }
if (!regexec(&blank_or_comment_expr, line, 0, NULL, 0)) @@ -638,6 +637,8 @@ static void create_entry(cmos_entry_t * cmos_entry, }
cmos_entry->config_id = string_to_unsigned(config_id_str, "config-ID"); + if (cmos_entry->config == CMOS_ENTRY_ENUM) + cmos_entry->config_id += enum_id_offset;
if (strlen(name_str) >= CMOS_MAX_NAME_LENGTH) { fprintf(stderr, @@ -715,9 +716,12 @@ static void try_add_layout_file_entry(const cmos_entry_t * cmos_entry) static void create_enum(cmos_enum_t * cmos_enum, const char id_str[], const char value_str[], const char text_str[]) { - cmos_enum->config_id = string_to_unsigned(id_str, "ID"); + cmos_enum->config_id = string_to_unsigned(id_str, "ID") + enum_id_offset; cmos_enum->value = string_to_unsigned_long(value_str, "value");
+ if (cmos_enum->config_id >= max_enum_id) + max_enum_id = cmos_enum->config_id; + if (strlen(text_str) >= CMOS_MAX_TEXT_LENGTH) { fprintf(stderr, "%s: Error on line %d of CMOS layout file: text too " diff --git a/util/nvramtool/accessors/layout-text.h b/util/nvramtool/accessors/layout-text.h index 85628f7..37f2313 100644 --- a/util/nvramtool/accessors/layout-text.h +++ b/util/nvramtool/accessors/layout-text.h @@ -34,7 +34,7 @@ #include "common.h" #include "coreboot_tables.h"
-void set_layout_filename(const char filename[]); +void set_layout_filenames(const char *filenames[]); void get_layout_from_file(void); void write_cmos_layout(FILE * f); void write_cmos_output_bin(const char *binary_filename); diff --git a/util/nvramtool/cli/nvramtool.c b/util/nvramtool/cli/nvramtool.c index bdfaaff..6fc6bdb 100644 --- a/util/nvramtool/cli/nvramtool.c +++ b/util/nvramtool/cli/nvramtool.c @@ -137,10 +137,12 @@ int main(int argc, char *argv[]) fn = get_layout_from_cbfs_file; }
+ /* If the user wants to use a specific layout file or explicitly use * the coreboot option table allow him to override previous settings. */ - if (nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE].found) { - set_layout_filename(nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE].param); + if (layout_files[0]) { + printf ("%s, %s\n", layout_files[0], layout_files[1]); + set_layout_filenames(layout_files); fn = get_layout_from_file; } else if (nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_OPT_TABLE].found) { fn = get_layout_from_cmos_table; diff --git a/util/nvramtool/cli/opts.c b/util/nvramtool/cli/opts.c index 8e920e8..a4a113f 100644 --- a/util/nvramtool/cli/opts.c +++ b/util/nvramtool/cli/opts.c @@ -34,6 +34,9 @@ nvramtool_op_info_t nvramtool_op;
nvramtool_op_modifier_info_t nvramtool_op_modifiers[NVRAMTOOL_NUM_OP_MODIFIERS]; +#define MAX_LAYOUT_FILES 100 +const char *layout_files[MAX_LAYOUT_FILES + 1]; +int layout_file_number;
static char *handle_optional_arg(int argc, char *argv[]); static void register_op(int *op_found, nvramtool_op_t op, char op_param[]); @@ -147,8 +150,10 @@ void parse_nvramtool_args(int argc, char *argv[]) optarg); break; case 'y': - register_op_modifier(NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE, - optarg); + case 1: + if (layout_file_number >= MAX_LAYOUT_FILES) + usage(stderr); + layout_files[layout_file_number++] = strdup(optarg); break; case 'Y': register_op(&op_found, NVRAMTOOL_OP_SHOW_LAYOUT, NULL); @@ -156,7 +161,6 @@ void parse_nvramtool_args(int argc, char *argv[]) case -1: /* no more command line args */ break; case '?': /* unknown option found */ - case 1: /* nonoption command line arg found */ default: usage(stderr); break; diff --git a/util/nvramtool/cli/opts.h b/util/nvramtool/cli/opts.h index a011ef1..e22f102 100644 --- a/util/nvramtool/cli/opts.h +++ b/util/nvramtool/cli/opts.h @@ -75,6 +75,7 @@ typedef struct { extern nvramtool_op_info_t nvramtool_op;
extern nvramtool_op_modifier_info_t nvramtool_op_modifiers[]; +extern const char *layout_files[];
void parse_nvramtool_args(int argc, char *argv[]);