Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/tadpolectl Add new binary tadpolectl for use with T...



details:   https://anonhg.NetBSD.org/src/rev/fec9918b8d94
branches:  trunk
changeset: 479649:fec9918b8d94
user:      garbled <garbled%NetBSD.org@localhost>
date:      Fri Dec 17 05:30:02 1999 +0000

description:
Add new binary tadpolectl for use with Tadpole SparcBook machines.
Presents a sysctl(8)-like interface for the user to read and modify
tadpole specific values and hardware states. (for things like changing the
bell frequency/volume, tft brightness, mouse variables, etc)

diffstat:

 usr.sbin/tadpolectl/Makefile     |   10 +
 usr.sbin/tadpolectl/tadpolectl.8 |  140 +++++++
 usr.sbin/tadpolectl/tadpolectl.c |  765 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 915 insertions(+), 0 deletions(-)

diffs (truncated from 927 to 300 lines):

diff -r 3454fc232b8f -r fec9918b8d94 usr.sbin/tadpolectl/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/tadpolectl/Makefile      Fri Dec 17 05:30:02 1999 +0000
@@ -0,0 +1,10 @@
+#      $NetBSD: Makefile,v 1.1 1999/12/17 05:30:02 garbled Exp $
+
+.if ${MACHINE} == "sparc"
+PROG=  tadpolectl
+SRCS=  tadpolectl.c
+.endif
+
+MAN=   tadpolectl.8
+
+.include <bsd.prog.mk>
diff -r 3454fc232b8f -r fec9918b8d94 usr.sbin/tadpolectl/tadpolectl.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/tadpolectl/tadpolectl.8  Fri Dec 17 05:30:02 1999 +0000
@@ -0,0 +1,140 @@
+.\" $NetBSD: tadpolectl.8,v 1.1 1999/12/17 05:30:02 garbled Exp $
+.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Tim Rightnour
+.\"
+.\" 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 December 16, 1999
+.Dt TADPOLECTL 8
+.Os
+.Sh NAME
+.Nm tadpolectl
+.Nd get or set tadpole microcontroller state
+.Sh SYNOPSIS
+.Nm tadpolectl
+.Op Fl n
+.Ar name ...
+.Nm tadpolectl
+.Op Fl n
+.Fl w
+.Ar name=value ...
+.Nm tadpolectl
+.Op Fl n
+.Fl a
+.Sh DESCRIPTION
+The
+.Nm tadpolectl
+utility retrieves values from the ts102 microcontroller
+ and allows processes with appropriate privilege to set some values.
+The state to be retrieved or set is described using a
+``Management Information Base'' (``MIB'') style name,
+described as a dotted set of components.
+The
+.Fl a
+flag can be used to list all the currently available string or integer values.
+.Pp
+The
+.Fl n
+flag specifies that the printing of the field name should be
+suppressed and that only its value should be output.
+This flag is useful for setting shell variables.
+For example, to save the pagesize in variable psize, use:
+.Bd -literal -offset indent -compact
+set psize=`tadpolectl -n hw.power.mains`
+.Ed
+.Pp
+If just a MIB style name is given,
+the corresponding value is retrieved.
+If a value is to be set, the
+.Fl w
+flag must be specified and the MIB name followed
+by an equal sign and the new value to be used.
+.Pp
+The information available from
+.Nm tadpolectl
+consists of only integers.  Some registers can be modified, but have no
+way of reading what the current value is.  Those registers will allways
+display
+.Dq 0 .
+.Pp
+The changeable column indicates whether a process with appropriate
+privilege can change the value, and if a displayed value is valid.
+.Bl -column hw.power.battery.int.chargelevel Changeable Valid
+.It Sy Name    Changeable      Valid
+.It hw.microcontroller.version no      yes
+.It hw.version no      yes
+.It hw.poweroncycles   no      yes
+.It hw.poweronseconds  no      yes
+.It hw.power.mains     no      yes
+.It hw.power.battery.int       no      yes
+.It hw.power.battery.ext       no      yes
+.It hw.power.battery.chargedisabled    yes     yes
+.It hw.power.battery.int.chargerate    yes     yes
+.It hw.power.battery.ext.chargerate    yes     yes
+.It hw.power.battery.int.chargelevel   no      yes
+.It hw.power.battery.ext.chargelevel   no      yes
+.It hw.video.external  no      yes
+.It hw.video.lid       no      yes
+.It hw.video.syncinva  yes     yes
+.It hw.video.syncinvb  yes     yes
+.It hw.video.compsync  yes     yes
+.It hw.video.tft.brightness    yes     yes
+.It hw.speaker.freq    yes     no
+.It hw.speaker.volume  yes     yes
+.It hw.kbd.repeat.delay        yes     yes
+.It hw.kbd.repeat.speed        yes     yes
+.It hw.kbd.click       yes     yes
+.It hw.mouse.recalibrate       yes     no
+.It hw.mouse.disable   yes     yes
+.It hw.mouse.intclick  yes     yes
+.It hw.mouse.extclick  yes     yes
+.It hw.mouse.sensitivity       yes     yes
+.El
+.Sh EXAMPLES
+.Pp
+For example, to retrieve the current internal battery charge level
+, one would use the following request:
+.Bd -literal -offset indent -compact
+tadpolectl hw.power.battery.int.chargelevel
+.Ed
+.Pp
+To set the speaker beep frequency of
+the system to 1000, one would use the following request:
+.Bd -literal -offset indent -compact
+tadpolectl -w hw.speaker.freq=1000
+.Ed
+.Sh SEE ALSO
+.Xr sysctl 8
+.Sh HISTORY
+.Nm tadpolectl
+first appeared in
+.Nx 1.5 .
diff -r 3454fc232b8f -r fec9918b8d94 usr.sbin/tadpolectl/tadpolectl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/tadpolectl/tadpolectl.c  Fri Dec 17 05:30:02 1999 +0000
@@ -0,0 +1,765 @@
+/* $NetBSD: tadpolectl.c,v 1.1 1999/12/17 05:30:03 garbled Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tim Rightnour.
+ *
+ * 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.
+ */
+
+#include <ctype.h>
+#include <err.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/envsys.h>
+#include <sys/apmvar.h>
+#include <machine/tctrl.h>
+
+int aflag, nflag, wflag, dev;
+
+#define PROTO(x) int x __P((int, int, int));
+char *dashdot __P((char *));
+PROTO(hw_version)
+PROTO(hw_microcontroller_version)
+PROTO(hw_poweroncycles)
+PROTO(hw_poweronseconds)
+PROTO(hw_power_mains)
+PROTO(hw_power_battery_int)
+PROTO(hw_power_battery_ext)
+PROTO(hw_power_battery_int_chargerate)
+PROTO(hw_power_battery_ext_chargerate)
+PROTO(hw_power_battery_int_chargelevel)
+PROTO(hw_power_battery_ext_chargelevel)
+PROTO(hw_video_external)
+PROTO(hw_video_lid)
+PROTO(hw_video_syncinva)
+PROTO(hw_video_syncinvb)
+PROTO(hw_video_compsync)
+PROTO(hw_video_tft_brightness)
+PROTO(hw_speaker_freq)
+PROTO(hw_speaker_volume)
+PROTO(hw_kbd_repeat_delay)
+PROTO(hw_kbd_repeat_speed)
+PROTO(hw_mouse_recalibrate)
+PROTO(hw_power_battery_chargedisabled)
+PROTO(hw_mouse_disable)
+PROTO(hw_kbd_click)
+PROTO(hw_mouse_intclick)
+PROTO(hw_mouse_extclick)
+PROTO(hw_mouse_sensitivity)
+
+#define NUM_MIBS 28
+#define TABLE(n) { __STRING(n), 0, n }
+
+struct {
+       char *mib;
+       int value;
+       int (*funcptr)(int, int, int);
+} table[NUM_MIBS] = {
+       TABLE(hw_microcontroller_version),
+       TABLE(hw_version),
+       TABLE(hw_poweroncycles),
+       TABLE(hw_poweronseconds),
+       TABLE(hw_power_mains),
+       TABLE(hw_power_battery_int),
+       TABLE(hw_power_battery_ext),
+       TABLE(hw_power_battery_chargedisabled),
+       TABLE(hw_power_battery_int_chargerate),
+       TABLE(hw_power_battery_ext_chargerate),
+       TABLE(hw_power_battery_int_chargelevel),
+       TABLE(hw_power_battery_ext_chargelevel),
+       TABLE(hw_video_external),
+       TABLE(hw_video_lid),
+       TABLE(hw_video_syncinva),
+       TABLE(hw_video_syncinvb),
+       TABLE(hw_video_compsync),
+       TABLE(hw_video_tft_brightness),
+       TABLE(hw_speaker_freq),
+       TABLE(hw_speaker_volume),
+       TABLE(hw_kbd_repeat_delay),
+       TABLE(hw_kbd_repeat_speed),
+       TABLE(hw_kbd_click),
+       TABLE(hw_mouse_recalibrate),
+       TABLE(hw_mouse_disable),
+       TABLE(hw_mouse_intclick),
+       TABLE(hw_mouse_extclick),
+       TABLE(hw_mouse_sensitivity),
+};
+
+#define FUNC(x) \
+int \
+x(read, new, num) \
+       int read, new, num;
+
+#define READ_REQ(a, b, c) \
+       req.cmdbuf[0] = a; \
+       req.cmdlen = b; \
+       req.rsplen = c; \
+       ioctl(dev, TCTRL_CMD_REQ, &req)
+
+#define WRITE_REQ(a, b, c) \
+       req.cmdbuf[0] = a; \
+       req.cmdlen = b; \
+       req.rsplen = c; \
+       ioctl(dev, TCTRL_CMD_REQ, &req)



Home | Main Index | Thread Index | Old Index