home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / everxled / part01 < prev    next >
Encoding:
Text File  |  1993-06-19  |  21.2 KB  |  752 lines

  1. Newsgroups: comp.sources.unix
  2. From: druid!darcy@uunet.UU.NET (D'Arcy J.M. Cain)
  3. Subject: v26i241: everex-led - LED driver for Everex Step machines, Part01/01
  4. Sender: unix-sources-moderator@gw.home.vix.com
  5. Approved: vixie@gw.home.vix.com
  6.  
  7. Submitted-By: druid!darcy@uunet.UU.NET (D'Arcy J.M. Cain)
  8. Posting-Number: Volume 26, Issue 241
  9. Archive-Name: everex-led/part01
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 1 (of 1)."
  18. # Contents:  MANIFEST Makefile README led.7 led.c ledtime.1 ledtime.c
  19. # Wrapped by vixie@gw.home.vix.com on Sun Jun 20 11:57:04 1993
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  23. else
  24. echo shar: Extracting \"'MANIFEST'\" \(331 characters\)
  25. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  26. X   File Name        Archive #    Description
  27. X-----------------------------------------------------------
  28. X MANIFEST                   1    This shipping list
  29. X Makefile                   1    
  30. X README                     1    
  31. X led.7                      1    
  32. X led.c                      1    
  33. X ledtime.1                  1    
  34. X ledtime.c                  1    
  35. END_OF_FILE
  36. if test 331 -ne `wc -c <'MANIFEST'`; then
  37.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  38. fi
  39. # end of 'MANIFEST'
  40. fi
  41. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  42.   echo shar: Will not clobber existing file \"'Makefile'\"
  43. else
  44. echo shar: Extracting \"'Makefile'\" \(3852 characters\)
  45. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  46. X# Makefile for LED driver
  47. X# Written by D'Arcy J.M. Cain
  48. X# For package written by Stephen J. Friedl and D'Arcy J.M. Cain
  49. X
  50. X# Note that anything that runs su displays the command line so that
  51. X# the builder knows what he/she is getting into.
  52. X
  53. X# Change LED_INIT_STR for your taste or remove it for default (version #)
  54. X# Define CLOCK12 to have ledtime display time in 12 hour format
  55. XCFLAGS    = -O -Xa -v -DCLOCK12 -DLED_INIT_STR=\"`uname -n`\"
  56. X
  57. X# If you don't want to run ledtime automatically change "respawn" in
  58. X# the following definition to "off"
  59. XRESPAWN =    respawn
  60. X
  61. X# If you want to build and install all the files but not activate
  62. X# the driver then change the 'Y' here to 'N'.
  63. XACTIVE =    Y
  64. X
  65. X# modify these if things are kept somewhere else on your system
  66. XBIN =        /usr/local/bin
  67. XMAN =        /usr/share/man/man
  68. XCONFBIN =    /etc/conf/bin
  69. XINCLUDE =    /usr/include/sys
  70. X
  71. X# You shouldn't have to change anything after this (with the possible
  72. X# exception of Node, see comments below.)  If you do find changes
  73. X# necessary I would appreciate a message at darcy@druid.UUCP.  In
  74. X# fact please tell me when you have to make any changes to the package
  75. X# other than above.
  76. X
  77. XSU_INSTALL =    "if $(CONFBIN)/idcheck -p led;\
  78. X                then $(CONFBIN)/idinstall -k -a led;\
  79. X                else $(CONFBIN)/idinstall -k -u led;\
  80. X                fi"
  81. XSU_UNINSTALL =    "$(CONFBIN)/idinstall -k -d led; $(CONFBIN)/idbuild"
  82. XSU_BUILD =        "$(CONFBIN)/idbuild"
  83. X
  84. XSYSFILES =    Init Master Name Node System
  85. X.SILENT:
  86. X
  87. Xall:    Driver.o ledtime
  88. X
  89. XInit:    Makefile
  90. X    echo "Creating Init"
  91. X    echo "led0:23:$(RESPAWN):nice -100 $(BIN)/ledtime" > Init
  92. X
  93. XMaster:        Makefile
  94. X    echo "Creating Master"
  95. X    echo "led    ocwiI    icoH    led    0    0    1    4    -1" > Master
  96. X
  97. XName:        Makefile
  98. X    echo "Creating Name"
  99. X    echo "LED driver" > Name
  100. X
  101. X# If you change the number of minor devices you should probably
  102. X# make some changes here but this seems unlikely.  I'm sure that
  103. X# four devices on a single 8 character display is overkill already
  104. XNode:        Makefile
  105. X    echo "Creating Node"
  106. X    echo "led    ledclock    c    0" > Node
  107. X    echo "led    led1        c    1" >> Node
  108. X    echo "led    led2        c    2" >> Node
  109. X    echo "led    led            c    3" >> Node
  110. X
  111. XSystem:        Makefile
  112. X    echo "Creating System"
  113. X    echo "led    $(ACTIVE)    1    0    0    0    0    0    0    0" > System
  114. X
  115. Xclean:
  116. X    rm -f ledtime *.o core $(SYSFILES) install build led.shar
  117. X
  118. XDriver.o: led.c
  119. X    echo "Creating Driver.o from led.c"
  120. X    $(CC) -c $(CFLAGS) led.c
  121. X    mv led.o Driver.o
  122. X
  123. Xinstall:    Driver.o ledtime $(SYSFILES)
  124. X    echo "Installing package files"
  125. X    rm -f $(BIN)/ledtime
  126. X    cp ledtime $(BIN)
  127. X    chmod 711 $(BIN)/ledtime
  128. X    cp led.7 $(MAN)7
  129. X    cp ledtime.1 $(MAN)1
  130. X    chmod 644 $(MAN)7/led.7 $(MAN)1/ledtime.1
  131. X    echo "If ledtime is already running you should kill it in order"
  132. X    echo "to let init restart with the new binary."
  133. X    echo "I need the root password to run the following command"
  134. X    echo $(SU_INSTALL)
  135. X    su root -c $(SU_INSTALL)
  136. X    touch install
  137. X
  138. Xuninstall:
  139. X    echo "Removing LED driver"
  140. X    echo "I need the root password to run the following command"
  141. X    echo $(SU_UNINSTALL)
  142. X    su root -c $(SU_UNINSTALL)
  143. X    rm -f $(BIN)/ledtime $(MAN)7/led.7 $(MAN)1/ledtime.1
  144. X    rm -f install
  145. X
  146. Xbuild:    install
  147. X    echo "Rebuilding kernel"
  148. X    echo "I need the root password to run the following command"
  149. X    echo $(SU_BUILD)
  150. X    su root -c $(CONFBIN)/idbuild
  151. X    touch build
  152. X
  153. Xshar:    led.shar
  154. X
  155. Xled.shar:    Readme Makefile led.7 ledtime.1 led.c ledtime.c
  156. X    shar -vxf $^ > led.shar
  157. X
  158. Xwhat:
  159. X    clear
  160. X    echo "The following options are available in this makefile\n"
  161. X    echo "all:       This is the default.  It makes the driver, the config"
  162. X    echo "           files and the user programs.  Root password is not"
  163. X    echo "           required for this option\n"
  164. X    echo "shar:      Builds the shar distribution file\n"
  165. X    echo "install:   Installs the driver - root password required\n"
  166. X    echo "build:     Installs and builds the driver - root password required\n"
  167. X    echo "uninstall: Removes the driver - root password required\n"
  168. X    echo "clean:     Removes files built from distribution"
  169. END_OF_FILE
  170. if test 3852 -ne `wc -c <'Makefile'`; then
  171.     echo shar: \"'Makefile'\" unpacked with wrong size!
  172. fi
  173. # end of 'Makefile'
  174. fi
  175. if test -f 'README' -a "${1}" != "-c" ; then 
  176.   echo shar: Will not clobber existing file \"'README'\"
  177. else
  178. echo shar: Extracting \"'README'\" \(1290 characters\)
  179. sed "s/^X//" >'README' <<'END_OF_FILE'
  180. XThis driver is based on the driver written by Stephen J. Friedl
  181. X(friedl@mtndew.Tustin.CA.US).  I have made a few modifications:
  182. X
  183. X  - The Makefile has been completely revamped.  Many small files
  184. X    are now created directly rather than being part of the shar
  185. X    distribution.  Type 'make what' for a list of the more
  186. X    important make options.
  187. X
  188. X  - All code is fully ANSI compliant.
  189. X
  190. X  - The driver supports multiple devices with device minor numbers
  191. X    corresponding to priority on the LED display.
  192. X
  193. X  - The write function takes a regular stream of characters and
  194. X    displays them in scrolling fashion.  An ioctl performs the
  195. X    function performed by the original write function.
  196. X
  197. X  - The ledtime program has been modified to use the ioctl so that
  198. X    the display of time doesn't chase across the LEDs.  A makefile
  199. X    option allows you to select 12 or 24 hour time styles.
  200. X
  201. X  - The ledtime function uses /dev/ledclock which is minor 0.  This
  202. X    allows other programs to temporarily use the LEDs without
  203. X    having to stop and restart the clock display.
  204. X
  205. XNote that if you do not have an ANSI compiler you will have to run
  206. Xthis through unproto or change it by hand.  I have attempted to cast
  207. Xeverthing that may cause problems due to any such change.
  208. X
  209. XD'Arcy J.M. Cain
  210. Xdarcy@druid.UUCP
  211. END_OF_FILE
  212. if test 1290 -ne `wc -c <'README'`; then
  213.     echo shar: \"'README'\" unpacked with wrong size!
  214. fi
  215. # end of 'README'
  216. fi
  217. if test -f 'led.7' -a "${1}" != "-c" ; then 
  218.   echo shar: Will not clobber existing file \"'led.7'\"
  219. else
  220. echo shar: Extracting \"'led.7'\" \(1979 characters\)
  221. sed "s/^X//" >'led.7' <<'END_OF_FILE'
  222. X.TH LED 7
  223. X.de I
  224. X\fI$0\fR
  225. X..
  226. X.SH NAME
  227. Xled - LED driver for Everex front panel
  228. X.SH DESCRIPTION
  229. XThis is a driver for the front-panel LEDs on an Everex
  230. XSTEP system.  This is an eight-character display, and is
  231. Xnormally driven by the BIOS to show the current drive,
  232. Xcylinder, and head being accessed.  UNIX bypasses the BIOS
  233. Xentirely, so it freezes shortly after bootup.
  234. X.PP
  235. XThis is a simple driver which displays a signon message then accepts
  236. Xcalls to write to the LEDs.  Normal writes cause the text to scroll
  237. Xacross the display.
  238. X.PP
  239. XThere is also an ioctl call supported.  Function 0 re-displays the
  240. Xsignon message and function 1 displays the string pointed to by the
  241. Xthird argument, padding to and truncating at 8 characters as necessary.
  242. X.PP
  243. XMore than one device is supported in this driver and the default
  244. Xconfiguration sets up four.  Each device may only be opened by
  245. Xone process at a time.  When more than one device is opened at
  246. Xthe same time the ones with the lower minor number are blocked
  247. Xuntil they become the highest.  This allows something like a
  248. Xclock, for example, to continuously display the time but still
  249. Xallow other processes to take over the display on a temporary
  250. Xbasis.  When the second process is finished with the device
  251. Xthe clock display will resume.
  252. X.PP
  253. XThis driver has been tested on an Everex STEP/25 running
  254. XESIX 5.4.0.4 beta.  Information about the
  255. Xusage of the 8042 UPI has been derived from the Everex
  256. XSTEP 386 Hardware Service and Maintenance Guide, part
  257. Xnumber KIT 00076-00 (about a hundred bucks from your
  258. XAuthorized Everex dealer).
  259. X.SH FILES
  260. X/dev/led
  261. X.br
  262. X/dev/led1
  263. X.br
  264. X/dev/led2
  265. X.br
  266. X/dev/ledclock
  267. X.SH SEE ALSO
  268. Xledtime(1)
  269. X.SH AUTHOR
  270. XStephen J. Friedl (fred@mtndew.Tustin.CA.US)
  271. X.br
  272. XD'Arcy J.M. Cain (darcy@druid.UUCP)
  273. X.SH COPYRIGHT
  274. XIn the spirit of free interchange of (hopefully) high
  275. Xquality software, this driver is released to the public
  276. Xdomain and can be used for any purposes at all, including
  277. Xpersonal, commercial, military, blackmail, etc.
  278. END_OF_FILE
  279. if test 1979 -ne `wc -c <'led.7'`; then
  280.     echo shar: \"'led.7'\" unpacked with wrong size!
  281. fi
  282. # end of 'led.7'
  283. fi
  284. if test -f 'led.c' -a "${1}" != "-c" ; then 
  285.   echo shar: Will not clobber existing file \"'led.c'\"
  286. else
  287. echo shar: Extracting \"'led.c'\" \(7859 characters\)
  288. sed "s/^X//" >'led.c' <<'END_OF_FILE'
  289. X/*
  290. X * led.c
  291. X *
  292. X * Written by:    Stephen J. Friedl
  293. X *        V-Systems, Inc.
  294. X *        friedl@mtndew.Tustin.CA.US
  295. X *        29 July, 1989
  296. X *
  297. X *  Re-written by D'Arcy J.M. Cain
  298. X *  given version number 2.0
  299. X *
  300. X *    This is a driver for the front-panel LEDs on an Everex
  301. X *    STEP system.  This is an eight-character display, and is
  302. X *    normally driven by the BIOS to show the current drive,
  303. X *    cylinder, and head being accessed.  UNIX bypasses the BIOS
  304. X *    entirely, so it freezes shortly after bootup.
  305. X *
  306. X *    You can make the thing display some cute signon message when
  307. X *    the machine boots by setting the string LED_INIT_STR in the make
  308. X *  file.  A normal write call will scroll the output across the LEDs
  309. X *  (referred to by a friend as "times squaring" the output.)  There
  310. X *  are two ioctl calls available.  Function 0 re-displays the signon
  311. X *  message and function 1 displays the message pointed to by the third
  312. X *  argument to ioctl.  Both of these functions display all at once as
  313. X *  opposed to the scroll effect of the normal write call.
  314. X *
  315. X *  There are multiple devices available to the user.  The way that this
  316. X *  works is that any of the devices may be opened by any process but
  317. X *  each is opened exclusively and each device blocks while devices
  318. X *  with a higher minor number are open.  The idea is to put something
  319. X *  like ledtime on the lowest device and letting other things interupt
  320. X *  it temporarily.
  321. X *
  322. X *  This driver has been tested on an Everex STEP/25 running
  323. X *    Esix System V Release 4.0.4 beta.  Information about the
  324. X *    usage of the 8042 UPI has been derived from the Everex
  325. X *    STEP 386 Hardware Service and Maintenance Guide, part
  326. X *    number KIT 00076-00 (about a hundred bucks from your
  327. X *    Authorized Everex dealer).
  328. X *
  329. X *    ========================================================
  330. X *    In the spirit of free interchange of { hopefully } high-
  331. X *    quality software, this driver is released to the public
  332. X *    domain and can be used for any purposes at all, including
  333. X *    personal, commercial, military, blackmail, etc.
  334. X *
  335. X *    Have fun, folks.
  336. X *    ========================================================
  337. X *  Additional from D'Arcy:  I am including my changes in the
  338. X *  above release.
  339. X */
  340. X
  341. X#define        _KERNEL        1
  342. X#include    <limits.h>
  343. X#include    <sys/types.h>
  344. X#include    <sys/param.h>
  345. X#include    <sys/user.h>
  346. X#include    <sys/systm.h>
  347. X#include    <sys/sysmacros.h>
  348. X#include    <sys/inline.h>
  349. X#include    <sys/errno.h>
  350. X#include    <sys/signal.h>
  351. X#include    <sys/dir.h>
  352. X#include    <sys/clock.h>
  353. X#include    <sys/cmn_err.h>
  354. X
  355. X#define        LED_WIDTH    8
  356. X#define        LED_BLANKS    "        "
  357. X
  358. X#ifndef        LED_MAX_DEV
  359. X#define        LED_MAX_DEV        4
  360. X#endif
  361. X
  362. X#ifndef        LED_INIT_STR
  363. X#define        LED_INIT_STR    "led 2.0"
  364. X#endif
  365. X
  366. X#define        DEBUGx
  367. X
  368. X/*----------------------------------------------------------------------
  369. X * Everex 8042 UPI controller chip port defines
  370. X */
  371. X#define     DATA        0x60
  372. X#define     COMMAND        0x64
  373. X#define     STATUS        0x64
  374. X
  375. X#define     BUSY        0x02
  376. X
  377. X#define        waitbusy()    while (inb(STATUS)&BUSY)
  378. X
  379. Xstatic char    buf[LED_WIDTH];        /* the current display */
  380. Xstatic int    dev_open;            /* currently open devices */
  381. X
  382. X/* check priority of current process */
  383. X/* if higher device numbers are currently open then go to sleep */
  384. Xstatic void    chk_pri(int d)
  385. X{
  386. X    int        k = 1 << d;
  387. X
  388. X    d = -1 << d;
  389. X
  390. X    while ((dev_open & d) > k)
  391. X    {
  392. X#ifdef    DEBUG
  393. X        printf("\nled: priority - dev_open = %x, this = %d", dev_open, k);
  394. X#endif
  395. X
  396. X        /* woken up by ledclose */
  397. X        /* note that delays sleep on buf rather than &dev_open*/
  398. X        sleep((caddr_t)(&dev_open), PZERO + 2);
  399. X    }
  400. X}
  401. X
  402. Xstatic void    end_timeout(void)
  403. X{
  404. X#ifdef    DEBUG
  405. X    printf("\nled: Rise and shine");
  406. X#endif
  407. X
  408. X    wakeup((caddr_t)(buf));
  409. X}
  410. X
  411. X#ifndef        waitbusy
  412. Xstatic void    waitbusy(void)
  413. X{
  414. X    while (inb(STATUS) & BUSY)
  415. X    {
  416. X        timeout(end_timeout, NULL, 1);
  417. X        sleep((caddr_t)(buf), PZERO + 2);
  418. X    }
  419. X}
  420. X#endif
  421. X
  422. X/*----------------------------------------------------------------------
  423. X * This routine outputs the current display in buf to the leds
  424. X */
  425. Xstatic void    out_buf(void)
  426. X{
  427. X    int        k;
  428. X
  429. X    waitbusy();
  430. X    outb(COMMAND, 0xb0);
  431. X
  432. X    for (k = 0; k < LED_WIDTH; k++)
  433. X    {
  434. X        waitbusy();
  435. X        outb(DATA, buf[k]);
  436. X    }
  437. X}
  438. X
  439. X/*----------------------------------------------------------------------
  440. X * This routine outputs a string.  An arg of NULL outputs the signon
  441. X * string.  At most LED_WIDTH characters are output.  If there are
  442. X * less characters, the output is space padded.
  443. X */
  444. Xstatic void    out_str(const char *str, int d)
  445. X{
  446. X    int        k;
  447. X
  448. X    chk_pri(d);
  449. X
  450. X    if (!str)
  451. X        str = LED_INIT_STR;
  452. X
  453. X    /* fill buffer with up to 8 characters padding with spaces if necessary */
  454. X    for (k = 0; k < LED_WIDTH; k++)
  455. X        if (*str)
  456. X            buf[k] = *str++;
  457. X        else
  458. X            buf[k] = ' ';
  459. X
  460. X    out_buf();
  461. X}
  462. X
  463. X/*----------------------------------------------------------------------
  464. X * This routine outputs a character.  If the argument is -1 then it
  465. X * displays the signon message (defined in the make file.)  The
  466. X * output (other than the signon) scrolls across the leds.
  467. X */
  468. Xstatic void    out_char(int c, int d)
  469. X{
  470. X    int        k;
  471. X
  472. X    timeout(end_timeout, (caddr_t)(0), (long)(HZ/10));
  473. X    sleep((caddr_t)(buf), PZERO + 2);
  474. X    
  475. X    chk_pri(d);
  476. X    
  477. X    for (k = 0; k < LED_WIDTH - 1; k++)
  478. X        buf[k] = buf[k + 1];
  479. X
  480. X    buf[k] = c;
  481. X    out_buf();
  482. X}
  483. X
  484. X/*----------------------------------------------------------------------
  485. X * ledinit()
  486. X *
  487. X *    This is called by the kernel early in the boot sequence, and we
  488. X *    simply display some more reasonable message here instead of the
  489. X *    last cylinder accessed by the BIOS.  This can be whatever you like,
  490. X *    Define your message in the make file.
  491. X *
  492. X *    Be creative!
  493. X */
  494. Xvoid ledinit(void)
  495. X{
  496. X    printf("LED Device driver\n");
  497. X    dev_open = 0;        /* all devices closed */
  498. X    out_str(NULL, 0);    /* display signon */
  499. X}
  500. X
  501. X/*----------------------------------------------------------------------
  502. X * ledwrite()
  503. X *
  504. X *    Do the actual write to the display.
  505. X */
  506. Xvoid ledwrite(dev_t dev)
  507. X{
  508. X    int            d, k;
  509. X    static int    sp = 0;        /* precede next with space flag */
  510. X
  511. X    /*--------------------------------------------------------------
  512. X     * grab the characters from the user space and return a fault
  513. X     * error on a bad address.  CRs and LFs cause the display to
  514. X     * pause for 1 second while FFs display the signon message.
  515. X     * the other control characters are printed.  Try them to
  516. X     * see what they display.
  517. X     */
  518. X
  519. X    if ((d = minor(dev)) < 0 || d >= LED_MAX_DEV)
  520. X        u.u_error = ENXIO;
  521. X    else while (u.u_count)
  522. X    {
  523. X        if ((k = cpass()) == '\n' || k == '\r')
  524. X        {
  525. X            sp = 2;
  526. X
  527. X            timeout(end_timeout, (caddr_t)(0), (long)(HZ));
  528. X            sleep((caddr_t)(buf), PZERO + 2);
  529. X        }
  530. X        else if (k == '\f')
  531. X            out_str(NULL, d);
  532. X        else if (k == '\t')
  533. X            out_char(' ', d);
  534. X        else
  535. X        {
  536. X            if (sp)
  537. X                out_char(' ', d);
  538. X
  539. X            out_char(k, d);
  540. X        }
  541. X
  542. X        if (sp)
  543. X            sp--;
  544. X    }
  545. X}
  546. X
  547. X/* open clears the display */
  548. Xvoid    ledopen(dev_t dev)
  549. X{
  550. X    int        d;
  551. X
  552. X#ifdef    DEBUG
  553. X    printf("\nledopen: dev = %x", dev);
  554. X#endif
  555. X
  556. X    if ((d = minor(dev)) < 0 || d >= LED_MAX_DEV)
  557. X        u.u_error = ENXIO;
  558. X    else if ((1 << d) & dev_open)
  559. X        u.u_error = EBUSY;
  560. X    else
  561. X    {
  562. X#ifdef    DEBUG
  563. X        printf("\nledopen: d = %x, 1 << d = %x", d, 1 << d);
  564. X#endif
  565. X
  566. X        dev_open |= (1 << d);
  567. X        out_str(LED_BLANKS, d);
  568. X    }
  569. X
  570. X#ifdef    DEBUG
  571. X    printf("\nledopen: error = %d, d = %x, 1<<d = %x", u.u_error, d, 1 << d);
  572. X#endif
  573. X}
  574. X
  575. Xvoid    ledclose(dev_t dev)
  576. X{
  577. X    int        d;
  578. X
  579. X    if ((d = minor(dev)) < 0 || d >= LED_MAX_DEV)
  580. X        u.u_error = ENXIO;
  581. X    else
  582. X        dev_open &= ~(1 << d);
  583. X
  584. X#ifdef    DEBUG
  585. X    printf("\nled: Close device %d", d);
  586. X#endif
  587. X
  588. X    wakeup((caddr_t)(&dev_open));
  589. X}
  590. X
  591. X/*
  592. X * ioctl function allows signon message to be displayed (function
  593. X * 0) or any string to be display (1).  In the case of function 1
  594. X * the last argument points to the string.
  595. X*/
  596. Xint ledioctl(dev_t dev, int cmd, char *cmdarg)
  597. X{
  598. X    int        d;
  599. X
  600. X    if ((d = minor(dev)) < 0 || d >= LED_MAX_DEV)
  601. X        u.u_error = ENXIO;
  602. X    else if (cmd == 0)
  603. X        out_str(NULL, d);
  604. X    else if (cmd == 1)
  605. X    {
  606. X        int        k;
  607. X
  608. X        chk_pri(d);
  609. X
  610. X        for (k = 0; k < LED_WIDTH; k++)
  611. X            if (*cmdarg)
  612. X                buf[k] = *cmdarg++;
  613. X            else
  614. X                buf[k] = ' ';
  615. X
  616. X        out_buf();
  617. X    }
  618. X    else
  619. X        u.u_error = EINVAL;
  620. X}
  621. END_OF_FILE
  622. if test 7859 -ne `wc -c <'led.c'`; then
  623.     echo shar: \"'led.c'\" unpacked with wrong size!
  624. fi
  625. # end of 'led.c'
  626. fi
  627. if test -f 'ledtime.1' -a "${1}" != "-c" ; then 
  628.   echo shar: Will not clobber existing file \"'ledtime.1'\"
  629. else
  630. echo shar: Extracting \"'ledtime.1'\" \(609 characters\)
  631. sed "s/^X//" >'ledtime.1' <<'END_OF_FILE'
  632. X\" t
  633. X.TH LEDTIME 1
  634. X.de I
  635. X\fI\\$0\fR
  636. X..
  637. X.SH NAME
  638. Xledtime - Displays time on Everex front panel
  639. X.SH DESCRIPTION
  640. XThis program displays the time on the front panel LEDs
  641. Xon an Everex Step machine.  It requires that the LED driver be installed.
  642. X.SH FILES
  643. X/dev/ledclock
  644. X.SH SEE ALSO
  645. Xled(7)
  646. X.SH AUTHOR
  647. XStephen J. Friedl (fred@mtndew.Tustin.CA.US)
  648. X.br
  649. XD'Arcy J.M. Cain (darcy@druid.UUCP)
  650. X.SH COPYRIGHT
  651. XIn the spirit of free interchange of (hopefully) high
  652. Xquality software, this driver is released to the public
  653. Xdomain and can be used for any purposes at all, including
  654. Xpersonal, commercial, military, blackmail, etc.
  655. END_OF_FILE
  656. if test 609 -ne `wc -c <'ledtime.1'`; then
  657.     echo shar: \"'ledtime.1'\" unpacked with wrong size!
  658. fi
  659. # end of 'ledtime.1'
  660. fi
  661. if test -f 'ledtime.c' -a "${1}" != "-c" ; then 
  662.   echo shar: Will not clobber existing file \"'ledtime.c'\"
  663. else
  664. echo shar: Extracting \"'ledtime.c'\" \(1509 characters\)
  665. sed "s/^X//" >'ledtime.c' <<'END_OF_FILE'
  666. X/*
  667. X * ledtime()
  668. X *
  669. X * written by:    Stephen J. Friedl
  670. X *        V-Systems, Inc.
  671. X *        +1 714 545 6442
  672. X *        friedl@mtndew.Tustin.CA.US
  673. X *
  674. X *  Modified to use ioctl() by D'Arcy J.M. Cain (darcy@druid.UUCP)
  675. X *
  676. X *    This program sits in the background and writes the current time to the
  677. X *  led device via ioctl function 1 so the Everex front-panel display always
  678. X *  shows the time.  This is run from inittab.  If you prefer not to run this
  679. X *  change the relevant line in the Makefile.
  680. X *
  681. X *    This is in the public domain (not that you couldn't figure
  682. X *    this out in about two minutes anyway).
  683. X */
  684. X
  685. X#include    <stdio.h>
  686. X#include    <stdlib.h>
  687. X#include    <string.h>
  688. X#include    <errno.h>
  689. X#include    <unistd.h>
  690. X#include    <fcntl.h>
  691. X#include    <time.h>
  692. X
  693. Xint        main(int argc, char **argv)
  694. X{
  695. X    const char    *led_device = "/dev/ledclock";
  696. X    struct tm    *tm;
  697. X    time_t        now;        /* current UNIX time            */
  698. X    int            led;        /* LED device                    */
  699. X    char        buf[40];    /* buffer for the time string    */
  700. X
  701. X    if (argc > 1)        /* we can name led device if we want */
  702. X        led_device = argv[1];
  703. X
  704. X    if ((led = open(led_device, O_WRONLY)) == -1)
  705. X    {
  706. X        fprintf(stderr, "Can't open %s - %s", led_device, strerror(errno));
  707. X        return(1);
  708. X    }
  709. X
  710. X    for (;;)
  711. X    {
  712. X        time(&now);
  713. X        tm = localtime(&now);
  714. X
  715. X#ifdef    CLOCK12
  716. X        if (tm->tm_hour > 12)
  717. X            tm->tm_hour -= 12;
  718. X        else if (!tm->tm_hour)
  719. X            tm->tm_hour = 12;
  720. X
  721. X        sprintf(buf, "%2d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
  722. X#else
  723. X        sprintf(buf, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
  724. X#endif
  725. X        ioctl(led, 1, buf);
  726. X        sleep(1);
  727. X    }
  728. X}
  729. END_OF_FILE
  730. if test 1509 -ne `wc -c <'ledtime.c'`; then
  731.     echo shar: \"'ledtime.c'\" unpacked with wrong size!
  732. fi
  733. # end of 'ledtime.c'
  734. fi
  735. echo shar: End of archive 1 \(of 1\).
  736. cp /dev/null ark1isdone
  737. MISSING=""
  738. for I in 1 ; do
  739.     if test ! -f ark${I}isdone ; then
  740.     MISSING="${MISSING} ${I}"
  741.     fi
  742. done
  743. if test "${MISSING}" = "" ; then
  744.     echo You have the archive.
  745.     rm -f ark[1-9]isdone
  746. else
  747.     echo You still need to unpack the following archives:
  748.     echo "        " ${MISSING}
  749. fi
  750. ##  End of shell archive.
  751. exit 0
  752.