Linux Audio

Check our new training course

Loading...
v3.1
 
  1#ifndef _ALPHA_TERMIOS_H
  2#define _ALPHA_TERMIOS_H
  3
  4#include <asm/ioctls.h>
  5#include <asm/termbits.h>
  6
  7struct sgttyb {
  8	char	sg_ispeed;
  9	char	sg_ospeed;
 10	char	sg_erase;
 11	char	sg_kill;
 12	short	sg_flags;
 13};
 14
 15struct tchars {
 16	char	t_intrc;
 17	char	t_quitc;
 18	char	t_startc;
 19	char	t_stopc;
 20	char	t_eofc;
 21	char	t_brkc;
 22};
 23
 24struct ltchars {
 25	char	t_suspc;
 26	char	t_dsuspc;
 27	char	t_rprntc;
 28	char	t_flushc;
 29	char	t_werasc;
 30	char	t_lnextc;
 31};
 32
 33struct winsize {
 34	unsigned short ws_row;
 35	unsigned short ws_col;
 36	unsigned short ws_xpixel;
 37	unsigned short ws_ypixel;
 38};
 39
 40#define NCC 8
 41struct termio {
 42	unsigned short c_iflag;		/* input mode flags */
 43	unsigned short c_oflag;		/* output mode flags */
 44	unsigned short c_cflag;		/* control mode flags */
 45	unsigned short c_lflag;		/* local mode flags */
 46	unsigned char c_line;		/* line discipline */
 47	unsigned char c_cc[NCC];	/* control characters */
 48};
 49
 50/*
 51 * c_cc characters in the termio structure.  Oh, how I love being
 52 * backwardly compatible.  Notice that character 4 and 5 are
 53 * interpreted differently depending on whether ICANON is set in
 54 * c_lflag.  If it's set, they are used as _VEOF and _VEOL, otherwise
 55 * as _VMIN and V_TIME.  This is for compatibility with OSF/1 (which
 56 * is compatible with sysV)...
 57 */
 58#define _VINTR	0
 59#define _VQUIT	1
 60#define _VERASE	2
 61#define _VKILL	3
 62#define _VEOF	4
 63#define _VMIN	4
 64#define _VEOL	5
 65#define _VTIME	5
 66#define _VEOL2	6
 67#define _VSWTC	7
 68
 69#ifdef __KERNEL__
 70/*	eof=^D		eol=\0		eol2=\0		erase=del
 71	werase=^W	kill=^U		reprint=^R	sxtc=\0
 72	intr=^C		quit=^\		susp=^Z		<OSF/1 VDSUSP>
 73	start=^Q	stop=^S		lnext=^V	discard=^U
 74	vmin=\1		vtime=\0
 75*/
 76#define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000"
 77
 78/*
 79 * Translate a "termio" structure into a "termios". Ugh.
 80 */
 81
 82#define user_termio_to_kernel_termios(a_termios, u_termio)			\
 83({										\
 84	struct ktermios *k_termios = (a_termios);				\
 85	struct termio k_termio;							\
 86	int canon, ret;								\
 87										\
 88	ret = copy_from_user(&k_termio, u_termio, sizeof(k_termio));		\
 89	if (!ret) {								\
 90		/* Overwrite only the low bits.  */				\
 91		*(unsigned short *)&k_termios->c_iflag = k_termio.c_iflag;	\
 92		*(unsigned short *)&k_termios->c_oflag = k_termio.c_oflag;	\
 93		*(unsigned short *)&k_termios->c_cflag = k_termio.c_cflag;	\
 94		*(unsigned short *)&k_termios->c_lflag = k_termio.c_lflag;	\
 95		canon = k_termio.c_lflag & ICANON;				\
 96										\
 97		k_termios->c_cc[VINTR]  = k_termio.c_cc[_VINTR];		\
 98		k_termios->c_cc[VQUIT]  = k_termio.c_cc[_VQUIT];		\
 99		k_termios->c_cc[VERASE] = k_termio.c_cc[_VERASE];		\
100		k_termios->c_cc[VKILL]  = k_termio.c_cc[_VKILL];		\
101		k_termios->c_cc[VEOL2]  = k_termio.c_cc[_VEOL2];		\
102		k_termios->c_cc[VSWTC]  = k_termio.c_cc[_VSWTC];		\
103		k_termios->c_cc[canon ? VEOF : VMIN]  = k_termio.c_cc[_VEOF];	\
104		k_termios->c_cc[canon ? VEOL : VTIME] = k_termio.c_cc[_VEOL];	\
105	}									\
106	ret;									\
107})
108
109/*
110 * Translate a "termios" structure into a "termio". Ugh.
111 *
112 * Note the "fun" _VMIN overloading.
113 */
114#define kernel_termios_to_user_termio(u_termio, a_termios)		\
115({									\
116	struct ktermios *k_termios = (a_termios);			\
117	struct termio k_termio;						\
118	int canon;							\
119									\
120	k_termio.c_iflag = k_termios->c_iflag;				\
121	k_termio.c_oflag = k_termios->c_oflag;				\
122	k_termio.c_cflag = k_termios->c_cflag;				\
123	canon = (k_termio.c_lflag = k_termios->c_lflag) & ICANON;	\
124									\
125	k_termio.c_line = k_termios->c_line;				\
126	k_termio.c_cc[_VINTR]  = k_termios->c_cc[VINTR];		\
127	k_termio.c_cc[_VQUIT]  = k_termios->c_cc[VQUIT];		\
128	k_termio.c_cc[_VERASE] = k_termios->c_cc[VERASE];		\
129	k_termio.c_cc[_VKILL]  = k_termios->c_cc[VKILL];		\
130	k_termio.c_cc[_VEOF]   = k_termios->c_cc[canon ? VEOF : VMIN];	\
131	k_termio.c_cc[_VEOL]   = k_termios->c_cc[canon ? VEOL : VTIME];	\
132	k_termio.c_cc[_VEOL2]  = k_termios->c_cc[VEOL2];		\
133	k_termio.c_cc[_VSWTC]  = k_termios->c_cc[VSWTC];		\
134									\
135	copy_to_user(u_termio, &k_termio, sizeof(k_termio));		\
136})
137
138#define user_termios_to_kernel_termios(k, u) \
139	copy_from_user(k, u, sizeof(struct termios))
140
141#define kernel_termios_to_user_termios(u, k) \
142	copy_to_user(u, k, sizeof(struct termios))
 
 
 
143
144#endif	/* __KERNEL__ */
 
145
146#endif	/* _ALPHA_TERMIOS_H */
v5.4
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _ALPHA_TERMIOS_H
 3#define _ALPHA_TERMIOS_H
 4
 5#include <uapi/asm/termios.h>
 
 6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 7/*	eof=^D		eol=\0		eol2=\0		erase=del
 8	werase=^W	kill=^U		reprint=^R	sxtc=\0
 9	intr=^C		quit=^\		susp=^Z		<OSF/1 VDSUSP>
10	start=^Q	stop=^S		lnext=^V	discard=^U
11	vmin=\1		vtime=\0
12*/
13#define INIT_C_CC "\004\000\000\177\027\025\022\000\003\034\032\000\021\023\026\025\001\000"
14
15/*
16 * Translate a "termio" structure into a "termios". Ugh.
17 */
18
19#define user_termio_to_kernel_termios(a_termios, u_termio)			\
20({										\
21	struct ktermios *k_termios = (a_termios);				\
22	struct termio k_termio;							\
23	int canon, ret;								\
24										\
25	ret = copy_from_user(&k_termio, u_termio, sizeof(k_termio));		\
26	if (!ret) {								\
27		/* Overwrite only the low bits.  */				\
28		*(unsigned short *)&k_termios->c_iflag = k_termio.c_iflag;	\
29		*(unsigned short *)&k_termios->c_oflag = k_termio.c_oflag;	\
30		*(unsigned short *)&k_termios->c_cflag = k_termio.c_cflag;	\
31		*(unsigned short *)&k_termios->c_lflag = k_termio.c_lflag;	\
32		canon = k_termio.c_lflag & ICANON;				\
33										\
34		k_termios->c_cc[VINTR]  = k_termio.c_cc[_VINTR];		\
35		k_termios->c_cc[VQUIT]  = k_termio.c_cc[_VQUIT];		\
36		k_termios->c_cc[VERASE] = k_termio.c_cc[_VERASE];		\
37		k_termios->c_cc[VKILL]  = k_termio.c_cc[_VKILL];		\
38		k_termios->c_cc[VEOL2]  = k_termio.c_cc[_VEOL2];		\
39		k_termios->c_cc[VSWTC]  = k_termio.c_cc[_VSWTC];		\
40		k_termios->c_cc[canon ? VEOF : VMIN]  = k_termio.c_cc[_VEOF];	\
41		k_termios->c_cc[canon ? VEOL : VTIME] = k_termio.c_cc[_VEOL];	\
42	}									\
43	ret;									\
44})
45
46/*
47 * Translate a "termios" structure into a "termio". Ugh.
48 *
49 * Note the "fun" _VMIN overloading.
50 */
51#define kernel_termios_to_user_termio(u_termio, a_termios)		\
52({									\
53	struct ktermios *k_termios = (a_termios);			\
54	struct termio k_termio;						\
55	int canon;							\
56									\
57	k_termio.c_iflag = k_termios->c_iflag;				\
58	k_termio.c_oflag = k_termios->c_oflag;				\
59	k_termio.c_cflag = k_termios->c_cflag;				\
60	canon = (k_termio.c_lflag = k_termios->c_lflag) & ICANON;	\
61									\
62	k_termio.c_line = k_termios->c_line;				\
63	k_termio.c_cc[_VINTR]  = k_termios->c_cc[VINTR];		\
64	k_termio.c_cc[_VQUIT]  = k_termios->c_cc[VQUIT];		\
65	k_termio.c_cc[_VERASE] = k_termios->c_cc[VERASE];		\
66	k_termio.c_cc[_VKILL]  = k_termios->c_cc[VKILL];		\
67	k_termio.c_cc[_VEOF]   = k_termios->c_cc[canon ? VEOF : VMIN];	\
68	k_termio.c_cc[_VEOL]   = k_termios->c_cc[canon ? VEOL : VTIME];	\
69	k_termio.c_cc[_VEOL2]  = k_termios->c_cc[VEOL2];		\
70	k_termio.c_cc[_VSWTC]  = k_termios->c_cc[VSWTC];		\
71									\
72	copy_to_user(u_termio, &k_termio, sizeof(k_termio));		\
73})
74
75#define user_termios_to_kernel_termios(k, u) \
76	copy_from_user(k, u, sizeof(struct termios2))
77
78#define kernel_termios_to_user_termios(u, k) \
79	copy_to_user(u, k, sizeof(struct termios2))
80
81#define user_termios_to_kernel_termios_1(k, u) \
82	copy_from_user(k, u, sizeof(struct termios))
83
84#define kernel_termios_to_user_termios_1(u, k) \
85	copy_to_user(u, k, sizeof(struct termios))
86
87#endif	/* _ALPHA_TERMIOS_H */