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. */
39 static int32 oldbits[MAXDEV], bitsleft[MAXDEV];
42 static FILE *dumpfile; /* REG dump file handle */
43 static unsigned char dumpbuf[1024]; /* REG dump buffer */
44 static int dumpptr = 0; /* Pointer into dump buffer */
47 static int32 OpenDev(DevOpts *opts) {
54 for (i = 0; i < 37; i++) {
55 seed = (seed << 3) ^ LEnextByte();
59 for (i = 0; i < (seed & 0x37); i++) {
65 static int32 Sample(int32 dd, uint16 bits) {
72 sum += (oldbits[dd] & 0x01);
79 dumpbuf[dumpptr++] = c1;
80 if (dumpptr >= sizeof(dumpbuf)) {
81 fwrite(dumpbuf, sizeof(dumpbuf), 1, dumpfile);
93 #define SAMP_PERIOD 1000 /* msec */
94 #define MARGIN .95 /* how much to headroom to allow in
97 static int32 EvalSpeed(int32 dd) {
98 struct timeval start, end;
101 gettimeofday(&start, NULL);
104 gettimeofday(&end, NULL);
105 if (deltams(&end, &start) >= SAMP_PERIOD) break;
106 samp = Sample(dd, 1);
110 return (int32)(bitct * MARGIN);
113 static int32 Discard(int32 dd) {
121 static int32 CloseDev(int32 dd) {
125 /* Driver description table. */
127 REG_driver REG_pseudo = {