Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

baycom_epp.c File Reference

#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/ptrace.h>
#include <linux/socket.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/in.h>
#include <linux/string.h>
#include <linux/parport.h>
#include <linux/bitops.h>
#include <asm/system.h>
#include <asm/io.h>
#include <asm/processor.h>
#include <asm/uaccess.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/kmod.h>
#include <linux/init.h>
#include <linux/hdlcdrv.h>
#include <linux/baycom.h>
#include <linux/soundmodem.h>
#include <linux/unistd.h>

Include dependency graph for baycom_epp.c:

Go to the source code of this file.

Defines

#define __KERNEL_SYSCALLS__
#define BAYCOM_DEBUG
#define BAYCOM_MAGIC   19730510
#define baycom_paranoia_check(dev, routine, retval)
#define baycom_paranoia_check_void(dev, routine)
#define NR_PORTS   4
#define EPP_DCDBIT   0x80
#define EPP_PTTBIT   0x08
#define EPP_NREF   0x01
#define EPP_NRAEF   0x02
#define EPP_NRHF   0x04
#define EPP_NTHF   0x20
#define EPP_NTAEF   0x10
#define EPP_NTEF   EPP_PTTBIT
#define EPP_TX_FIFO_ENABLE   0x10
#define EPP_RX_FIFO_ENABLE   0x08
#define EPP_MODEM_ENABLE   0x20
#define EPP_LEDS   0xC0
#define EPP_IRQ_ENABLE   0x10
#define LPTREG_ECONTROL   0x402
#define LPTREG_CONFIGB   0x401
#define LPTREG_CONFIGA   0x400
#define LPTREG_EPPDATA   0x004
#define LPTREG_EPPADDR   0x003
#define LPTREG_CONTROL   0x002
#define LPTREG_STATUS   0x001
#define LPTREG_DATA   0x000
#define LPTCTRL_PROGRAM   0x04
#define LPTCTRL_WRITE   0x01
#define LPTCTRL_ADDRSTB   0x08
#define LPTCTRL_DATASTB   0x02
#define LPTCTRL_INTEN   0x10
#define LPTSTAT_SHIFT_NINTR   6
#define LPTSTAT_WAIT   0x80
#define LPTSTAT_NINTR   (1<<LPTSTAT_SHIFT_NINTR)
#define LPTSTAT_PE   0x20
#define LPTSTAT_DONE   0x10
#define LPTSTAT_NERROR   0x08
#define LPTSTAT_EPPTIMEOUT   0x01
#define LPTDATA_SHIFT_TDI   0
#define LPTDATA_SHIFT_TMS   2
#define LPTDATA_TDI   (1<<LPTDATA_SHIFT_TDI)
#define LPTDATA_TCK   0x02
#define LPTDATA_TMS   (1<<LPTDATA_SHIFT_TMS)
#define LPTDATA_INITBIAS   0x80
#define EPP_DCDBIT   0x80
#define EPP_PTTBIT   0x08
#define EPP_RXEBIT   0x01
#define EPP_RXAEBIT   0x02
#define EPP_RXHFULL   0x04
#define EPP_NTHF   0x20
#define EPP_NTAEF   0x10
#define EPP_NTEF   EPP_PTTBIT
#define EPP_TX_FIFO_ENABLE   0x10
#define EPP_RX_FIFO_ENABLE   0x08
#define EPP_MODEM_ENABLE   0x20
#define EPP_LEDS   0xC0
#define EPP_IRQ_ENABLE   0x10
#define XC4K_IRLENGTH   3
#define XC4K_EXTEST   0
#define XC4K_PRELOAD   1
#define XC4K_CONFIGURE   5
#define XC4K_BYPASS   7
#define EPP_CONVENTIONAL   0
#define EPP_FPGA   1
#define EPP_FPGAEXTSTATUS   2
#define TXBUFFER_SIZE   ((HDLCDRV_MAXFLEN*6/5)+8)
#define min(a, b)   (((a) < (b)) ? (a) : (b))
#define max(a, b)   (((a) > (b)) ? (a) : (b))
#define KISS_VERBOSE
#define PARAM_TXDELAY   1
#define PARAM_PERSIST   2
#define PARAM_SLOTTIME   3
#define PARAM_TXTAIL   4
#define PARAM_FULLDUP   5
#define PARAM_HARDWARE   6
#define PARAM_RETURN   255
#define tenms_to_flags(bc, tenms)   ((tenms * bc->bitrate) / 800)
#define PKP(a, b)   printk(KERN_INFO "%s: channel params: " a "\n", bc->ifname, b)
#define ENCODEITERA(j)
#define ENCODEITERB(j)
#define DECODEITERA(j)
#define DECODEITERB(j)
#define GETTICK(x)

Functions

int check_crc_ccitt (const unsigned char *buf, int cnt)
int calc_crc_ccitt (const unsigned char *buf, int cnt)
static void baycom_int_freq (struct baycom_state *bc)
static int exec_eppfpga (void *b)
static int eppconfig (struct baycom_state *bc)
static void epp_interrupt (int irq, void *dev_id, struct pt_regs *regs)
static void do_kiss_params (struct baycom_state *bc, unsigned char *data, unsigned long len)
static void encode_hdlc (struct baycom_state *bc)
static unsigned short random_num (void)
static void transmit (struct baycom_state *bc, int cnt, unsigned char stat)
static void do_rxpacket (struct device *dev)
static void receive (struct device *dev, int cnt)
static void epp_bh (struct device *dev)
static int baycom_send_packet (struct sk_buff *skb, struct device *dev)
static int baycom_set_mac_address (struct device *dev, void *addr)
static struct net_device_statsbaycom_get_stats (struct device *dev)
static void epp_wakeup (void *handle)
static int epp_open (struct device *dev)
static int epp_close (struct device *dev)
static int baycom_setmode (struct baycom_state *bc, const char *modestr)
static int baycom_ioctl (struct device *dev, struct ifreq *ifr, int cmd)
static int baycom_probe (struct device *dev)
 __initfunc (int baycom_epp_init(void))
 __initfunc (void baycom_epp_setup(char *str, int *ints))

Variables

static const char paranoia_str []
static const char bc_drvname [] = "baycom_epp"
static const char bc_drvinfo []
static struct device baycom_device [NR_PORTS]
struct {
   const char *   mode
   int   iobase
baycom_ports [NR_PORTS]
static const unsigned short crc_ccitt_table []
char eppconfig_path [256] = "/sbin/eppfpga"
static char * envp [] = { "HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL }
static int errno
static unsigned short random_seed


Define Documentation

#define __KERNEL_SYSCALLS__
 

Definition at line 70 of file baycom_epp.c.

#define BAYCOM_DEBUG
 

Definition at line 75 of file baycom_epp.c.

#define BAYCOM_MAGIC   19730510
 

Definition at line 76 of file baycom_epp.c.

Referenced by __initfunc().

#define baycom_paranoia_check dev,
routine,
retval   ) 
 

Value:

({                                                                                             \
        if (!dev || !dev->priv || ((struct baycom_state *)dev->priv)->magic != BAYCOM_MAGIC) { \
                printk(paranoia_str, routine);                                                 \
                return retval;                                                                 \
        }                                                                                      \
})

Definition at line 83 of file baycom_epp.c.

Referenced by baycom_get_stats(), baycom_ioctl(), baycom_probe(), baycom_send_packet(), epp_close(), and epp_open().

#define baycom_paranoia_check_void dev,
routine   ) 
 

Value:

({                                                                                             \
        if (!dev || !dev->priv || ((struct baycom_state *)dev->priv)->magic != BAYCOM_MAGIC) { \
                printk(paranoia_str, routine);                                                 \
                return;                                                                        \
        }                                                                                      \
})

Definition at line 91 of file baycom_epp.c.

Referenced by epp_bh(), and epp_wakeup().

#define DECODEITERA j   ) 
 

Value:

({                                                                            \
        if (!(notbitstream & (0x0fc << j)))              /* flag or abort */  \
                goto flgabrt##j;                                              \
        if ((bitstream & (0x1f8 << j)) == (0xf8 << j))   /* stuffed bit */    \
                goto stuff##j;                                                \
  enditer##j:                                                                 \
})

Definition at line 720 of file baycom_epp.c.

Referenced by receive().

#define DECODEITERB j   ) 
 

Value:

({                                                                                     \
  flgabrt##j:                                                                          \
        if (!(notbitstream & (0x1fc << j))) {              /* abort received */        \
                state = 0;                                                             \
                goto enditer##j;                                                       \
        }                                                                              \
        if ((bitstream & (0x1fe << j)) != (0x0fc << j))   /* flag received */          \
                goto enditer##j;                                                       \
        if (state)                                                                     \
                do_rxpacket(dev);                                                      \
        bc->hdlcrx.bufcnt = 0;                                                         \
        bc->hdlcrx.bufptr = bc->hdlcrx.buf;                                            \
        state = 1;                                                                     \
        numbits = 7-j;                                                                 \
        goto enditer##j;                                                               \
  stuff##j:                                                                            \
        numbits--;                                                                     \
        bitbuf = (bitbuf & ((~0xff) << j)) | ((bitbuf & ~((~0xff) << j)) << 1);        \
        goto enditer##j;                                                               \
})

Definition at line 729 of file baycom_epp.c.

Referenced by receive().

#define ENCODEITERA j   ) 
 

Value:

({                                             \
        if (!(notbitstream & (0x1f0 << j)))    \
                goto stuff##j;                 \
  encodeend##j:                                \
})

Definition at line 498 of file baycom_epp.c.

Referenced by encode_hdlc().

#define ENCODEITERB j   ) 
 

Value:

({                                                              \
  stuff##j:                                                     \
        bitstream &= ~(0x100 << j);                             \
        bitbuf = (bitbuf & (((2 << j) << numbit) - 1)) |        \
                ((bitbuf & ~(((2 << j) << numbit) - 1)) << 1);  \
        numbit++;                                               \
        notbitstream = ~bitstream;                              \
        goto encodeend##j;                                      \
})

Definition at line 505 of file baycom_epp.c.

Referenced by encode_hdlc().

#define EPP_CONVENTIONAL   0
 

Definition at line 194 of file baycom_epp.c.

Referenced by epp_open().

#define EPP_DCDBIT   0x80
 

Definition at line 171 of file baycom_epp.c.

#define EPP_DCDBIT   0x80
 

Definition at line 171 of file baycom_epp.c.

Referenced by baycom_ioctl(), epp_close(), and transmit().

#define EPP_FPGA   1
 

Definition at line 195 of file baycom_epp.c.

#define EPP_FPGAEXTSTATUS   2
 

Definition at line 196 of file baycom_epp.c.

Referenced by epp_bh(), and epp_open().

#define EPP_IRQ_ENABLE   0x10
 

Definition at line 185 of file baycom_epp.c.

#define EPP_IRQ_ENABLE   0x10
 

Definition at line 185 of file baycom_epp.c.

#define EPP_LEDS   0xC0
 

Definition at line 184 of file baycom_epp.c.

#define EPP_LEDS   0xC0
 

Definition at line 184 of file baycom_epp.c.

#define EPP_MODEM_ENABLE   0x20
 

Definition at line 183 of file baycom_epp.c.

#define EPP_MODEM_ENABLE   0x20
 

Definition at line 183 of file baycom_epp.c.

Referenced by epp_bh(), and epp_open().

#define EPP_NRAEF   0x02
 

Definition at line 122 of file baycom_epp.c.

Referenced by epp_bh(), and epp_open().

#define EPP_NREF   0x01
 

Definition at line 121 of file baycom_epp.c.

Referenced by epp_bh(), and epp_open().

#define EPP_NRHF   0x04
 

Definition at line 123 of file baycom_epp.c.

Referenced by epp_bh(), and epp_open().

#define EPP_NTAEF   0x10
 

Definition at line 178 of file baycom_epp.c.

#define EPP_NTAEF   0x10
 

Definition at line 178 of file baycom_epp.c.

Referenced by epp_bh().

#define EPP_NTEF   EPP_PTTBIT
 

Definition at line 179 of file baycom_epp.c.

#define EPP_NTEF   EPP_PTTBIT
 

Definition at line 179 of file baycom_epp.c.

#define EPP_NTHF   0x20
 

Definition at line 177 of file baycom_epp.c.

#define EPP_NTHF   0x20
 

Definition at line 177 of file baycom_epp.c.

Referenced by epp_bh().

#define EPP_PTTBIT   0x08
 

Definition at line 172 of file baycom_epp.c.

#define EPP_PTTBIT   0x08
 

Definition at line 172 of file baycom_epp.c.

Referenced by baycom_ioctl(), and transmit().

#define EPP_RX_FIFO_ENABLE   0x08
 

Definition at line 182 of file baycom_epp.c.

#define EPP_RX_FIFO_ENABLE   0x08
 

Definition at line 182 of file baycom_epp.c.

Referenced by epp_bh(), and epp_open().

#define EPP_RXAEBIT   0x02
 

Definition at line 174 of file baycom_epp.c.

#define EPP_RXEBIT   0x01
 

Definition at line 173 of file baycom_epp.c.

#define EPP_RXHFULL   0x04
 

Definition at line 175 of file baycom_epp.c.

#define EPP_TX_FIFO_ENABLE   0x10
 

Definition at line 181 of file baycom_epp.c.

#define EPP_TX_FIFO_ENABLE   0x10
 

Definition at line 181 of file baycom_epp.c.

Referenced by epp_bh(), and epp_open().

#define GETTICK x   ) 
 

Definition at line 813 of file baycom_epp.c.

Referenced by epp_bh().

#define KISS_VERBOSE
 

Definition at line 268 of file baycom_epp.c.

#define LPTCTRL_ADDRSTB   0x08
 

Definition at line 148 of file baycom_epp.c.

#define LPTCTRL_DATASTB   0x02
 

Definition at line 149 of file baycom_epp.c.

#define LPTCTRL_INTEN   0x10
 

Definition at line 150 of file baycom_epp.c.

#define LPTCTRL_PROGRAM   0x04
 

Definition at line 146 of file baycom_epp.c.

Referenced by epp_open().

#define LPTCTRL_WRITE   0x01
 

Definition at line 147 of file baycom_epp.c.

#define LPTDATA_INITBIAS   0x80
 

Definition at line 167 of file baycom_epp.c.

#define LPTDATA_SHIFT_TDI   0
 

Definition at line 162 of file baycom_epp.c.

#define LPTDATA_SHIFT_TMS   2
 

Definition at line 163 of file baycom_epp.c.

#define LPTDATA_TCK   0x02
 

Definition at line 165 of file baycom_epp.c.

#define LPTDATA_TDI   (1<<LPTDATA_SHIFT_TDI)
 

Definition at line 164 of file baycom_epp.c.

#define LPTDATA_TMS   (1<<LPTDATA_SHIFT_TMS)
 

Definition at line 166 of file baycom_epp.c.

#define LPTREG_CONFIGA   0x400
 

Definition at line 138 of file baycom_epp.c.

#define LPTREG_CONFIGB   0x401
 

Definition at line 137 of file baycom_epp.c.

#define LPTREG_CONTROL   0x002
 

Definition at line 141 of file baycom_epp.c.

#define LPTREG_DATA   0x000
 

Definition at line 143 of file baycom_epp.c.

#define LPTREG_ECONTROL   0x402
 

Definition at line 136 of file baycom_epp.c.

#define LPTREG_EPPADDR   0x003
 

Definition at line 140 of file baycom_epp.c.

#define LPTREG_EPPDATA   0x004
 

Definition at line 139 of file baycom_epp.c.

#define LPTREG_STATUS   0x001
 

Definition at line 142 of file baycom_epp.c.

#define LPTSTAT_DONE   0x10
 

Definition at line 157 of file baycom_epp.c.

#define LPTSTAT_EPPTIMEOUT   0x01
 

Definition at line 159 of file baycom_epp.c.

#define LPTSTAT_NERROR   0x08
 

Definition at line 158 of file baycom_epp.c.

#define LPTSTAT_NINTR   (1<<LPTSTAT_SHIFT_NINTR)
 

Definition at line 155 of file baycom_epp.c.

#define LPTSTAT_PE   0x20
 

Definition at line 156 of file baycom_epp.c.

#define LPTSTAT_SHIFT_NINTR   6
 

Definition at line 153 of file baycom_epp.c.

#define LPTSTAT_WAIT   0x80
 

Definition at line 154 of file baycom_epp.c.

#define max a,
 )     (((a) > (b)) ? (a) : (b))
 

Definition at line 264 of file baycom_epp.c.

#define min a,
 )     (((a) < (b)) ? (a) : (b))
 

Definition at line 263 of file baycom_epp.c.

#define NR_PORTS   4
 

Definition at line 107 of file baycom_epp.c.

#define PARAM_FULLDUP   5
 

Definition at line 276 of file baycom_epp.c.

Referenced by do_kiss_params(), hardware_send_packet(), scc_get_param(), and scc_set_param().

#define PARAM_HARDWARE   6
 

Definition at line 277 of file baycom_epp.c.

#define PARAM_PERSIST   2
 

Definition at line 273 of file baycom_epp.c.

Referenced by do_kiss_params(), hardware_send_packet(), scc_get_param(), and scc_set_param().

#define PARAM_RETURN   255
 

Definition at line 278 of file baycom_epp.c.

#define PARAM_SLOTTIME   3
 

Definition at line 274 of file baycom_epp.c.

Referenced by do_kiss_params(), hardware_send_packet(), scc_get_param(), and scc_set_param().

#define PARAM_TXDELAY   1
 

Definition at line 272 of file baycom_epp.c.

Referenced by do_kiss_params(), hardware_send_packet(), scc_get_param(), and scc_set_param().

#define PARAM_TXTAIL   4
 

Definition at line 275 of file baycom_epp.c.

Referenced by do_kiss_params(), scc_get_param(), and scc_set_param().

#define PKP a,
 )     printk(KERN_INFO "%s: channel params: " a "\n", bc->ifname, b)
 

Referenced by do_kiss_params().

#define tenms_to_flags bc,
tenms   )     ((tenms * bc->bitrate) / 800)
 

Definition at line 361 of file baycom_epp.c.

Referenced by transmit().

#define TXBUFFER_SIZE   ((HDLCDRV_MAXFLEN*6/5)+8)
 

Definition at line 198 of file baycom_epp.c.

Referenced by receive().

#define XC4K_BYPASS   7
 

Definition at line 192 of file baycom_epp.c.

#define XC4K_CONFIGURE   5
 

Definition at line 191 of file baycom_epp.c.

#define XC4K_EXTEST   0
 

Definition at line 189 of file baycom_epp.c.

#define XC4K_IRLENGTH   3
 

Definition at line 188 of file baycom_epp.c.

#define XC4K_PRELOAD   1
 

Definition at line 190 of file baycom_epp.c.


Function Documentation

__initfunc void   baycom_epp_setup(char *str, int *ints)  ) 
 

Definition at line 1482 of file baycom_epp.c.

References baycom_ports, bc_drvname, KERN_INFO, NULL, and printk.

__initfunc int   baycom_epp_init(void)  ) 
 

Definition at line 1368 of file baycom_epp.c.

References baycom_device, BAYCOM_MAGIC, baycom_ports, baycom_probe(), baycom_setmode(), bc, bc_drvinfo, bc_drvname, dev, device, ENOMEM, ENXIO, found, i, KERN_WARNING, kfree(), kmalloc(), memset, NR_PORTS, printk, register_netdev, and sprintf().

Here is the call graph for this function:

static struct net_device_stats* baycom_get_stats struct device *  dev  )  [static]
 

Definition at line 945 of file baycom_epp.c.

References baycom_paranoia_check, bc, NULL, and baycom_state::stats.

Referenced by baycom_probe().

static void baycom_int_freq struct baycom_state bc  )  [inline, static]
 

Definition at line 365 of file baycom_epp.c.

References HZ, and jiffies.

Referenced by epp_bh(), par96_interrupt(), and ser12_interrupt().

static int baycom_ioctl struct device *  dev,
struct ifreq ifr,
int  cmd
[static]
 

Definition at line 1163 of file baycom_epp.c.

References baycom_paranoia_check, baycom_setmode(), BAYCOMCTL_GETDEBUG, bc, baycom_state::bitrate, baycom_state::cfg, baycom_state::ch_params, copy_from_user, copy_to_user, sm_ioctl::data, baycom_ioctl::data, baycom_state::debug_vals, baycom_state::debug_vals::demod_cycles, EACCES, EFAULT, EINVAL, ENOIOCTLCMD, EPP_DCDBIT, EPP_PTTBIT, hdlcdrv_channel_params::fulldup, get_user, HDLCDRV_PARMASK_IOBASE, HDLCDRVCTL_CALIBRATE, HDLCDRVCTL_DRIVERNAME, HDLCDRVCTL_GETCHANNELPAR, HDLCDRVCTL_GETMODE, HDLCDRVCTL_GETMODEMPAR, HDLCDRVCTL_GETSTAT, HDLCDRVCTL_MODELIST, HDLCDRVCTL_MODEMPARMASK, HDLCDRVCTL_OLDGETSTAT, HDLCDRVCTL_SETCHANNELPAR, HDLCDRVCTL_SETMODE, HDLCDRVCTL_SETMODEMPAR, baycom_state::hdlctx, baycom_state::debug_vals::last_intcnt, baycom_state::debug_vals::last_pllcorr, baycom_state::debug_vals::mod_cycles, hdlcdrv_channel_params::ppersist, baycom_state::ptt_keyed, net_device_stats::rx_errors, net_device_stats::rx_packets, SIOCDEVPRIVATE, hdlcdrv_channel_params::slottime, SMCTL_GETDEBUG, sprintf(), baycom_state::stat, baycom_state::stats, strncpy, hdlcdrv_channel_params::tx_delay, net_device_stats::tx_errors, net_device_stats::tx_packets, and hdlcdrv_channel_params::tx_tail.

Here is the call graph for this function:

static int baycom_probe struct device *  dev  )  [static]
 

Definition at line 1304 of file baycom_epp.c.

References ARPHRD_AX25, AX25_ADDR_LEN, ax25_bcast, AX25_BPQ_HEADER_LEN, AX25_DEF_PACLEN, ax25_encapsulate(), AX25_MAX_HEADER_LEN, ax25_nocall, ax25_rebuild_header(), baycom_get_stats(), baycom_paranoia_check, baycom_send_packet(), baycom_set_mac_address(), bc, baycom_state::ch_params, dev_init_buffers(), ENXIO, epp_close(), epp_open(), memcpy, NULL, baycom_state::ptt_keyed, and baycom_state::send_queue.

Referenced by __initfunc().

Here is the call graph for this function:

static int baycom_send_packet struct sk_buff skb,
struct device *  dev
[static]
 

Definition at line 921 of file baycom_epp.c.

References baycom_paranoia_check, bc, jiffies, and baycom_state::send_queue<