Linux Audio

Check our new training course

Loading...
v5.4
  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, 2000, 2001 by Ralf Baechle
  7 * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
  8 */
  9#ifndef _ASM_TERMIOS_H
 10#define _ASM_TERMIOS_H
 11
 12#include <linux/uaccess.h>
 13#include <uapi/asm/termios.h>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 14
 15/*
 16 *	intr=^C		quit=^\		erase=del	kill=^U
 17 *	vmin=\1		vtime=\0	eol2=\0		swtc=\0
 18 *	start=^Q	stop=^S		susp=^Z		vdsusp=
 19 *	reprint=^R	discard=^U	werase=^W	lnext=^V
 20 *	eof=^D		eol=\0
 21 */
 22#define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 23
 24#include <linux/string.h>
 25
 26/*
 27 * Translate a "termio" structure into a "termios". Ugh.
 28 */
 29static inline int user_termio_to_kernel_termios(struct ktermios *termios,
 30	struct termio __user *termio)
 31{
 32	unsigned short iflag, oflag, cflag, lflag;
 33	unsigned int err;
 34
 35	if (!access_ok(termio, sizeof(struct termio)))
 36		return -EFAULT;
 37
 38	err = __get_user(iflag, &termio->c_iflag);
 39	termios->c_iflag = (termios->c_iflag & 0xffff0000) | iflag;
 40	err |=__get_user(oflag, &termio->c_oflag);
 41	termios->c_oflag = (termios->c_oflag & 0xffff0000) | oflag;
 42	err |=__get_user(cflag, &termio->c_cflag);
 43	termios->c_cflag = (termios->c_cflag & 0xffff0000) | cflag;
 44	err |=__get_user(lflag, &termio->c_lflag);
 45	termios->c_lflag = (termios->c_lflag & 0xffff0000) | lflag;
 46	err |=__get_user(termios->c_line, &termio->c_line);
 47	if (err)
 48		return -EFAULT;
 49
 50	if (__copy_from_user(termios->c_cc, termio->c_cc, NCC))
 51		return -EFAULT;
 52
 53	return 0;
 54}
 55
 56/*
 57 * Translate a "termios" structure into a "termio". Ugh.
 58 */
 59static inline int kernel_termios_to_user_termio(struct termio __user *termio,
 60	struct ktermios *termios)
 61{
 62	int err;
 63
 64	if (!access_ok(termio, sizeof(struct termio)))
 65		return -EFAULT;
 66
 67	err = __put_user(termios->c_iflag, &termio->c_iflag);
 68	err |= __put_user(termios->c_oflag, &termio->c_oflag);
 69	err |= __put_user(termios->c_cflag, &termio->c_cflag);
 70	err |= __put_user(termios->c_lflag, &termio->c_lflag);
 71	err |= __put_user(termios->c_line, &termio->c_line);
 72	if (err)
 73		return -EFAULT;
 74
 75	if (__copy_to_user(termio->c_cc, termios->c_cc, NCC))
 76		return -EFAULT;
 77
 78	return 0;
 79}
 80
 81static inline int user_termios_to_kernel_termios(struct ktermios __user *k,
 82	struct termios2 *u)
 83{
 84	return copy_from_user(k, u, sizeof(struct termios2)) ? -EFAULT : 0;
 85}
 86
 87static inline int kernel_termios_to_user_termios(struct termios2 __user *u,
 88	struct ktermios *k)
 89{
 90	return copy_to_user(u, k, sizeof(struct termios2)) ? -EFAULT : 0;
 91}
 92
 93static inline int user_termios_to_kernel_termios_1(struct ktermios *k,
 94	struct termios __user *u)
 95{
 96	return copy_from_user(k, u, sizeof(struct termios)) ? -EFAULT : 0;
 97}
 98
 99static inline int kernel_termios_to_user_termios_1(struct termios __user *u,
100	struct ktermios *k)
101{
102	return copy_to_user(u, k, sizeof(struct termios)) ? -EFAULT : 0;
103}
 
 
104
105#endif /* _ASM_TERMIOS_H */
v3.1
  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, 2000, 2001 by Ralf Baechle
  7 * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
  8 */
  9#ifndef _ASM_TERMIOS_H
 10#define _ASM_TERMIOS_H
 11
 12#include <linux/errno.h>
 13#include <asm/termbits.h>
 14#include <asm/ioctls.h>
 15
 16struct sgttyb {
 17	char	sg_ispeed;
 18	char	sg_ospeed;
 19	char	sg_erase;
 20	char	sg_kill;
 21	int	sg_flags;	/* SGI special - int, not short */
 22};
 23
 24struct tchars {
 25	char	t_intrc;
 26	char	t_quitc;
 27	char	t_startc;
 28	char	t_stopc;
 29	char	t_eofc;
 30	char	t_brkc;
 31};
 32
 33struct ltchars {
 34        char    t_suspc;        /* stop process signal */
 35        char    t_dsuspc;       /* delayed stop process signal */
 36        char    t_rprntc;       /* reprint line */
 37        char    t_flushc;       /* flush output (toggles) */
 38        char    t_werasc;       /* word erase */
 39        char    t_lnextc;       /* literal next character */
 40};
 41
 42/* TIOCGSIZE, TIOCSSIZE not defined yet.  Only needed for SunOS source
 43   compatibility anyway ... */
 44
 45struct winsize {
 46	unsigned short ws_row;
 47	unsigned short ws_col;
 48	unsigned short ws_xpixel;
 49	unsigned short ws_ypixel;
 50};
 51
 52#define NCC	8
 53struct termio {
 54	unsigned short c_iflag;		/* input mode flags */
 55	unsigned short c_oflag;		/* output mode flags */
 56	unsigned short c_cflag;		/* control mode flags */
 57	unsigned short c_lflag;		/* local mode flags */
 58	char c_line;			/* line discipline */
 59	unsigned char c_cc[NCCS];	/* control characters */
 60};
 61
 62#ifdef __KERNEL__
 63#include <linux/module.h>
 64
 65/*
 66 *	intr=^C		quit=^\		erase=del	kill=^U
 67 *	vmin=\1		vtime=\0	eol2=\0		swtc=\0
 68 *	start=^Q	stop=^S		susp=^Z		vdsusp=
 69 *	reprint=^R	discard=^U	werase=^W	lnext=^V
 70 *	eof=^D		eol=\0
 71 */
 72#define INIT_C_CC "\003\034\177\025\1\0\0\0\021\023\032\0\022\017\027\026\004\0"
 73#endif
 74
 75/* modem lines */
 76#define TIOCM_LE	0x001		/* line enable */
 77#define TIOCM_DTR	0x002		/* data terminal ready */
 78#define TIOCM_RTS	0x004		/* request to send */
 79#define TIOCM_ST	0x010		/* secondary transmit */
 80#define TIOCM_SR	0x020		/* secondary receive */
 81#define TIOCM_CTS	0x040		/* clear to send */
 82#define TIOCM_CAR	0x100		/* carrier detect */
 83#define TIOCM_CD	TIOCM_CAR
 84#define TIOCM_RNG	0x200		/* ring */
 85#define TIOCM_RI	TIOCM_RNG
 86#define TIOCM_DSR	0x400		/* data set ready */
 87#define TIOCM_OUT1	0x2000
 88#define TIOCM_OUT2	0x4000
 89#define TIOCM_LOOP	0x8000
 90
 91#ifdef __KERNEL__
 92
 93#include <linux/string.h>
 94
 95/*
 96 * Translate a "termio" structure into a "termios". Ugh.
 97 */
 98static inline int user_termio_to_kernel_termios(struct ktermios *termios,
 99	struct termio __user *termio)
100{
101	unsigned short iflag, oflag, cflag, lflag;
102	unsigned int err;
103
104	if (!access_ok(VERIFY_READ, termio, sizeof(struct termio)))
105		return -EFAULT;
106
107	err = __get_user(iflag, &termio->c_iflag);
108	termios->c_iflag = (termios->c_iflag & 0xffff0000) | iflag;
109	err |=__get_user(oflag, &termio->c_oflag);
110	termios->c_oflag = (termios->c_oflag & 0xffff0000) | oflag;
111	err |=__get_user(cflag, &termio->c_cflag);
112	termios->c_cflag = (termios->c_cflag & 0xffff0000) | cflag;
113	err |=__get_user(lflag, &termio->c_lflag);
114	termios->c_lflag = (termios->c_lflag & 0xffff0000) | lflag;
115	err |=__get_user(termios->c_line, &termio->c_line);
116	if (err)
117		return -EFAULT;
118
119	if (__copy_from_user(termios->c_cc, termio->c_cc, NCC))
120		return -EFAULT;
121
122	return 0;
123}
124
125/*
126 * Translate a "termios" structure into a "termio". Ugh.
127 */
128static inline int kernel_termios_to_user_termio(struct termio __user *termio,
129	struct ktermios *termios)
130{
131	int err;
132
133	if (!access_ok(VERIFY_WRITE, termio, sizeof(struct termio)))
134		return -EFAULT;
135
136	err = __put_user(termios->c_iflag, &termio->c_iflag);
137	err |= __put_user(termios->c_oflag, &termio->c_oflag);
138	err |= __put_user(termios->c_cflag, &termio->c_cflag);
139	err |= __put_user(termios->c_lflag, &termio->c_lflag);
140	err |= __put_user(termios->c_line, &termio->c_line);
141	if (err)
142		return -EFAULT;
143
144	if (__copy_to_user(termio->c_cc, termios->c_cc, NCC))
145		return -EFAULT;
146
147	return 0;
148}
149
150static inline int user_termios_to_kernel_termios(struct ktermios __user *k,
151	struct termios2 *u)
152{
153	return copy_from_user(k, u, sizeof(struct termios2)) ? -EFAULT : 0;
154}
155
156static inline int kernel_termios_to_user_termios(struct termios2 __user *u,
157	struct ktermios *k)
158{
159	return copy_to_user(u, k, sizeof(struct termios2)) ? -EFAULT : 0;
160}
161
162static inline int user_termios_to_kernel_termios_1(struct ktermios *k,
163	struct termios __user *u)
164{
165	return copy_from_user(k, u, sizeof(struct termios)) ? -EFAULT : 0;
166}
167
168static inline int kernel_termios_to_user_termios_1(struct termios __user *u,
169	struct ktermios *k)
170{
171	return copy_to_user(u, k, sizeof(struct termios)) ? -EFAULT : 0;
172}
173
174#endif /* defined(__KERNEL__) */
175
176#endif /* _ASM_TERMIOS_H */