From: freb@goldfnch.mv.com (Karl Freburger)
Subject: Re: Everex STEP display driver
Organization: Goldfinch Software
Date: Sun, 4 Oct 1992 14:15:58 GMT
Summary: Here it is

I've seen a few requests for this driver go by, and I happen to have a copy
of it, and it's pretty small, so here it is.  I hope that Steve Friedl
(who appears to be the author) won't be upset by me doing this.  And
since the shar archive is only 357 lines long, I trust that I won't
be flamed by people offended by seeing actual source code in this group.

	- karl freburger


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Makefile Master Node README System led.c ledtime.c
# Wrapped by root@goldfnch on Sun Oct  4 10:10:20 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(385 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XCFLAGS	= -O -DAT386 -DINKERNEL -DiAPX386
X
Xled.o: led.c
X
XDriver.o: led.o
X	ld -r -o $@ led.o
X
Xinstall:	Driver.o
X	/etc/conf/bin/idinstall -k -a led ; touch $@
X
Xuninstall:	Driver.o
X	/etc/conf/bin/idinstall -k -d led ; touch $@
X
Xupdate:		Driver.o
X	/etc/conf/bin/idinstall -k -u led ; touch $@
X
Xbuild : update
X	/etc/conf/bin/idbuild ; touch $@
X
Xledtime : ledtime.c
X	${CC} -o $@ -O ledtime.c
END_OF_FILE
if test 385 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'Master' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Master'\"
else
echo shar: Extracting \"'Master'\" \(27 characters\)
sed "s/^X//" >'Master' <<'END_OF_FILE'
Xled	Iw	ico		led	0	0	1	1	-1
END_OF_FILE
if test 27 -ne `wc -c <'Master'`; then
    echo shar: \"'Master'\" unpacked with wrong size!
fi
# end of 'Master'
fi
if test -f 'Node' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Node'\"
else
echo shar: Extracting \"'Node'\" \(12 characters\)
sed "s/^X//" >'Node' <<'END_OF_FILE'
Xled	led	c	0
END_OF_FILE
if test 12 -ne `wc -c <'Node'`; then
    echo shar: \"'Node'\" unpacked with wrong size!
fi
# end of 'Node'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1515 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XFrom virgin!decvax!decwrl!wuarchive!wugate!uunet!vsi!bang!friedl Tue Oct 10 08:54:47 EDT 1989
XPath: goldfnch!virgin!decvax!decwrl!wuarchive!wugate!uunet!vsi!bang!friedl
X>From: friedl@bang.UUCP (Steve Friedl)
XNewsgroups: comp.unix.i386
XSubject: Source to enhanced Everex front-panel driver
XMessage-ID: <286@bang.UUCP>
XDate: 29 Sep 89 21:37:26 GMT
XOrganization: Steve's Barnburner 386
XLines: 279
XStatus: RO
X
XHi folks,
X
X     Some time ago Dave Carlson from Micropen posted a
Xquick+dirty driver for the front-panel LED display on the Everex
XSTEP 386 family, and at the time I was working on my own.  Mine
Xis a lot more flexible, as it gives access to the panel to the
Xuser (via /dev/led), and I've been using it for months.
X
X     I always run a program in the background that updates
Xthe time constantly in HH:MM:SS format, and in general I like
Xit a lot.  I suspect that you could use this for feedback from
Xsome noninteractive program, and kernel debugging might be
Xanother good use for it.
X
X     I wrote this on the Everex STEP 386/25 running AT&T System V
XRelease 3.2, but you get to figure out how to make it work
Xelsewhere.  This is my first driver, so comments and feedback
X(flames too) are welcome.
X
X     This code is in the public domain and can be used for
Xanything by anybody.
X
X     Steve
X
X
X-- 
XStephen J. Friedl  /  Software Consultant  /  Tustin, CA  /  + 714 544 6561
X3B2-kind-of-guy    /  {attmail uunet}!vsi!{bang!}friedl   /  friedl@vsi.com
X
X"C is a disease." - Philippe Kahn, head honcho of Borland
X
X
END_OF_FILE
if test 1515 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'System' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'System'\"
else
echo shar: Extracting \"'System'\" \(22 characters\)
sed "s/^X//" >'System' <<'END_OF_FILE'
Xled	Y	1	0	0	0	0	0	0	0
END_OF_FILE
if test 22 -ne `wc -c <'System'`; then
    echo shar: \"'System'\" unpacked with wrong size!
fi
# end of 'System'
fi
if test -f 'led.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'led.c'\"
else
echo shar: Extracting \"'led.c'\" \(4876 characters\)
sed "s/^X//" >'led.c' <<'END_OF_FILE'
X/*
X * led.c
X *
X * Written by:	Stephen J. Friedl
X *		V-Systems, Inc.
X *		friedl@vsi.com
X *		29 July, 1989
X *
X *	This is a driver for the front-panel LEDs on an Everex
X *	STEP system.  This is an eight-character display, and is
X *	normally driven by the BIOS to show the current drive,
X *	cylinder, and head being accessed.  UNIX bypasses the BIOS
X *	entirely, so it freezes shortly after bootup.
X *
X *	This is a _really_simple_ driver with two parts.  First,
X *	you can make the thing display some cute signon message
X *	when the machine boots, and then later change it with
X *	a normal write(2) system call.  See the docs on the
X *	"ledwrite()" function below for restrictions.
X *
X *	This driver has been tested on an Everex STEP/25 running
X *	real AT&T System V Release 3.2.  Information about the
X *	usage of the 8042 UPI has been derived from the Everex
X *	STEP 386 Hardware Service and Maintenance Guide, part
X *	number KIT 00076-00 (about a hundred bucks from your
X *	Authorized Everex dealer).
X *
X *	========================================================
X *	In the spirit of free interchange of { hopefully } high-
X *	quality software, this driver is released to the public
X *	domain and can be used for any purposes at all, including
X *	personal, commercial, military, blackmail, etc.
X *
X *	Have fun, folks.
X *	========================================================
X */
X#include	<sys/types.h>
X#include	<sys/signal.h>
X#include	<sys/dir.h>
X#include	<sys/param.h>
X#include	<sys/errno.h>
X#include	<sys/user.h>
X#include	<sys/inline.h>
X
X/*----------------------------------------------------------------------
X * Stuff for ANSI C (someday).
X */
X#ifndef	__STDC__
X#  define	const		/*nothing*/
X#endif
X
X#define		LED_WIDTH	8
X
X/*----------------------------------------------------------------------
X * Everex 8042 UPI controller chip port defines
X */
X#define 	DATA		0x60
X#define 	COMMAND		0x64
X#define 	STATUS		0x64
X
X#define 	BUSY		0x02
X
X#define		WAITBUSY()	while (inb(STATUS)&BUSY)
X
X/*----------------------------------------------------------------------
X * program_leds()
X *
X *	Given a NUL-terminated string, program the LEDs to display
X *	this value.  Up to {LED_WIDTH} characters are displayed, and
X *	spaces are added at the end for padding.  No examination of
X *	the characters to be displayed is done.  Note that a newline
X *	appears as an ugly character and is probably not what you
X *	want.
X *
X *	===NOTE=== this routine demands that the address provided
X *	be valid.  Be careful.
X *
X *	If you want to use this routine for kernel debugging -- we
X *	have not done this -- you will have to remove the "static"
X *	storage class specifier below.
X */
Xstatic void
Xprogram_leds(str)
Xchar const	*str;
X{
Xint	n;
X
X	intr_disable();			/* this looks like a copout...	*/
X
X	WAITBUSY();			/* wait for 8042 to be unbusy	*/
X
X	outb(COMMAND, 0xb0);		/* initialize display		*/
X
X	/*--------------------------------------------------------------
X	 * now, for up to eight characters, update the display.  We stick
X	 * on spaces at the end if the user-provided string is shorter.
X	 * Newlines look funny so we really should trap them out, but
X	 * it won't be so bad to make the user strip it out on his/her own.
X	 */
X	for (n = 0; n < LED_WIDTH; n++)
X	{
X		WAITBUSY();
X		outb(DATA, *str ? *str++ : ' ');
X	}
X
X	intr_restore();
X}
X
X/*----------------------------------------------------------------------
X * ledinit()
X *
X *	This is called by the kernel early in the boot sequence, and we
X *	simply display some more reasonable message here instead of the
X *	last cylinder accessed by the BIOS.  This can be whatever you like,
X *	and it is automatically truncated to proper width.
X *
X *	Be creative!
X */
Xvoid
Xledinit()
X{
X	program_leds("386 UNIX");
X}
X
X/*----------------------------------------------------------------------
X * ledwrite()
X *
X *	Do the actual write to the display.  Note that each write(2)
X *	call is treated separately, and the message to be displayed
X *	must all be written at once (i.e., character-at-a-time writes
X *	won't do what's intended).  If you don't like this, we can
X *	always change the driver to require ioctls() for character
X *	output and *really* make it inconvenient...
X */
X/*ARGSUSED*/
Xvoid
Xledwrite(dev)
Xint	dev;
X{
Xchar		ledbuf[LED_WIDTH+1];	/* buffer for the message	*/
Xunsigned int	count;			/* # of chars to write		*/
X
X	/*--------------------------------------------------------------
X	 * We can only write a few characters, so just limit the
X	 * length here.
X	 */
X	count = (u.u_count > LED_WIDTH) ? LED_WIDTH : u.u_count;
X
X	/*--------------------------------------------------------------
X	 * grab the characters from the user space and return a fault
X	 * error on a bad address.
X	 */
X	if (copyin(u.u_base, ledbuf, count) == -1)
X		u.u_error = EFAULT;
X	else
X	{
X		ledbuf[count] = '\0';	/* NUL-terminated, remember?	*/
X		program_leds(ledbuf);	/* do it!			*/
X	}
X}
END_OF_FILE
if test 4876 -ne `wc -c <'led.c'`; then
    echo shar: \"'led.c'\" unpacked with wrong size!
fi
# end of 'led.c'
fi
if test -f 'ledtime.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ledtime.c'\"
else
echo shar: Extracting \"'ledtime.c'\" \(966 characters\)
sed "s/^X//" >'ledtime.c' <<'END_OF_FILE'
X/*
X * ledtime()
X *
X * written by:	Stephen J. Friedl
X *		V-Systems, Inc.
X *		+1 714 545 6442
X *		friedl@vsi.com
X *
X *	This program sits in the background and writes the current
X *	time to stdout.  It is meant to be directed at /dev/led
X *	so the Everex front-panel display always shows the time.
X *	It should be run out of /etc/rc2.d (I use S12ledtime) and
X *	looks like:
X *
X *		/usr/local/bin/ledtime > /dev/led &
X *
X *	This is in the public domain (not that you couldn't figure
X *	this out in about two minutes anyway).
X */
X#include	<stdio.h>
X#include	<sys/types.h>
X#include	<time.h>
X
Xmain()
X{
X	while (1)
X	{
X	struct tm	*tm;
X	time_t		now;		/* current UNIX time		*/
X	int		len;		/* length of the time buffer	*/
X	char		buf[40];	/* buffer for the time string	*/
X
X		(void)time(&now);
X		tm = localtime(&now);
X		len = sprintf(buf, "%02d:%02d:%02d\n",
X		  tm->tm_hour, tm->tm_min, tm->tm_sec);
X		(void)write(fileno(stdout), buf, len);
X		(void)sleep(1);
X	}
X	/*NOTREACHED*/
X}
END_OF_FILE
if test 966 -ne `wc -c <'ledtime.c'`; then
    echo shar: \"'ledtime.c'\" unpacked with wrong size!
fi
# end of 'ledtime.c'
fi
echo shar: End of shell archive.
exit 0
-- 
Karl Freburger (freb@goldfnch.mv.com)
Newsgroups: comp.unix.sysv386