This source file includes following definitions.
- teles_readstatus
- teles_putstatus
- ll_init
- ll_stop
- ll_unload
1 #define __NO_VERSION__
2 #include "teles.h"
3 #include <linux/malloc.h>
4 #include <linux/timer.h>
5
6
7 extern struct Channel *chanlist;
8 int drid;
9 char *teles_id = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
10
11 isdn_if iif;
12
13 #define TELES_STATUS_BUFSIZE 4096
14 static byte *teles_status_buf = NULL;
15 static byte *teles_status_read = NULL;
16 static byte *teles_status_write = NULL;
17 static byte *teles_status_end = NULL;
18
19 int
20 teles_readstatus(byte * buf, int len, int user)
21 {
22 int count;
23 byte *p;
24
25 for (p = buf, count = 0; count < len; p++, count++) {
26 if (user)
27 put_fs_byte(*teles_status_read++, p);
28 else
29 *p++ = *teles_status_read++;
30 if (teles_status_read > teles_status_end)
31 teles_status_read = teles_status_buf;
32 }
33 return count;
34 }
35
36 void
37 teles_putstatus(char *buf)
38 {
39 long flags;
40 int len, count, i;
41 byte *p;
42 isdn_ctrl ic;
43
44 save_flags(flags);
45 cli();
46 count = 0;
47 len = strlen(buf);
48 for (p = buf, i = len; i > 0; i--, p++) {
49 *teles_status_write++ = *p;
50 if (teles_status_write > teles_status_end)
51 teles_status_write = teles_status_buf;
52 count++;
53 }
54 restore_flags(flags);
55 if (count) {
56 ic.command = ISDN_STAT_STAVAIL;
57 ic.driver = drid;
58 ic.arg = count;
59 iif.statcallb(&ic);
60 }
61 }
62
63
64 int
65 ll_init(void)
66 {
67 isdn_ctrl ic;
68
69 teles_status_buf = Smalloc(TELES_STATUS_BUFSIZE,
70 GFP_KERNEL, "teles_status_buf");
71 if (!teles_status_buf) {
72 printk(KERN_ERR "teles: Could not allocate status-buffer\n");
73 return (-EIO);
74 } else {
75 teles_status_read = teles_status_buf;
76 teles_status_write = teles_status_buf;
77 teles_status_end = teles_status_buf + TELES_STATUS_BUFSIZE - 1;
78 }
79
80 iif.channels = CallcNewChan();
81 iif.maxbufsize = BUFFER_SIZE(HSCX_SBUF_ORDER, HSCX_SBUF_BPPS);
82 iif.features =
83 ISDN_FEATURE_L2_X75I |
84 ISDN_FEATURE_L2_HDLC |
85 ISDN_FEATURE_L3_TRANS |
86 ISDN_FEATURE_P_1TR6 |
87 ISDN_FEATURE_P_EURO;
88
89 iif.command = teles_command;
90 iif.writebuf = teles_writebuf;
91 iif.writecmd = NULL;
92 iif.readstat = teles_readstatus;
93 strncpy(iif.id, teles_id, sizeof(iif.id) - 1);
94
95 register_isdn(&iif);
96 drid = iif.channels;
97
98 ic.driver = drid;
99 ic.command = ISDN_STAT_RUN;
100 iif.statcallb(&ic);
101 return 0;
102 }
103
104 void
105 ll_stop(void)
106 {
107 isdn_ctrl ic;
108
109 ic.command = ISDN_STAT_STOP;
110 ic.driver = drid;
111 iif.statcallb(&ic);
112
113 CallcFreeChan();
114 }
115
116 void
117 ll_unload(void)
118 {
119 isdn_ctrl ic;
120
121 ic.command = ISDN_STAT_UNLOAD;
122 ic.driver = drid;
123 iif.statcallb(&ic);
124 }