diff options
Diffstat (limited to 'util/nvramtool/accessors/layout-text.c')
-rw-r--r-- | util/nvramtool/accessors/layout-text.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/util/nvramtool/accessors/layout-text.c b/util/nvramtool/accessors/layout-text.c index cbe698c504..a06f560cee 100644 --- a/util/nvramtool/accessors/layout-text.c +++ b/util/nvramtool/accessors/layout-text.c @@ -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 * |