Root/target/linux/ubicom32/files/arch/ubicom32/include/asm/termios.h

1/*
2 * arch/ubicom32/include/asm/termios.h
3 * Ubicom32 termio definitions.
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 * arch/m68knommu
25 * arch/blackfin
26 * arch/parisc
27 */
28#ifndef _ASM_UBICOM32_TERMIOS_H
29#define _ASM_UBICOM32_TERMIOS_H
30
31#include <asm/termbits.h>
32#include <asm/ioctls.h>
33
34struct winsize {
35    unsigned short ws_row;
36    unsigned short ws_col;
37    unsigned short ws_xpixel;
38    unsigned short ws_ypixel;
39};
40
41#define NCC 8
42struct termio {
43    unsigned short c_iflag; /* input mode flags */
44    unsigned short c_oflag; /* output mode flags */
45    unsigned short c_cflag; /* control mode flags */
46    unsigned short c_lflag; /* local mode flags */
47    unsigned char c_line; /* line discipline */
48    unsigned char c_cc[NCC]; /* control characters */
49};
50
51#ifdef __KERNEL__
52/* intr=^C quit=^| erase=del kill=^U
53    eof=^D vtime=\0 vmin=\1 sxtc=\0
54    start=^Q stop=^S susp=^Z eol=\0
55    reprint=^R discard=^U werase=^W lnext=^V
56    eol2=\0
57*/
58#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
59#endif
60
61/* modem lines */
62#define TIOCM_LE 0x001
63#define TIOCM_DTR 0x002
64#define TIOCM_RTS 0x004
65#define TIOCM_ST 0x008
66#define TIOCM_SR 0x010
67#define TIOCM_CTS 0x020
68#define TIOCM_CAR 0x040
69#define TIOCM_RNG 0x080
70#define TIOCM_DSR 0x100
71#define TIOCM_CD TIOCM_CAR
72#define TIOCM_RI TIOCM_RNG
73#define TIOCM_OUT1 0x2000
74#define TIOCM_OUT2 0x4000
75#define TIOCM_LOOP 0x8000
76
77/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
78
79#ifdef __KERNEL__
80
81/*
82 * Translate a "termio" structure into a "termios". Ugh.
83 */
84#define user_termio_to_kernel_termios(termios, termio) \
85({ \
86    unsigned short tmp; \
87    get_user(tmp, &(termio)->c_iflag); \
88    (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \
89    get_user(tmp, &(termio)->c_oflag); \
90    (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \
91    get_user(tmp, &(termio)->c_cflag); \
92    (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \
93    get_user(tmp, &(termio)->c_lflag); \
94    (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \
95    get_user((termios)->c_line, &(termio)->c_line); \
96    copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
97})
98
99/*
100 * Translate a "termios" structure into a "termio". Ugh.
101 */
102#define kernel_termios_to_user_termio(termio, termios) \
103({ \
104    put_user((termios)->c_iflag, &(termio)->c_iflag); \
105    put_user((termios)->c_oflag, &(termio)->c_oflag); \
106    put_user((termios)->c_cflag, &(termio)->c_cflag); \
107    put_user((termios)->c_lflag, &(termio)->c_lflag); \
108    put_user((termios)->c_line, &(termio)->c_line); \
109    copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
110})
111
112#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
113#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
114#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
115#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
116
117#endif /* __KERNEL__ */
118
119#endif /* _ASM_UBICOM32_TERMIOS_H */
120

Archive Download this file



interactive