summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
Commit message (Collapse)AuthorAgeFilesLines
* Call tty_close() at the very end of ttyclose() since otherwise NULLjhb2004-12-301-1/+1
| | | | | | | deferences can occur since tty_close() may end up freeing the tty structure if it drops the last reference to it. Glanced at by: phk
* fix a misleading sleep identifier.phk2004-12-201-1/+1
|
* Improvements and fixes in the 1.241 commit:dds2004-11-161-6/+9
| | | | | | | | | | | - Have TS_ZOMBIE ttys return POLLHUP instead of POLLERR - Remove unneeded POLLWRNORM (old bug) - TS_ZOMBIE ttys will set POLLIN and POLLRDNORM - Do not call selrecord in TS_ZOMBIE ttys PR: kern/73821 Reviewed by: bde MFC after: 4 weeks
* Return POLLERR rather than POLLIN/POLLOUT on TS_ZOMBIE ttys.dds2004-11-111-4/+5
| | | | | PR: kern/73821 MFC after: 4 weeks
* Restore TTYDEF_LFLAG to set echo bits.phk2004-11-031-1/+1
|
* Add new function ttyinitmode() which sets our systemwide defaultphk2004-10-181-12/+29
| | | | | | | | | | | | | | modes on a tty structure. Both the ".init" and the current settings are initialized allowing the function to be used both at attach and open time. The function takes an argument to decide if echoing should be enabled. Echoing should not be enabled for regular physical serial ports unless they are consoles, in which case they should be configured by ttyconsolemode() instead. Use the new function throughout.
* Make pty's always come up in echo mode.phk2004-10-151-1/+1
|
* Add missing chunk of code to enforce the lock-bits of termios.phk2004-10-141-1/+26
| | | | | | | This solves the problem where serial consoles suddenly required DCD to be asserted. Reported by: Randy Bush <randy@psg.com>
* Don't call driver close unless we have one.phk2004-10-121-2/+4
|
* Rework how we store process times in the kernel such that we always storejhb2004-10-051-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the raw values including for child process statistics and only compute the system and user timevals on demand. - Fix the various kern_wait() syscall wrappers to only pass in a rusage pointer if they are going to use the result. - Add a kern_getrusage() function for the ABI syscalls to use so that they don't have to play stackgap games to call getrusage(). - Fix the svr4_sys_times() syscall to just call calcru() to calculate the times it needs rather than calling getrusage() twice with associated stackgap, etc. - Add a new rusage_ext structure to store raw time stats such as tick counts for user, system, and interrupt time as well as a bintime of the total runtime. A new p_rux field in struct proc replaces the same inline fields from struct proc (i.e. p_[isu]ticks, p_[isu]u, and p_runtime). A new p_crux field in struct proc contains the "raw" child time usage statistics. ruadd() has been changed to handle adding the associated rusage_ext structures as well as the values in rusage. Effectively, the values in rusage_ext replace the ru_utime and ru_stime values in struct rusage. These two fields in struct rusage are no longer used in the kernel. - calcru() has been split into a static worker function calcru1() that calculates appropriate timevals for user and system time as well as updating the rux_[isu]u fields of a passed in rusage_ext structure. calcru() uses a copy of the process' p_rux structure to compute the timevals after updating the runtime appropriately if any of the threads in that process are currently executing. It also now only locks sched_lock internally while doing the rux_runtime fixup. calcru() now only requires the caller to hold the proc lock and calcru1() only requires the proc lock internally. calcru() also no longer allows callers to ask for an interrupt timeval since none of them actually did. - calcru() now correctly handles threads executing on other CPUs. - A new calccru() function computes the child system and user timevals by calling calcru1() on p_crux. Note that this means that any code that wants child times must now call this function rather than reading from p_cru directly. This function also requires the proc lock. - This finishes the locking for rusage and friends so some of the Giant locks in exit1() and kern_wait() are now gone. - The locking in ttyinfo() has been tweaked so that a shared lock of the proctree lock is used to protect the process group rather than the process group lock. By holding this lock until the end of the function we now ensure that the process/thread that we pick to dump info about will no longer vanish while we are trying to output its info to the console. Submitted by: bde (mostly) MFC after: 1 month
* Assign a global unit number for the tty slave devices (init/lock) usingphk2004-09-301-6/+23
| | | | | | | the new subr_unit.c code. For now assert Giant in ttycreate() and ttyfree(). It is not obvious that it will ever pay off to lock these with anything else.
* Add functions to create and free the "tty-ness" of a serial port in aphk2004-09-281-6/+233
| | | | | | | | | | | | | | | | | | | | | | | | | generic way. This code will allow a similar amount of code to be removed from most if not all serial port drivers. Add generic cdevsw for tty devices. Add generic slave cdevsw for init/lock devices. Add ttypurge function which wakes up all know generic sleep points in the tty code, and calls into the hw-driver if it provides a method. Add ttycreate function which creates tty device and optionally cua device. In both cases .init/.lock devices are created as well. Change ttygone() slightly to also call the hw driver provided purge routine. Add ttyfree() which will purge and destroy the cdevs. Add ttyconsole mode for setting console friendly termios on a port.
* Hold threadcount while throbbing cdevsw in our underlying driver.phk2004-09-241-20/+25
| | | | | This is a bit heavyhanded, and will be simplified once the tty code learns to properly deal with disappearing hw and drivers.
* Initialize new ttys a bit more.phk2004-09-181-8/+22
| | | | Check TS_GONE flag for gone-ness.
* Add ttyopen and ttyclose functions which will do the right stuff forphk2004-09-171-0/+97
| | | | | | | most if not all of our tty drivers in the future. Centralizing this stuff enables us to remove about 100 lines of almost but not quite perfectly copy&paste code from each tty driver.
* Add ttyalloc() which in due time will be the successor to ttymalloc(),phk2004-09-171-0/+7
| | | | but without the "struct tty *" argument.
* Add locking to the kqueue subsystem. This also makes the kqueue subsystemjmg2004-08-151-7/+13
| | | | | | | | | | | | | a more complete subsystem, and removes the knowlege of how things are implemented from the drivers. Include locking around filter ops, so a module like aio will know when not to be unloaded if there are outstanding knotes using it's filter ops. Currently, it uses the MTX_DUPOK even though it is not always safe to aquire duplicate locks. Witness currently doesn't support the ability to discover if a dup lock is ok (in some cases). Reviewed by: green, rwatson (both earlier versions)
* Preparation commit for the tty cleanups that will follow in the nearphk2004-07-151-4/+4
| | | | | | | | | future: rename ttyopen() -> tty_open() and ttyclose() -> tty_close(). We need the ttyopen() and ttyclose() for the new generic cdevsw functions for tty devices in order to have consistent naming.
* Introduce ttygone() which indicates that the hardware is detached.phk2004-07-111-0/+64
| | | | Move dtrwait logic to the generic TTY level.
* Pick the hotchar out of the tty structure instead of caching privatephk2004-06-261-2/+1
| | | | | | | | copies. No current line disciplines have a dynamically changing hotchar, and expecting to receive anything sensible during a change in ldisc is insane so no locking of the hotchar field is necessary.
* Fix line discipline switching issues: If opening a new ldisc fails,phk2004-06-261-12/+21
| | | | | | | | | | | | | we have to revert to TTYDISC which we know will successfully open rather than try the previous ldisc which might also fail to open. Do not let ldisc implementations muck about with ->t_line, and remove code which checks for reopens, it should never happen. Move ldisc->l_hotchar to tty->t_hotchar and have ldisc implementation initialize it in their open routines. Reset to zero when we enter TTYDISC. ("no" should really be -1 since zero could be a valid hotchar for certain old european mainframe protocols.)
* Add two new methods to struct tty: One for manipulating BREAK conditionphk2004-06-251-1/+49
| | | | | | | and one for fiddling modem-control signals. Add generic code to deal with the relevant ioctls if these methods are present.
* #include <sys/serial.h>phk2004-06-241-0/+1
|
* Use CTASSERT to enforce the relationship between the new serial portphk2004-06-241-0/+17
| | | | modem definitions and the old definitions from ioctls.
* Put the pre FreeBSD-2.x tty compat code under BURN_BRIDGES.phk2004-06-211-0/+8
|
* Do the dreaded s/dev_t/struct cdev */phk2004-06-161-11/+11
| | | | Bump __FreeBSD_version accordingly.
* Deorbit COMPAT_SUNOS.phk2004-06-111-3/+3
| | | | | We inherited this from the sparc32 port of BSD4.4-Lite1. We have neither a sparc32 port nor a SunOS4.x compatibility desire these days.
* Reference count struct tty.phk2004-06-091-21/+93
| | | | | | | | | | | Add two new functions: ttyref() and ttyrel(). ttymalloc() creates a struct tty with a reference count of one. when ttyrel sees the count go to zero, struct tty is freed. Hold references for open ttys and for ttys which are controlling terminal for sessions. Until drivers start using ttyrel(), this commit will make no difference.
* Make linesw[] an array of pointers to linedesc instead of an array ofphk2004-06-071-3/+3
| | | | linedisc.
* Centralize the line discipline optimization determination in a functionphk2004-06-041-0/+18
| | | | | | | | | called ttyldoptim(). Use this function from all the relevant drivers. I belive no drivers finger linesw[] directly anymore, paving the way for locking and refcounting.
* Manual edits to change linesw[]-frobbing to ttyld_*() calls.phk2004-06-041-1/+1
|
* Machine generated patch which changes linedisc calls from accessingphk2004-06-041-5/+5
| | | | | | linesw[] directly to using the ttyld...() functions The ttyld...() functions ar inline so there is no performance hit.
* Get rid of ttyregister(). All drivers now use ttymalloc() for structphk2004-06-041-8/+2
| | | | | tty, so now we stand a chance of implementing refcounting and getting rid of the damn things again.
* Introduce a ttyioctl() cdevsw default function.phk2004-06-011-0/+15
|
* Remove advertising clause from University of California Regent'simp2004-04-071-4/+0
| | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson
* Device megapatch 3/6:phk2004-02-211-1/+18
| | | | | | | | | | | | Add missing D_TTY flags to various drivers. Complete asserts that dev_t's passed to ttyread(), ttywrite(), ttypoll() and ttykqwrite() have (d_flags & D_TTY) and a struct tty pointer. Make ttyread(), ttywrite(), ttypoll() and ttykqwrite() the default cdevsw methods for D_TTY drivers and remove the explicit initializations in various drivers cdevsw structures.
* T -CURRENT DO NOT CRASH UPON ^T K PLZ THX.green2004-02-141-1/+2
| | | | Also, use sched_pctcpu() instead of assuming td->td_kse is non-NULL.
* A variety of further cleanups to ttyinfo():rwatson2004-02-041-77/+84
| | | | | | | | | | | | | | | | | | | | | | | | | - Rename temporary variable names ("tmp", "tmp2") to more informative names ("load", "pctcpu", "rss", ...) - Unclutter indentation and return paths: rather than lots of nested ifs, simply return earlier if it's not going to work out. Simplify general structure and avoid "deep" code. - Comment on the thread/process selection and locking. - Correct handling of "running"/"runnable" states, avoid "unknown" that people were seeing for running processes. This was due to a misunderstanding of the more complex state machine / inhibitors behavior of KSE. - Do perform ttyinfo() printing on KSE (P_SA) processes, it seems generally to work. While I initially attempted to formulate this as two commits (one layout, the other content), I concluded that the layout changes were really structural changes. Many elements submitted by: bde
* Improve the expressiveness of ttyinfo (^T) when dealing with threadsrwatson2004-01-081-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | in slightly less usual states: If the thread is on a run queue, display "running" if the thread is actually running, otherwise, "runnable". If the thread is sleeping, and it's on a sleep queue, display the name of the queue, otherwise "unknown" -- previously, in this situation we would display "iowait". If the thread is waiting on a lock, display *lockname. If the thread is suspended, display "suspended" -- previously, in this situation we would display "iowait". If the thread is waiting for an interrupt, display "intrwait" -- previously, in this situation we would display "iowait". If the thread is in a state not handled by the above, display "unknown" -- previously, we would print "iowait". Among other things, this avoids displaying "iowait" when the foreground process turns out to be suspended waiting for a debugger to properly attach.
* - Implement selwakeuppri() which allows raising the priority of atanimura2003-11-091-2/+2
| | | | | | | | | | | | | thread being waken up. The thread waken up can run at a priority as high as after tsleep(). - Replace selwakeup()s with selwakeuppri()s and pass appropriate priorities. - Add cv_broadcastpri() which raises the priority of the broadcast threads. Used by selwakeuppri() if collision occurs. Not objected in: -arch, -current
* Use a new message buffer `consmsgbuf' to forward messages to aiedowse2003-06-221-3/+3
| | | | | | | | | | | | | | | TIOCCONS console (e.g. xconsole) via a timeout routine instead of calling into the tty code directly from printf(). This fixes a number of cases where calling printf() at the wrong time (such as with locks held) would cause a panic if xconsole is running. The TIOCCONS message buffer is 8k in size by default, but this can be changed with the kern.consmsgbuf_size sysctl. By default, messages are checked for 5 times per second. The timer runs and the buffer memory remains allocated only at times when a TIOCCONS console is active. Discussed on: freebsd-arch
* Rename P_THREADED to P_SA. P_SA means a process is using schedulerdavidxu2003-06-151-1/+1
| | | | activations.
* Use __FBSDID().obrien2003-06-111-1/+3
|
* p_sigignore moved into struct sigacts. move one which was missed.ps2003-05-141-1/+1
| | | | Approved by: re (scottl)
* - Merge struct procsig with struct sigacts.jhb2003-05-131-2/+2
| | | | | | | | | | | | | | | | | - Move struct sigacts out of the u-area and malloc() it using the M_SUBPROC malloc bucket. - Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(), sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared(). - Remove the p_sigignore, p_sigacts, and p_sigcatch macros. - Add a mutex to struct sigacts that protects all the members of the struct. - Add sigacts locking. - Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now that sigacts is locked. - Several in-kernel functions such as psignal(), tdsignal(), trapsignal(), and thread_stopped() are now MP safe. Reviewed by: arch@ Approved by: re (rwatson)
* - Use a local struct proc variable to improve readability.jhb2003-04-171-11/+11
| | | | | - Use a local variable to close a minor race when determining if the wmesg printed out needs a prefix such as when a thread is blocked on a lock.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-13/+19
| | | | | | | a follow on commit to kern_sig.c - signotify() now operates on a thread since unmasked pending signals are stored in the thread. - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
* Make TTYHOG tunable.das2003-03-051-0/+1
| | | | Reviewed by: mike (mentor)
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-1/+1
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
OpenPOWER on IntegriCloud