root/drivers/isdn/teles/llglue.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. teles_readstatus
  2. teles_putstatus
  3. ll_init
  4. ll_stop
  5. ll_unload

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

/* [previous][next][first][last][top][bottom][index][help] */