summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpatlooptest.c110
-rwxr-xr-xtor2.c13
2 files changed, 123 insertions, 0 deletions
diff --git a/patlooptest.c b/patlooptest.c
new file mode 100755
index 0000000..605f254
--- /dev/null
+++ b/patlooptest.c
@@ -0,0 +1,110 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <linux/zaptel.h>
+#include <stdio.h>
+#include <linux/types.h>
+#include <linux/ppp_defs.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#define BLOCK_SIZE 2039
+
+void print_packet(unsigned char *buf, int len)
+{
+ int x;
+ printf("{ ");
+ for (x=0;x<len;x++)
+ printf("%02x ",buf[x]);
+ printf("}\n");
+}
+
+int main(int argc, char *argv[])
+{
+ int fd;
+ int fd2;
+ int ires, res, x;
+ int i;
+ ZT_PARAMS tp;
+ int bs = BLOCK_SIZE;
+ int skipcount = 10;
+ unsigned char c=0,c1=0;
+ unsigned char inbuf[BLOCK_SIZE];
+ unsigned char outbuf[BLOCK_SIZE];
+ unsigned int fcs;
+ static int packets=0;
+ int setup=0;
+ int errors=0;
+ int bytes=0;
+ if (argc < 2) {
+ fprintf(stderr, "Usage: markhdlctest <zaptel device>\n");
+ exit(1);
+ }
+ fd = open(argv[1], O_RDWR, 0600);
+ if (fd < 0) {
+ fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+ exit(1);
+ }
+ if (ioctl(fd, ZT_SET_BLOCKSIZE, &bs)) {
+ fprintf(stderr, "Unable to set block size to %d: %s\n", bs, strerror(errno));
+ exit(1);
+ }
+ if (ioctl(fd, ZT_GET_PARAMS, &tp)) {
+ fprintf(stderr, "Unable to get channel parameters\n");
+ exit(1);
+ }
+ ioctl(fd, ZT_GETEVENT);
+
+ i = ZT_FLUSH_ALL;
+ if (ioctl(fd,ZT_FLUSH,&i) == -1)
+ {
+ perror("tor_flush");
+ exit(255);
+ }
+
+ for(;;) {
+ res = bs;
+ for (x=0;x<bs;x++)
+ outbuf[x] = c1++;
+
+ res = write(fd,outbuf,bs);
+ if (res != bs)
+ {
+ printf("Res is %d\n", res);
+ exit(1);
+ }
+
+ if (skipcount)
+ {
+ if (skipcount > 1) read(fd,inbuf,bs);
+ skipcount--;
+ if (!skipcount) puts("Going for it...");
+ continue;
+ }
+
+ res = read(fd, inbuf, bs);
+ if (res < bs) {
+ printf("Res is %d\n", res);
+ exit(1);
+ }
+ if (!setup) {
+ c = inbuf[0];
+ setup++;
+ }
+ for (x=0;x<bs;x++) {
+ if (inbuf[x] != c) {
+ printf("(Error %d): Unexpected result, %d != %d, %d bytes since last error.\n", ++errors, inbuf[x],c, bytes);
+ c = inbuf[x];
+ bytes=0;
+ }
+ c++;
+ bytes++;
+ }
+#if 0
+ printf("(%d) Wrote %d bytes\n", packets++, res);
+#endif
+ }
+
+}
diff --git a/tor2.c b/tor2.c
index cb93702..40f59f4 100755
--- a/tor2.c
+++ b/tor2.c
@@ -135,12 +135,15 @@ static void tor2_tasklet(unsigned long data);
#define LEDREG 0x402
#define STATREG 0x400
#define SWREG 0x401
+#define CTLREG1 0x404
#define INTENA (1 + ((loopback & 3) << 5))
#define OUTBIT (2 + ((loopback & 3) << 5))
#define E1DIV 0x10
#define INTACK (0x80 + ((loopback & 3) << 5))
#define INTACTIVE 2
+/* un-define this if you dont want NON-REV A hardware support */
+/* #define NONREVA 1 */
#define SYNCSELF 0
#define SYNC1 1
@@ -474,7 +477,17 @@ static int __devinit tor2_probe(struct pci_dev *pdev, const struct pci_device_id
tor->mem8[SYNCREG] = 0;
tor->mem8[CTLREG] = 0;
+ tor->mem8[CTLREG1] = 0;
tor->mem8[LEDREG] = 0;
+
+ /* check part revision data */
+ x = t1in(tor,1,0xf) & 15;
+#ifdef NONREVA
+ if (x > 3)
+ {
+ tor->mem8[CTLREG1] = NONREVA;
+ }
+#endif
for(x = 0; x < 256; x++) tor->mem32[x] = 0x7f7f7f7f;