#ifndef _SYS_TTY_H_
#define _SYS_TTY_H_
struct clist {
int c_cc;
int c_ccmax;
int c_cchead;
int c_unused01;
short *c_data;
};
#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
#include <sys/_termios.h>
#include <sys/event.h>
#include <sys/queue.h>
#include <sys/ttycom.h>
#ifdef _KERNEL
#include <sys/device.h>
#endif
#ifndef _SYS_THREAD_H_
#include <sys/thread.h>
#endif
struct tty {
struct lwkt_token t_token;
struct clist t_rawq;
long t_rawcc;
struct clist t_canq;
long t_cancc;
struct clist t_outq;
long t_outcc;
int t_line;
struct cdev *t_dev;
int t_state;
int t_flags;
int t_timeout;
struct pgrp *t_pgrp;
struct session *t_session;
struct sigio *t_sigio;
struct kqinfo t_rkq;
struct kqinfo t_wkq;
struct termios t_termios;
struct winsize t_winsize;
void (*t_oproc) (struct tty *);
void (*t_stop) (struct tty *, int);
int (*t_param) (struct tty *, struct termios *);
void (*t_unhold) (struct tty *);
void *t_sc;
void *t_slsc;
int t_column;
int t_rocount, t_rocol;
int t_ififosize;
int t_ihiwat;
int t_ilowat;
speed_t t_ispeedwat;
int t_ohiwat;
int t_olowat;
speed_t t_ospeedwat;
int t_gen;
TAILQ_ENTRY(tty) t_list;
int t_refs;
};
#define t_cc t_termios.c_cc
#define t_cflag t_termios.c_cflag
#define t_iflag t_termios.c_iflag
#define t_ispeed t_termios.c_ispeed
#define t_lflag t_termios.c_lflag
#define t_min t_termios.c_min
#define t_oflag t_termios.c_oflag
#define t_ospeed t_termios.c_ospeed
#define t_time t_termios.c_time
#endif
#define IBUFSIZ 384
#define OBUFSIZ 100
#ifndef TTYHOG
#define TTYHOG 1024
#endif
#ifdef _KERNEL
#define TTMAXHIWAT 2048
#define TTMINHIWAT 100
#define TTMAXLOWAT 256
#define TTMINLOWAT 32
#endif
#define TS_SO_OLOWAT 0x00001
#define TS_ASYNC 0x00002
#define TS_BUSY 0x00004
#define TS_CARR_ON 0x00008
#define TS_FLUSH 0x00010
#define TS_ISOPEN 0x00020
#define TS_TBLOCK 0x00040
#define TS_TIMEOUT 0x00080
#define TS_TTSTOP 0x00100
#ifdef notyet
#define TS_WOPEN 0x00200
#endif
#define TS_XCLUDE 0x00400
#define TS_BKSL 0x00800
#define TS_CNTTB 0x01000
#define TS_ERASE 0x02000
#define TS_LNCH 0x04000
#define TS_TYPEN 0x08000
#define TS_LOCAL (TS_BKSL | TS_CNTTB | TS_ERASE | TS_LNCH | TS_TYPEN)
#define TS_CAN_BYPASS_L_RINT 0x010000
#define TS_CONNECTED 0x020000
#define TS_SNOOP 0x040000
#define TS_SO_OCOMPLETE 0x080000
#define TS_ZOMBIE 0x100000
#define TS_CAR_OFLOW 0x200000
#ifdef notyet
#define TS_CTS_OFLOW 0x400000
#define TS_DSR_OFLOW 0x800000
#endif
#define TS_REGISTERED 0x1000000
#define TS_MARKER 0x2000000
#define ORDINARY 0
#define CONTROL 1
#define BACKSPACE 2
#define NEWLINE 3
#define TAB 4
#define VTAB 5
#define RETURN 6
struct speedtab {
int sp_speed;
int sp_code;
};
#define DMSET 0
#define DMBIS 1
#define DMBIC 2
#define DMGET 3
#define TTY_CHARMASK 0x00ff
#define TTY_QUOTE 0x0100
#define TTY_ERRORMASK 0xff000000
#define TTY_FE 0x01000000
#define TTY_PE 0x02000000
#define TTY_OE 0x04000000
#define TTY_BI 0x08000000
#define isctty(p, tp) \
((p)->p_session == (tp)->t_session && ((p)->p_flags & P_CONTROLT))
#define isbackground(p, tp) \
(isctty((p), (tp)) && (p)->p_pgrp != (tp)->t_pgrp)
#define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq)
#define TSA_HUP_OR_INPUT(tp) ((void *)&(tp)->t_rawq.c_cchead)
#define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq.c_ccmax)
#define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq)
#define TSA_PTC_READ(tp) ((void *)&(tp)->t_outq.c_cchead)
#define TSA_PTC_WRITE(tp) ((void *)&(tp)->t_rawq.c_ccmax)
#define TSA_PTS_READ(tp) ((void *)&(tp)->t_canq)
#ifdef _KERNEL
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_TTYS);
#endif
extern struct tty *constty;
int clist_btoq (char *cp, int cc, struct clist *q);
void clist_catq (struct clist *from, struct clist *to);
void clist_alloc_cblocks (struct clist *q, int ccmax);
void clist_free_cblocks (struct clist *q);
int clist_getc (struct clist *q);
int clist_unputc (struct clist *q);
void ndflush (struct clist *q, int cc);
void *clist_nextc (struct clist *q, void *cp, int *c);
void nottystop (struct tty *tp, int rw);
int clist_putc (int c, struct clist *q);
int clist_qtob (struct clist *q, char *cp, int cc);
void termioschars (struct termios *t);
int tputchar (int c, struct tty *tp);
int ttcompat (struct tty *tp, u_long com, caddr_t data, int flag);
int ttioctl (struct tty *tp, u_long com, void *data, int flag);
int ttread (struct tty *tp, struct uio *uio, int flag);
int ttsetcompat (struct tty *tp, u_long *com, caddr_t data,
struct termios *term);
void ttsetwater (struct tty *tp);
int ttspeedtab (int speed, struct speedtab *table);
int ttstart (struct tty *tp);
void ttwakeup (struct tty *tp);
int ttwrite (struct tty *tp, struct uio *uio, int flag);
void ttwwakeup (struct tty *tp);
void ttyblock (struct tty *tp);
void ttychars (struct tty *tp);
int ttycheckoutq (struct tty *tp, int wait);
int ttyclose (struct tty *tp);
void ttyclearsession (struct tty *tp);
void ttyclosesession (struct session *, int);
void ttyflush (struct tty *tp, int rw);
void ttyhold (struct tty *tp);
void ttyunhold (struct tty *tp);
void ttyinfo (struct tty *tp);
int ttyinput (int c, struct tty *tp);
int ttylclose (struct tty *tp, int flag);
struct tty *ttymalloc (struct tty **tpp);
int ttymodem (struct tty *tp, int flag);
int ttyopen (cdev_t device, struct tty *tp);
int ttykqfilter (struct dev_kqfilter_args *);
int ttyread (struct dev_read_args *);
void ttyregister (struct tty *tp);
void ttyinit (struct tty *tp);
void ttyunregister (struct tty *tp);
int ttysleep (struct tty *tp, void *chan, int slpflags, char *wmesg,
int timeout);
int ttyrevoke (struct dev_revoke_args *);
int ttywait (struct tty *tp);
int ttywrite (struct dev_write_args *);
#endif
#endif