⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 termios.h

📁 一个简单的操作系统minix的核心代码
💻 H
字号:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				include/termios.h	 	 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

01100	/* The <termios.h> header is used for controlling tty modes. */
01101	
01102	#ifndef _TERMIOS_H
01103	#define _TERMIOS_H
01104	
01105	typedef unsigned short tcflag_t;
01106	typedef unsigned char cc_t;
01107	typedef unsigned int speed_t;
01108	
01109	#define NCCS            20      /* size of cc_c array, some extra space
01110	                                 * for extensions. */
01111	
01112	/* Primary terminal control structure. POSIX Table 7-1. */
01113	struct termios {
01114	  tcflag_t c_iflag;             /* input modes */
01115	  tcflag_t c_oflag;             /* output modes */
01116	  tcflag_t c_cflag;             /* control modes */
01117	  tcflag_t c_lflag;             /* local modes */
01118	  speed_t  c_ispeed;            /* input speed */
01119	  speed_t  c_ospeed;            /* output speed */
01120	  cc_t c_cc[NCCS];              /* control characters */
01121	};
01122	
01123	/* Values for termios c_iflag bit map.  POSIX Table 7-2. */
01124	#define BRKINT          0x0001  /* signal interrupt on break */
01125	#define ICRNL           0x0002  /* map CR to NL on input */
01126	#define IGNBRK          0x0004  /* ignore break */
01127	#define IGNCR           0x0008  /* ignore CR */
01128	#define IGNPAR          0x0010  /* ignore characters with parity errors */
01129	#define INLCR           0x0020  /* map NL to CR on input */
01130	#define INPCK           0x0040  /* enable input parity check */
01131	#define ISTRIP          0x0080  /* mask off 8th bit */
01132	#define IXOFF           0x0100  /* enable start/stop input control */
01133	#define IXON            0x0200  /* enable start/stop output control */
01134	#define PARMRK          0x0400  /* mark parity errors in the input queue */
01135	
01136	/* Values for termios c_oflag bit map.  POSIX Sec. 7.1.2.3. */
01137	#define OPOST           0x0001  /* perform output processing */
01138	
01139	/* Values for termios c_cflag bit map.  POSIX Table 7-3. */
01140	#define CLOCAL          0x0001  /* ignore modem status lines */
01141	#define CREAD           0x0002  /* enable receiver */
01142	#define CSIZE           0x000C  /* number of bits per character */
01143	#define         CS5     0x0000  /* if CSIZE is CS5, characters are 5 bits */
01144	#define         CS6     0x0004  /* if CSIZE is CS6, characters are 6 bits */
01145	#define         CS7     0x0008  /* if CSIZE is CS7, characters are 7 bits */
01146	#define         CS8     0x000C  /* if CSIZE is CS8, characters are 8 bits */
01147	#define CSTOPB          0x0010  /* send 2 stop bits if set, else 1 */
01148	#define HUPCL           0x0020  /* hang up on last close */
01149	#define PARENB          0x0040  /* enable parity on output */
01150	#define PARODD          0x0080  /* use odd parity if set, else even */
01151	
01152	/* Values for termios c_lflag bit map.  POSIX Table 7-4. */
01153	#define ECHO            0x0001  /* enable echoing of input characters */
01154	#define ECHOE           0x0002  /* echo ERASE as backspace */
01155	#define ECHOK           0x0004  /* echo KILL */
01156	#define ECHONL          0x0008  /* echo NL */
01157	#define ICANON          0x0010  /* canonical input (erase and kill enabled) */
01158	#define IEXTEN          0x0020  /* enable extended functions */
01159	#define ISIG            0x0040  /* enable signals */
01160	#define NOFLSH          0x0080  /* disable flush after interrupt or quit */
01161	#define TOSTOP          0x0100  /* send SIGTTOU (job control, not implemented*/
01162	
01163	/* Indices into c_cc array.  Default values in parentheses. POSIX Table 7-5. */
01164	#define VEOF               0    /* cc_c[VEOF] = EOF char (^D) */
01165	#define VEOL               1    /* cc_c[VEOL] = EOL char (undef) */
01166	#define VERASE             2    /* cc_c[VERASE] = ERASE char (^H) */
01167	#define VINTR              3    /* cc_c[VINTR] = INTR char (DEL) */
01168	#define VKILL              4    /* cc_c[VKILL] = KILL char (^U) */
01169	#define VMIN               5    /* cc_c[VMIN] = MIN value for timer */
01170	#define VQUIT              6    /* cc_c[VQUIT] = QUIT char (^\) */
01171	#define VTIME              7    /* cc_c[VTIME] = TIME value for timer */
01172	#define VSUSP              8    /* cc_c[VSUSP] = SUSP (^Z, ignored) */
01173	#define VSTART             9    /* cc_c[VSTART] = START char (^S) */
01174	#define VSTOP             10    /* cc_c[VSTOP] = STOP char (^Q) */
01175	
01176	#define _POSIX_VDISABLE   (cc_t)0xFF    /* You can't even generate this 
01177	                                         * character with 'normal' keyboards.
01178	                                         * But some language specific keyboards
01179	                                         * can generate 0xFF. It seems that all
01180	                                         * 256 are used, so cc_t should be a
01181	                                         * short...
01182	                                         */
01183	
01184	/* Values for the baud rate settings.  POSIX Table 7-6. */
01185	#define B0              0x0000  /* hang up the line */
01186	#define B50             0x1000  /* 50 baud */
01187	#define B75             0x2000  /* 75 baud */
01188	#define B110            0x3000  /* 110 baud */
01189	#define B134            0x4000  /* 134.5 baud */
01190	#define B150            0x5000  /* 150 baud */
01191	#define B200            0x6000  /* 200 baud */
01192	#define B300            0x7000  /* 300 baud */
01193	#define B600            0x8000  /* 600 baud */
01194	#define B1200           0x9000  /* 1200 baud */
01195	#define B1800           0xA000  /* 1800 baud */
01196	#define B2400           0xB000  /* 2400 baud */
01197	#define B4800           0xC000  /* 4800 baud */
01198	#define B9600           0xD000  /* 9600 baud */
01199	#define B19200          0xE000  /* 19200 baud */
01200	#define B38400          0xF000  /* 38400 baud */
01201	
01202	/* Optional actions for tcsetattr().  POSIX Sec. 7.2.1.2. */
01203	#define TCSANOW            1    /* changes take effect immediately */
01204	#define TCSADRAIN          2    /* changes take effect after output is done */
01205	#define TCSAFLUSH          3    /* wait for output to finish and flush input */
01206	
01207	/* Queue_selector values for tcflush().  POSIX Sec. 7.2.2.2. */
01208	#define TCIFLUSH           1    /* flush accumulated input data */
01209	#define TCOFLUSH           2    /* flush accumulated output data */
01210	#define TCIOFLUSH          3    /* flush accumulated input and output data */
01211	
01212	/* Action values for tcflow().  POSIX Sec. 7.2.2.2. */
01213	#define TCOOFF             1    /* suspend output */
01214	#define TCOON              2    /* restart suspended output */
01215	#define TCIOFF             3    /* transmit a STOP character on the line */
01216	#define TCION              4    /* transmit a START character on the line */
01217	
01218	
01219	/* Function Prototypes. */
01220	#ifndef _ANSI_H
01221	#include <ansi.h>
01222	#endif
01223	
01224	_PROTOTYPE( int tcsendbreak, (int _fildes, int _duration)                    );
01225	_PROTOTYPE( int tcdrain, (int _filedes)                                      );
01226	_PROTOTYPE( int tcflush, (int _filedes, int _queue_selector)                 );
01227	_PROTOTYPE( int tcflow, (int _filedes, int _action)                          );
01228	_PROTOTYPE( speed_t cfgetispeed, (const struct termios *_termios_p)          );
01229	_PROTOTYPE( speed_t cfgetospeed, (const struct termios *_termios_p)          );
01230	_PROTOTYPE( int cfsetispeed, (struct termios *_termios_p, speed_t _speed)    );
01231	_PROTOTYPE( int cfsetospeed, (struct termios *_termios_p, speed_t _speed)    );
01232	_PROTOTYPE( int tcgetattr, (int _filedes, struct termios *_termios_p)        );
01233	_PROTOTYPE( int tcsetattr, \
01234	        (int _filedes, int _opt_actions, const struct termios *_termios_p)   );
01235	
01236	#define cfgetispeed(termios_p)          ((termios_p)->c_ispeed)
01237	#define cfgetospeed(termios_p)          ((termios_p)->c_ospeed)
01238	#define cfsetispeed(termios_p, speed)   ((termios_p)->c_ispeed = (speed), 0)
01239	#define cfsetospeed(termios_p, speed)   ((termios_p)->c_ospeed = (speed), 0)
01240	
01241	#ifdef _MINIX
01242	/* Here are the local extensions to the POSIX standard for Minix. Posix
01243	 * conforming programs are not able to access these, and therefore they are
01244	 * only defined when a Minix program is compiled.
01245	 */
01246	
01247	/* Extensions to the termios c_iflag bit map.  */
01248	#define IXANY           0x0800  /* allow any key to continue ouptut */
01249	
01250	/* Extensions to the termios c_oflag bit map. They are only active iff
01251	 * OPOST is enabled. */
01252	#define ONLCR           0x0002  /* Map NL to CR-NL on output */
01253	#define XTABS           0x0004  /* Expand tabs to spaces */
01254	#define ONOEOT          0x0008  /* discard EOT's (^D) on output) */
01255	
01256	/* Extensions to the termios c_lflag bit map.  */
01257	#define LFLUSHO         0x0200  /* Flush output. */
01258	
01259	/* Extensions to the c_cc array. */
01260	#define VREPRINT          11    /* cc_c[VREPRINT] (^R) */
01261	#define VLNEXT            12    /* cc_c[VLNEXT] (^V) */
01262	#define VDISCARD          13    /* cc_c[VDISCARD] (^O) */
01263	
01264	/* Extensions to baud rate settings. */
01265	#define B57600          0x0100  /* 57600 baud */
01266	#define B115200         0x0200  /* 115200 baud */
01267	
01268	/* These are the default settings used by the kernel and by 'stty sane' */
01269	
01270	#define TCTRL_DEF       (CREAD | CS8 | HUPCL)
01271	#define TINPUT_DEF      (BRKINT | ICRNL | IXON | IXANY)
01272	#define TOUTPUT_DEF     (OPOST | ONLCR)
01273	#define TLOCAL_DEF      (ISIG | IEXTEN | ICANON | ECHO | ECHOE)
01274	#define TSPEED_DEF      B9600
01275	
01276	#define TEOF_DEF        '\4'    /* ^D */
01277	#define TEOL_DEF        _POSIX_VDISABLE
01278	#define TERASE_DEF      '\10'   /* ^H */
01279	#define TINTR_DEF       '\177'  /* ^? */
01280	#define TKILL_DEF       '\25'   /* ^U */
01281	#define TMIN_DEF        1
01282	#define TQUIT_DEF       '\34'   /* ^\ */
01283	#define TSTART_DEF      '\21'   /* ^Q */
01284	#define TSTOP_DEF       '\23'   /* ^S */
01285	#define TSUSP_DEF       '\32'   /* ^Z */
01286	#define TTIME_DEF       0
01287	#define TREPRINT_DEF    '\22'   /* ^R */
01288	#define TLNEXT_DEF      '\26'   /* ^V */
01289	#define TDISCARD_DEF    '\17'   /* ^O */
01290	
01291	/* Window size. This information is stored in the TTY driver but not used.
01292	 * This can be used for screen based applications in a window environment. 
01293	 * The ioctls TIOCGWINSZ and TIOCSWINSZ can be used to get and set this 
01294	 * information.
01295	 */
01296	
01297	struct winsize
01298	{
01299	        unsigned short  ws_row;         /* rows, in characters */
01300	        unsigned short  ws_col;         /* columns, in characters */
01301	        unsigned short  ws_xpixel;      /* horizontal size, pixels */
01302	        unsigned short  ws_ypixel;      /* vertical size, pixels */
01303	};
01304	#endif /* _MINIX */
01305	
01306	#endif /* _TERMIOS_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -