toshset-1.76/0000755000076400007640000000000011335305163013446 5ustar schwitrsschwitrstoshset-1.76/toshset.10000644000076400007640000001357711335305161015234 0ustar schwitrsschwitrs.TH TOSHSET 1 "March 2008" "toshset 2" "User-installed Software" .SH NAME toshset \- manipulate bios and hardware settings of Toshiba laptops .SH SYNOPSIS .B toshset [\fITOGGLEOPTIONS\fR | \fIQUERYOPTIONS\fR | \fIFEATUREOPTIONS\fR]... .SH DESCRIPTION .PP Toshset ia a command-line tool to allow access to much of the Toshiba hardware interface developed by Jonathan Buzzard. It can do things like set the hard drive spin-down time, turn off the display and set the fan speed. Credit for the difficult task of reverse-engineering the Toshiba hardware interface goes to Jonathan Buzzard. A link for Jonathan's tools is .hr http://www.buzzard.org.uk/toshiba/ All options are listed by running toshset with no arguments. If an argument option is specified as the ``-'' character, stdin is read for that option. This is particularly convenient when setting the owner string. The method used for access to the laptop hardware is given by the the HCI/SCI access mode query field. This should be kernel or direct. The kernel method requires kernel support and it is the only access method supported for ACPI kernels. If ACPI is not used this package does not require a special kernel module. Also, it is highly likely that this tool will work under different flavors of *NIX. As a result of this design consideration, and because of my own desire that not every user be able to change my laptop's hardware settings, the user must have read/write permission to /dev/toshiba in order for this program to run properly. .PP .SS "Toggle Options:" .TP \fB\-l\fR toggle long query in which the assocated command-line option is printed with each queried feature. .TP \fB\-fast\fR run in fast mode: a startup check is skipped, and values are not queried after the are set. On machines for which ioctl is slow, this can speed toshset up by up to a factor of 2/5. .TP \fB\-v\fR toggle verbose mode in which normally silent messages are printed. .PP .SS "Query Options:" .TP \fB\-q\fR \fI [glob]\fR query features specified by glob (all features if glob omitted). The glob string is sandwiched between asterisks, so specifying -q bat will query all features whose names contain the ``bat'' substring. If no glob is given, then all features are queried. .PP .SS "Feature Options:" Valid settings for features can be listed by omitting the argument. The current list of feature options is .TP \fB\-b\fR \fI \fR enable/disable system beep .TP \fB\-lcd\fR \fI\fR set lcd brightness. .TP \fB\-inten\fR \fI\fR set lcd brightness. Not all models support both -lcd and -inten. .TP \fB\-pow\fR \fI\fR set power-up mode .TP \fB\-vol\fR \fI<0-4>\fR set beep volume. Note that this controls the modem volume for my PCMCIA modem. .TP \fB\-hdd\fR \fI\fR number of minutes until disk spindown .TP \fB\-dstretch\fR \fI\fR enable/disable display stretch .TP \fB\-d\fR \fI\fR number of minutes until display auto-off .TP \fB\-c\fR \fI\fR set cooling method .TP \fB\-bs\fR \fI\fR set battery-save mode .TP \fB\-bl\fR \fI\fR control lcd backlight .TP \fB\-bluetooth\fR \fI\fR power-up + attach internal bluetooth device, or shutdown. .TP \fB\-fan\fR \fI\fR control fan .TP \fB\-video\fR \fI\fR set display device for video: internal lcd, external monitor, or tv-out .TP \fB\-cpu\fR \fI\fR set CPU speed .TP \fB\-cpucache\fR \fI\fR enable/disable CPU cache .TP \fB\-sleep\fR \fI\fR enable/disable CPU sleep mode .TP \fB\-balarm\fR \fI\fR enable/disable battery alarm .TP \fB\-palarm\fR \fI\fR enable/disable lid-closed alarm .TP \fB\-walarm\fR \fI\fR set time/date to wake .TP \fB\-ppower\fR \fI\fR enable/disable annoying feature of powering-off computer when lid is closed. .TP \fB\-parallel\fR \fI\fR set parallel port mode .TP \fB\-autooff\fR \fR number of minutes of idle time until system auto-off .TP \fB\-ostring\fR \fI\fR set owner string. This string is displayed at boot or resume time, if a user or supervisor password is set. .TP \fB\-upasswd\fR set or clear the user password. Toshset must be run on the console for this to work. The password should be entered when the prompt is displayed. If the password is currently set, entering it will clear the password. .TP \fB\-spasswd\fR set the supervisor password. See the docs for -upasswd. .TP \fB\-usblegacy\fR USB legacy mode: enable/disable using an USB mouse as it would be a PS/2 one, without the need to install a USB driver. .TP \fB\-3g\fR power-up + attach internal 3g modem device, or shutdown. .TP \fB\-usbfdd\fR USB FDD emulation mode: is almost the same of the previous one for a floppy. It enables the use of an USB floppy as it would be attached to an internal FD controller (for booting etc.) .TP \fB\-lan\fR Enables/disables internal LAN controller. .TP \fB\-soundlogo\fR enable/disable startup sound logo. .TP \fB\-startlogo\fR startup logo mode (picture or animation>. .TP \fB\-trmode\fR enable/disable the display's transreflective mode. Features may also be set by specifying the (zero-offset) index of the option. e.g. toshset -cpu 0 sets the cpu speed to slow. .SH BUGS Many features are locked and can not be changed when the battery save mode is not ``user.'' Since I only have one laptop, I can't test this utility on other hardware. User feedback in this regard is helpful. Some features do not work on my laptop and they may work on your's, and visa-versa. Toshset requires an experimental version of the toshiba_acpi kernel module with an ACPI-enabled kernel. .SH AUTHOR Written by .br News, updates and documentation: visit http://schwieters.org/toshset.html .SH COPYRIGHT Copyright \(co 2002-8 Charles D. Schwieters .br This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. toshset-1.76/config.guess0000644000076400007640000004762211335305161015774 0ustar schwitrsschwitrs#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc. # # This file 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; either version 2 of the License, or # (at your option) any later version. # # 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # The master version of this file is at the FSF in /home/gd/gnu/lib. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit system type (host/target name). # # Only a few systems have been added to this list; please add others # (but try to keep the structure clean). # # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 8/24/94.) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in alpha:OSF1:*:*) # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'` exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-cbm-sysv4 exit 0;; amiga:NetBSD:*:*) echo m68k-cbm-netbsd${UNAME_RELEASE} exit 0 ;; amiga:OpenBSD:*:*) echo m68k-cbm-openbsd${UNAME_RELEASE} exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; atari*:NetBSD:*:*) echo m68k-atari-netbsd${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-atari-openbsd${UNAME_RELEASE} exit 0 ;; sun3*:NetBSD:*:*) echo m68k-sun-netbsd${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-sun-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:NetBSD:*:*) echo m68k-apple-netbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-apple-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >dummy.c int main (argc, argv) int argc; char **argv; { #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF ${CC-cc} dummy.c -o dummy \ && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i?86:AIX:*:*) echo i386-ibm-aix exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:4) if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=4.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[3478]??:HP-UX:*:*) case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; 9000/8?? ) HP_ARCH=hppa1.0 ;; esac HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i?86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; F300:UNIX_System_V:*:*) FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; F301:UNIX_System_V:*:*) echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` exit 0 ;; hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; hp3[0-9][05]:OpenBSD:*:*) echo m68k-hp-openbsd${UNAME_RELEASE} exit 0 ;; i?86:BSD/386:*:* | *:BSD/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo i386-pc-cygwin32 exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin32 exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. ld_help_string=`ld --help 2>&1` if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then echo "powerpc-unknown-linux-gnu" ; exit 0 elif test "${UNAME_MACHINE}" = "alpha" ; then echo alpha-unknown-linux-gnu ; exit 0 elif test "${UNAME_MACHINE}" = "sparc" ; then echo sparc-unknown-linux-gnu ; exit 0 else # Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us # useful --help. Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout. test ! -d /usr/lib/ldscripts/. \ && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 # Determine whether the default compiler is a.out or elf cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 rm -f dummy.c dummy fi ;; # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions # are messed up and put the nodename in both sysname and nodename. i?86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} fi exit 0 ;; i?86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i?86:LynxOS:2.*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) printf ("vax-dec-bsd\n"); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi #echo '(Unable to guess system type)' 1>&2 exit 1 toshset-1.76/cdsList.hh0000644000076400007640000000457111335305161015401 0ustar schwitrsschwitrs/* CDSList.h headers for my own List template class 9/1/95 - CDS */ #ifndef __cdslist_hh__ #define __cdslist_hh__ 1 /* ostream is a typedef in the new standard, a class in the old, so forward * declarations are painful */ #include using namespace std; template class CDSList { int size_; //number of elements used int asize; //numer of elements allocated int blockSize; //size for next allocation block T* data; // enum { DefaultListSize = 100 }; public: CDSList (int s=0, int a=DefaultSize); ~CDSList (); CDSList (const CDSList&); //copy constructor CDSList &resize(const int s); CDSList &operator= (const CDSList&); const T &operator[] (const int &index) const; T &operator[] (const int &index); // operator T*() { return data; } //convert to array const T &append(const T& member); bool contains(const T& member); void remove(const int i); int getIndex(const T& member); void setBlockSize(const int); // int size() {return size_;} int size() const {return size_;} // template // friend ostream& operator<<(ostream& os, // const CDSList& v); #ifdef TESTING static int test(); #endif }; template ostream& operator<<(ostream& os, const CDSList& v); //constructors template CDSList::CDSList(const int s, const int a) : size_(s), asize(0), blockSize(a) { while (size_ > asize) { asize += blockSize; } data = new T[asize]; } /* CDSList::CDSList */ template CDSList::~CDSList() { delete [] data; } template inline T& CDSList::operator[](const int &index) //non-const version { #ifdef CHECKRANGE if (index+1>size_ || index<0) { cerr << "CDSList::operator[]: index out of range (" << index << ")\n"; abort(); } #endif return (data[index]); } template inline const T& CDSList::operator[](const int &index) const //const version { #ifdef CHECKRANGE if (index+1>size_ || index<0) { cerr << "CDSList::operator[]: index out of range (" << index << ")\n"; abort(); } #endif return (data[index]); } template const T& CDSList::append(const T &member) { resize(size_+1); data[size_-1] = member; return member; } #endif /*__cdslist_hh__*/ toshset-1.76/toshset.cc0000644000076400007640000017144611335305161015461 0ustar schwitrsschwitrs/* toshset.cc * * Copyright (C) 1999, 2000, 2001, 2002 Charles D. Schwieters * * Based on tools by Jonathan Buzzard * * 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; either version 2 of the License, or * (at your option) any later version. * * 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 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ static char const rcsid[]="$Id: toshset.cc,v 1.51 2010-02-12 16:30:51 schwitrs Exp $"; static char const rcsversion[]="$State: Exp $"; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef LINUX # include # include # include #else /* LINUX */ # include #endif #include #include #include #include "cdsList.hh" #include "cdsString.hh" #include "cdsSStream.hh" #include "cdsExcept.hh" #ifdef __GLIBC__ #include #endif #include "kernelInterface.h" #include "sci.h" #include "hci.h" #include "toshibaIDs.hh" #include "wildmat.h" using namespace std; enum { EMPTY, PRIMARY, AUXILLARY }; static int id; static char versionString[80]; static int verbose=0; static int longQuery=0; static int fast=0; /* * Convert a single character to an interger, similar to atoi */ inline int ctoi(char *s) { return ((*s>='0') && (*s<='9')) ? *s-'0' : -1; } struct ValueSet { const char* iString; unsigned short sciCode; const char* oString; ValueSet(const char* input, unsigned short sciCode, const char* output) : iString(input), sciCode(sciCode), oString(output) {} }; struct Feature { const char* name; Feature(const char* name) : name(name) {} virtual ~Feature() {} // the next two return 0 on success, otherwise return an error code // which is interpreted using error() virtual int action(const char**) const=0; virtual int query(OStringStream &os) const=0; virtual const char* error(int) const=0; }; struct ToggleFeature : public Feature { int& toggleVar; // const char* name; ToggleFeature( int& toggleVar, const char* name) : Feature(name), toggleVar(toggleVar) {} virtual ~ToggleFeature() {} virtual int action(const char**) const { toggleVar = (toggleVar?0:1); return 1;} virtual int query(OStringStream &os) const {return 1;} virtual const char* error(int) const {return "";} }; struct VersionFeature : public Feature { VersionFeature() : Feature("toshset version") {} virtual ~VersionFeature() {} virtual int action(const char**) const {return 1;} virtual int query(OStringStream &os) const { os << "toshset version: " << VERSION << ends; return 0;} virtual const char* error(int) const {return "";} }; struct AccessFeature : public Feature { AccessFeature() : Feature("HCI/SCI access") {} virtual ~AccessFeature() {} virtual int action(const char**) const {return 1;} virtual int query(OStringStream &os) const { os << "HCI/SCI access mode: " << (accessMode==ACCESS_DIRECT?"direct":"kernel") << ends; return 0;} virtual const char* error(int) const {return "";} }; struct ModelFeature : public Feature { int id; ModelFeature(int id) : Feature("hardware model"), id(id) {} virtual ~ModelFeature() {} virtual int action(const char**) const {return 1;} virtual int query(OStringStream &os) const { os << "Toshiba Model: " << toshibaModelName(id) << ends; return 0;} virtual const char* error(int) const {return "";} }; struct SciFeature : public Feature { unsigned short sciMode; // const char* name; SciFeature(unsigned short sciMode,const char* name) : Feature(name), sciMode(sciMode) {} CDSList values; void addValue(const char* input, unsigned short sciCode, const char* output) { values.append(new ValueSet(input,sciCode,output)); } virtual ~SciFeature() { for (int i=0 ; iiString , *s ) == 0 ) { reg.ecx =values[i]->sciCode; reg.edx = reg.esi = reg.edi = 0; ret = SciSet( ® ); if ( ret == SCI_SUCCESS ) return 1; } // try setting indexed setting of option. if ( ret<0 ) { errno=0; int i = strtol(*s,(char **)NULL,10); if ( errno==0 && i>=0 && isciCode; reg.edx = reg.esi = reg.edi = 0; ret = SciSet( ® ); if ( ret == SCI_SUCCESS ) return 1; } } if ( ret>=0 ) { cerr << "SciFeature:action: error setting " << name << '\n'; cerr << "\tSciSet returned: " << error(ret) <<'\n'; return 0; } cerr << "SCIFeature: error when setting feature " << name << ":\n\terror in command-line option: " << *s << "\n"; cerr << "valid settings are:\n"; for (int i=0 ; iiString << '\n'; return 0; } /* SciFeature::action */ int SciFeature::query(OStringStream& os) const { SMMRegisters reg; reg.ebx = sciMode; int ret = SciGet( ® ); if ( ret == SCI_SUCCESS ) { for (int i=0 ; isciCode ) { os << name << ": " << values[i]->oString << ends; return 0; } cerr << "SciFeature::query: received an unexpected response for feature " << name << ": " << reg.ecx << '\n'; } //else // cerr << "SciFeature:query: error when querying feature " << name << '\n' // << "\tSciGet returned " << error(ret) << '\n'; return ret; } /* SciFeature::action */ struct TimeFeature : public SciFeature { TimeFeature(unsigned short sciMode,const char* name) : SciFeature(sciMode,name) {} virtual ~TimeFeature() { for (int i=0 ; i time/date to wake\n"; return 0; } SMMRegisters reg; enum { ALARM_TIME = 0x0001, ALARM_DATE = 0x0002, ALARM_EVERY = 0x0004, ALARM_YEAR = 0x0008 }; int support = 0x0000; reg.ebx = SCI_ALARM_TIME; if (SciGet(®)==SCI_SUCCESS) { support |= ALARM_TIME; } reg.ebx = SCI_ALARM_DATE; if ( SciGet(®) == SCI_SUCCESS ) { reg.edx &= 0xffff; support |= ALARM_DATE; if ( SCI_DATE_EVERYDAY(reg.edx) ) support |= ALARM_EVERY; if (SCI_YEAR(reg.edx)!=1990) support |= ALARM_YEAR; } if ( verbose ) cout << "TimeFeature: supported date elements: " << (support&ALARM_DATE?"month/day ":"") << (support&ALARM_YEAR?"year ":"") << (support&ALARM_EVERY?"everyday\n":"\n"); reg.ebx = sciMode; int ret=0; if ( strncmp(*s,"dis",3) == 0 ) { reg.ecx = SCI_ALARM_DISABLED; ret = SciSet( ® ); } else { IStringStream istr(*s); char delim; char hour[4]; istr.get(hour,4,':'); istr.get( delim ); char minute[4]; istr.get(minute,4,'/'); istr.get( delim ); reg.ecx = SCI_TIME( atoi(hour) , atoi(minute) ); //cout << "setting time\n"; ret = SciSet( ® ); if ( delim == '/' && ret == SCI_SUCCESS && support&ALARM_DATE ) { reg.ebx = SCI_ALARM_DATE; //reg.ebx = sciMode; reg.ecx = 0; reg.edx = 0; delim = '\0'; char day[9]; char month[3]; char year[9]; year[0]='\0'; istr.get(day,9,'/'); istr.get( delim ); if ( delim=='\0' && strcmp(day,"everyday")==0 ) { if (support&ALARM_EVERY) reg.ecx = 1; else cerr << "TimeFeature::action: everyday not supported\n"; } else { delim = '\0'; istr.get(month,3,'/'); istr.get( delim ); if ( delim=='/' && support&ALARM_YEAR) { istr.get(year,9,'/'); reg.ecx = SCI_FULLDATE( atoi(year) , atoi(month) , atoi(day) ); } else reg.ecx = SCI_DATE( atoi(month) , atoi(day) ); } //cout << "setting date to " << day << '/' << month << '/' << year << '\n'; if (reg.ecx) ret=SciSet( ® ); if ( ret != SCI_SUCCESS ) { cerr << "TimeFeature:action: error when setting date for feature " << name << '\n' << "\tSciSet returned " << error(ret) << '\n'; return 0; } } } if ( ret == SCI_SUCCESS ) return 1; else cerr << "TimeFeature:action: error when setting feature " << name << '\n' << "\tSciSet returned " << error(ret) << '\n'; return 0; } /* TimeFeature::action */ int TimeFeature::query(OStringStream& os) const { SMMRegisters reg; reg.ebx = sciMode; int ret = SciGet( ® ); if ( ret == SCI_SUCCESS ) { os << name << ": "; if ( reg.ecx == SCI_ALARM_DISABLED ) os << "disabled"; else { os << setfill('0') << setw(2) << SCI_HOUR(reg.ecx) << ':' << setfill('0') << setw(2) << SCI_MINUTE(reg.ecx) << ' '; reg.ebx = SCI_ALARM_DATE; SciGet( ® ); int year = SCI_YEAR(reg.ecx); if ( SCI_DATE_EVERYDAY(reg.ecx) ) os << "everyday"; else { os << SCI_DAY(reg.ecx) << '/' << SCI_MONTH(reg.ecx); if ( year !=1990 ) os << year << '/'; } } os << ends; return 0; } return ret; //else // cerr << "TimeFeature:query: error when querying feature " << name << '\n' // << "\tSciGet returned " << error(ret) << '\n'; // return 0; } /* SciFeature::action */ struct PasswdFeature : public SciFeature { unsigned short passwdType; PasswdFeature(unsigned short passwdType,const char* name) : SciFeature(SCI_PASSWORD,name), passwdType(passwdType) {} virtual ~PasswdFeature() {} virtual int action(const char**) const; virtual int query(OStringStream& os) const; }; /* * Put terminal into raw mode and then get a single keypress */ int GetScanCode() { struct termio new_key; static struct termio saved; unsigned char key[1]; int fd = open("/dev/tty", O_RDWR); /* exit if unable to open the console */ if ( fd<0 ) { cerr <<"unable to open console\n"; throw CDS::exception("unable to open console\n"); } //terminal = 1; /* get the current terminal state */ int keyboard; ioctl(fd, KDGKBMODE, &keyboard); ioctl(fd, TCGETA, &saved); ioctl(fd, TCGETA, &new_key); /* set appropriate terminal mode */ new_key.c_lflag &= ~ (ICANON | ECHO | ISIG); new_key.c_iflag = 0; new_key.c_cc[VMIN] = 1; new_key.c_cc[VTIME] = 1; ioctl(fd, TCSETAW, &new_key); ioctl(fd, KDSKBMODE, K_RAW); key[0] = 0; read(fd, key, 1); ioctl(fd, TCSETAW, &saved); ioctl(fd, KDSKBMODE, keyboard); keyboard = -1; /* close the connection to the terminal */ close(fd); // terminal = 0; return (int) key[0]; } /* * Get a password from the user echoing astrix's */ void GetPassword(char *password) { /* blank the password */ for(int loop=0 ; loop<10 ; loop++) *(password+loop) = 0; fflush(stdout); /* now get the password from the user*/ for (int loop=0;;) { int scan = GetScanCode(); if ((scan<0x02) || (scan>0x39)) continue; if ((scan==0x1d) || (scan==0x2a) || (scan==0x36) || (scan==0x37) || (scan==0x38)) continue; if (scan==0x0f) continue; if (scan==0x1c) { cout << endl; break; } if (scan==0x0e) { if (loop>0) { cout << "\b \b"; fflush(stdout); loop--; *(password+loop) = 0; } continue; } if (loop<10) { *(password+loop) = scan; cout << '*'; cout.flush(); loop++; } } return; } static int setPasswd(char* password, unsigned short passwdType) { SMMRegisters reg; reg.eax = 0xf4f4; reg.ebx = SCI_PASSWORD; reg.ecx = passwdType; reg.edx = *(password+3) + *(password+2)*0x100 + *(password+1)*0x10000 + *(password)*0x1000000; reg.esi = *(password+7) + *(password+6)*0x100 + *(password+5)*0x10000 + *(password+4)*0x1000000; reg.edi = *(password+9) + *(password+8)*0x100; int ret = SciSet( ® ); int trys = (int) (reg.edx & 0xffff); if ( trys <1 ) cerr << "setPasswd: maximum password trys exceeded.\n" << "\tplease reboot or suspend/resume and try again.\n"; return ret; } /* setPasswd */ int PasswdFeature::action(const char **s) const { int fd = open("/dev/tty", O_RDWR); if (fd<0) { cerr << "PasswdFeature: unable to open console.\n"; return 0; } struct vt_mode vtm; if (ioctl(fd, VT_GETMODE, &vtm)!=0) { close(fd); cerr << "PasswdFeature: must be run from the console.\n"; return 0; } close(fd); SMMRegisters reg; reg.ebx = sciMode; reg.ecx = passwdType; int ret = SciGet( ® ); if ( ret != SCI_SUCCESS ) return ret; if ( reg.ecx == 0 ) { // not registered char password1[11]; cout << "enter new password:"; GetPassword(password1); char password2[11]; cout << "reenter new password:"; GetPassword(password2); if ( String(password1) != password2 ) { cerr << "passwords do not match...\n"; return 1; } ret = setPasswd(password1,passwdType); } else if (reg.ecx == 1) { //registered char password1[11]; cout << "enter current password to disable:"; GetPassword(password1); ret = setPasswd(password1,passwdType); } else ret = SCI_FAILURE; if ( ret == SCI_SUCCESS ) return 1; else cerr << "PasswdFeature:action: error when setting feature " << name << '\n' << "\tSciSetPasswd returned " << error(ret) << '\n'; return 0; } /* PasswdFeature::action */ int PasswdFeature::query(OStringStream& os) const { SMMRegisters reg; reg.ebx = sciMode; reg.ecx = passwdType; int ret = SciGet( ® ); if ( ret == SCI_SUCCESS ) { os << name << ": "; switch ( reg.ecx ) { case 0 : os << "not registered"; break; case 1 : os << "registered"; break; default : os << "unexpected response: " << reg.ebx; } os << ends; return 0; } //else // cerr << "PasswdFeature:query: error when querying feature " << name << '\n' // << "\tSciGet returned " << error(ret) << '\n'; // return 0; return ret; } /* PasswdFeature::query */ struct PercentFeature : public SciFeature { PercentFeature(unsigned short sciMode,const char* name) : SciFeature(sciMode,name) {} ~PercentFeature() {} int action(const char**) const {return 1;} int query(OStringStream& os) const; }; int PercentFeature::query(OStringStream& os) const { SMMRegisters reg; reg.ebx = sciMode; int ret = SciGet( ® ); if ( ret == SCI_SUCCESS ) { int percent = ((100*reg.ecx)/reg.edx); os << name << ": " << percent << "\% " << ends; } return ret; } /* Feature::action */ struct HciFeature : public Feature { unsigned short hciMode; HciFeature(unsigned short hciMode,const char* name) : Feature(name), hciMode(hciMode) {} CDSList values; void addValue(const char* input, unsigned short hciCode, const char* output) { values.append(new ValueSet(input,hciCode,output)); } virtual ~HciFeature() { for (int i=0 ; iiString , *s ) == 0 ) { reg.ecx =values[i]->sciCode; ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) return 1; } // try setting indexed setting of option. int i = atoi(*s); if ( ret<0 && isdigit(**s) && i>=0 && isciCode; int ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) { //sleep(1); return 1; } } if ( ret>=0 ) { cerr << "HCI error setting " << name << '\n'; cerr << "\tHciFunction returned: " << error(ret) <<'\n'; return 0; } cerr << "HCI error setting " << name << '\n'; cerr << "valid settings are:\n"; for (int i=0 ; iiString << '\n'; return 0; } /* Feature::action */ int HciFeature::query(OStringStream& os) const { SMMRegisters reg; reg.eax = HCI_GET; reg.ebx = hciMode; reg.ecx = 0; reg.edx = 0; int ret=0; int retries=3; while ( --retries ) { ret = HciFunction( ® ); if ( ret != HCI_BUSY ) break; } // reg.ecx &= ~0x0080; //this is some sort of status bit if ( ret == HCI_SUCCESS ) { for (int i=0 ; isciCode ) { os << name << ": " << values[i]->oString << ends; return 0; } cerr << "HciFeature::query: received an unexpected response for feature " << name << ": " << reg.ecx << '\n'; } return ret; } /* HciFeature::query */ // are these really constant?? const int HCI_LCD_BRIGHTNESS_BITS = 3; const int HCI_LCD_BRIGHTNESS_SHIFT = (16-HCI_LCD_BRIGHTNESS_BITS); const int HCI_LCD_BRIGHTNESS_LEVELS = (1 << HCI_LCD_BRIGHTNESS_BITS); struct LCDIntensityFeature : public HciFeature { LCDIntensityFeature(const char* name) : HciFeature(HCI_LCD_BRIGHTNESS,name) {} virtual int action(const char**) const; virtual int query(OStringStream& os) const; }; int LCDIntensityFeature::action(const char **s) const { SMMRegisters reg; reg.eax = HCI_SET; reg.ebx = hciMode; reg.edx = 0; if ( ! **s) { cerr << "HCI error: argument required\n"; return 0; } int ret = -1; int val = atoi(*s); if (val >=0 && val < HCI_LCD_BRIGHTNESS_LEVELS) { reg.ecx =val << HCI_LCD_BRIGHTNESS_SHIFT; ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) return 1; } if ( ret>=0 ) { cerr << "HCI error setting " << name << '\n'; cerr << "\tHciFunction returned: " << error(ret) <<'\n'; return 0; } cerr << "HCI error setting " << name << '\n'; cerr << "valid settings are: 0-" << (HCI_LCD_BRIGHTNESS_LEVELS-1) << '\n'; return 0; } /* LCDIntensityFeature::action */ int LCDIntensityFeature::query(OStringStream& os) const { SMMRegisters reg; reg.eax = HCI_GET; reg.ebx = hciMode; reg.ecx = 0; reg.edx = 0; int ret=0; ret = HciFunction( ® ); // reg.ecx &= ~0x0080; //this is some sort of status bit if ( ret == HCI_SUCCESS ) { int value = reg.ecx >> HCI_LCD_BRIGHTNESS_SHIFT; os << name << ": " << value << "/" << (HCI_LCD_BRIGHTNESS_LEVELS-1) << ends; return 0; } return ret; } /* LCDIntensityFeature::query */ struct WirelessFeature : public HciFeature { int mode; WirelessFeature(int mode, const char* name) : HciFeature(HCI_WIRELESS,name), mode(mode) {} virtual int action(const char**) const; virtual int query(OStringStream& os) const; }; int WirelessFeature::action(const char **s) const { SMMRegisters reg; reg.eax = HCI_SET; reg.ebx = hciMode; reg.edx = mode; if ( ! **s) { cerr << "HCI error: argument required\n"; return 0; } int ret = -1; for (int i=0 ; iiString , *s ) == 0 ) { reg.ecx =values[i]->sciCode; ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) return 1; } // try setting indexed setting of option. int i = atoi(*s); if ( ret<0 && strlen(*s)==1 && isdigit(**s) && i>=0 && isciCode; int ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) { //sleep(1); return 1; } } if ( ret>=0 ) { cerr << "HCI error setting " << name << '\n'; cerr << "\tHciFunction returned: " << error(ret) <<'\n'; return 0; } cerr << "HCI error setting " << name << '\n'; cerr << "valid settings are:\n"; for (int i=0 ; iiString << '\n'; return 0; } /* WirelessFeature::action */ int WirelessFeature::query(OStringStream& os) const { SMMRegisters reg; reg.eax = HCI_GET; reg.ebx = hciMode; reg.ecx = 1; reg.edx = mode; int ret=0; ret = HciFunction( ® ); // cerr << "cx: " << reg.ecx <sciCode ) { os << name << ": " << values[i]->oString << ends; return 0; } cerr << "VideoFeature::query: received an unexpected response for feature " << name << ": " << reg.ecx << '\n'; } return ret; } /* VideoFeature::query */ struct LbaFeature : public HciFeature { LbaFeature(unsigned short hciMode,const char* name) : HciFeature(hciMode,name) {} virtual ~LbaFeature() {} // virtual int action(const char**) const; virtual int action(const char **s) const { SMMRegisters reg; reg.eax = HCI_SET; reg.ebx = hciMode; reg.edx = 0; if ((*s)[0]=='0' && tolower((*s)[1])=='x') { IStringStream is( (*s)+2 ); long tmp = reg.ecx; is >> hex >> tmp; } else { IStringStream is( *s ); long tmp = reg.ecx; is >> tmp; } cout << "setting lba to " << reg.ecx << '\n'; int ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) return 1; else { cerr << "HCI error setting " << name << '\n'; cerr << "\tHciFunction returned: " << error(ret) <<'\n'; return 0; } }; virtual int query(OStringStream& os) const { SMMRegisters reg; reg.eax = HCI_GET; reg.ebx = hciMode; reg.ecx = 0; int ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) { os << name << ": 0x" << hex << reg.ecx << dec << " (" << reg.ecx << ")"; return 0; } return ret; } }; struct HibInfoFeature : public HciFeature { int hibInfoMode; HibInfoFeature(int hibInfoMode,const char* name) : HciFeature(HCI_HIBERNATION_INFO,name), hibInfoMode(hibInfoMode) {} virtual ~HibInfoFeature() {} // virtual int action(const char**) const; virtual int action(const char **s) const { SMMRegisters reg; reg.eax = HCI_SET; reg.ebx = hciMode; reg.ecx = 0; reg.edx = hibInfoMode; if ((*s)[0]=='0' && tolower((*s)[1])=='x') { IStringStream is( (*s)+2 ); long tmp = reg.ecx; is >> hex >> tmp; } else { IStringStream is( *s ); long tmp = reg.ecx; is >> tmp; } String type = "invalid"; switch (hibInfoMode) { case HCI_BIOS_SIZE : type = "BIOS"; break; case HCI_MEMORY_SIZE : type = "Memory"; break; case HCI_VRAM_SIZE : type = "VRAM"; break; } cout << "setting " << type << " size to " << reg.ecx << '\n'; int ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) return 1; else { cerr << "HCI error setting " << name << '\n'; cerr << "\tHciFunction returned: " << error(ret) <<'\n'; return 0; } }; virtual int query(OStringStream& os) const { SMMRegisters reg; reg.eax = HCI_GET; reg.ebx = hciMode; reg.ecx = hibInfoMode; int ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) { os << name << ": " << reg.ecx; return 0; } return ret; } }; // HibInfoFeature struct OwnerStringFeature : public HciFeature { OwnerStringFeature(unsigned short hciMode,const char* name) : HciFeature(hciMode,name) {} virtual ~OwnerStringFeature() {} virtual int action(const char**) const; virtual int query(OStringStream& os) const; }; int OwnerStringFeature::action(const char **s) const { SMMRegisters reg; String str(*s); str.gsub("\\n","\n\r"); //deal w newlines and tabs str.gsub("\\t" ," "); // str.gsub("\n[^\r]","\n\r"); //doesn't work for (int i=0 ; i<(int)str.length() ; i++) if ( str[i] == '\n' ) str = subString(str,0,i) + "\n\r" + subString(str,i+1,-1); // str.gsub(" "," "); // str.gsub("\011"," "); // str.gsub("\t"," "); const char* p=str; // cout << "setting owner string to " << p << '\n'; if ( strlen(p) > 512 ) {//FIX: should query for this cerr << "string too long\n"; return 0; } int allowedFailures=30; for (int i=0 ; i<512 ; i+=4) { reg.eax = HCI_SET; reg.ebx = HCI_OWNERSTRING; reg.ecx = 4; reg.esi = i; reg.edx = 0; for (int j=0 ; j<4 ; j++,p++) { unsigned int tmp=0; tmp |= *p; tmp = tmp<<8*j; reg.edx |= tmp; if ( !*p) { // reg.edx = reg.edx<<(3-j)*8; break; } } // cout << "edx: " << hex << reg.edx << dec << '\n'; int ret = HciFunction(®); if ( ret != HCI_SUCCESS ) { allowedFailures--; if ( allowedFailures<=0 ) { cerr << "too many HCI errors setting feature " << name << '\n' << "\tHciFunction returned " << error(ret) << " for i= " << i << '\n'; return 0; } i -= 4; p -= 4; } // cerr << "HCI error setting feature " << name << '\n' // << "\tHciFunction returned " << error(ret) // << "for i= " << i << '\n'; // return 0; } return 1; } /* OwnerStringFeature::action */ int OwnerStringFeature::query(OStringStream& os) const { SMMRegisters reg; reg.eax = HCI_GET; reg.ebx = hciMode; reg.ecx = 0; reg.esi = 0; int ret = HciFunction( ® ); os << name << ": "; if ( ret == HCI_SUCCESS ) { int length = (reg.ecx & 0xffff0000)>>16; os << "[ max length: " << length << ']' << '\n'; for (int i=0 ; i> 8; } // if ((c>=0x20) && (c<=0x80)) // *(string++) = c; // if (c==0x0d) // *(string++) = c; } } // char temp[5]; // memcpy(temp,®.ecx,4); // temp[4]='\0'; // os << name << ": " << temp[0] << temp[1] << temp[2] << temp[3] << '\n'; // os << reg.ecx << '\n' << ends; // cout << name << ": " << temp[3] << '\n'; // cout << reg.ecx << '\n'; //os << name << ':' << ( reg.cx?(char*)reg.cx:(char*)"" ) << ends; os << '\n'; } os << ends; //else { // cerr << "HciFeature::query: HciFunction for feature " // << name << " returned " << error(ret) << '\n'; // return 0; // } return ret; } /* OwnerStringFeature::query */ struct LCDFeature : public HciFeature { LCDFeature(unsigned short hciMode,const char* name) : HciFeature(hciMode,name) {} CDSList values; void addValue(const char* input, unsigned short hciCode, const char* output) { values.append(new ValueSet(input,hciCode,output)); } virtual ~LCDFeature() {} virtual int action(const char**) const { return 0; } virtual int query(OStringStream& os) const; }; int LCDFeature::query(OStringStream& os) const { SMMRegisters reg; reg.eax = HCI_GET; reg.ebx = hciMode; int ret = HciFunction( ® ); if ( ret == HCI_SUCCESS ) { os << name << ": "; switch ( (reg.ecx & 0xff00)>>8 ) { case HCI_640_480 : os << " 640x480, "; break; case HCI_800_600 : os << " 800x600, "; break; case HCI_1024_768: os << "1024x768, "; break; case HCI_1024_600: os << "1024x600, "; break; case HCI_800_480 : os << " 800x480, "; break; case HCI_1400_1050 : os << " 1400x1050, "; break; case HCI_1600_1200 : os << " 1600x1200, "; break; case HCI_1280_600 : os << " 1280x600, "; break; case HCI_1280_800 : os << " 1280x800, "; break; case HCI_1440_900 : os << " 1440x900, "; break; case HCI_1920_1200 : os << " 1920x1200, "; break; default: os << "resolution (" << ((reg.ecx & 0xff00)>>8 ) << ") unknown"; } switch ( reg.ecx & 0xff ) { case HCI_STN_MONO : os << "mono STN "; break; case HCI_STN_COLOUR : os << "colour STN"; break; case HCI_9BIT_TFT : os << "9 bit TFT "; break; case HCI_12BIT_TFT : os << "12 bit TFT"; break; case HCI_18BIT_TFT : os << "18 bit TFT"; break; case HCI_24BIT_TFT : os << "24 bit TFT"; break; default: os << "type (" << (reg.ecx&0xff) << ") unknown"; } os << ends; return 0; } return ret; } /* LCDFeature::query */ class CmdLineArg { public: virtual ~CmdLineArg() {} virtual const char* flag() const =0; virtual int numArgs() const =0; virtual const char* usage() const =0; virtual void action(const int&, const char**) =0; virtual const char* name() const { return ""; } }; class CmdLineArgs { CDSList argList; const char* path; CmdLineArg** options; public: CmdLineArgs(const char* path, CmdLineArg** options) : path(path), options(options) {} int process(const int argc, const char** argv); void usage(); void error(const char *err); }; void CmdLineArgs::usage() { cerr << "usage: " << path << " [args]\n"; cerr << "\twhere args are one or more of:\n"; for ( CmdLineArg** opp=options ; *opp ; opp++ ) { CmdLineArg* op = *opp; cerr << op->flag() << ": " << op->usage() << '\n'; } } /* CmdLineArgs::usage */ void CmdLineArgs::error(const char *err) { cerr << "Command line error: " << err << '\n'; usage(); exit(2); } int CmdLineArgs::process(const int argc, const char** argv) { int argcnt = argc-1; const char **argvp = argv; int ret=1; while (argvp++ , (argcnt--) > 0) { if (**argvp == '-') { int ok=0; for ( CmdLineArg** opp=options ; *opp ; opp++ ) { CmdLineArg* op = *opp; if ( strcmp( op->flag() , argvp[0] ) == 0 ) { const char **p = argvp; const char* empty = ""; if (argcnt < op->numArgs()) // error( op->flag() ); p = ∅ op->action( argcnt, p ); argcnt-=op->numArgs(); argvp+=op->numArgs(); ok=1; break; } } if ( !ok ) { error("unrecognized command-line option"); ret=0; } } // deal with default arguments (no ``-'') argList.append( argvp[0] ); } return ret; } /* CmdLineArg::process */ template class ArgSet : public CmdLineArg { const char* flag_; const char* usage_; const Feature* feature; public: ArgSet(const char* flag, const char* usage, const Feature* feature) : flag_(flag), usage_(usage), feature(feature) {} const char* flag() const { return flag_; } int numArgs() const { return args; } const char* usage() const { return usage_; } void action(const int& i, const char** a) { const char* empty = ""; const char* p[args+1]; String tmpStr; for (int j=0 ; jaction( p ); if ( !fast ) { OStringStream os; feature->query(os); os << ends; cout << os.rdbuf() << '\n'; } } const char* name() const { return feature->name; } }; class ArgQuery : public CmdLineArg { const char* flag_; const char* usage_; int numArgs_; CDSList features; CmdLineArg** options; public: ArgQuery(const char* flag, const char* usage, const CDSList& features, CmdLineArg** options) : flag_(flag), usage_(usage), numArgs_(0), features(features), options(options) {} const char* flag() const { return flag_; } int numArgs() const { return numArgs_; } const char* usage() const { return usage_; } void action(const int& numArgs, const char** a ); }; //change: query should return a list of strings (or streams) which ArgQuery // formats for output void ArgQuery::action(const int& numArgs, const char** a ) { String glob = "*"; if (numArgs == 0) { cout << versionString; numArgs_=0; } else { glob = String("*") + a[1] + "*"; numArgs_=1; } int cnt=0; for (int i=0 ; iname , glob,1) ) { int ret = features[i]->query(os); if ( ret==0 ) { cout.setf(ios::left); os << ends; const char* str = os.str(); if ( longQuery ) { const char* flag = ""; for (CmdLineArg** cl=options ; *cl ; cl++) if ( features[i]->name == (*cl)->name() ) flag = (*cl)->flag(); cout << ' ' << setw(10) << flag << " " << setw(38) << (str?str:"") << '\n'; } else { cout << ' ' << setfill(' ') <name << ": " << features[i]->error(ret) << '\n'; } } if ( !longQuery && cnt%2==1 ) cout << '\n'; } /* ArgQuery::action */ int main( int argc, const char* argv[]) { int version,bios; // if (ioperm(0xb2, 1, 1)) { // cerr << argv[0] << ": can't get I/O permissions.\n" // << "\tRead/write permission to /dev/toshiba is required.\n"; // return 1; // } // should be use /dev/toshiba or direct calls to the BIOS detAccessMode(); /* do some quick checks on the laptop */ bios = HciGetBiosVersion(); if (bios==0) { cerr << argv[0] << ": unable to get BIOS version" << endl; return 1; } if (HciGetMachineID(&id)==HCI_FAILURE) { cerr << argv[0] << ": unable to get machine identification" << endl; return 1; } /* drop root priveleges to minimize the risk of running suid root */ seteuid(getuid()); //FIX: use setuid/setgid setegid(getgid()); if ( (id>>8) != 0xfc ) cout << "This machine does not appear to have a Toshiba BIOS.\n\t" << "machine id: " << hex << id << "\n\t" << "Don't expect this program to do anything useful!!\n"; if (SciSupportCheck(&version)==1) { cerr << argv[0] << ": this computer is not supported" << endl; return 1; } if ( checkToshibaID(id) ) snprintf(versionString,80, " machine id: 0x%04x BIOS version:" " %d.%d SCI version: %d.%d\n", id, (bios & 0xff00)>>8, bios & 0xff, (version & 0xff00)>>8, version & 0xff); else { printf("%s: unrecognized machine " "identification:\n",argv[0]); printf("machine id : 0x%04x BIOS version : %d.%d" " SCI version: %d.%d\n", id, (bios & 0xff00)>>8, bios & 0xff, (version & 0xff00)>>8, version & 0xff); cout << "\nplease email this information to charles@schwieters.org " << " and include the following: \n" << " model\nand model number, eg. Libretto 50CT model number PA1249E\n" << " the output of cat /proc/acpi/toshiba/version\n" << " lsmod |grep tosh\n"; } /* check to see if a copy of wmTuxTime is already running */ SciOpenInterface(); CDSList features; ToggleFeature verboseFeature(verbose,"verbose"); ToggleFeature longFeature(longQuery,"long query"); ToggleFeature fastFeature(fast,"run fast"); VersionFeature versionFeature; features.append(&versionFeature); ModelFeature modelFeature(id); features.append(&modelFeature); AccessFeature accessFeature; features.append(&accessFeature); SciFeature batteryFeature(SCI_BATTERY_SAVE,"battery save mode"); batteryFeature.addValue( "user" , SCI_USER_SETTINGS , "user settings"); batteryFeature.addValue( "full" , SCI_FULL_POWER , "full power"); batteryFeature.addValue( "low" , SCI_LOW_POWER , "low power"); batteryFeature.addValue( "economy", SCI_ECONOMY , "economy settings"); batteryFeature.addValue( "normal" , SCI_NORMAL_LIFE , "normal life"); batteryFeature.addValue( "long" , SCI_LONG_LIFE , "long life"); batteryFeature.addValue( "full" , SCI_FULL_LIFE , "full life"); features.append(&batteryFeature); HciFeature acFeature(HCI_AC_ADAPTOR,"power source"); acFeature.addValue( "" , 3 , "battery" ); acFeature.addValue( "" , 4 , "external" ); features.append(&acFeature); HciFeature backlightFeature(HCI_BACKLIGHT,"LCD backlight"); backlightFeature.addValue( "off" , HCI_DISABLE , "off" ); backlightFeature.addValue( "on" , HCI_ENABLE , "on" ); features.append(&backlightFeature); HciFeature trBacklightFeature(HCI_TR_BACKLIGHT,"transreflective mode"); trBacklightFeature.addValue( "off" , HCI_ENABLE , "off" ); trBacklightFeature.addValue( "on" , HCI_DISABLE , "on" ); features.append(&trBacklightFeature); HciFeature fanFeature(HCI_FAN,"fan"); fanFeature.addValue( "off" , HCI_DISABLE , "off" ); fanFeature.addValue( "on" , HCI_ENABLE , "on" ); fanFeature.addValue( "fan1" , HCI_FAN_FAN1 , "fan1" ); fanFeature.addValue( "fan2" , HCI_FAN_FAN2 , "fan2" ); fanFeature.addValue( "1/4" , HCI_FAN_LOW2 , "1/4" ); fanFeature.addValue( "3/4" , HCI_FAN_HIGH2 , "3/4" ); fanFeature.addValue( "2/4" , HCI_FAN_LOW3 , "2/4" ); fanFeature.addValue( "high1" , HCI_FAN_HIGH1 , "high1" ); fanFeature.addValue( "high" , HCI_FAN_HIGH , "high" ); fanFeature.addValue( "low" , HCI_FAN_LOW , "low" ); fanFeature.addValue( "1/8" , HCI_FAN_LOW4 , "1/8" ); features.append(&fanFeature); HciFeature selectBayFeature(HCI_SELECT_STATUS,"select bay"); // fanFeature.addValue( "on" , HCI_ENABLE , "on" ); selectBayFeature.addValue( "" , HCI_NOTHING , "empty" ); selectBayFeature.addValue( "" , HCI_FLOPPY , "floppy" ); selectBayFeature.addValue( "" , HCI_ATAPI , "CDROM" ); selectBayFeature.addValue( "" , HCI_IDE , "hard disk" ); selectBayFeature.addValue( "" , HCI_BATTERY , "battery" ); features.append(&selectBayFeature); HciFeature selectBayLockFeature(HCI_LOCK_STATUS,"select bay lock"); // fanFeature.addValue( "on" , HCI_ENABLE , "on" ); selectBayLockFeature.addValue( "engage" , HCI_LOCKED , "engaged" ); selectBayLockFeature.addValue( "dis" , HCI_UNLOCKED , "disabled" ); features.append(&selectBayLockFeature); SciFeature irFeature(SCI_INFRARED_PORT,"IR port"); irFeature.addValue( "off" , SCI_OFF , "off" ); irFeature.addValue( "on" , SCI_ON , "on" ); features.append(&irFeature); // HciFeature firFeature(HCI_FIR_STATUS,"HCI IR port"); // firFeature.addValue( "on" , HCI_ENABLE , "on" ); // firFeature.addValue( "off" , HCI_DISABLE , "off" ); // features.append(&firFeature); SciFeature legacyUSBFeature(SCI_USB_LEGACY_MODE, "USB legacy mode"); legacyUSBFeature.addValue("disable" , SCI_DISABLED , "disabled"); legacyUSBFeature.addValue("enable" , SCI_ENABLED , "enabled"); features.append(&legacyUSBFeature); SciFeature USBFDDFeature(SCI_USB_FDD_EMULAT, "USB FDD emulation mode"); USBFDDFeature.addValue("disable" , SCI_DISABLED , "disabled"); USBFDDFeature.addValue("enable" , SCI_ENABLED , "enabled"); features.append(&USBFDDFeature); SciFeature LANcontrollerFeature(SCI_LAN_CONTROLLER, "LAN controller"); LANcontrollerFeature.addValue("disable" , SCI_DISABLED , "disabled"); LANcontrollerFeature.addValue("enable" , SCI_ENABLED , "enabled"); features.append(&LANcontrollerFeature); SciFeature soundlogoFeature(SCI_SOUND_LOGO, "sound logo"); soundlogoFeature.addValue("disable" , SCI_DISABLED , "disabled"); soundlogoFeature.addValue("enable" , SCI_ENABLED , "enabled"); features.append(&soundlogoFeature); SciFeature startuplogoFeature(SCI_STARTUP_LOGO, "startup logo"); startuplogoFeature.addValue("picture" , SCI_PICTURE_LOGO , "picture"); startuplogoFeature.addValue("animation" , SCI_ANIMATION_LOGO , "animation"); features.append(&startuplogoFeature); HciFeature videoFeature(HCI_VIDEO_OUT,"Video out"); videoFeature.addValue("int" ,HCI_INTERNAL , "internal: LCD" ); videoFeature.addValue("ext" ,HCI_EXTERNAL , "external monitor" ); videoFeature.addValue("both",HCI_SIMULTANEOUS , "internal and external monitor"); videoFeature.addValue("tv",HCI_TVOUT , "tv out"); videoFeature.addValue("mode5", 0x105 , "mode5 ??"); videoFeature.addValue("mode6", 0x106 , "mode6 ??"); videoFeature.addValue("mode7", 0x107 , "mode7 ??"); features.append(&videoFeature); int supportsHibernation = 1; HibInfoFeature hibInfoBIOSFeature(HCI_BIOS_SIZE,"HibInfo: BIOS size"); HibInfoFeature hibInfoMemoryFeature(HCI_MEMORY_SIZE,"HibInfo: memory size"); HibInfoFeature hibInfoVRAMFeature(HCI_VRAM_SIZE,"HibInfo: VRAM size"); if ( supportsHibernation ) { features.append(&hibInfoBIOSFeature); features.append(&hibInfoMemoryFeature); features.append(&hibInfoVRAMFeature); } //FIX: should rename class LbaFeature hibLbaFeature(HCI_HIBERNATION_LBA,"Hibernation LBA"); // LbaFeature biosSizeFeature(HCI_BIOS_SIZE,"BIOS size"); // LbaFeature vmemSizeFeature(HCI_MEMORY_SIZE,"virtual Memory size"); // LbaFeature ramSizeFeature(HCI_VRAM_SIZE,"RAM size"); if ( supportsHibernation ) { features.append(&hibLbaFeature); // features.append(&biosSizeFeature); // features.append(&vmemSizeFeature); // features.append(&ramSizeFeature); } LCDFeature fpanelFeature(HCI_FLAT_PANEL,"flat panel"); // fpanelFeature.addValue("" , 516 , "1024x768 active matrix"); // fanFeature.addValue( "on" , HCI_ENABLE , "on" ); // fanFeature.addValue( "off" , HCI_DISABLE , "off" ); features.append(&fpanelFeature); SciFeature beepFeature(SCI_SYSTEM_BEEP,"system beep"); beepFeature.addValue( "off" , SCI_OFF , "off" ); beepFeature.addValue( "on" , SCI_ON , "on" ); features.append(&beepFeature); SciFeature lcdFeature(SCI_LCD_BRIGHTNESS,"lcd brightness"); lcdFeature.addValue("semi" , SCI_SEMI_BRIGHT , "semi-bright" ); lcdFeature.addValue("bright" , SCI_BRIGHT , "bright" ); lcdFeature.addValue("super" , SCI_SUPER_BRIGHT , "super-bright" ); features.append(&lcdFeature); LCDIntensityFeature intensityFeature("lcd intensity"); features.append(&intensityFeature); SciFeature processingFeature(SCI_PROCESSING,"CPU speed"); processingFeature.addValue("slow" , SCI_LOW , "slow" ); processingFeature.addValue("fast" , SCI_HIGH , "fast" ); features.append(&processingFeature); SciFeature sleepFeature(SCI_SLEEP_MODE,"CPU sleep mode"); sleepFeature.addValue( "off" , SCI_OFF , "off" ); sleepFeature.addValue( "on" , SCI_ON , "on" ); features.append(&sleepFeature); SciFeature dstretchFeature(SCI_SLEEP_MODE,"Display stretch"); dstretchFeature.addValue( "off" , SCI_OFF , "off" ); dstretchFeature.addValue( "on" , SCI_ON , "on" ); features.append(&dstretchFeature); SciFeature cpuCacheFeature(SCI_CPU_CACHE,"CPU cache"); cpuCacheFeature.addValue( "off" , SCI_OFF , "off" ); cpuCacheFeature.addValue( "on" , SCI_ON , "on" ); features.append(&cpuCacheFeature); //???? SciFeature cachePolicyFeature(SCI_CACHE_POLICY,"cache policy"); cachePolicyFeature.addValue( "write-back" , 0 , "write back" ); cachePolicyFeature.addValue( "write-through" , 1 , "write through" ); features.append(&cachePolicyFeature); SciFeature volumeFeature(SCI_SPEAKER_VOLUME,"speaker volume"); volumeFeature.addValue( "off" , SCI_VOLUME_OFF , "off" ); volumeFeature.addValue( "low" , SCI_VOLUME_LOW , "low" ); volumeFeature.addValue( "medium" , SCI_VOLUME_MEDIUM , "medium" ); volumeFeature.addValue( "high" , SCI_VOLUME_HIGH , "high" ); features.append(&volumeFeature); SciFeature batAlarmFeature(SCI_BATTERY_ALARM,"battery alarm"); batAlarmFeature.addValue( "off" , SCI_OFF , "off" ); batAlarmFeature.addValue( "on" , SCI_ON , "on" ); features.append(&batAlarmFeature); SciFeature panAlarmFeature(SCI_PANEL_ALARM,"panel alarm"); panAlarmFeature.addValue( "off" , SCI_OFF , "off" ); panAlarmFeature.addValue( "on" , SCI_ON , "on" ); features.append(&panAlarmFeature); SciFeature panPowerFeature(SCI_PANEL_POWER,"panel power"); panPowerFeature.addValue( "off" , SCI_OFF , "off" ); panPowerFeature.addValue( "on" , SCI_ON , "on" ); features.append(&panPowerFeature); SciFeature hddFeature(SCI_HDD_AUTO_OFF,"hard disk auto-off time"); hddFeature.addValue( "dis" , SCI_TIME_DISABLED , "disabled"); hddFeature.addValue( "1" , SCI_TIME_01 , "1 minute"); hddFeature.addValue( "3" , SCI_TIME_03 , "3 minutes"); hddFeature.addValue( "5" , SCI_TIME_05 , "5 minutes"); hddFeature.addValue( "10" , SCI_TIME_10 , "10 minutes"); hddFeature.addValue( "15" , SCI_TIME_15 , "15 minutes"); hddFeature.addValue( "20" , SCI_TIME_20 , "20 minutes"); hddFeature.addValue( "30" , SCI_TIME_30 , "30 minutes"); features.append(&hddFeature); SciFeature displayFeature(SCI_DISPLAY_AUTO,"display auto-off time"); displayFeature.addValue( "dis" , SCI_TIME_DISABLED , "disabled"); displayFeature.addValue( "1" , SCI_TIME_01 , "1 minute"); displayFeature.addValue( "3" , SCI_TIME_03 , "3 minutes"); displayFeature.addValue( "5" , SCI_TIME_05 , "5 minutes"); displayFeature.addValue( "10" , SCI_TIME_10 , "10 minutes"); displayFeature.addValue( "15" , SCI_TIME_15 , "15 minutes"); displayFeature.addValue( "20" , SCI_TIME_20 , "20 minutes"); displayFeature.addValue( "30" , SCI_TIME_30 , "30 minutes"); features.append(&displayFeature); // HciFeature hciPowerFeature(HCI_POWER_UP,"HCI power-up mode"); // hciPowerFeature.addValue( "boot" , SCI_BOOT , "boot"); // hciPowerFeature.addValue( "resume" , SCI_RESUME , "resume"); // hciPowerFeature.addValue( "hibernate" , SCI_HIBERNATE , "hibernate"); // hciPowerFeature.addValue( "quick" , SCI_QUICK_HIBERNATE , "quick-hibernate"); // features.append(&hciPowerFeature); SciFeature sciPowerFeature(SCI_POWER_UP,"power-up mode"); sciPowerFeature.addValue( "boot" , SCI_BOOT , "boot"); sciPowerFeature.addValue( "resume" , SCI_RESUME , "resume"); sciPowerFeature.addValue( "hibernate" , SCI_HIBERNATE , "hibernate"); sciPowerFeature.addValue( "quick" , SCI_QUICK_HIBERNATE , "quick-hibernate"); features.append(&sciPowerFeature); PercentFeature batteryPercentFeature(SCI_BATTERY_PERCENT,"battery percent"); features.append(&batteryPercentFeature); PercentFeature secBatteryPercentFeature(SCI_2ND_BATTERY, "second battery"); features.append(&secBatteryPercentFeature); // PercentFeature secBatteryPercentFeature(SCI_2ND_BATTERY,"second battery"); // secBatFeature.addValue("disable" , 0 , "disabled"); // secBatFeature.addValue("enable" , 1 , "enabled"); // secBatFeature.addValue("enable" , 65 , "present"); // features.append(&secBatFeature); SciFeature coolingFeature(SCI_COOLING_METHOD,"cooling method"); coolingFeature.addValue( "perform" , SCI_PERFORMANCE , "performance"); coolingFeature.addValue( "quiet" , SCI_QUIET , "quiet"); coolingFeature.addValue( "other" , 2 , "other"); features.append(&coolingFeature); TimeFeature wakeAlarmFeature(SCI_ALARM_POWER,"power-up alarm"); // wakeAlarmFeature.addValue( "on" , SCI_ALARM_ENABLED , "on" ); // wakeAlarmFeature.addValue( "off" , SCI_ALARM_DISABLED , "off" ); features.append(&wakeAlarmFeature); SciFeature autoOffFeature(SCI_SYSTEM_AUTO,"auto-off time"); autoOffFeature.addValue( "dis" , SCI_TIME_DISABLED , "disabled"); autoOffFeature.addValue( "10" , SCI_TIME_10 , " 10 minutes"); autoOffFeature.addValue( "20" , SCI_TIME_20 , " 20 minutes"); autoOffFeature.addValue( "30" , SCI_TIME_30 , " 30 minutes"); autoOffFeature.addValue( "40" , SCI_TIME_40 , " 40 minutes"); autoOffFeature.addValue( "50" , SCI_TIME_50 , " 50 minutes"); autoOffFeature.addValue( "60" , SCI_TIME_60 , " 60 minutes"); features.append(&autoOffFeature); SciFeature parallelFeature(SCI_PARALLEL_PORT,"parallel port mode"); parallelFeature.addValue( "ecp" ,SCI_PARALLEL_ECP, "ecp" ); parallelFeature.addValue( "spp" ,SCI_PARALLEL_SPP, "spp" ); parallelFeature.addValue( "ps2" ,SCI_PARALLEL_PS2, "ps2" ); // parallelFeature.addValue features.append(¶llelFeature); SciFeature standbyFeature(SCI_STANDBY_TIME,"Standby time"); features.append(&standbyFeature); SciFeature hibernationFeature(SCI_HIBERNATION,"Hibernation"); hibernationFeature.addValue("disable" , 0 , "not configured"); hibernationFeature.addValue("enable" , 1 , "configured"); features.append(&hibernationFeature); // I don't know what this option does, but the following values seem to // be valid on my 8100 SciFeature pointerFeature(SCI_POINTING_DEVICE,"Pointer"); pointerFeature.addValue("0" , 0 , "0"); pointerFeature.addValue("1" , 1 , "1"); pointerFeature.addValue("2" , 2 , "2"); pointerFeature.addValue("3" , 3 , "3"); features.append(&pointerFeature); SciFeature bootFeature(SCI_BOOT_METHOD,"boot method"); bootFeature.addValue( "fdhdcd" , SCI_FD_HD , "floppy->hard disk->CDROM"); bootFeature.addValue( "hdfdcd" , SCI_HD_FD , "hard disk->floppy->CDROM"); bootFeature.addValue( "fdcdhd" , 2 , "floppy->CDROM->hard disk"); bootFeature.addValue( "hdcdfd" , 3 , "hard disk->CDROM->floppy"); bootFeature.addValue( "cdfdhd" , 4 , "CDROM->floppy->hard disk"); bootFeature.addValue( "cdhdfd" , 5 , "CDROM->hard disk->floppy"); features.append(&bootFeature); HciFeature wirelessFeature(HCI_WIRELESS,"wireless support"); wirelessFeature.addValue( "" , 0 , "not present"); wirelessFeature.addValue( "" , 0xf , "present"); features.append(&wirelessFeature); WirelessFeature wirelessSwitchFeature(0x1, "wireless switch"); features.append(&wirelessSwitchFeature); BlueToothFeature blueToothFeature("bluetooth"); features.append(&blueToothFeature); ThreeGRFFeature threeGRFFeature("3g"); features.append(&threeGRFFeature); //FIX: need to enumerate these HciFeature bootDeviceFeature(HCI_BOOT_DEVICE,"boot device"); //features.append(&bootDeviceFeature); PasswdFeature userPasswdFeature(SCI_USER_PASSWORD,"user password"); features.append(&userPasswdFeature); PasswdFeature superPasswdFeature(SCI_SUPER_PASSWORD,"supervisor password"); features.append(&superPasswdFeature); OwnerStringFeature ownerStringFeature(HCI_OWNERSTRING,"owner string"); features.append(&ownerStringFeature); CmdLineArg* argList[] = { new ArgSet<1>("-b"," enable/disable system beep" , &beepFeature), new ArgSet<1>("-lcd"," set lcd brightness" , &lcdFeature), new ArgSet<1>("-inten"," set lcd intensity" , &intensityFeature), new ArgSet<1>("-pow"," set power-up mode", &sciPowerFeature), // new ArgSet<1>("-hpow"," set power-up mode", // &hciPowerFeature), new ArgSet<1>("-vol","<0-3> set beep (and modem!) volume", &volumeFeature), new ArgSet<1>("-hdd"," number of minutes until disk spindown",&hddFeature), new ArgSet<1>("-dstretch"," display stretch",&dstretchFeature), new ArgSet<1>("-d"," number of minutes until display auto-off",&displayFeature), new ArgSet<1>("-c"," set cooling method",&coolingFeature), new ArgSet<1>("-bs"," battery-save mode",&batteryFeature), new ArgSet<1>("-bl"," lcd backlight",&backlightFeature), new ArgSet<1>("-trmode"," transreflective mode", &trBacklightFeature), new ArgSet<1>("-fan"," fan",&fanFeature), new ArgSet<1>("-hib"," hibernation",&hibernationFeature), new ArgSet<1>("-memsize","memory size in bytes",&hibInfoMemoryFeature), new ArgSet<1>("-pointer","<0|1|2> pointer",&pointerFeature), new ArgSet<1>("-lba","hibernation address",&hibLbaFeature), new ArgSet<1>("-video"," video out",&videoFeature), new ArgSet<1>("-cpu"," CPU speed",&processingFeature), new ArgSet<1>("-cpucache"," CPU cache",&cpuCacheFeature), new ArgSet<1>("-sleep"," sleep mode",&sleepFeature), new ArgSet<1>("-balarm"," battery alarm",&batAlarmFeature), new ArgSet<1>("-palarm"," lid-closed alarm",&panAlarmFeature), new ArgSet<1>("-walarm", " time/date to wake", &wakeAlarmFeature), new ArgSet<1>("-ostring"," owner string",&ownerStringFeature), new ArgSet<1>("-ppower"," power-off when lid closed",&panPowerFeature), new ArgSet<1>("-boot","",&bootFeature), new ArgSet<1>("-parallel","