Add string support to nvramtool.
authorStefan Reinauer <stepan@coresystems.de>
Sat, 27 Sep 2008 10:08:28 +0000 (10:08 +0000)
committerStefan Reinauer <stepan@openbios.org>
Sat, 27 Sep 2008 10:08:28 +0000 (10:08 +0000)
To add a string to your cmos.layout, you need to specify type 's':

#start     len       type    unused   name
416        512       s       0        boot_devices

With this patch you can do

$ nvramtool -w boot_devices="(hd0,0);(hd2,1);(hd3)"

And FILO will attempt to load a menu.lst from any of these devices in that
order.

The patch is not exactly pretty, but a cleaner solution might have resulted in
a complete rewrite of the tool, which I did not want.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Joseph Smith <joe@settoplinux.org>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3613 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

29 files changed:
util/nvramtool/ChangeLog
util/nvramtool/DISCLAIMER
util/nvramtool/Makefile
util/nvramtool/README
util/nvramtool/cmos_lowlevel.c
util/nvramtool/cmos_lowlevel.h
util/nvramtool/cmos_ops.c
util/nvramtool/cmos_ops.h
util/nvramtool/common.c
util/nvramtool/common.h
util/nvramtool/compute_ip_checksum.c
util/nvramtool/hexdump.c
util/nvramtool/hexdump.h
util/nvramtool/input_file.c
util/nvramtool/input_file.h
util/nvramtool/ip_checksum.h
util/nvramtool/layout.c
util/nvramtool/layout.h
util/nvramtool/layout_file.c
util/nvramtool/layout_file.h
util/nvramtool/lbtable.c
util/nvramtool/lbtable.h
util/nvramtool/nvramtool.1
util/nvramtool/nvramtool.c
util/nvramtool/nvramtool.spec
util/nvramtool/opts.c
util/nvramtool/opts.h
util/nvramtool/reg_expr.c
util/nvramtool/reg_expr.h

index 57d879edb20580a3a434acc13806a6a2c14c01fe..46564ec36f9cf6bf3894c4d16adddc5a6742a2e0 100644 (file)
@@ -1,3 +1,11 @@
+Tue Sep 23 19:14:27 CEST 2008  Stefan Reinauer (stepan@coresystems.de)
+
+       Version 2.1
+
+       * Fix a number of off by one errors when accessing arrays
+
+       * Add support for reading/writing strings from/to CMOS.
+
 Mon Jan 23 16:00:00 PST 2006  David S. Peterson (dsp@llnl.gov)
 
        Version 2.0.1
 Mon Jan 23 16:00:00 PST 2006  David S. Peterson (dsp@llnl.gov)
 
        Version 2.0.1
index 28a447581c28b75146c210cc9583add8d97fb231..dba80757672753861728a30c823aa6bc15a57962 100644 (file)
@@ -1,8 +1,8 @@
 ####################################################################
 ####################################################################
-# $Id$
-####################################################################
 
 Copyright (C) 2002 The Regents of the University of California.
 
 Copyright (C) 2002 The Regents of the University of California.
+Copyright (C) 2008 coresystems GmbH
+
 Produced at the Lawrence Livermore National Laboratory.
 Written by David S. Peterson <dsp@llnl.gov>.
 UCRL-CODE-2003-012
 Produced at the Lawrence Livermore National Laboratory.
 Written by David S. Peterson <dsp@llnl.gov>.
 UCRL-CODE-2003-012
index 5d9ddc0619f052fac60c318cd39fafc1fdb8a183..6feea95eae39e21b9fdd8982b99cd8487bdc3c7c 100644 (file)
@@ -1,28 +1,43 @@
-# $Id$
+#
+# Makefile for nvram utility
+# 
+# (C) 2005-2008 coresystems GmbH
+# written by Stefan Reinauer <stepan@coresystems.de>
+#
 
 
-PROJECT = nvramtool
-CC = gcc
-CFLAGS = -O2 -W -Wall
-LDFLAGS =
-OBJS = common.o compute_ip_checksum.o hexdump.o cmos_lowlevel.o \
-       reg_expr.o layout.o layout_file.o lbtable.o cmos_ops.o input_file.o \
-       opts.o nvramtool.o
-HEADERS = common.h ip_checksum.h coreboot_tables.h hexdump.h \
-          cmos_lowlevel.h reg_expr.h layout.h layout_file.h lbtable.h \
-          cmos_ops.h input_file.h opts.h
+PROGRAM = nvramtool
 
 
-all: nvramtool man
+CC      = gcc
+STRIP  = strip
+INSTALL = /usr/bin/install
+PREFIX  = /usr/local
+CFLAGS  = -O2 -g -Wall -W
+#CFLAGS  = -Os -Wall
 
 
-nvramtool: $(OBJS)
-       $(CC) $(LDFLAGS) -o $@ $(OBJS)
+OBJS =  cmos_lowlevel.o cmos_ops.o common.o compute_ip_checksum.o \
+       hexdump.o input_file.o layout.o layout_file.o lbtable.o   \
+       nvramtool.o opts.o reg_expr.o
 
 
-man: nvramtool.1.gz
+all: dep $(PROGRAM)
 
 
-$(OBJS): $(HEADERS)
-
-nvramtool.1.gz: nvramtool.1
-       gzip -c --best nvramtool.1 > nvramtool.1.gz
+$(PROGRAM): $(OBJS)
+       $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
+       $(STRIP) $(STRIP_ARGS) $(PROGRAM)
 
 clean:
 
 clean:
-       rm -f *.o nvramtool nvramtool.1.gz
+       rm -f $(PROGRAM) *.o
+
+distclean: clean
+       rm -f .dependencies
+
+dep:
+       @$(CC) -MM *.c > .dependencies
+
+install: $(PROGRAM)
+       $(INSTALL) $(PROGRAM) $(PREFIX)/sbin
+       mkdir -p $(PREFIX)/share/man/man1
+       $(INSTALL) $(PROGRAM).1 $(PREFIX)/share/man/man1
+
+.PHONY: all clean distclean dep
 
 
+-include .dependencies
index 976bcb02a384d51411099aa3f5fff26379050e74..183b84c0428a0c30bd3fcac92c446575bd3420ea 100644 (file)
@@ -1,5 +1,3 @@
-$Id$
-
 Summary of Operation
 --------------------
 nvramtool is a utility for reading/writing coreboot parameters and
 Summary of Operation
 --------------------
 nvramtool is a utility for reading/writing coreboot parameters and
index ab116797a26eb50aad23c6b5fcaa70c88bb9d8bd..9ad6891d0c4d617a84e865186bbe48af7e277c86 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * cmos_lowlevel.c
 /*****************************************************************************\
  * cmos_lowlevel.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -70,7 +69,7 @@ static inline unsigned char get_bits (unsigned long long value, unsigned bit,
  ****************************************************************************/
 static inline void put_bits (unsigned char value, unsigned bit,
                              unsigned nr_bits, unsigned long long *result)
  ****************************************************************************/
 static inline void put_bits (unsigned char value, unsigned bit,
                              unsigned nr_bits, unsigned long long *result)
- { *result += (value & ((unsigned char) ((1 << nr_bits) - 1))) << bit; }
+ { *result += ((unsigned long long)(value & ((unsigned char) ((1 << nr_bits) - 1)))) << bit; }
 
 /****************************************************************************
  * cmos_read
 
 /****************************************************************************
  * cmos_read
@@ -79,21 +78,39 @@ static inline void put_bits (unsigned char value, unsigned bit,
  * and return this value.  The I/O privilege level of the currently executing
  * process must be set appropriately.
  ****************************************************************************/
  * and return this value.  The I/O privilege level of the currently executing
  * process must be set appropriately.
  ****************************************************************************/
-unsigned long long cmos_read (unsigned bit, unsigned length)
+unsigned long long cmos_read (const cmos_entry_t *e)
  { cmos_bit_op_location_t where;
  { cmos_bit_op_location_t where;
+   unsigned bit = e->bit, length=e->length;
    unsigned next_bit, bits_left, nr_bits;
    unsigned next_bit, bits_left, nr_bits;
-   unsigned long long result;
+   unsigned long long result = 0;
    unsigned char value;
 
    unsigned char value;
 
-   assert(!verify_cmos_op(bit, length));
+   assert(!verify_cmos_op(bit, length, e->config));
    result = 0;
 
    result = 0;
 
-   for (next_bit = 0, bits_left = length;
-        bits_left;
-        next_bit += nr_bits, bits_left -= nr_bits)
-    { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left, &where);
-      value = cmos_read_bits(&where, nr_bits);
-      put_bits(value, next_bit, nr_bits, &result);
+   if (e->config == CMOS_ENTRY_STRING)
+    { char *newstring = malloc((length+7)/8);
+      unsigned usize = (8 * sizeof(unsigned long long));
+
+      if(!newstring) { out_of_memory(); }
+
+      for (next_bit = 0, bits_left = length;
+           bits_left;
+           next_bit += nr_bits, bits_left -= nr_bits)
+       { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left>usize?usize:bits_left, &where);
+         value = cmos_read_bits(&where, nr_bits);
+         put_bits(value, next_bit % usize, nr_bits, &((unsigned long long *)newstring)[next_bit/usize]);
+        result = (unsigned long)newstring;
+       }
+    }
+   else
+    { for (next_bit = 0, bits_left = length;
+           bits_left;
+           next_bit += nr_bits, bits_left -= nr_bits)
+       { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left, &where);
+         value = cmos_read_bits(&where, nr_bits);
+         put_bits(value, next_bit, nr_bits, &result);
+       }
     }
 
    return result;
     }
 
    return result;
@@ -106,17 +123,32 @@ unsigned long long cmos_read (unsigned bit, unsigned length)
  * The I/O privilege level of the currently executing process must be set
  * appropriately.
  ****************************************************************************/
  * The I/O privilege level of the currently executing process must be set
  * appropriately.
  ****************************************************************************/
-void cmos_write (unsigned bit, unsigned length, unsigned long long value)
+void cmos_write (const cmos_entry_t *e, unsigned long long value)
  { cmos_bit_op_location_t where;
  { cmos_bit_op_location_t where;
+   unsigned bit = e->bit, length=e->length;
    unsigned next_bit, bits_left, nr_bits;
 
    unsigned next_bit, bits_left, nr_bits;
 
-   assert(!verify_cmos_op(bit, length));
+   assert(!verify_cmos_op(bit, length, e->config));
 
 
-   for (next_bit = 0, bits_left = length;
-        bits_left;
-        next_bit += nr_bits, bits_left -= nr_bits)
-    { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left, &where);
-      cmos_write_bits(&where, nr_bits, get_bits(value, next_bit, nr_bits));
+   if (e->config == CMOS_ENTRY_STRING) 
+    { unsigned long long *data = (unsigned long long *)(unsigned long)value;
+      unsigned usize = (8 * sizeof(unsigned long long));
+
+      for (next_bit = 0, bits_left = length;
+           bits_left;
+           next_bit += nr_bits, bits_left -= nr_bits)
+       { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left>usize?usize:bits_left, &where);
+         value = data[next_bit/usize];
+         cmos_write_bits(&where, nr_bits, get_bits(value, next_bit % usize, nr_bits));
+       }
+    }
+   else
+    { for (next_bit = 0, bits_left = length;
+           bits_left;
+           next_bit += nr_bits, bits_left -= nr_bits)
+       { nr_bits = cmos_bit_op_strategy(bit + next_bit, bits_left, &where);
+         cmos_write_bits(&where, nr_bits, get_bits(value, next_bit, nr_bits));
+       }
     }
  }
 
     }
  }
 
@@ -236,13 +268,16 @@ void set_iopl (int level)
  * wish to read or write.  Perform sanity checking on 'bit' and 'length'.  If
  * no problems were encountered, return OK.  Else return an error code.
  ****************************************************************************/
  * wish to read or write.  Perform sanity checking on 'bit' and 'length'.  If
  * no problems were encountered, return OK.  Else return an error code.
  ****************************************************************************/
-int verify_cmos_op (unsigned bit, unsigned length)
+int verify_cmos_op (unsigned bit, unsigned length, cmos_entry_config_t config)
  { if ((bit >= (8 * CMOS_SIZE)) || ((bit + length) > (8 * CMOS_SIZE)))
       return CMOS_AREA_OUT_OF_RANGE;
 
    if (bit < (8 * CMOS_RTC_AREA_SIZE))
       return CMOS_AREA_OVERLAPS_RTC;
 
  { if ((bit >= (8 * CMOS_SIZE)) || ((bit + length) > (8 * CMOS_SIZE)))
       return CMOS_AREA_OUT_OF_RANGE;
 
    if (bit < (8 * CMOS_RTC_AREA_SIZE))
       return CMOS_AREA_OVERLAPS_RTC;
 
+   if (config == CMOS_ENTRY_STRING)
+      return OK;
+
    if (length > (8 * sizeof(unsigned long long)))
       return CMOS_AREA_TOO_WIDE;
 
    if (length > (8 * sizeof(unsigned long long)))
       return CMOS_AREA_TOO_WIDE;
 
index 73634e02c9c1b3f5ccdb93ecd4add6928f219141..20a503f75b4e7ab3a23669c4e168ae4bd2a3dd41 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * cmos_lowlevel.h
 /*****************************************************************************\
  * cmos_lowlevel.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
 #define NVRAMTOOL_CMOS_LOWLEVEL_H
 
 #include "common.h"
 #define NVRAMTOOL_CMOS_LOWLEVEL_H
 
 #include "common.h"
+#include "layout.h"
 
 #define CMOS_AREA_OUT_OF_RANGE (CMOS_RESULT_START + 0)
 #define CMOS_AREA_OVERLAPS_RTC (CMOS_RESULT_START + 1)
 #define CMOS_AREA_TOO_WIDE (CMOS_RESULT_START + 2)
 
 
 #define CMOS_AREA_OUT_OF_RANGE (CMOS_RESULT_START + 0)
 #define CMOS_AREA_OVERLAPS_RTC (CMOS_RESULT_START + 1)
 #define CMOS_AREA_TOO_WIDE (CMOS_RESULT_START + 2)
 
-unsigned long long cmos_read (unsigned bit, unsigned length);
-void cmos_write (unsigned bit, unsigned length, unsigned long long value);
+unsigned long long cmos_read (const cmos_entry_t *e);
+void cmos_write (const cmos_entry_t *e, unsigned long long value);
 unsigned char cmos_read_byte (unsigned index);
 void cmos_write_byte (unsigned index, unsigned char value);
 void cmos_read_all (unsigned char data[]);
 void cmos_write_all (unsigned char data[]);
 void set_iopl (int level);
 unsigned char cmos_read_byte (unsigned index);
 void cmos_write_byte (unsigned index, unsigned char value);
 void cmos_read_all (unsigned char data[]);
 void cmos_write_all (unsigned char data[]);
 void set_iopl (int level);
-int verify_cmos_op (unsigned bit, unsigned length);
+int verify_cmos_op (unsigned bit, unsigned length, cmos_entry_config_t config);
 
 #define CMOS_SIZE 256  /* size of CMOS memory in bytes */
 #define CMOS_RTC_AREA_SIZE 14  /* first 14 bytes control real time clock */
 
 #define CMOS_SIZE 256  /* size of CMOS memory in bytes */
 #define CMOS_RTC_AREA_SIZE 14  /* first 14 bytes control real time clock */
index 170e944678b8c952b8a764604253dd4f598696f7..20b1093b7ed369588fe6e4df1ab8ce4bcd166045 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * cmos_ops.c
 /*****************************************************************************\
  * cmos_ops.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -47,7 +46,7 @@ static int prepare_cmos_op_common (const cmos_entry_t *e)
       /* Access to reserved parameters is not permitted. */
       return CMOS_OP_RESERVED;
 
       /* Access to reserved parameters is not permitted. */
       return CMOS_OP_RESERVED;
 
-   if ((result = verify_cmos_op(e->bit, e->length)) != OK)
+   if ((result = verify_cmos_op(e->bit, e->length, e->config)) != OK)
       return result;
 
    assert(e->length > 0);
       return result;
 
    assert(e->length > 0);
@@ -70,6 +69,7 @@ int prepare_cmos_read (const cmos_entry_t *e)
    switch (e->config)
     { case CMOS_ENTRY_ENUM:
       case CMOS_ENTRY_HEX:
    switch (e->config)
     { case CMOS_ENTRY_ENUM:
       case CMOS_ENTRY_HEX:
+      case CMOS_ENTRY_STRING:
          break;
 
       default:
          break;
 
       default:
@@ -92,6 +92,7 @@ int prepare_cmos_write (const cmos_entry_t *e, const char value_str[],
  { const cmos_enum_t *q;
    unsigned long long out;
    const char *p;
  { const cmos_enum_t *q;
    unsigned long long out;
    const char *p;
+   char *memory;
    int negative, result, found_one;
 
    if ((result = prepare_cmos_op_common(e)) != OK)
    int negative, result, found_one;
 
    if ((result = prepare_cmos_op_common(e)) != OK)
@@ -139,6 +140,15 @@ int prepare_cmos_write (const cmos_entry_t *e, const char value_str[],
 
          break;
 
 
          break;
 
+      case CMOS_ENTRY_STRING:
+        if (e->length < (8 * strlen(value_str)))
+           return CMOS_OP_VALUE_TOO_WIDE;
+        memory = malloc(e->length / 8);
+         memset(memory, 0, e->length / 8);
+         strcpy(memory, value_str);
+         out = (unsigned long)memory;
+        break;
+
       default:
          BUG();
     }
       default:
          BUG();
     }
index ea743336828f9af538e04518040fb735e5b42810..16aa923752467acbafbeb03b36f24eebd3c7c596 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * cmos_ops.h
 /*****************************************************************************\
  * cmos_ops.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index cb9e9c817b017561873f2e41a4d7e35ec693b09a..f59be8a02e00db87a70a716fccbc86b30fe6d208 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * common.c
 /*****************************************************************************\
  * common.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -35,7 +34,7 @@
 const char prog_name[] = "nvramtool";
 
 /* version of this program */
 const char prog_name[] = "nvramtool";
 
 /* version of this program */
-const char prog_version[] = "2.0.1";
+const char prog_version[] = "2.1";
 
 /****************************************************************************
  * get_line_from_file
 
 /****************************************************************************
  * get_line_from_file
index 5b479c0c40cbcb5b366cd83232ed4a85f3d1535e..f262ea41ab0a9dd00b6ab7cd87a16520b6255aff 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * common.h
 /*****************************************************************************\
  * common.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index 3d2c29feb8caf9c9225ca4c6f73ac5c0b59b4e7a..12bed5fbf3c80e18e970d1170915501c9a26db20 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * compute_ip_checksum.c
 /*****************************************************************************\
  * compute_ip_checksum.c
- * $Id$
 \*****************************************************************************/
 
 #include <stdint.h>
 \*****************************************************************************/
 
 #include <stdint.h>
index b5c81f08663fd5f0e406dd30ad76a5506f88918f..5df261988123da082bd176a8f7b314f4202c76ff 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * hexdump.c
 /*****************************************************************************\
  * hexdump.c
- * $Id$
 \*****************************************************************************/
 
 #include "hexdump.h"
 \*****************************************************************************/
 
 #include "hexdump.h"
index 4ee77f9fca7bccbeaa33efc9ad3fb866048f4da9..bd21ed9749b00f9ca13b10a38743b2ea28f5977e 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * hexdump.h
 /*****************************************************************************\
  * hexdump.h
- * $Id$
 \*****************************************************************************/
 
 #ifndef _HEXDUMP_H
 \*****************************************************************************/
 
 #ifndef _HEXDUMP_H
index eafea4ca026e8de6a8374891995333c65c490705..4c5b5bb28026bc3bb88f6a0f4ccc6b0ff715049f 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * input_file.c
 /*****************************************************************************\
  * input_file.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -137,6 +136,7 @@ cmos_write_t * process_input_file (FILE *f)
 
       item->bit = e->bit;
       item->length = e->length;
 
       item->bit = e->bit;
       item->length = e->length;
+      item->config = e->config;
       item->value = try_prepare_cmos_write(e, value);
 
       /* Append write operation to pending write list. */
       item->value = try_prepare_cmos_write(e, value);
 
       /* Append write operation to pending write list. */
@@ -162,9 +162,13 @@ void do_cmos_writes (cmos_write_t *list)
    set_iopl(3);
 
    while (list != NULL)
    set_iopl(3);
 
    while (list != NULL)
-    { item = list;
+    { cmos_entry_t e;
+      item = list;
+      e.bit = item->bit;
+      e.length = item->length;
+      e.config = item->config;
       list = item->next;
       list = item->next;
-      cmos_write(item->bit, item->length, item->value);
+      cmos_write(&e, item->value);
       free(item);
     }
 
       free(item);
     }
 
index 5d4764c08bb6c6c5ca52f2df249d658a9549aaec..16003087405be861448e7477959a7190b214313b 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * input_file.h
 /*****************************************************************************\
  * input_file.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -33,6 +32,7 @@
 #define INPUT_FILE_H
 
 #include "common.h"
 #define INPUT_FILE_H
 
 #include "common.h"
+#include "layout.h"
 
 typedef struct cmos_write_t cmos_write_t;
 
 
 typedef struct cmos_write_t cmos_write_t;
 
@@ -44,6 +44,7 @@ typedef struct cmos_write_t cmos_write_t;
 struct cmos_write_t
  { unsigned bit;
    unsigned length;
 struct cmos_write_t
  { unsigned bit;
    unsigned length;
+   cmos_entry_config_t config;
    unsigned long long value;
    cmos_write_t *next;
  };
    unsigned long long value;
    cmos_write_t *next;
  };
index 885197749eea033254d88d1cebbc0c9588b144a2..365bbd15db992a48bed2db1aafa4c4df176b3656 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * ip_checksum.h
 /*****************************************************************************\
  * ip_checksum.h
- * $Id$
 \*****************************************************************************/
 
 #ifndef IP_CHECKSUM_H
 \*****************************************************************************/
 
 #ifndef IP_CHECKSUM_H
index 6e47521c479882d91e4c364f46d62e49d0dd74dd..556bdb5921220558f62269c849636603523d084b 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * layout.c
 /*****************************************************************************\
  * layout.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index 69e71d6a9d7e7602cef55d671721008c27a9ffec..6bfb5215cd55ec0b2e297b9fc2a83cfc5b309766 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * layout.h
 /*****************************************************************************\
  * layout.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -49,6 +48,7 @@
 typedef enum
  { CMOS_ENTRY_ENUM,
    CMOS_ENTRY_HEX,
 typedef enum
  { CMOS_ENTRY_ENUM,
    CMOS_ENTRY_HEX,
+   CMOS_ENTRY_STRING,
    CMOS_ENTRY_RESERVED
  }
 cmos_entry_config_t;
    CMOS_ENTRY_RESERVED
  }
 cmos_entry_config_t;
index 4e6b12d51bbe60cb1b64b2776b800c992ae376fe..35751c0f4d9a7d1fca44857352a74f94e9514ef5 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * layout_file.c
 /*****************************************************************************\
  * layout_file.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -551,6 +550,10 @@ static void create_entry (cmos_entry_t *cmos_entry,
          cmos_entry->config = CMOS_ENTRY_HEX;
          break;
 
          cmos_entry->config = CMOS_ENTRY_HEX;
          break;
 
+      case 's':
+        cmos_entry->config = CMOS_ENTRY_STRING;
+        break;
+
       case 'r':
          cmos_entry->config = CMOS_ENTRY_RESERVED;
          break;
       case 'r':
          cmos_entry->config = CMOS_ENTRY_RESERVED;
          break;
@@ -758,6 +761,9 @@ static char cmos_entry_char_value (cmos_entry_config_t config)
       case CMOS_ENTRY_RESERVED:
          return 'r';
 
       case CMOS_ENTRY_RESERVED:
          return 'r';
 
+      case CMOS_ENTRY_STRING:
+         return 's';
+
       default:
          BUG();
     }
       default:
          BUG();
     }
index 3f4f3faf65f0b84e8f826c4840ab160cbbd62a07..87be6aadf43e3c657ad335061df71efc943c1405 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * layout_file.h
 /*****************************************************************************\
  * layout_file.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index 176085228f4deb6b205c9c7b51e49e9083af8395..05d70c2929694d0f863a3980658aea134fdd0526 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * lbtable.c
 /*****************************************************************************\
  * lbtable.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -582,6 +581,10 @@ static void process_cmos_table (void)
             cmos_entry.config = CMOS_ENTRY_RESERVED;
             break;
 
             cmos_entry.config = CMOS_ENTRY_RESERVED;
             break;
 
+         case 's':
+            cmos_entry.config = CMOS_ENTRY_STRING;
+            break;
+
          default:
             fprintf(stderr,
                     "%s: Entry in CMOS option table has unknown config "
          default:
             fprintf(stderr,
                     "%s: Entry in CMOS option table has unknown config "
index f632f1a9562b3a168a5f5c164cb3e071a5406db0..cbe1a5057e650f8b3026f68fa9ff627fa42ae914 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * lbtable.h
 /*****************************************************************************\
  * lbtable.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index 95f25b4480be5478a58db49d75c23c9d5e71671b..45ced60ca853206917f5fe0793914bfa5094fa22 100644 (file)
@@ -1,6 +1,5 @@
 .\"***************************************************************************\
 .\" nvramtool.1
 .\"***************************************************************************\
 .\" nvramtool.1
-.\" $Id$
 .\"***************************************************************************
 .\"  Copyright (C) 2002, 2003 The Regents of the University of California.
 .\"  Produced at the Lawrence Livermore National Laboratory.
 .\"***************************************************************************
 .\"  Copyright (C) 2002, 2003 The Regents of the University of California.
 .\"  Produced at the Lawrence Livermore National Laboratory.
@@ -28,7 +27,7 @@
 .\"  with this program; if not, write to the Free Software Foundation, Inc.,
 .\"  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 .\"***************************************************************************/
 .\"  with this program; if not, write to the Free Software Foundation, Inc.,
 .\"  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 .\"***************************************************************************/
-.TH NVRAMTOOL 1 "January 2008" Linux
+.TH NVRAMTOOL 1 "September 2008" Linux
 .SH NAME
 nvramtool \- read/write coreboot-related information
 .SH SYNOPSIS
 .SH NAME
 nvramtool \- read/write coreboot-related information
 .SH SYNOPSIS
@@ -252,4 +251,4 @@ concurrently.
 .SH AUTHORS
 David S. Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>
 .br
 .SH AUTHORS
 David S. Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>
 .br
-Stefan Reinauer <stepan@openbios.org>
+Stefan Reinauer <stepan@coresystems.de>
index 98de6dc929274060145a278bd5feffbf1ee2c4ed..183247713998232aff660ce429eea7bc0a9d4ff2 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * nvramtool.c
 /*****************************************************************************\
  * nvramtool.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
@@ -477,6 +476,11 @@ static void list_param_enums (const char name[])
                 e->length);
          break;
 
                 e->length);
          break;
 
+      case CMOS_ENTRY_STRING:
+         printf("Parameter %s requires a %u-byte string.\n", name,
+                e->length / 8);
+         break;
+
       case CMOS_ENTRY_RESERVED:
          printf("Parameter %s is reserved.\n", name);
          break;
       case CMOS_ENTRY_RESERVED:
          printf("Parameter %s is reserved.\n", name);
          break;
@@ -570,7 +574,7 @@ static void set_one_param (const char name[], const char value[])
 
    /* write the value to nonvolatile RAM */
    set_iopl(3);
 
    /* write the value to nonvolatile RAM */
    set_iopl(3);
-   cmos_write(e->bit, e->length, n);
+   cmos_write(e, n);
    cmos_checksum_write(cmos_checksum_compute());
    set_iopl(0);
    return;
    cmos_checksum_write(cmos_checksum_compute());
    set_iopl(0);
    return;
@@ -674,7 +678,7 @@ static int list_cmos_entry (const cmos_entry_t *e, int show_name)
 
    /* read the value from CMOS */
    set_iopl(3);
 
    /* read the value from CMOS */
    set_iopl(3);
-   value = cmos_read(e->bit, e->length);
+   value = cmos_read(e);
    set_iopl(0);
 
    /* display the value */
    set_iopl(0);
 
    /* display the value */
@@ -703,6 +707,16 @@ static int list_cmos_entry (const cmos_entry_t *e, int show_name)
 
          break;
 
 
          break;
 
+      case CMOS_ENTRY_STRING:
+         if (show_name)
+           printf("%s = %s\n", e->name, (char *)(unsigned long)value);
+        else
+           printf("%s\n", (char *)(unsigned long)value);
+
+         free((void *)(unsigned long)value);
+
+         break;
+
       case CMOS_ENTRY_RESERVED:
       default:
          BUG();
       case CMOS_ENTRY_RESERVED:
       default:
          BUG();
index 1493604dca98390359d043469ab0411806dc878c..dcc23a9e2a70b24aca89fde5f90c73c14b2eccd4 100644 (file)
@@ -1,9 +1,7 @@
 ##
 ##
-# $Id$
-##
 
 Name:    nvramtool
 
 Name:    nvramtool
-Version: 2.0.1
+Version: 2.1
 Release: 0
 
 Summary: coreboot utility program
 Release: 0
 
 Summary: coreboot utility program
index 34311531799ef1377b9b0866f3bf7ccd27e65e2a..27b3b481e9a58506e3381b5da9f851ad337ed11c 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * opts.c
 /*****************************************************************************\
  * opts.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index b335b16165cbc5e1ac761050debb07bbaf31e42a..729c5e2a72081c5a3338aa1f8a03b255d9a2455c 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * opts.h
 /*****************************************************************************\
  * opts.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index 0737866666008bed0ed4ba40f63b32c05e361211..bd349712bd7dfa5be577466a38bf1ab47b83b654 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * reg_expr.c
 /*****************************************************************************\
  * reg_expr.c
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
index cf8f8a9b4d54468af1a7a6f7e45e884cc56955cf..28ff7339c076bbc4e34a24734bf36a2a37f16527 100644 (file)
@@ -1,6 +1,5 @@
 /*****************************************************************************\
  * reg_expr.h
 /*****************************************************************************\
  * reg_expr.h
- * $Id$
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.
  *****************************************************************************
  *  Copyright (C) 2002-2005 The Regents of the University of California.
  *  Produced at the Lawrence Livermore National Laboratory.