Author: oxygene
Date: Fri Jan 28 08:47:10 2011
New Revision: 6310
URL: https://tracker.coreboot.org/trac/coreboot/changeset/6310

Log:
Move CLI portion of nvramtool into cli/ subdirectory as first step towards 
librarization.
Also: update one regex wrapper user.

Signed-off-by: Patrick Georgi <patrick.geo...@secunet.com>
Acked-by: Stefan Reinauer <stefan.reina...@coreboot.org>

Added:
   trunk/util/nvramtool/cli/
   trunk/util/nvramtool/cli/nvramtool.8
      - copied unchanged from r6309, trunk/util/nvramtool/nvramtool.8
   trunk/util/nvramtool/cli/nvramtool.c
      - copied, changed from r6309, trunk/util/nvramtool/nvramtool.c
   trunk/util/nvramtool/cli/opts.c
      - copied unchanged from r6309, trunk/util/nvramtool/opts.c
   trunk/util/nvramtool/cli/opts.h
      - copied unchanged from r6309, trunk/util/nvramtool/opts.h
Deleted:
   trunk/util/nvramtool/nvramtool.8
   trunk/util/nvramtool/nvramtool.c
   trunk/util/nvramtool/opts.c
   trunk/util/nvramtool/opts.h
Modified:
   trunk/util/nvramtool/Makefile

Modified: trunk/util/nvramtool/Makefile
==============================================================================
--- trunk/util/nvramtool/Makefile       Fri Jan 28 08:41:10 2011        (r6309)
+++ trunk/util/nvramtool/Makefile       Fri Jan 28 08:47:10 2011        (r6310)
@@ -24,12 +24,16 @@
 STRIP  = strip
 INSTALL = /usr/bin/install
 PREFIX  = /usr/local
-CFLAGS  = -O2 -g -Wall -W
+CFLAGS  = -O2 -g -Wall -W -I.
 #CFLAGS  = -Os -Wall
 
+CLI_OBJS = cli/nvramtool.o cli/opts.o
+
 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 cbfs.o
+       reg_expr.o cbfs.o
+
+OBJS += $(CLI_OBJS)
 
 OS_ARCH        = $(shell uname)
 ifeq ($(OS_ARCH), Darwin)
@@ -43,7 +47,7 @@
        $(STRIP) $(STRIP_ARGS) $(PROGRAM)
 
 clean:
-       rm -f $(PROGRAM) *.o
+       rm -f $(PROGRAM) $(OBJS)
 
 distclean: clean
        rm -f .dependencies
@@ -55,7 +59,7 @@
        mkdir -p $(DESTDIR)$(PREFIX)/sbin
        $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
        mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
-       $(INSTALL) $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
+       $(INSTALL) cli/$(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
 
 .PHONY: all clean distclean dep
 

Copied: trunk/util/nvramtool/cli/nvramtool.8 (from r6309, 
trunk/util/nvramtool/nvramtool.8)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/util/nvramtool/cli/nvramtool.8        Fri Jan 28 08:47:10 2011        
(r6310, copy of r6309, trunk/util/nvramtool/nvramtool.8)
@@ -0,0 +1,254 @@
+.\"***************************************************************************\
+.\" nvramtool.8
+.\"***************************************************************************
+.\"  Copyright (C) 2002, 2003 The Regents of the University of California.
+.\"  Produced at the Lawrence Livermore National Laboratory.
+.\"  Written by David S. Peterson <d...@llnl.gov> <dave_peter...@pobox.com>.
+.\"  UCRL-CODE-2003-012
+.\"  All rights reserved.
+.\"
+.\"  This file is part of nvramtool, a utility for reading/writing coreboot
+.\"  parameters and displaying information from the coreboot table.
+.\"  For details, see http://coreboot.org/nvramtool.
+.\"
+.\"  Please also read the file DISCLAIMER which is included in this software
+.\"  distribution.
+.\"
+.\"  This program is free software; you can redistribute it and/or modify it
+.\"  under the terms of the GNU General Public License (as published by the
+.\"  Free Software Foundation) version 2, dated June 1991.
+.\"
+.\"  This program is distributed in the hope that it will be useful, but
+.\"  WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+.\"  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the terms and
+.\"  conditions of the GNU General Public License for more details.
+.\"
+.\"  You should have received a copy of the GNU General Public License along
+.\"  with this program; if not, write to the Free Software Foundation, Inc.,
+.\"  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+.\"***************************************************************************/
+.TH NVRAMTOOL 8 "September 2008"
+.SH NAME
+nvramtool \- read/write coreboot-related information
+.SH SYNOPSIS
+.B "nvramtool [OPTS] [-n] -r NAME"
+.br
+.B "nvramtool [OPTS] -e NAME"
+.br
+.B "nvramtool [OPTS] -a"
+.br
+.B "nvramtool [OPTS] -w NAME=VALUE"
+.br
+.B "nvramtool [OPTS] -p INPUT_FILE"
+.br
+.B "nvramtool [OPTS] -i"
+.br
+.B "nvramtool [OPTS] -c [VALUE]"
+.br
+.B "nvramtool [OPTS] -l [ARG]"
+.br
+.B "nvramtool [OPTS] -d"
+.br
+.B "nvramtool [OPTS] -Y"
+.br
+.B "nvramtool [OPTS] -b OUTPUT_FILE"
+.br
+.B "nvramtool [OPTS] -B INPUT_FILE"
+.br
+.B "nvramtool [OPTS] -x"
+.br
+.B "nvramtool [OPTS] -X DUMPFILE"
+.br
+.B "nvramtool [OPTS] -v"
+.br
+.B "nvramtool [OPTS] -h"
+.SH DESCRIPTION
+.B "nvramtool"
+is a utility for reading/writing coreboot parameters and displaying
+information from the coreboot table.
+
+The coreboot table resides in low physical memory.  It is created at boot
+time by coreboot, and contains various system information such as the type
+of mainboard in use.  It specifies locations in the CMOS (nonvolatile RAM)
+where the coreboot parameters are stored.
+
+This program is intended for (x86-based) systems that use coreboot.  For
+information about coreboot, see
+.br
+http://www.coreboot.org/.
+.SH PARAMETERS
+.TP
+.B "[-n] -r NAME"
+Show the value of the coreboot parameter given by
+.B "NAME."
+If
+.B "-n"
+is specified, show only the value.  Otherwise show both parameter name and
+value.
+.TP
+.B "-e NAME"
+Show all possible values for parameter given by
+.B "NAME."
+.TP
+.B "-a"
+Show the names and values for all coreboot parameters.
+.TP
+.B "-w NAME=VALUE"
+Assign
+.B "VALUE"
+to coreboot parameter given by
+.B "NAME."
+.TP
+.B "-p INPUT_FILE"
+Assign values to coreboot parameters according to the contents of
+.B "INPUT_FILE."
+The format of this file is described below.
+.TP
+.B "-i"
+This is similar to the
+.B "-p"
+option, except that the contents of the input file are taken from standard
+input.
+.TP
+.B "-c [VALUE]"
+If
+.B "VALUE"
+is present then set the CMOS checksum for the coreboot parameters to
+.B "VALUE."
+Otherwise, show the checksum value.
+.TP
+.B "-l [ARG]"
+If
+.B "ARG"
+is present then show information from the coreboot table as specified by
+.B "ARG."
+Otherwise show all possible values for
+.B "ARG."
+.TP
+.B "-d"
+Do a low-level dump of the coreboot table.
+.TP
+.B "-Y"
+Write CMOS layout information to standard output.  If redirected to a file,
+the layout information may be used as input for the
+.B "'-y LAYOUT_FILE'"
+option (see below).
+.TP
+.B "-b OUTPUT_FILE"
+Write the contents of CMOS memory to the binary file
+.B "OUTPUT_FILE."
+The first 14 bytes of
+.B "OUTPUT_FILE"
+do not contain actual CMOS data, and are always written as zeros.  This is
+because the first 14 bytes of the CMOS area do not contain CMOS memory.  These
+bytes are involved with the functioning of the real time clock.
+.TP
+.B "-B INPUT_FILE"
+Read binary data from
+.B "INPUT_FILE"
+and write the data to CMOS memory.  The first 14 bytes of
+.B "INPUT_FILE"
+are skipped and data is written to CMOS starting at the 15th byte of the CMOS
+area.  This is because the first 14 bytes of the CMOS area do not contain CMOS
+memory.  These bytes are involved with the functioning of the real time clock.
+.TP
+.B "-x"
+Show a hex dump of all CMOS data.  The first 14 bytes of the dump do not
+contain actual CMOS data, and are always shown as zeros.  This is because the
+first 14 bytes of the CMOS area do not contain CMOS memory.  These bytes are
+involved with the functioning of the real time clock.
+.TP
+.B "-X DUMPFILE"
+Read binary data from
+.B "DUMPFILE"
+(presumably a CMOS dumpfile created using the
+.B "-b OUTPUT_FILE"
+option) and show a hex dump of the data.
+.TP
+.B "-v"
+Show version information for this program.
+.TP
+.B "-h"
+Show a help message for this program.
+.SH "OPTIONS"
+In all cases above,
+.B "[OPTS]"
+evaluates to the following:
+
+.B "    [-y LAYOUT_FILE | -t]"
+
+The
+.B "'-y LAYOUT_FILE'"
+option tells nvramtool to obtain CMOS layout information from the contents of
+.B "LAYOUT_FILE."
+Likewise, the
+.B "'-t'"
+option tells nvramtool to obtain CMOS layout information from the CMOS option
+table (contained within the coreboot table).  If neither option is
+specified, the CMOS option table is used by default.
+.B "LAYOUT_FILE"
+follows the format of the
+.B "cmos.layout"
+files provided by coreboot.
+
+If the coreboot installed on your system was built without specifying
+.B "CONFIG_HAVE_OPTION_TABLE,"
+then the coreboot table will not contain a CMOS option table.  In this case,
+the
+.B "'-y LAYOUT_FILE'"
+option must be used.
+
+These two options are silently ignored when used in combination with other
+options (such as
+.B "-h,"
+for instance) for which they are not applicable.
+.SH FILE FORMAT
+For the
+.B "-p"
+option,
+.B "INPUT_FILE"
+must consist of a sequence of lines such that each line is either a blank
+line, a comment, or an assignment.  A blank line consists only of zero or
+more whitespace characters (spaces and tabs).  A comment is constructed as
+follows:
+
+.B "    [ws]#[text]"
+
+Here,
+.B "[ws]"
+indicates optional whitespace characters and
+.B "[text]"
+indicates optional text.  Blank lines and comments are both ignored.  An
+assignment is constructed as follows:
+
+.B "    [ws]NAME[ws]=[ws]VALUE[ws]"
+
+Here,
+.B "NAME"
+is the name of a coreboot parameter and
+.B "VALUE"
+is the value that will be assigned to
+.B "NAME."
+.B "VALUE"
+is allowed to contain whitespace characters, but it must begin and end with
+nonwhitespace characters.  Note that each comment must appear on a line by
+itself.  If you attempt to add a comment to the end of an assignment, then the
+comment will be interpreted as part of
+.B "VALUE."
+It is useful to observe that the output produced by both the
+.B "-a"
+and the
+.B "'[-n] NAME'"
+options (without
+.B "-n"
+specified) adheres to this file format.
+.SH BUGS
+This program does not implement any type of synchronization to ensure that
+different processes don't stomp on each other when trying to access the
+nonvolatile RAM simultaneously.  Therefore, corruption of the BIOS parameter
+values may occur if multiple instances of this program are executed
+concurrently.
+.SH AUTHORS
+David S. Peterson <d...@llnl.gov> <dave_peter...@pobox.com>
+.br
+Stefan Reinauer <ste...@coresystems.de>

Copied and modified: trunk/util/nvramtool/cli/nvramtool.c (from r6309, 
trunk/util/nvramtool/nvramtool.c)
==============================================================================
--- trunk/util/nvramtool/nvramtool.c    Fri Jan 28 08:41:10 2011        (r6309, 
copy source)
+++ trunk/util/nvramtool/cli/nvramtool.c        Fri Jan 28 08:47:10 2011        
(r6310)
@@ -682,8 +682,7 @@
        regmatch_t match[N_MATCHES];
        regex_t assignment;
 
-       compile_reg_exprs(REG_EXTENDED | REG_NEWLINE, 1, assignment_regex,
-                         &assignment);
+       compile_reg_expr(REG_EXTENDED | REG_NEWLINE, assignment_regex, 
&assignment);
 
        /* Does 'arg' conform to proper assignment syntax?  If not, exit with a
         * usage message.
@@ -699,7 +698,7 @@
        *name = &arg[match[1].rm_so];
        *value = &arg[match[2].rm_so];
 
-       free_reg_exprs(1, &assignment);
+       regfree(&assignment);
 }
 
 /****************************************************************************

Copied: trunk/util/nvramtool/cli/opts.c (from r6309, 
trunk/util/nvramtool/opts.c)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/util/nvramtool/cli/opts.c     Fri Jan 28 08:47:10 2011        (r6310, 
copy of r6309, trunk/util/nvramtool/opts.c)
@@ -0,0 +1,259 @@
+/*****************************************************************************\
+ * opts.c
+ *****************************************************************************
+ *  Copyright (C) 2002-2005 The Regents of the University of California.
+ *  Produced at the Lawrence Livermore National Laboratory.
+ *  Written by Dave Peterson <d...@llnl.gov> <dave_peter...@pobox.com>.
+ *  UCRL-CODE-2003-012
+ *  All rights reserved.
+ *
+ *  This file is part of nvramtool, a utility for reading/writing coreboot
+ *  parameters and displaying information from the coreboot table.
+ *  For details, see http://coreboot.org/nvramtool.
+ *
+ *  Please also read the file DISCLAIMER which is included in this software
+ *  distribution.
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License (as published by the
+ *  Free Software Foundation) version 2, dated June 1991.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the terms and
+ *  conditions of the GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+\*****************************************************************************/
+
+#include "common.h"
+#include "opts.h"
+
+nvramtool_op_info_t nvramtool_op;
+
+nvramtool_op_modifier_info_t 
nvramtool_op_modifiers[NVRAMTOOL_NUM_OP_MODIFIERS];
+
+static char *handle_optional_arg(int argc, char *argv[]);
+static void register_op(int *op_found, nvramtool_op_t op, char op_param[]);
+static void register_op_modifier(nvramtool_op_modifier_t mod, char 
mod_param[]);
+static void resolve_op_modifiers(void);
+static void sanity_check_args(void);
+
+static const char getopt_string[] = "-ab:B:c::C:dD:e:hil::np:r:tvw:xX:y:Y";
+
+/****************************************************************************
+ * parse_nvramtool_args
+ *
+ * Parse command line arguments.
+ ****************************************************************************/
+void parse_nvramtool_args(int argc, char *argv[])
+{
+       nvramtool_op_modifier_info_t *mod_info;
+       int i, op_found;
+       char c;
+
+       for (i = 0, mod_info = nvramtool_op_modifiers;
+            i < NVRAMTOOL_NUM_OP_MODIFIERS; i++, mod_info++) {
+               mod_info->found = FALSE;
+               mod_info->found_seq = 0;
+               mod_info->param = NULL;
+       }
+
+       op_found = FALSE;
+       opterr = 0;
+
+       do {
+               switch (c = getopt(argc, argv, getopt_string)) {
+               case 'a':
+                       register_op(&op_found,
+                                   NVRAMTOOL_OP_CMOS_SHOW_ALL_PARAMS, NULL);
+                       break;
+               case 'b':
+                       register_op(&op_found, NVRAMTOOL_OP_WRITE_CMOS_DUMP,
+                                   optarg);
+                       break;
+               case 'B':
+                       register_op(&op_found, NVRAMTOOL_OP_READ_CMOS_DUMP,
+                                   optarg);
+                       break;
+               case 'c':
+                       register_op(&op_found, NVRAMTOOL_OP_CMOS_CHECKSUM,
+                                   handle_optional_arg(argc, argv));
+                       break;
+               case 'C':
+                       register_op_modifier(NVRAMTOOL_MOD_USE_CBFS_FILE,
+                                            optarg);
+                       break;
+               case 'd':
+                       register_op(&op_found, NVRAMTOOL_OP_LBTABLE_DUMP, NULL);
+                       break;
+               case 'D':
+                       register_op_modifier(NVRAMTOOL_MOD_USE_CMOS_FILE,
+                                            optarg);
+                       break;
+               case 'e':
+                       register_op(&op_found, NVRAMTOOL_OP_SHOW_PARAM_VALUES,
+                                   optarg);
+                       break;
+               case 'h':
+                       register_op(&op_found, NVRAMTOOL_OP_SHOW_USAGE, NULL);
+                       break;
+               case 'i':
+                       register_op(&op_found,
+                                   NVRAMTOOL_OP_CMOS_SET_PARAMS_STDIN, NULL);
+                       break;
+               case 'l':
+                       register_op(&op_found, NVRAMTOOL_OP_LBTABLE_SHOW_INFO,
+                                   handle_optional_arg(argc, argv));
+                       break;
+               case 'n':
+                       register_op_modifier(NVRAMTOOL_MOD_SHOW_VALUE_ONLY,
+                                            NULL);
+                       break;
+               case 'p':
+                       register_op(&op_found,
+                                   NVRAMTOOL_OP_CMOS_SET_PARAMS_FILE, optarg);
+                       break;
+               case 'r':
+                       register_op(&op_found, NVRAMTOOL_OP_CMOS_SHOW_ONE_PARAM,
+                                   optarg);
+                       break;
+               case 't':
+                       register_op_modifier(NVRAMTOOL_MOD_USE_CMOS_OPT_TABLE,
+                                            NULL);
+                       break;
+               case 'v':
+                       register_op(&op_found, NVRAMTOOL_OP_SHOW_VERSION, NULL);
+                       break;
+               case 'w':
+                       register_op(&op_found, NVRAMTOOL_OP_CMOS_SET_ONE_PARAM,
+                                   optarg);
+                       break;
+               case 'x':
+                       register_op(&op_found, NVRAMTOOL_OP_SHOW_CMOS_HEX_DUMP,
+                                   NULL);
+                       break;
+               case 'X':
+                       register_op(&op_found, NVRAMTOOL_OP_SHOW_CMOS_DUMPFILE,
+                                   optarg);
+                       break;
+               case 'y':
+                       register_op_modifier(NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE,
+                                            optarg);
+                       break;
+               case 'Y':
+                       register_op(&op_found, NVRAMTOOL_OP_SHOW_LAYOUT, NULL);
+                       break;
+               case -1:        /* no more command line args */
+                       break;
+               case '?':       /* unknown option found */
+               case 1: /* nonoption command line arg found */
+               default:
+                       usage(stderr);
+                       break;
+               }
+       } while (c != -1);
+
+       if (!op_found)
+               usage(stderr);
+
+       resolve_op_modifiers();
+       sanity_check_args();
+}
+
+/****************************************************************************
+ * handle_optional_arg
+ *
+ * Handle a command line option with an optional argument.
+ ****************************************************************************/
+static char *handle_optional_arg(int argc, char *argv[])
+{
+       char *arg;
+
+       if (optarg != NULL) {
+               /* optional arg is present and arg was specified as
+                * "-zarg" (with no whitespace between "z" and "arg"),
+                * where -z is the option and "arg" is the value of the
+                * optional arg
+                */
+               return optarg;
+       }
+
+       if ((argv[optind] == NULL) || (argv[optind][0] == '-'))
+               return NULL;
+
+       arg = argv[optind];     /* optional arg is present */
+
+       /* This call to getopt yields the optional arg we just found,
+        * which we want to skip.
+        */
+       getopt(argc, argv, getopt_string);
+
+       return arg;
+}
+
+/****************************************************************************
+ * register_op
+ *
+ * Store the user's selection of which operation this program should perform.
+ ****************************************************************************/
+static void register_op(int *op_found, nvramtool_op_t op, char op_param[])
+{
+       if (*op_found && (op != nvramtool_op.op))
+               usage(stderr);
+
+       *op_found = TRUE;
+       nvramtool_op.op = op;
+       nvramtool_op.param = op_param;
+}
+
+/****************************************************************************
+ * register_op_modifier
+ *
+ * Store information regarding an optional argument specified in addition to
+ * the user's selection of which operation this program should perform.
+ ****************************************************************************/
+static void register_op_modifier(nvramtool_op_modifier_t mod, char mod_param[])
+{
+       static int found_seq = 0;
+       nvramtool_op_modifier_info_t *mod_info;
+
+       mod_info = &nvramtool_op_modifiers[mod];
+       mod_info->found = TRUE;
+       mod_info->found_seq = ++found_seq;
+       mod_info->param = mod_param;
+}
+
+/****************************************************************************
+ * resolve_op_modifiers
+ *
+ * If the user specifies multiple arguments that conflict with each other,
+ * the last specified argument overrides previous conflicting arguments.
+ ****************************************************************************/
+static void resolve_op_modifiers(void)
+{
+       if (nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE].found &&
+           nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_OPT_TABLE].found) {
+               if 
(nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE].found_seq >
+                   
nvramtool_op_modifiers[NVRAMTOOL_MOD_USE_CMOS_OPT_TABLE].found_seq)
+                       nvramtool_op_modifiers
+                           [NVRAMTOOL_MOD_USE_CMOS_OPT_TABLE].found = FALSE;
+               else
+                       nvramtool_op_modifiers
+                           [NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE].found = FALSE;
+       }
+}
+
+/****************************************************************************
+ * sanity_check_args
+ *
+ * Perform sanity checking on command line arguments.
+ ****************************************************************************/
+static void sanity_check_args(void)
+{
+       if ((nvramtool_op_modifiers[NVRAMTOOL_MOD_SHOW_VALUE_ONLY].found) &&
+           (nvramtool_op.op != NVRAMTOOL_OP_CMOS_SHOW_ONE_PARAM))
+               usage(stderr);
+}

Copied: trunk/util/nvramtool/cli/opts.h (from r6309, 
trunk/util/nvramtool/opts.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/util/nvramtool/cli/opts.h     Fri Jan 28 08:47:10 2011        (r6310, 
copy of r6309, trunk/util/nvramtool/opts.h)
@@ -0,0 +1,79 @@
+/*****************************************************************************\
+ * opts.h
+ *****************************************************************************
+ *  Copyright (C) 2002-2005 The Regents of the University of California.
+ *  Produced at the Lawrence Livermore National Laboratory.
+ *  Written by Dave Peterson <d...@llnl.gov> <dave_peter...@pobox.com>.
+ *  UCRL-CODE-2003-012
+ *  All rights reserved.
+ *
+ *  This file is part of nvramtool, a utility for reading/writing coreboot
+ *  parameters and displaying information from the coreboot table.
+ *  For details, see http://coreboot.org/nvramtool.
+ *
+ *  Please also read the file DISCLAIMER which is included in this software
+ *  distribution.
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License (as published by the
+ *  Free Software Foundation) version 2, dated June 1991.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the terms and
+ *  conditions of the GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+\*****************************************************************************/
+
+#ifndef OPTS_H
+#define OPTS_H
+
+#include "common.h"
+
+typedef enum { NVRAMTOOL_OP_SHOW_VERSION = 0,
+       NVRAMTOOL_OP_SHOW_USAGE,
+       NVRAMTOOL_OP_LBTABLE_SHOW_INFO,
+       NVRAMTOOL_OP_LBTABLE_DUMP,
+       NVRAMTOOL_OP_SHOW_PARAM_VALUES,
+       NVRAMTOOL_OP_CMOS_SHOW_ONE_PARAM,
+       NVRAMTOOL_OP_CMOS_SHOW_ALL_PARAMS,
+       NVRAMTOOL_OP_CMOS_SET_ONE_PARAM,
+       NVRAMTOOL_OP_CMOS_SET_PARAMS_STDIN,
+       NVRAMTOOL_OP_CMOS_SET_PARAMS_FILE,
+       NVRAMTOOL_OP_CMOS_CHECKSUM,
+       NVRAMTOOL_OP_SHOW_LAYOUT,
+       NVRAMTOOL_OP_WRITE_CMOS_DUMP,
+       NVRAMTOOL_OP_READ_CMOS_DUMP,
+       NVRAMTOOL_OP_SHOW_CMOS_HEX_DUMP,
+       NVRAMTOOL_OP_SHOW_CMOS_DUMPFILE
+} nvramtool_op_t;
+
+typedef struct {
+       nvramtool_op_t op;
+       char *param;
+} nvramtool_op_info_t;
+
+typedef enum { NVRAMTOOL_MOD_SHOW_VALUE_ONLY = 0,
+       NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE,
+       NVRAMTOOL_MOD_USE_CBFS_FILE,
+       NVRAMTOOL_MOD_USE_CMOS_FILE,
+       NVRAMTOOL_MOD_USE_CMOS_OPT_TABLE,
+       NVRAMTOOL_NUM_OP_MODIFIERS      /* must always be last */
+} nvramtool_op_modifier_t;
+
+typedef struct {
+       int found;
+       int found_seq;
+       char *param;
+} nvramtool_op_modifier_info_t;
+
+extern nvramtool_op_info_t nvramtool_op;
+
+extern nvramtool_op_modifier_info_t nvramtool_op_modifiers[];
+
+void parse_nvramtool_args(int argc, char *argv[]);
+
+#endif                         /* OPTS_H */

-- 
coreboot mailing list: coreboot@coreboot.org
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to