⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scc.h

📁 嵌入式ARM的一些源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* $Id: scc.h,v 1.29 1997/04/10 15:27:21 jreuter Exp jreuter $ */

#ifndef	_SCC_H
#define	_SCC_H

#include <linux/if_ether.h>

/* selection of hardware types */

#define PA0HZP		0x00	/* hardware type for PA0HZP SCC card and compatible */
#define EAGLE         	0x01    /* hardware type for EAGLE card */
#define PC100		0x02	/* hardware type for PC100 card */
#define PRIMUS		0x04	/* hardware type for PRIMUS-PC (DG9BL) card */
#define DRSI		0x08	/* hardware type for DRSI PC*Packet card */
#define BAYCOM		0x10	/* hardware type for BayCom (U)SCC */

/* Paranoia check... */

#define SCC_PARANOIA_CHECK	/* tell the user if something is going wrong */

/* TTY ioctl() commands */

#define TIOCSCCCFG	 _IOW('Z', 0, sizeof(struct scc_hw_config))	/* set hardware parameters */
#define TIOCSCCINI	  _IO('Z', 1)					/* init driver */
#define TIOCSCCCHANINI	 _IOW('Z', 2, sizeof(struct scc_modem))		/* init channel */
#define TIOCSCCSMEM	 _IOW('Z', 3, sizeof(struct scc_mem_config))	/* adjust buffer pools */
#define TIOCSCCGKISS	_IOWR('Z', 4, sizeof(struct scc_kiss_cmd))	/* get kiss parameter */
#define TIOCSCCSKISS	 _IOW('Z', 5, sizeof(struct scc_kiss_cmd))	/* set kiss parameter */
#define TIOCSCCGSTAT	 _IOR('Z', 6, sizeof(struct scc_stat))		/* get scc status */

/* old TTY ioctl() commands */

#define TIOCSCCCFG_OLD	0x2200
#define TIOCSCCINI_OLD	0x2201
#define TIOCCHANINI_OLD	0x2202
#define TIOCCHANMEM_OLD 0x2210
#define TIOCSKISS_OLD	0x2282
#define TIOCGKISS_OLD	0x2283
#define TIOCSCCSTAT_OLD 0x2284

/* DEV ioctl() commands */

enum SCC_IOCTL_CMD {
	SIOCSCCRESERVED=SIOCDEVPRIVATE,
	SIOCSCCCFG,
	SIOCSCCINI,
	SIOCSCCCHANINI,
	SIOCSCCSMEM,
	SIOCSCCGKISS,
	SIOCSCCSKISS,
	SIOCSCCGSTAT
};

/* magic number */

#define SCC_MAGIC	0x8530		/* ;-) */

/* KISS protocol flags */
#define FEND	192
#define FESC	219
#define TFEND	220
#define TFESC	221

/* KISS state machine */

enum SCC_KISS_STATES {
	KISS_IDLE,
	KISS_DATA,
	KISS_ESCAPE,
	KISS_RXFRAME
};

/* Device parameter control (from WAMPES) */

enum SCC_KISS_PARAMS {
	PARAM_TXDELAY=1,
	PARAM_PERSIST,
	PARAM_SLOTTIME,
	PARAM_TXTAIL,
	PARAM_FULLDUP,
	PARAM_SOFTDCD,		/* was: PARAM_HW */
	PARAM_MUTE,		/* ??? */
	PARAM_DTR,
	PARAM_RTS,
	PARAM_SPEED,
	PARAM_ENDDELAY,		/* ??? */
	PARAM_GROUP,
	PARAM_IDLE,
	PARAM_MIN,
	PARAM_MAXKEY,
	PARAM_WAIT,
	PARAM_MAXDEFER,
	PARAM_TX,
	PARAM_HWEVENT=31,
	PARAM_RETURN=255	/* reset kiss mode */
};

/* fulldup parameter */

enum SCC_KISS_DUPLEX_MODES {
	KISS_DUPLEX_HALF,	/* normal CSMA operation */
	KISS_DUPLEX_FULL,	/* fullduplex, key down trx after transmission */
	KISS_DUPLEX_LINK,	/* fullduplex, key down trx after 'idletime' sec */
	KISS_DUPLEX_OPTIMA,	/* fullduplex, let the protocol layer control the hw */
};

/* misc. parameters */

#define TIMER_OFF	65535U	/* to switch off timers */
#define NO_SUCH_PARAM	65534U	/* param not implemented */

/* HWEVENT parameter */

enum SCC_HWEV_PARAMETERS {
	HWEV_DCD_ON,
	HWEV_DCD_OFF,
	HWEV_ALL_SENT
};

/* channel grouping */

#define RXGROUP		0x100	/* if set, only tx when all channels clear */
#define TXGROUP		0x200	/* if set, don't transmit simultaneously */

/* Tx/Rx clock sources */

enum SCC_CLK_SOURCES {
	CLK_DPLL,	/* normal halfduplex operation */
	CLK_EXTERNAL,	/* external clocking (G3RUH/DF9IC modems) */
	CLK_DIVIDER	/* Rx = DPLL, Tx = divider (fullduplex with */
			/* modems without clock regeneration */
};

/* Tx state */

enum SCC_TX_STATES {
	TXS_IDLE,	/* Transmitter off, no data pending */
	TXS_BUSY,	/* waiting for permission to send / tailtime */
	TXS_ACTIVE,	/* Transmitter on, sending data */
	TXS_NEWFRAME,	/* reset CRC and send (next) frame */
	TXS_IDLE2,	/* Transmitter on, no data pending */
	TXS_WAIT,	/* Waiting for Mintime to expire */
	TXS_TIMEOUT	/* We had a transmission timeout */
};

enum SCC_TX_KEY {TX_OFF, TX_ON}; /* command for scc_key_trx() */

/* Buffer management */

#define BT_RECEIVE  1		/* buffer allocated by receive */
#define BT_TRANSMIT 2		/* buffer allocated by transmit */

#define NULLBUF  (struct mbuf *)0
#define NULLBUFP (struct mbuf **)0


typedef unsigned short io_port;	/* type definition for an 'io port address' */
typedef unsigned short ioaddr;  /* old def */

#ifdef SCC_DELAY
#define Inb(port)	inb_p(port)
#define Outb(port, val)	outb_p(val, port)
#else
#define Inb(port)	inb(port)
#define Outb(port, val)	outb(val, port)
#endif

#define TIMER_OFF 65535U

/* Basic message buffer structure */

struct mbuf {
	struct mbuf *next;	/* Link to next buffer */
	struct mbuf *prev;	/* Link to previous buffer */
	
	int cnt;		/* Number of bytes stored in buffer */
	unsigned char *rw_ptr;	/* read-write pointer */
	unsigned char data[0];	/* anchor for allocated buffer */
};
	
/* SCC channel control structure for KISS */

struct scc_kiss {
	unsigned char txdelay;		/* Transmit Delay 10 ms/cnt */
	unsigned char persist;		/* Persistence (0-255) as a % */
	unsigned char slottime;		/* Delay to wait on persistence hit */
	unsigned char tailtime;		/* Delay after last byte written */
	unsigned char fulldup;		/* Full Duplex mode 0=CSMA 1=DUP 2=ALWAYS KEYED */
	unsigned char waittime;		/* Waittime before any transmit attempt */
	unsigned int  maxkeyup;		/* Maximum time to transmit (seconds) */
	unsigned char mintime;		/* Minimal offtime after MAXKEYUP timeout (seconds) */
	unsigned int  idletime;		/* Maximum idle time in ALWAYS KEYED mode (seconds) */
	unsigned int  maxdefer;		/* Timer for CSMA channel busy limit */
	unsigned char tx_inhibit;	/* Transmit is not allowed when set */	
	unsigned char group;		/* Group ID for AX.25 TX interlocking */
	unsigned char mode;		/* 'normal' or 'hwctrl' mode (unused) */

	unsigned char softdcd;		/* Use DPLL instead of DCD pin for carrier detect */
};


/* SCC statistical information */

struct scc_stat {
        long rxints;            /* Receiver interrupts */
        long txints;            /* Transmitter interrupts */
        long exints;            /* External/status interrupts */
        long spints;            /* Special receiver interrupts */

        long txframes;          /* Packets sent */
        long rxframes;          /* Number of Frames Actually Received */
        long rxerrs;            /* CRC Errors */
        long txerrs;		/* KISS errors */
        
	unsigned int nospace;	/* "Out of buffers" */
	unsigned int rx_over;	/* Receiver Overruns */
	unsigned int tx_under;	/* Transmitter Underruns */

	unsigned int tx_state;	/* Transmitter state */
	
	char tx_kiss_state;	/* state of the kiss interpreter */
	char rx_kiss_state;	/* state of the kiss encoder */
	
	int tx_queued;		/* tx frames enqueued */
	int rx_queued; 		/* rx frames enqueued */
	
	unsigned int rxbuffers;	/* allocated rx_buffers */
	unsigned int txbuffers;	/* allocated tx_buffers */
	unsigned int bufsize;	/* used buffersize */

	unsigned char is_netdev;/* If set: act as network instead of character device */
};


struct scc_modem {
	long speed;		/* Line speed, bps */
	char clocksrc;		/* 0 = DPLL, 1 = external, 2 = divider */
	char nrz;		/* NRZ instead of NRZI */	
};

struct scc_kiss_cmd {
	int  	 command;	/* one of the KISS-Commands defined above */
	unsigned param;		/* KISS-Param */
};

struct scc_hw_config {
	io_port data_a;		/* data port channel A */
	io_port ctrl_a;		/* control port channel A */
	io_port data_b;		/* data port channel B */
	io_port ctrl_b;		/* control port channel B */
	io_port vector_latch;	/* INTACK-Latch (#) */
	io_port	special;	/* special function port */

	int	irq;		/* irq */
	long	clock;		/* clock */
	char	option;		/* command for function port */
	
	char brand;		/* hardware type */
	char escc;		/* use ext. features of a 8580/85180/85280 */
};

/* (#) only one INTACK latch allowed. */


struct scc_mem_config {
	unsigned int rxbuffers;
	unsigned int txbuffers;
	unsigned int bufsize;
};


/* SCC channel structure */

struct scc_channel {
	int magic;		/* magic word */
	
	int init;		/* channel exists? */
	struct tty_struct *tty; /* link to tty control structure */
	char tty_opened;	/* No. of open() calls... */
	char throttled;		/* driver is throttled  */
	
	struct device *dev;	/* link to device control structure */
	struct enet_statistics dev_stat;
				/* device statistics */
		
	char brand;		/* manufacturer of the board */
	long clock;		/* used clock */
	
	io_port ctrl;		/* I/O address of CONTROL register */
	io_port	data;		/* I/O address of DATA register */
	io_port special;	/* I/O address of special function port */
	int irq;		/* Number of Interrupt */
	
	char option;
	char enhanced;		/* Enhanced SCC support */

	unsigned char wreg[16]; /* Copy of last written value in WRx */
	unsigned char status;	/* Copy of R0 at last external interrupt */

        struct scc_kiss kiss;	/* control structure for KISS params */
        struct scc_stat stat;	/* statistical information */
        struct scc_modem modem; /* modem information */
        
        char mempool;		/* pool empty or allocated? */
        struct mbuf *rx_buffer_pool; /* free buffers for rx/tx frames are */
        struct mbuf *tx_buffer_pool; /* linked in these ring chains */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -