Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/memswitch Initial version of memswitch(8), utility ...



details:   https://anonhg.NetBSD.org/src/rev/0820b663a199
branches:  trunk
changeset: 473908:0820b663a199
user:      minoura <minoura%NetBSD.org@localhost>
date:      Mon Jun 21 15:56:03 1999 +0000

description:
Initial version of memswitch(8), utility to get or set x68k memory switch.

diffstat:

 usr.sbin/memswitch/Makefile     |   11 +
 usr.sbin/memswitch/memswitch.8  |   85 +++++
 usr.sbin/memswitch/memswitch.c  |  434 +++++++++++++++++++++++++++++
 usr.sbin/memswitch/memswitch.h  |   98 ++++++
 usr.sbin/memswitch/methods.c    |  584 ++++++++++++++++++++++++++++++++++++++++
 usr.sbin/memswitch/methods.h    |   66 ++++
 usr.sbin/memswitch/properties.c |  336 +++++++++++++++++++++++
 7 files changed, 1614 insertions(+), 0 deletions(-)

diffs (truncated from 1642 to 300 lines):

diff -r 0070601867cb -r 0820b663a199 usr.sbin/memswitch/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/memswitch/Makefile       Mon Jun 21 15:56:03 1999 +0000
@@ -0,0 +1,11 @@
+#      $NetBSD: Makefile,v 1.1.1.1 1999/06/21 15:56:03 minoura Exp $
+
+.if ${MACHINE} == "x68k"
+PROG=  memswitch
+SRCS=  memswitch.c properties.c methods.c
+.endif
+
+MAN=   memswitch.8
+MANSUBDIR=     /x68k
+
+.include <bsd.prog.mk>
diff -r 0070601867cb -r 0820b663a199 usr.sbin/memswitch/memswitch.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/memswitch/memswitch.8    Mon Jun 21 15:56:03 1999 +0000
@@ -0,0 +1,85 @@
+.\" $NetBSD: memswitch.8,v 1.1.1.1 1999/06/21 15:56:03 minoura Exp $
+.\"
+.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Minoura Makoto.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"    This product includes software developed by the NetBSD
+.\"    Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"/
+.Dd 
+.Dt MEMSWITCH 8 x68k
+.Os
+.Sh NAME
+.Nm memswitch
+.Nd get or set x68k memory switch
+.Sh SYNOPSIS
+.Nm
+.Fl a
+.Nm ""
+.Op Fl h
+.Op Fl n
+.Ar variable ...
+.Nm ""
+.Fl w Ar variable=value ...
+.Nm ""
+.Fl r Ar filename
+.Nm ""
+.Fl s Ar filename
+.Sh DESCRIPTION
+The
+.Nm
+command gets or sets the x68k memory switch stored in the non-volatile
+static ram.
+.Pp
+The first form shows the current values of all the variables of the memory
+switch.
+.Pp
+The second form shows the current values of the specified variables.  If the
+.Fl h
+flag is specified, a brief descriptions of the variables are displayed.
+The
+.Fl n
+flag suppresses printing of the variable name.
+.Pp
+The third form sets or modifies the specified variables to the given value.
+.Pp
+In the fourth and fifth form, the whole memory switch part of non-volatile
+SRAM is saved to, or restored from the specified file, respectively.
+.Sh FILES
+.Bl -tag -width /dev/sram
+.It Pa /dev/sram
+non-volatile static memory control device
+.El
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Nx 1.5 .
diff -r 0070601867cb -r 0820b663a199 usr.sbin/memswitch/memswitch.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/memswitch/memswitch.c    Mon Jun 21 15:56:03 1999 +0000
@@ -0,0 +1,434 @@
+/*     $NetBSD: memswitch.c,v 1.1.1.1 1999/06/21 15:56:03 minoura Exp $        */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Minoura Makoto.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* memswitch.c */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <err.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <sys/ioctl.h>
+
+#include <machine/sram.h>
+
+#include "memswitch.h"
+
+char *progname;
+int nflag = 0;
+u_int8_t *current_values = 0;
+u_int8_t *modified_values = 0;
+
+void
+usage(void)
+{
+       fprintf (stderr, "Usage: %s -a\n", progname);
+       fprintf (stderr, "       %s [-h] variable ...\n", progname);
+       fprintf (stderr, "       %s variable=value ...\n", progname);
+       fprintf (stderr, "       %s [-rs] filename\n", progname);
+       exit(1);
+}
+
+int
+main(argc, argv)
+       int argc;
+       char *argv[];
+{
+       int ch;
+       extern char *optarg;
+       extern int optind;
+       enum md {
+               MD_NONE, MD_WRITE, MD_HELP, MD_SHOWALL, MD_SAVE, MD_RESTORE
+       } mode = MD_NONE;
+
+       progname = argv[0];
+
+       while ((ch = getopt(argc, argv, "whanrs")) != -1) {
+               switch (ch) {
+               case 'w':       /* write */
+                       mode = MD_WRITE;
+                       break;
+               case 'h':
+                       mode = MD_HELP;
+                       break;
+               case 'a':
+                       mode = MD_SHOWALL;
+                       break;
+               case 'n':
+                       nflag = 1;
+                       break;
+               case 's':
+                       mode = MD_SAVE;
+                       break;
+               case 'r':
+                       mode = MD_RESTORE;
+                       break;
+               }
+       }
+       argc -= optind;
+       argv += optind;
+
+       switch (mode) {
+       case MD_NONE:
+               if (argc == 0)
+                       usage();
+               while (argv[0]) {
+                       show_single (argv[0]);
+                       argv++;
+               }
+               break;
+       case MD_SHOWALL:
+               if (argc)
+                       usage();
+               show_all();
+               break;
+       case MD_WRITE:
+               if (argc == 0)
+                       usage();
+               while (argv[0]) {
+                       modify_single (argv[0]);
+                       argv++;
+               }
+               flush ();
+               break;
+       case MD_HELP:
+               if (argc == 0)
+                       usage();
+               while (argv[0]) {
+                       help_single (argv[0]);
+                       argv++;
+               }
+               break;
+       case MD_SAVE:
+               if (argc != 1)
+                       usage();
+               save(argv[0]);
+               break;
+       case MD_RESTORE:
+               if (argc != 1)
+                       usage();
+               restore(argv[0]);
+               break;
+               
+       }
+
+       return 0;
+}
+
+void
+show_single(name)
+       const char *name;
+{
+       int i;
+       char fullname[50];
+       char valuestr[MAXVALUELEN];
+
+       for (i = 0; i < number_of_props; i++) {
+               sprintf(fullname, "%s.%s",
+                       properties[i].class, properties[i].node);
+               if (strcmp(name, fullname) == 0) {
+                       properties[i].print (&properties[i], valuestr);
+                       if (!nflag)
+                               printf ("%s=%s\n", fullname, valuestr);
+                       break;
+               }
+       }
+       if (i >= number_of_props) {
+               errx (1, "No such property: %s\n", name);
+       }
+
+       return;
+}
+
+void
+show_all(void)
+{
+       int i;
+       char valuestr[MAXVALUELEN];
+
+       for (i = 0; i < number_of_props; i++) {
+               properties[i].print (&properties[i], valuestr);
+               if (!nflag)
+                       printf ("%s.%s=",
+                               properties[i].class, properties[i].node);
+               printf ("%s\n", valuestr);
+       }



Home | Main Index | Thread Index | Old Index