nvramtool: Unify nvramtool and build_opt_tbl
As cmos.layout parsing capabilities are already there in nvramtool, use those than using build_opt_tbl.c. Add binary and header file generation in nvramtool. Make appropriate changes to Makefile.inc. Change-Id: Iaf3f5d4f51451aeb33c92800a0c895045f2388cf Signed-off-by: Vikram Narayanan <vikram186@gmail.com> Reviewed-on: http://review.coreboot.org/898 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
committed by
Patrick Georgi
parent
c3fc4b9337
commit
a8111cf980
@@ -1,6 +1,12 @@
|
||||
/*****************************************************************************\
|
||||
* layout-text.c
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2012, Vikram Narayanan
|
||||
* Unified build_opt_tbl and nvramtool
|
||||
* build_opt_tbl.c
|
||||
* Copyright (C) 2003 Eric Biederman (ebiederm@xmission.com)
|
||||
* Copyright (C) 2007-2010 coresystems GmbH
|
||||
*
|
||||
* Copyright (C) 2002-2005 The Regents of the University of California.
|
||||
* Produced at the Lawrence Livermore National Laboratory.
|
||||
* Written by Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>.
|
||||
@@ -218,6 +224,57 @@ void get_layout_from_file(void)
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void write_cmos_layout_header(const char *header_filename)
|
||||
{
|
||||
FILE *fp;
|
||||
const cmos_entry_t *cmos_entry;
|
||||
cmos_checksum_layout_t layout;
|
||||
|
||||
if ((fp = fopen(header_filename, "w+")) == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: Can't open file %s for writing: %s\n",
|
||||
prog_name, header_filename, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(fp, "/**\n * This is an autogenerated file. Do not EDIT.\n"
|
||||
" * All changes made to this file will be lost.\n"
|
||||
" * See mainboard's cmos.layout file.\n */\n"
|
||||
"\n#ifndef __OPTION_TABLE_H\n"
|
||||
"#define __OPTION_TABLE_H\n\n");
|
||||
|
||||
for (cmos_entry = first_cmos_entry(); cmos_entry != NULL;
|
||||
cmos_entry = next_cmos_entry(cmos_entry)) {
|
||||
|
||||
if (!is_ident((char *)cmos_entry->name)) {
|
||||
fprintf(stderr,
|
||||
"Error - Name %s is an invalid identifier\n",
|
||||
cmos_entry->name);
|
||||
fclose(fp);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(fp, "#define CMOS_VSTART_%s\t%d\n",
|
||||
cmos_entry->name, cmos_entry->bit);
|
||||
fprintf(fp, "#define CMOS_VLEN_%s\t%d\n",
|
||||
cmos_entry->name, cmos_entry->length);
|
||||
}
|
||||
|
||||
layout.summed_area_start = cmos_checksum_start;
|
||||
layout.summed_area_end = cmos_checksum_end;
|
||||
layout.checksum_at = cmos_checksum_index;
|
||||
checksum_layout_to_bits(&layout);
|
||||
|
||||
fprintf(fp, "\n#define LB_CKS_RANGE_START %d\n",
|
||||
layout.summed_area_start / 8);
|
||||
fprintf(fp, "#define LB_CKS_RANGE_END %d\n",
|
||||
layout.summed_area_end / 8);
|
||||
fprintf(fp, "#define LB_CKS_LOC %d\n",
|
||||
layout.checksum_at / 8);
|
||||
fprintf(fp, "\n#endif /* __OPTION_TABLE_H */\n");
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
/****************************************************************************
|
||||
* write_cmos_layout
|
||||
*
|
||||
|
Reference in New Issue
Block a user