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 b5af9a860fb1d3de6964271e0862a62c546fa07c 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 --- src/arch/x86/Makefile.inc | 10 +++++---- src/include/boot/coreboot_tables.h | 4 ++++ util/nvramtool/accessors/layout-text.c | 39 ++++++++++++++++++++++------------ 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, 48 insertions(+), 24 deletions(-)
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/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h index 87a9db7..3b611e0 100644 --- a/src/include/boot/coreboot_tables.h +++ b/src/include/boot/coreboot_tables.h @@ -226,6 +226,8 @@ struct lb_gpios { struct lb_gpio gpios[0]; };
+#ifndef __ROMCC__ + #define LB_TAG_VDAT 0x0015 #define LB_TAG_VBNV 0x0019 #define LB_TAB_VBOOT_HANDOFF 0x0020 @@ -249,6 +251,8 @@ struct lb_cbmem_ref { uint64_t cbmem_addr; };
+#endif + #define LB_TAG_X86_ROM_MTRR 0x0021 struct lb_x86_rom_mtrr { uint32_t tag; diff --git a/util/nvramtool/accessors/layout-text.c b/util/nvramtool/accessors/layout-text.c index a06f560..49460db 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 = -1, 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) @@ -638,6 +644,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 +723,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[]);