2 * FILE: $Header: /home/egg/src/RCS/reg_pseudo.c,v 1.1 1998/12/31 22:04:39 ghn Exp $
3 * PURPOSE: PEAR (Bradish box/micro-REG) hardware interface
7 * REVISED: $Log: reg_pseudo.c,v $
8 * REVISED: Revision 1.1 1998/12/31 22:04:39 ghn
9 * REVISED: Initial revision
11 * REVISED: Revision 1.3 1998/08/01 18:50:39 ghn
12 * REVISED: Added John's byte-order-independence changes and PSEUDO support.
14 * REVISED: Revision 1.2 1998/08/01 17:13:51 ghn
15 * REVISED: Added John's Solaris support and DUMPREG option.
17 * REVISED: Revision 1.1 1998/07/21 11:37:41 ghn
18 * REVISED: Initial revision
20 * Copyright 1998 - Greg Nelson
21 * Redistributable under the terms of the GNU Public Licence (GPL)
24 /* Define this to dump samples from the REG which we actually use into
25 a file named dumpreg.dat. */
38 static int32 oldbits[MAXDEV], bitsleft[MAXDEV];
41 static FILE *dumpfile; /* REG dump file handle */
42 static unsigned char dumpbuf[1024]; /* REG dump buffer */
43 static int dumpptr = 0; /* Pointer into dump buffer */
46 static int32 OpenDev(DevOpts *opts) {
53 for (i = 0; i < 37; i++) {
54 seed = (seed << 3) ^ LEnextByte();
58 for (i = 0; i < (seed & 0x37); i++) {
64 static int32 Sample(int32 dd, uint16 bits) {
71 sum += (oldbits[dd] & 0x01);
78 dumpbuf[dumpptr++] = c1;
79 if (dumpptr >= sizeof(dumpbuf)) {
80 fwrite(dumpbuf, sizeof(dumpbuf), 1, dumpfile);
92 #define SAMP_PERIOD 1000 /* msec */
93 #define MARGIN .95 /* how much to headroom to allow in
96 static int32 EvalSpeed(int32 dd) {
97 struct timeval start, end;
100 gettimeofday(&start, NULL);
103 gettimeofday(&end, NULL);
104 if (deltams(&end, &start) >= SAMP_PERIOD) break;
105 samp = Sample(dd, 1);
109 return (int32)(bitct * MARGIN);
112 static int32 Discard(int32 dd) {
120 static int32 CloseDev(int32 dd) {
124 /* Driver description table. */
126 REG_driver REG_pseudo = {