1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License.  See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1995, 1996, 2001 by Ralf Baechle
7 */
8#ifndef _ASM_TERMIOS_H
9#define _ASM_TERMIOS_H
10
11#include <asm/termbits.h>
12#include <asm/ioctls.h>
13
14struct sgttyb {
15	char	sg_ispeed;
16	char	sg_ospeed;
17	char	sg_erase;
18	char	sg_kill;
19	int	sg_flags;	/* SGI special - int, not short */
20};
21
22struct tchars {
23	char	t_intrc;
24	char	t_quitc;
25	char	t_startc;
26	char	t_stopc;
27	char	t_eofc;
28	char	t_brkc;
29};
30
31struct ltchars {
32        char    t_suspc;        /* stop process signal */
33        char    t_dsuspc;       /* delayed stop process signal */
34        char    t_rprntc;       /* reprint line */
35        char    t_flushc;       /* flush output (toggles) */
36        char    t_werasc;       /* word erase */
37        char    t_lnextc;       /* literal next character */
38};
39
40/* TIOCGSIZE, TIOCSSIZE not defined yet.  Only needed for SunOS source
41   compatibility anyway ... */
42
43struct winsize {
44	unsigned short ws_row;
45	unsigned short ws_col;
46	unsigned short ws_xpixel;
47	unsigned short ws_ypixel;
48};
49
50#define NCC	8
51struct termio {
52	unsigned short c_iflag;		/* input mode flags */
53	unsigned short c_oflag;		/* output mode flags */
54	unsigned short c_cflag;		/* control mode flags */
55	unsigned short c_lflag;		/* local mode flags */
56	char c_line;			/* line discipline */
57	unsigned char c_cc[NCCS];	/* control characters */
58};
59
60#ifdef __KERNEL__
61/*
62 *	intr=^C		quit=^\		erase=del	kill=^U
63 *	vmin=\1		vtime=\0	eol2=\0		swtc=\0
64 *	start=^Q	stop=^S		susp=^Z		vdsusp=
65 *	reprint=^R	discard=^U	werase=^W	lnext=^V
66 *	eof=^D		eol=\0
67 */
68#define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0"
69#endif
70
71/* modem lines */
72#define TIOCM_LE	0x001		/* line enable */
73#define TIOCM_DTR	0x002		/* data terminal ready */
74#define TIOCM_RTS	0x004		/* request to send */
75#define TIOCM_ST	0x010		/* secondary transmit */
76#define TIOCM_SR	0x020		/* secondary receive */
77#define TIOCM_CTS	0x040		/* clear to send */
78#define TIOCM_CAR	0x100		/* carrier detect */
79#define TIOCM_CD	TIOCM_CAR
80#define TIOCM_RNG	0x200		/* ring */
81#define TIOCM_RI	TIOCM_RNG
82#define TIOCM_DSR	0x400		/* data set ready */
83#define TIOCM_OUT1	0x2000
84#define TIOCM_OUT2	0x4000
85#define TIOCM_LOOP	0x8000
86
87#define TIOCM_MODEM_BITS       TIOCM_OUT2      /* IRDA support */
88
89/* line disciplines */
90#define N_TTY		0
91#define N_SLIP		1
92#define N_MOUSE		2
93#define N_PPP		3
94#define N_STRIP		4
95#define N_AX25		5
96#define N_X25		6		/* X.25 async */
97#define N_6PACK		7
98#define N_MASC		8	/* Reserved fo Mobitex module <kaz@cafe.net> */
99#define N_R3964		9	/* Reserved for Simatic R3964 module */
100#define N_PROFIBUS_FDL	10	/* Reserved for Profibus <Dave@mvhi.com> */
101#define N_IRDA		11	/* Linux IrDa - http://irda.sourceforge.net/ */
102#define N_SMSBLOCK	12	/* SMS block mode - for talking to GSM data cards about SMS messages */
103#define N_HDLC		13	/* synchronous HDLC */
104#define N_SYNC_PPP	14	/* synchronous PPP */
105#define N_HCI		15	/* Bluetooth HCI UART */
106
107#ifdef __KERNEL__
108
109#include <linux/string.h>
110
111/*
112 * Translate a "termio" structure into a "termios". Ugh.
113 */
114#define user_termio_to_kernel_termios(termios, termio) \
115({ \
116	unsigned short tmp; \
117	get_user(tmp, &(termio)->c_iflag); \
118	(termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
119	get_user(tmp, &(termio)->c_oflag); \
120	(termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
121	get_user(tmp, &(termio)->c_cflag); \
122	(termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
123	get_user(tmp, &(termio)->c_lflag); \
124	(termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
125	get_user((termios)->c_line, &(termio)->c_line); \
126	copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
127})
128
129/*
130 * Translate a "termios" structure into a "termio". Ugh.
131 */
132#define kernel_termios_to_user_termio(termio, termios) \
133({ \
134	put_user((termios)->c_iflag, &(termio)->c_iflag); \
135	put_user((termios)->c_oflag, &(termio)->c_oflag); \
136	put_user((termios)->c_cflag, &(termio)->c_cflag); \
137	put_user((termios)->c_lflag, &(termio)->c_lflag); \
138	put_user((termios)->c_line, &(termio)->c_line); \
139	copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
140})
141
142#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
143#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
144
145#endif /* defined(__KERNEL__) */
146
147#endif /* _ASM_TERMIOS_H */
148