summaryrefslogtreecommitdiff
path: root/packages/sccd
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
committerDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
commit709c4d66e0b107ca606941b988bad717c0b45d9b (patch)
tree37ee08b1eb308f3b2b6426d5793545c38396b838 /packages/sccd
parentfa6cd5a3b993f16c27de4ff82b42684516d433ba (diff)
rename packages/ to recipes/ per earlier agreement
See links below for more details: http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326 http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816 Signed-off-by: Denys Dmytriyenko <denis@denix.org> Acked-by: Mike Westerhof <mwester@dls.net> Acked-by: Philip Balister <philip@balister.org> Acked-by: Khem Raj <raj.khem@gmail.com> Acked-by: Marcin Juszkiewicz <hrw@openembedded.org> Acked-by: Koen Kooi <koen@openembedded.org> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'packages/sccd')
-rw-r--r--packages/sccd/files/Makefile52
-rw-r--r--packages/sccd/files/README220
-rw-r--r--packages/sccd/files/init-sccd38
-rw-r--r--packages/sccd/files/scc-disk.c167
-rw-r--r--packages/sccd/files/scc-utils.c376
-rw-r--r--packages/sccd/files/scc.1120
-rw-r--r--packages/sccd/files/scc.c412
-rw-r--r--packages/sccd/files/scc.h118
-rw-r--r--packages/sccd/files/sccd.c523
-rw-r--r--packages/sccd/sccd_1.0.bb28
10 files changed, 0 insertions, 2054 deletions
diff --git a/packages/sccd/files/Makefile b/packages/sccd/files/Makefile
deleted file mode 100644
index 650404643d..0000000000
--- a/packages/sccd/files/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2006
-# Protium Computing, Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. All advertising materials mentioning features or use of this software
-# must display the following acknowledgement:
-# This product includes software developed by Protium Computing, Inc.
-# 4. The name of Protium Computing, Inc. may not be used to endorse or
-# promote products derived from this software without specific prior
-# written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY PROTIUM COMPUTING ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL PROTIUM COMPUTING BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-TARGETS=sccd scc
-
-all: $(TARGETS)
-
-sccd: scc-disk.o scc-utils.o sccd.o
- $(CC) $(CFLAGS) -o sccd scc-utils.o scc-disk.o sccd.o
-
-scc: scc-utils.o scc.o
- $(CC) $(CFLAGS) -o scc scc-utils.o scc.o
-
-install: $(TARGETS)
- install -d $(DESTDIR)/sbin
- install -m 755 sccd $(DESTDIR)/sbin/sccd
- install -m 755 scc $(DESTDIR)/sbin/scc
- install -d $(DESTDIR)/etc/init.d
- install -m 755 init-sccd $(DESTDIR)/etc/init.d/sccd
- install -d $(DESTDIR)/usr/share/man/man1
- install -m 644 scc.1 $(DESTDIR)/usr/share/man/man1/scc.1
-
-clean:
- rm -f $(TARGETS) *.o core
diff --git a/packages/sccd/files/README b/packages/sccd/files/README
deleted file mode 100644
index d2d1934dd4..0000000000
--- a/packages/sccd/files/README
+++ /dev/null
@@ -1,220 +0,0 @@
- Iomega G2 MC68HC908QY4 Support Notes
- October 2006
-
-The Iomega G2 Version 3.x and 5.x boards have a secondary microcontroller
-aboard, a Freescale MC68HC908QY4. This microcontroller is connected to the
-board's LED, fan, digital thermometer, power switch, and main processor, the
-MPC8241. The connection to the main processor is through the 8241's second
-UART and possibly its reset lines.
-
-The microcontroller can perform the following functions:
- o The LED can be set to off, blue, red, blue flash, red flash,
- alternate (blue->red->blue) and some boards alternate3
- (blue->blue->blue->red->red->red). The flash and alernate rates
- can be be set. Alternate3 rate is fixed.
- o Fan can be set to on or auto. Auto mode is a thermostat function
- that turns the fan on and off based on two temprature settings:
- Fan Temp High and Fan Temp Low.
- o The system can be reset, causing a MPC8241 reset, or stopped,
- causing a full power down.
- o The microcontroller can detect if the soft power switch has been
- activated. There appears to a 20s delay after the power switch
- has been depressed before the microcontroller causes an actual
- power off. This event can be detected by polling the
- microcontroller.
-
-The running system communicates with microcontroller and ultimately controls
-the devices connected to it via the MPC8241's second UART. The connection
-settings are: 9600,8,n,1. The serial protocol is very simple, an alternating
-send and receive of data packets. Communication is done in 8 byte data packets
-and is initiated by the host processor. Once the host processor has sent 8
-bytes, the microcontroller responds with 8 bytes. The packet contains bytes
-that can affect the state of the power, led and fan. It also contains bits
-reflecting external soft power events. Both packets sent and received follow
-the same structure.
-
-The 8 bytes are decoded as follows:
-
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Power | LED | LED | Fan |
- | State | State | Flash Rate | State |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Fan High Temp | Fan Low Temp | | |
- | ON | OFF | ID | CheckSum |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Hex Ascii Comments
- --- ----- --------------------------------------------------
-Power State:
- 0x62 b Running, nominal running state
- 0x63 c Stop, power down immediately (ID == HOST) OR
- Stop, the power switch has been activated, stop in 20s
- (ID == CONTROLLERxx) OR
- Stop, the host has advised Stop
- (ID == CONTROLLERxx)
- 0x64 d Advise Stop, the host is annoucing its intention
- to stop (ID == HOST)
- 0x65 e Restart, restart immediately (ID == HOST) OR
- Restart, the host has advised Restart
- (ID == CONTROLLERxx)
- 0x66 f Advise Restart, the host is annoucing its intention
- to restart (ID == HOST)
- 0x67 g Reset, reset immediately (ID == HOST) OR
- Reset, the host has advised Reset
- (ID == CONTROLLERxx)
- 0x68 h Advise Reset, the host is annoucing its intention
- to reset (ID == HOST)
-
-Except for Running, the Power states are grouped in pairs: Advise [state] and
-[state], where state can be: Stop, Restart, or Reset. The Advise state lets
-the controller know that there is an intention to either stop, restart or
-reset the board. The controller responds by moving to that state and setting
-the LED to redflash, but it does not enact the power change. Instead it waits
-for the host to issue the actual state before performing the power commands.
-For example, assume the microcontroller is reporting the power state to be
-[Running, LED Blue]. After the host issues a Advise Stop, the microcontroller
-reports [Stop, LED Redflash] and then waits, indefinitely. The Host then
-issues a Stop, the microcontroller immediately turns the power off.
-
-There is nothing in the protocol that requires the Advise [state] packets. The
-Host can issue a Stop, Restart, or Reset directly from the Running state and
-the microcontroller will immediately enact the change.
-
-There is nothing in the protocol that forbids moving back to Running from the
-Stop, Restart or Reset states, i.e. undoing an Advise [state] packet.
-
-The exception to that rule is in the Stop state. The Stop state can be reached
-by either issuing a Advise Stop or from a softpower switch activation (someone
-hits the power switch). If the latter, then a request to move to any other
-state is ignored and the power will go off in approximately 20s.
-
-NOTE 1: There does not appear to be any difference in processing the Restart
-and Reset state changes. They both deliver a system restart.
-
-NOTE 2: Obvious absence of an 'a' state. Both the LED and Fan controls use 'a'
-as a state, but Power starts with 'b'. No evidence has shown 'a' to be a
-valid state.
-
-LED State:
- 0x61 a Off
- 0x62 b Blue
- 0x63 c Red
- 0x64 d Blue Flash
- 0x65 e Red Flash
- 0x66 f Alternate1 Blue/Red
- 0x67 g Alternate3 3 Blue/3 Red (only on version 5.x boards)
-
-LED States are self explanatory with one exception. Although state 'g' or
-Alternate3 has been observed, it only seems to function on IOMEGA G2 Version
-5.x boards and does not respond to rate changes.
-
-LED Flash Rate:
-The flash rate seems to be 1/x seconds on, then 1/x seconds off. So one cycle
-of off and on at an LED Flash rate of 1 is almost 2s. The value spans 8 bits
-but functionally 0 is off and 36-40 is on. Testing has shown an oddity, the
-value 35 is rejected by the microcontroller software and is not set.
-
-Fan State:
- 0x61 a Auto thermostat function
- 0x62 b On always on
-
-Fan High Temp:
-High Temp is the temprature in Celsius where the fan is be turned on.
-
-Fan Low Temp:
-Low Temp is the temprature in Celsius where the fan is be turned off.
-
-ID:
-The real purpose of this field is not known. It is known that it is a constant
-depending upon the direction of the packets and the board rev. It has been
-designated ID as a place holder but it could as easily be defined as version
-or it may be something else entirely.
-
- 0x00 DC2 CONTROLLER00
- IOMEGA G2 Version 5.x Controller ID (recv'd packets)
- 0x07 BEL HOST (sent packets)
- 0x12 DC2 CONTROLLER12
- IOMEGA G2 Version 3.x Controller ID (recv'd packets)
-
-Checksum:
-The check sum is an 8 bit sum of the first 7 bytes with the most significant
-bit cleared.
-
- Sum = ((b1 + b2 + b3 +b4 +b5 +b6 + b7) & 0x7f)
-
-The bytes and their meanings were determined by watching the serial port
-chatter during specific events such as LED Blue, LED Red, Fan ON, etc. So only
-events observed have been decoded. Although all the significant events were
-observed and decoded, there are some holes in the understanding of the
-protocol.
-
-There is one special packet that causes the microcontroller to reset. This
-packet is:
- 0x23696f6d 0x65676115
- (or as a string "#iomega\025")
-
-The resulting packet from the microcontroller is:
- 0x62000000 0x00000062
-
-Testing also yielded that a null packet will cause the microcontroller to
-feed back the current state. So this packet:
- 0x00000000 0x00000000
-
-will yield something like this (this is the default state):
- 0x62620a61 0x322d1220
-
-The default state when the board powers on is:
- State: Run
- LED: Red
- LED Rate: 10
- Fan: On
- Fan Temp High: 50C
- Fan Temp Low: 45C
-
-Below is some of the data collected while watching the serial port chatter:
-
-w: 0x23696f6d 0x65676115 #iomega\025
-r: 0x62000000 0x00000062 b\0\0\0\0\0\0b
-w: 0x62630a61 0x322d0716 bc\na2-\7\26 red state
-r: 0x62630a61 0x322d1221 bc\na2-\22!
-w: 0x62641161 0x322d071e bd\21a2-\7\36 blue flash
-r: 0x62641161 0x322d1229 bd\21a2-\22)
-w: 0x62641161 0x322d071e bd\21a2-\7\36 blue flash
-
-LED ok
-w: 0x62620a61 0x322d0715 bb\na2-\7\25
-r: 0x62630a61 0x322d1220 bb\na2-\22
-
-LED alt
-w: 0x626f0a61 0x322d0719 bf\na2-\7\31
-r: 0x626f0a61 0x322d1224 bf\na2-\22$
-
-reset
-w: 0x68620a61 0x322d071b hb\na2-\7\33 reset
-r: 0x67620a61 0x322d0013 gb\na2-\0\23 resetting
-
-restart
-w: 0x66620a61 0x322d0719 fb\na2-\7\31 restart
-r: 0x65620a61 0x322d1223 eb\na2-\22# restarting
-
-shutdown
-w: 0x64620a61 0x322d0717 db\na2-\7\27 shutdown
-r: 0x63620a61 0x322d1221 cb\na2-\22! power shutting down
-
-soft Power
-r: 0x63620a61 0x322d000f cb\na2-\0\17 power shutting down
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/sccd/files/init-sccd b/packages/sccd/files/init-sccd
deleted file mode 100644
index 372bfeae91..0000000000
--- a/packages/sccd/files/init-sccd
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-#
-# This is an init script for open protium for storcenter
-# Copy it to /etc/init.d/sccd and type
-# > update-rc.d sccd defaults 60
-#
-sccd=/sbin/sccd
-test -x "$sccd" || exit 0
-
-case "$1" in
- start)
- echo -n "Starting StorCenter Control Daemon"
- start-stop-daemon --start --quiet --exec $sccd
- echo "."
- ;;
- stop)
- echo -n "Stopping StorCenter Control Daemon"
- start-stop-daemon --stop --quiet --pidfile /var/run/sccd.pid
- echo "."
- ;;
- reload|force-reload)
- start-stop-daemon --stop --quiet --signal 1 --exec $sccd
- ;;
- restart)
- echo -n "Stopping StorCenter Control Daemon"
- start-stop-daemon --stop --quiet --pidfile /var/run/sccd.pid
- echo "."
- sleep 1
- echo -n "Starting StorCenter Control Daemon"
- start-stop-daemon --start --quiet --exec $sccd
- echo "."
- ;;
- *)
- echo "Usage: /etc/init.d/sccd {start|stop|reload|restart|force-reload}"
- exit 1
-esac
-
-exit 0
diff --git a/packages/sccd/files/scc-disk.c b/packages/sccd/files/scc-disk.c
deleted file mode 100644
index 4fd494203a..0000000000
--- a/packages/sccd/files/scc-disk.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2006
- * Protium Computing, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Protium Computing, Inc.
- * 4. The name of Protium Computing, Inc. may not be used to endorse or
- * promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PROTIUM COMPUTING ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL PROTIUM COMPUTING BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/un.h>
-#include <sys/syslog.h>
-#include <sys/param.h>
-
-struct watch_table {
- char *wt_path;
- int wt_status;
- int wt_reads;
- int wt_writes;
-#define WT_INVALID 0
-#define WT_VALID 1
-#define WT_CHECK 2
-} iowt[] = {
- { "/sys/block/hda/stat", WT_CHECK, 0, 0},
- { "/sys/block/hdb/stat", WT_CHECK, 0, 0},
- { "/sys/block/hdc/stat", WT_CHECK, 0, 0},
- { "/sys/block/hdd/stat", WT_CHECK, 0, 0},
- { NULL, WT_INVALID, -1, -1}
-};
-
-/*
- * disk_activity() returns back the total number of read and writes done
- * by the devices listed in the io watch table since the last call to
- * disk_activity. The number of reads and writes are determined by
- * opening and reading each of the valid files listed in the io watch
- * table.The number of reads and writes are stored in the io watch table so
- * that the next call to this routine can compare the current number of read
- * and writes to those stored in the io watch table. The difference for
- * each device is summed in the activity variable. The routine lazy
- * evaluates the existance of the devices in the table.
- *
- * For the storcenter, we are only concerned with internal drives.
- *
- * The wt_path element must point at a diskstat file in the sysfs filesystem.
- * File format can be found at: /usr/src/linux/Documentation/iostats.txt
- * For this routine:
- * nr, nw - number read and writes
- * nmr, nmw - number of merged reads and writes
- * nsr, nsw - number of the sectors read and written
- * tr, tw - time spent reading and writing
- * nio - raw number of ios
- * tio, wtio - time spent and weighted time spent doing io
- */
-int
-disk_activity()
-{
- int activity = 0;
- char mesg[256];
- int rc, nr, nmr, nsr, tr, nw, nmw, nsw, tw, nio, tio, wtio;
- FILE *f;
-
- struct stat st;
- struct watch_table *w;
-
- for (w = iowt; w->wt_path; w++) {
- /*
- * If status ids set to check, do the lazy existence
- * evaluation. If stat fails set to invalid. Don't
- * worry about perms here.
- */
- if ((w->wt_status == WT_CHECK) &&
- (stat(w->wt_path, &st) < 0)) {
- sprintf(mesg, "%s not available", w->wt_path);
- syslog(LOG_INFO, mesg);
- w->wt_status = WT_INVALID;
- }
-
- /*
- * Short circuit the loop if invalid.
- */
- if (w->wt_status == WT_INVALID)
- continue;
-
- /*
- * If it can't be opened rdonly, set to invalid
- */
- if ((f = fopen(w->wt_path, "r")) < 0) {
- sprintf(mesg, "Unable to open %s, no longer watching",
- w->wt_path);
- syslog(LOG_INFO, mesg);
- w->wt_status = WT_INVALID;
- continue;
- }
-
- rc = fscanf(f, "%d %d %d %d %d %d %d %d %d %d %d",
- &nr, &nmr, &nsr, &tr,
- &nw, &nmw, &nsw, &tw,
- &nio, &tio, &wtio);
-
- fclose(f);
-
- if (rc != 11) {
- sprintf(mesg, "Unable to read %s", w->wt_path);
- syslog(LOG_INFO, mesg);
- continue;
- }
-
- /*
- * If we haven't seen any activity on this device before
- * then just save the values and go on. This, although
- * not strictly necessary, prevents the initial call to
- * disk_activity returning back the base set io activity.
- * Remember it takes two calls to get a true difference.
- */
- if ((w->wt_reads == 0) && (w->wt_writes == 0)) {
- w->wt_reads = nr;
- w->wt_writes = nw;
- continue;
- }
-
- activity += (nr - w->wt_reads);
- activity += (nw - w->wt_writes);
-
- w->wt_reads = nr;
- w->wt_writes = nw;
-
- /*
- printf("%s: %d %d %d %d %d %d %d %d %d %d %d\n",
- w->wt_path,
- nr, nmr, nsr, tr,
- nw, nmw, nsw, tw,
- nio, tio, wtio);
- */
- }
-
- return(activity);
-}
diff --git a/packages/sccd/files/scc-utils.c b/packages/sccd/files/scc-utils.c
deleted file mode 100644
index ab48ecb677..0000000000
--- a/packages/sccd/files/scc-utils.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (c) 2006
- * Protium Computing, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Protium Computing, Inc.
- * 4. The name of Protium Computing, Inc. may not be used to endorse or
- * promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PROTIUM COMPUTING ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL PROTIUM COMPUTING BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <fcntl.h>
-#include <time.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/select.h>
-#include <sys/syslog.h>
-#include <sys/resource.h>
-#include <termios.h>
-
-#include "scc.h"
-
-int scc_die = 0;
-
-char
-scc_cksum(int *i, int *j)
-{
- unsigned char s;
- unsigned char *b;
-
- b = (unsigned char *)i;
- s = b[0] + b[1] + b[2] + b[3];
- b = (unsigned char *)j;
- s = s + b[0] + b[1] + b[2];
- s = (s & 0x7f);
-
- return((char)s);
-}
-
-int
-scc_validate(int *i, int *j, int verbose)
-{
- int r, s;
-
- /* if (verbose) printf("Packet: [0x%08x 0x%08x]\n", *i, *j); */
-
- switch (*i & SCC_POWERMASK) {
- case SCC_RUN:
- if (verbose) printf("\tPower: run\n");
- break;
- case SCC_STOP:
- if (verbose) printf("\tPower: stop\n");
- break;
- case SCC_ADVISESTOP:
- if (verbose) printf("\tPower: advise stop\n");
- break;
- case SCC_RESTART:
- if (verbose) printf("\tPower: restart\n");
- break;
- case SCC_ADVISERESTART:
- if (verbose) printf("\tPower: advise restart\n");
- break;
- case SCC_RESET:
- if (verbose) printf("\tPower: reset\n");
- break;
- case SCC_ADVISERESET:
- if (verbose) printf("\tPower: advise reset\n");
- break;
- default:
- if (verbose) printf("validate: bad power 0x%08x\n", *i);
- return(-1);
- }
-
- switch (*i & SCC_LEDMASK) {
- case SCC_LEDOFF:
- if (verbose) printf("\tLed: off\n");
- break;
- case SCC_LEDBLUE:
- if (verbose) printf("\tLed: blue\n");
- break;
- case SCC_LEDRED:
- if (verbose) printf("\tLed: red\n");
- break;
- case SCC_LEDBLUEFLASH:
- if (verbose) printf("\tLed: blue flash\n");
- break;
- case SCC_LEDREDFLASH:
- if (verbose) printf("\tLed: red flash\n");
- break;
- case SCC_LEDALTERNATE1:
- if (verbose) printf("\tLed: alternate1\n");
- break;
- case SCC_LEDALTERNATE3:
- if (verbose) printf("\tLed: alternate3\n");
- break;
- default:
- if (verbose) printf("validate: bad led value 0x%08x\n", *i);
- return(-1);
- }
-
- r = ((*i & SCC_LEDRATEMASK) >> SCC_LEDRATESHIFT);
-
- if (verbose) {
- printf("\tLed Flash Rate: %d\n", r);
- }
-
- if (r >= SCC_LEDRATEHI)
- printf("warning: led rate too high - led on (%d)\n", r);
- if (r <= SCC_LEDRATELO)
- printf("warning: led rate too low - led off (%d)\n", r);
-
-
- switch (*i & SCC_FANMASK) {
- case SCC_FANAUTO:
- if (verbose) printf("\tFan: auto\n");
- break;
- case SCC_FANON:
- if (verbose) printf("\tFan: on\n");
- break;
- default:
- if (verbose) printf("validate: bad fan value 0x%08x\n", *i);
- return(-1);
- }
-
- r = ((*j & SCC_FANTEMPONMASK) >> SCC_FANTEMPONSHIFT);
- s = ((*j & SCC_FANTEMPOFFMASK) >> SCC_FANTEMPOFFSHIFT);
-
- if (verbose) {
- printf("\tFan On Temprature: %dC\n", r);
- printf("\tFan Off Temprature: %dC\n", s);
- }
-
- if (r >= SCC_FANTEMPONHI)
- printf("warning: fan on temp too high - fan off (%dC)\n", r);
- if (s <= SCC_FANTEMPONLO)
- printf("warning: fan on temp too low - fan on (%dC)\n", s);
- if ((r - s) < SCC_FANTEMPDIFF) {
- printf("warning: fan on/off temp too close or on < off \n");
- printf("warning:\tfan on (%dC) fan off (%dC) \n", r, s);
- }
-
- r = *j & SCC_IDMASK;
- if ((r != SCC_HOST) &&
- (r != SCC_CTLR00) &&
- (r != SCC_CTLR12)) {
- printf("warning: bad id %08x\n", r);
- }
-
- r = *j & SCC_CKSUMMASK;
- if (r != scc_cksum(i, j)) {
- printf("warning: checksum incorrect (%02x != %02x)\n",
- r, scc_cksum(i, j));
- }
- return(0);
-}
-
-int
-scc_setval(int *i, int mask, int val)
-{
- /* clear the field */
- *i = (*i & (mask ^ 0xffffffff));
-
- /* insert the field */
- *i = (*i ^ val);
- return(0);
-}
-
-int
-scc_setrate(int *i, int mask, int shift, int val)
-{
- /* Assumption: val is < field width */
-
- /* clear the field */
- *i = (*i & (mask ^ 0xffffffff));
-
- /* insert the field */
- *i = (*i ^ (val << shift));
- return(0);
-}
-
-int
-scc_defaults(int *i, int *j)
-{
- scc_setval(i, SCC_POWERMASK, SCC_POWERDEFAULT);
- scc_setval(i, SCC_LEDMASK, SCC_LEDDEFAULT);
- scc_setrate(i, SCC_LEDRATEMASK, SCC_LEDRATESHIFT, SCC_LEDRATEDEFAULT);
- scc_setval(i, SCC_FANMASK, SCC_FANDEFAULT);
-
- scc_setrate(j, SCC_FANTEMPONMASK,
- SCC_FANTEMPONSHIFT, SCC_FANTEMPONDEFAULT);
- scc_setrate(j, SCC_FANTEMPOFFMASK,
- SCC_FANTEMPOFFSHIFT, SCC_FANTEMPOFFDEFAULT);
- return(0);
-}
-
-void
-scc_sighandler(int sig)
-{
- /*
- * Just catch quit and term and set die
- */
- switch(sig) {
- case SIGQUIT:
- case SIGTERM:
- syslog(LOG_INFO, "Terminating");
- scc_die=1;
- break;
- }
-}
-
-int
-scc_daemonize(int cores)
-{
- int fd, i;
- char pidstr[20];
- pid_t pid;
-
- struct rlimit limit[1] = {{ 0, 0 }};
-
-
- if (!cores) {
- /*
- * No corefiles please
- */
- if (getrlimit(RLIMIT_CORE, limit) == -1) {
- perror("getrlimit");
- return -1;
- }
-
- limit->rlim_cur = 0;
-
- if (setrlimit(RLIMIT_CORE, limit) != 0) {
- perror("setrlimit");
- return -1;
- }
- }
-
- /*
- * Must be root
- */
- if (getuid() != 0) {
- fprintf(stderr, "Must be root\n");
- return -1;
- }
-
- /*
- * If parent isn't init, make it init.
- */
- if (getppid() != 1) {
-
- pid = fork();
- if (pid == -1) {
- return -1;
- }
- if (pid != 0) {
- exit(EXIT_SUCCESS);
- }
-
- setsid();
-
- /*
- * ignore sig hup so that when our new padre exits
- * the kinder won't exit
- */
- signal(SIGHUP, SIG_IGN);
-
- pid = fork();
- if (pid == -1) {
- return -1;
- }
- if (pid != 0) {
- exit(EXIT_SUCCESS);
- }
- }
-
- /*
- * Set working dir to root
- */
- chdir("/");
-
- /*
- * Make sure file creations are created with explicit perms
- */
- umask(0);
-
- /*
- * Close all FDs
- */
- for (i = 0; i < sysconf(_SC_OPEN_MAX); i++) {
- close(i);
- }
-
- /*
- * set std in, out, err to /dev/null
- */
- for (i = 0; i < 3; i++) {
-
- if ((fd = open("/dev/null", (i==0?O_RDONLY:O_WRONLY))) == -1) {
- perror("setting up stdin, stdout, stderr");
- return -1;
- }
-
- if (i != fd) {
- if (dup2(fd, i) == -1) {
- perror("setting up stdin, stdout, stderr");
- return -1;
- }
- close(fd);
- }
- }
-
- /*
- * Open and lock the pid file. Ensures only one daemon
- * Write our pid into the file
- */
- fd = open(SCC_PIDFILE, O_RDWR|O_CREAT, 0640);
- if (fd < 0) {
- return(-1);
-
- }
-
- if (lockf(fd, F_TLOCK, 0) < 0) {
- /* we are not alone */
- close(fd);
- return(-1);
- }
-
- sprintf(pidstr,"%-6d\n", getpid());
- write(fd, pidstr, strlen(pidstr));
-
- /*
- * Open syslog
- */
- openlog("sccd", LOG_PID, LOG_DAEMON);
- syslog(LOG_INFO, "Starting");
-
- /*
- * Ignore some signals and handle others
- */
- signal(SIGCHLD, SIG_IGN);
- signal(SIGTSTP, SIG_IGN);
- signal(SIGTTOU, SIG_IGN);
- signal(SIGTTIN, SIG_IGN);
- signal(SIGQUIT, scc_sighandler);
- signal(SIGTERM, scc_sighandler);
-
- return(0);
-}
-
-
diff --git a/packages/sccd/files/scc.1 b/packages/sccd/files/scc.1
deleted file mode 100644
index be27a569c3..0000000000
--- a/packages/sccd/files/scc.1
+++ /dev/null
@@ -1,120 +0,0 @@
-.\" Copyright (c) 2006
-.\" Protium Computing, Inc. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by Protium Computing, Inc.
-.\" 4. The name of Protium Computing, Inc. may not be used to endorse or
-.\" promote products derived from this software without specific prior
-.\" written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY PROTIUM COMPUTING ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL PROTIUM COMPUTING BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.TH SCC "1" "November 2006" "scc 1.0" "User Commands"
-.SH NAME
-scc \- StorCenter Control Utility
-.SH SYNOPSIS
-.B scc
-\fI[OPTIONS]\fR ...
-.SH DESCRIPTION
-scc controls the Iomega StorCenter's LED, fan and soft power. It does this
-either by sending a message to the StorCenter Control Daemon, if available,
-or directly communicating with the StorCenter's microcontroller responsible
-for these devices.
-.PP
-The scc utility can perform the following functions:
-.TP
-\fB\fR
-The LED can be set to off, blue, red, blue flash, red flash,
-alternate (blue->red->blue) and on some boards alternate3
-(blue->blue->blue->red->red->red). The flash and alernate rates
-can be be set. Alternate3 rate is fixed.
-.TP
-\fB\fR
-Fan can be set to on or auto. Auto mode is a thermostat function
-that turns the fan on and off based on two temprature settings:
-Fan Temp High and Fan Temp Low.
-.TP
-\fB\fR
-The system can be reset, causing a StorCenter reset, or stopped,
-causing a full power down.
-.SH OPTIONS
-.TP
-\fB\-?\fR
-display this help and exit
-.TP
-\fB\-d\fR
-send send directly, stop/restart only
-.TP
-\fB\-p POWER\fR
-control soft power
-.br
-POWER=[run|off|restart]
-.TP
-\fB\-l LED\fR
-control LED state
-.br
-LED=[off|blue|red|blueflash|redflash|alternate|alternate3]
-.TP
-\fB\-r RATE\fR
-Rate the LED flashes (0<=RATE<256)
-.TP
-\fB\-f FAN\fR
-control fan operation
-.br
-FAN=[auto|on]
-.TP
-\fB\-h TEMP\fR
-Hot temp when FAN=auto should go on (0<=TEMP<256)
-.TP
-\fB\-c TEMP\fR
-Cold temp when FAN=auto should go off (0<=TEMP<256)
-.SH NOTES
-Care should be taken when changing the LED. The boot scripts and the
-.B sccd
-daemon use LED colors to indicate boot and disk activity. Changing the LED can
-cause some of these functions to be disabled.
-.SH AUTHOR
-Written by Philip Kufeldt.
-.SH "REPORTING BUGS"
-Report bugs at www.openprotium.org.