summaryrefslogtreecommitdiff
path: root/sys/kern/tty.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't include <sys/ioctl.h> in the kernel. Stage 5: includeBruce Evans1997-03-241-2/+5
| | | | | | | | | <sys/ioctl_compat.h> and sometimes <sys/filio.h> instead of <sys/ioctl.h> in tty-related files. <sys/ttycom.h> is still usually imported bogusly via <sys/termios.h>. Notes: svn path=/head/; revision=24207
* Don't #include <sys/fcntl.h> in <sys/file.h> if KERNEL is defined.Bruce Evans1997-03-231-2/+2
| | | | | | | | Fixed everything that depended on getting fcntl.h stuff from the wrong place. Most things don't depend on file.h stuff at all. Notes: svn path=/head/; revision=24131
* Fixed some invalid (non-atomic) accesses to `time', mostly ones of theBruce Evans1997-03-221-7/+3
| | | | | | | | | form `tv = time'. Use a new function gettime(). The current version just forces atomicicity without fixing precision or efficiency bugs. Simplified some related valid accesses by using the central function. Notes: svn path=/head/; revision=24101
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notPeter Wemm1997-02-221-1/+1
| | | | | | | ready for it yet. Notes: svn path=/head/; revision=22975
* This is the kernel Lite/2 commit. There are some requisite userlandJohn Dyson1997-02-101-1/+1
| | | | | | | | | | | | | | | | | | changes, so don't expect to be able to run the kernel as-is (very well) without the appropriate Lite/2 userland changes. The system boots and can mount UFS filesystems. Untested: ext2fs, msdosfs, NFS Known problems: Incorrect Berkeley ID strings in some files. Mount_std mounts will not work until the getfsent library routine is changed. Reviewed by: various people Submitted by: Jeffery Hsu <hsu@freebsd.org> Notes: svn path=/head/; revision=22521
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* Help broken d_stop() routines by flushing the output queue beforeBruce Evans1996-11-291-2/+4
| | | | | | | | | calling them (as well as after). Found by: NIST PCTS Notes: svn path=/head/; revision=20025
* Fixed bugs handling (background) orphaned process groups. ttyBruce Evans1996-11-291-5/+10
| | | | | | | | | | writes and tty ioctls by processes in such groups must return -1/EIO, but they were allowed. tty reads were handled correctly. Found by: NIST PCTS Notes: svn path=/head/; revision=20024
* Fixed some bugs in BREAK handling. If BRKINT is set, then always flushBruce Evans1996-11-291-7/+8
| | | | | | | | | | | | the queues and generate a SIGINT. Previously, this wasn't done if ISIG was clear or the VINTR character was disabled, and it was done by converting the BREAK to a VINTR character and sometimes bogusly echoing this character. Found by: NIST-PCTS Notes: svn path=/head/; revision=20021
* Fixed handling of non-POSIX control characters. They must not doBruce Evans1996-11-291-9/+11
| | | | | | | | | anything special unless IEXTEN is set. Found by: NIST-PCTS Notes: svn path=/head/; revision=20020
* Fixed the easy cases of const poisoning in the kernel. Cosmetic.Bruce Evans1996-08-311-3/+3
| | | | Notes: svn path=/head/; revision=17974
* Fixed a wrong comment. Did tsleep() ever return the networking errnoBruce Evans1996-08-281-2/+2
| | | | | | | ETIMEDOUT? Notes: svn path=/head/; revision=17876
* Clean up -Wunused warnings.Gary Palmer1996-06-121-1/+3
| | | | | | | Reviewed by: bde Notes: svn path=/head/; revision=16322
* removed:Poul-Henning Kamp1996-05-021-2/+2
| | | | | | | | | | | | CLBYTES PD_SHIFT PGSHIFT NBPG PGOFSET CLSIZELOG2 CLSIZE pdei() ptei() kvtopte() ptetov() ispt() ptetoav() &c &c new: NPDEPG Major macro cleanup. Notes: svn path=/head/; revision=15543
* From Lite2: proc LIST changes.Jeffrey Hsu1996-03-111-3/+3
| | | | | | | Reviewed by: david & bde Notes: svn path=/head/; revision=14529
* Add more options into the conf/options and i386/conf/options.i386 filesPeter Wemm1996-03-021-1/+2
| | | | | | | | | and the #include hooks so that 'make depend' is more useful. This covers most of the options I regularly use (but not all) and some other easy ones. Notes: svn path=/head/; revision=14328
* Oops, the last commit missed one change from 200 to OBUFSIZ + 100.Bruce Evans1995-12-161-2/+2
| | | | Notes: svn path=/head/; revision=12900
* Changed the maximum output queue count from (TTMAXHIWAT + 200) toBruce Evans1995-12-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (TTMAXHIWAT + OBUFSIZ + 100) in case someone changes OBUFSIZ. 200 was to allow 100 above high water for ordinary writes and another 100 for kernel printfs. Increased the reserved output queue count from 512 to the maximum output queue count. This prevents exhaustion of clists and increases the output throughput for 8 cy lines by almost a factor of 2 (on a system where there aren't many other open ttys so clists become exhausted after about 4 active lines (or earlier if TTMAXHIWAT is increased :-]). ttwrite() behaves very badly when clists are exhausted: (1) it sleeps on lbolt instead of on TSA_OLOWAT(tp). This could be fixed adequately by sleeping on TSA_OLOWAT(tp). The nonzero reserved count guaratees that space will become available independent of other ttys, and a reserved count of 512 is barely enough for efficiency. (2) it drops output if space runs out in the middle of special output processing. This is too hard to fix without hardening the reserved count. The watermark processing guarantees that space doesn't run out only if the advertised space is guaranteed. Increasing the reserved output queue count defeats the point of dynamic allocation of clists. Previously, about 2K of memory per tty was reserved (the raw queue was already reserved). Now, about 3.5K is reserved. Reserving everything would take a whole 0.5K more. Notes: svn path=/head/; revision=12856
* Disabled the sleep in ttyflush(). It can't work in general becauseBruce Evans1995-12-151-1/+15
| | | | | | | | | ttyflush() might be called from an interrupt handler. This fixes panics in IXOFF mode at the cost of more failures to send the START character to exit from IXOFF mode. Notes: svn path=/head/; revision=12855
* Restored unused function ttrstrt(). It would be used if the low levelBruce Evans1995-12-141-1/+27
| | | | | | | drivers supported inter-character delays. Notes: svn path=/head/; revision=12841
* A Major staticize sweep. Generates a couple of warnings that I'll dealPoul-Henning Kamp1995-12-141-23/+6
| | | | | | | | | with later. A number of unused vars removed. A number of unused procs removed or #ifdefed. Notes: svn path=/head/; revision=12819
* devsw tables are now arrays of POINTERS to struct [cb]devswJulian Elischer1995-12-131-6/+6
| | | | | | | | | | | | seems to work hre just fine though I can't check every file that changed due to limmited h/w, however I've checked enught to be petty happy withe hte code.. WARNING... struct lkm[mumble] has changed so it might be an idea to recompile any lkm related programs Notes: svn path=/head/; revision=12813
* Untangled the vm.h include file spaghetti.David Greenman1995-12-071-1/+6
| | | | Notes: svn path=/head/; revision=12662
* Fixed initialization of TS_CONNECTED bit in t_state. It wasn'tBruce Evans1995-10-311-1/+4
| | | | | | | | | | | set in open() when CLOCAL is set unless carrier is present. Fixed initialization of line discipline. It lived across opens. Lines that started with the wrong discipline probably didn't work at all, because TS_ISOPEN is only set by TTYDISC. Notes: svn path=/head/; revision=11965
* Fix wakeups for TIOCDRAINWAIT. The conditional wakeups introduced in revBruce Evans1995-09-101-2/+3
| | | | | | | | 1.59 defeated the point of doing the wakeups (having reduced timeouts take effect immediately). Notes: svn path=/head/; revision=10658
* Check for valid speed values in pty driveAndrey A. Chernov1995-08-021-22/+2
| | | | | | | | | Check for negative speed values in tty drive Back out valid speed values checking from tty drive Suggested by: bde Notes: svn path=/head/; revision=9851
* Optimize a bit valid speed search using fact that speed table sortedAndrey A. Chernov1995-08-011-1/+5
| | | | | | | | Submitted by: Obtained from: Notes: svn path=/head/; revision=9848
* Check for valid speeds in TIOCSET* and return EINVAL for incorrectAndrey A. Chernov1995-08-011-1/+19
| | | | | | | values instead of setting garbadge. Notes: svn path=/head/; revision=9847
* Obtained from: partly from ancient patches of mine via 1.1.5Bruce Evans1995-07-311-2/+2
| | | | | | | | | Change all short variables in `struct tty' to int. Shorts were only right on ancient systems with ints optimized for vaxness over efficiency. Notes: svn path=/head/; revision=9833
* Obtained from: partly from ancient patches of mine via 1.1.5Bruce Evans1995-07-311-2/+6
| | | | | | | | Handle MDMBUF a little better. Prepare to handle 4 different kinds of output flow control. Notes: svn path=/head/; revision=9832
* Obtained from: an ancient patch of mine via 1.1.5Bruce Evans1995-07-311-1/+2
| | | | | | | | Clear PENDIN when input is flushed so that the handling of future input doesn't get pessimized. Notes: svn path=/head/; revision=9829
* Obtained from: partly from ancient patches of mine via 1.1.5Bruce Evans1995-07-311-57/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce TS_CONNECTED and TS_ZOMBIE states. TS_CONNECTED is set while a connection is established. It is set while (TS_CARR_ON or CLOCAL is set) and TS_ZOMBIE is clear. TS_ZOMBIE is set for on to off transitions of TS_CARR_ON that occur when CLOCAL is clear and is cleared for off to on transitions of CLOCAL. I/o can only occur while TS_CONNECTED is set. TS_ZOMBIE prevents further i/o. Split the input-event sleep address TSA_CARR_ON(tp) into TSA_CARR_ON(tp) and TSA_HUP_OR_INPUT(tp). The former address is now used only for off to on carrier transitions and equivalent CLOCAL transitions. The latter is used for all input events, all carrier transitions and certain CLOCAL transitions. There are some harmless extra wakeups for rare connection- related events. Previously there were too many extra wakeups for non-rare input events. Drivers now call l_modem() instead of setting TS_CARR_ON directly to handle even the initial off to on transition of carrier. They should always have done this. l_modem() now handles TS_CONNECTED and TS_ZOMBIE as well as TS_CARR_ON. gnu/isdn/iitty.c: Set TS_CONNECTED for first open ourself to go with bogusly setting CLOCAL. i386/isa/syscons.c, i386/isa/pcvt/pcvt_drv.c: We fake carrier, so don't also fake CLOCAL. kern/tty.c: Testing TS_CONNECTED instead of TS_CARR_ON fixes TIOCCONS forgetting to test CLOCAL. TS_ISOPEN was tested instead, but that broke when we disabled the clearing of TS_ISOPEN for certain transitions of CLOCAL. Testing TS_CONNECTED fixes ttyselect() returning false success for output to devices in state !TS_CARR_ON && !CLOCAL. Optimize the other selwakeup() call (this is not related to the other changes). kern/tty_pty.c: ptcopen() can be declared in traditional C now that dev_t isn't short. Notes: svn path=/head/; revision=9824
* Assorted cosmetic changes:Bruce Evans1995-07-311-26/+29
| | | | | | | | | | | | | | | | | | | | | | Make more functions static. tty.c: Use tcflag_t (u_long) and cc_t instead of u_char and int/long. Don't record values that are only evaluated once. Compare ints using imin(), not min(). min() is for comparing u_ints. Old versions of tty.c used the type-safe but multiple-evaluation-unsafe macro MIN(). The args are apparently never negative; otherwise this change would be non-cosmetic. Don't repeat the loop test in ttywait(). tty.h: Improve English in and formatting of comments. Notes: svn path=/head/; revision=9823
* Improve input flow control.Bruce Evans1995-07-311-60/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use input buffer watermarks of TTYHOG-512 (high) and (high)*7/8 (low) instead of TTYHOG/2 (high) and TTYHOG/5 (low) to agree with some drivers. 512 is magic and some things depended on TTYHOG/2 >= TTYHOG-512 to work; now they depend on the 512 magic not changing and TTYHOG-512 being significantly larger than 0. This should be handled in ttsetwater(). Separate the decision about whether to do input flow control from doing it. ttyblock() now just starts input flow control (hardware and/or software) and there is a new function ttyunblock() to stop it. The decisions are the same except for the watermark changes and allowing for input expansion for PARMRK. When flushing input, try harder at first to send a start character if required, but give up if the first attempt fails. cy.c, rc.c, sio.c: Simplify: let ttyinput() handle input flow control if it is not being bypassed. Use ttyblock() to start flow control otherwise. rc.c: Use same input flow control test as elsewhere: test in a more efficient order and start flow control at >= highwater instead of at > highwater. Notes: svn path=/head/; revision=9822
* Don't swap the queue headers to implement concatenation of theBruce Evans1995-07-301-14/+23
| | | | | | | | | | | | | | | | | | | | queues for TIOCSETA[W]. Swapping an even number of times broke the queue resource limits. This would have broken CRTSCTS flow control if the clist slush list was used up. Don'concatenate the queues for TIOCSETA[W] if one of the queues has a resource limit of 0. Concatenation would cause a panic if one of the queues is nonempty and the other is limited to length 0. This may have caused panics in PPPDISC. Wake up readers after all transitions of ICANON. When ICANON is turned off it is quite likely that characters will become available to be read. Reduce indentation near these changes. Notes: svn path=/head/; revision=9796
* Split TS_ASLEEP (sleep on output [below low water])into TS_SO_OLOWAT (sleepBruce Evans1995-07-301-36/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | on output below low water) and TS_SO_OCOMPLETE (sleep on output complete). Most of the support for this has already been committed. Drivers should call ttwwakeup() to handle wakeups whenever output is below low water (and some output event causes this condition to be checked) or TS_BUSY is cleared. tty.c: Fix the livelock in ttywait() properly by sleeping on output complete, not on output below low water. Use ttwwakeup() instead of separate select and output wakeups for all wakeups of writers. Add wakeups of writers for output flushes and carrier/clocal transitions. Don't go to sleep in ttycheckoutq() if ttstart() reduces the queue to below low water. Use the timeout built into tsleep() in ttycheckoutq(). Optimize the select wakeup in ttwwakeup(). It seems reasonable to know too much about the internals of tp->t_wsel now that the knowledge is localised in tty.c. Notes: svn path=/head/; revision=9790
* Obtained from: partly from ancient patches by ache and me via 1.1.5Bruce Evans1995-07-291-24/+1
| | | | | | | | | | | | | | | | | | | Remove nullmodem(). It may be useful to have a null modem routine, but nullmodem() wasn't one. nullmodem() was identical to ttymodem() except it didn't implement MDMBUF (carrier) flow control, didn't do any wakeups for off to on carrier transitions, and didn't flush the i/o queues for on to off carrier transitions (flushing has the side effect of waking up readers and writers) although it did generate SIGHUPs. The wakeups must normally be done even if nullmodem() is null in case something is sleeping waiting for a carrier transition. In any case, the wakeups should be harmless. They may cause bogus results for select(), but select() is already bogus for nonstandard line disciplines. Notes: svn path=/head/; revision=9763
* Obtained from: partly from ancient patches of mine via 1.1.5Bruce Evans1995-07-221-11/+11
| | | | | | | | Give names to the magic tty i/o sleep addresses and use them. This makes it easier to remember what the addresses are for and to keep them unique. Notes: svn path=/head/; revision=9639
* Move the inline code for waking up writers to a new functionBruce Evans1995-07-221-1/+18
| | | | | | | | | | | | | | ttwwakeup(). The conditions for doing the wakeup will soon become more complicated and I don't want them duplicated in all drivers. It's probably not worth making ttwwakeup() a macro or an inline function. The cost of the function call is relatively small when there is a process to wake up. There is usually a process to wake up for large writes and the system call overhead dwarfs the function call overhead for small writes. Notes: svn path=/head/; revision=9626
* Obtained from: partly from ancient patches of mine via 1.1.5Bruce Evans1995-07-211-2/+13
| | | | | | | | Move static termioschars() from a couple of drivers to tty.c. Now there is only one copy of ttydefchars[]. Notes: svn path=/head/; revision=9625
* Obtained from: partly from ancient patches by ache and me via 1.1.5Bruce Evans1995-07-211-20/+15
| | | | | | | | Nuke `symbolic sleep message strings'. Use unique literal messages so that `ps l' shows unambiguously where processes are sleeping. Notes: svn path=/head/; revision=9624
* Obtained from: partly from anancient patch of mine via 1.1.5Bruce Evans1995-07-211-3/+11
| | | | | | | Fix races for FIONREAD, TIOCSTI and TIOCSTAT. Notes: svn path=/head/; revision=9622
* Obtained from: partly from an ancient patch of mine via 1.1.5Bruce Evans1995-07-211-4/+2
| | | | | | | | | | | | | | | | | | Temporarily nuke TS_WOPEN. It was only used for the obscure MDMBUF flow control option in the kernel and for informational purposes in `pstat -t'. The latter worked properly only for ptys. In general there may be multiple processes sleeping in open() and multiple processes that successfully opened the tty by opening it in O_NONBLOCK mode or during a window when CLOCAL was set. tty.c doesn't have enough information to maintain the flag but always cleared it in ttyopen(). TS_WOPEN should be restored someday just so that `pstat -t' can display it (MDMBUF is already fixed). Fixing it requires counting of processes sleeping in open() in too many serial drivers. Notes: svn path=/head/; revision=9619
* Obtained from: an ancient patch of mine via 1.1.5Bruce Evans1995-07-211-3/+11
| | | | | | | | | | Don't put partial PARMRK escape sequences in the input queue. Use MAX_INPUT = TTYHOG instead of TTYHOG directly for the maximum input queue size. Don't use the bogus MAX_INPUT advertised in <sys/syslimits.h>. Notes: svn path=/head/; revision=9617
* Add to TODO list and move it to near the top of the file.Bruce Evans1995-07-211-18/+29
| | | | Notes: svn path=/head/; revision=9616
* Obtained from: ancient usenet posting as applied to 1.1.5Bruce Evans1995-07-211-2/+2
| | | | | | | | | | | First of many changes required to restore lost stability to the tty driver. ECHONL is supposed to enable echoing of NL when ECHO is off, but it enabled echoing of everything except NL. Notes: svn path=/head/; revision=9615
* ttywait: convert EWOULDBLOCK to EIO, when t_timeout expiredAndrey A. Chernov1995-06-241-1/+3
| | | | Notes: svn path=/head/; revision=9293
* Replace EWOULDBLOCK to EIO in ttwrite, when t_timeout expiredAndrey A. Chernov1995-06-231-1/+3
| | | | Notes: svn path=/head/; revision=9289
* Merge RELENG_2_0_5 into HEADRodney W. Grimes1995-06-111-4/+21
| | | | Notes: svn path=/head/; revision=9202
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-2/+2
| | | | Notes: svn path=/head/; revision=8876