History log of /freebsd-10.1-release/sys/sys/tty.h
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 271773 18-Sep-2014 grehan

MFC tty fixes, r259549 and r259663

Keep tty_makedev as a function to preserve the KBI on 10-stable
(it is a macro in CURRENT). The changes for this are direct
commits to 10-stable.

r259549 (glebius):
- Rename tty_makedev() into tty_makedevf() and make it capable
to fail and return error.
- Use make_dev_p() in tty_makedevf() instead of make_dev_cred().
- Always pass MAKEDEV_CHECKNAME flag.
- Optionally pass MAKEDEV_REF flag.
- Provide macro for compatibility with old API.

This fixes races with simultaneous creation and desctruction of
ttys, and makes it possible to call tty_makedevf() from device
cloners.

A race in tty_watermarks() still exist, since the latter drops
lock for M_WAITOK allocation. This will be addressed in separate
commit.

r259663 (glebius):
Move list of ttys handling from the allocating procedures, to the
device creation stage. A device creation can fail, and in that case
an entry already on the list will be freed.

KBI issue pointed out by: kib
Reviewed by: kib (KBI addition)
Approved by: re (kib)


# 262861 06-Mar-2014 jhb

MFC 259016,259019,259049,259071,259102,259110,259129,259130,259178,259179,
259203,259221,259261,259532,259615,259650,259651,259667,259680,259727,
259761,259772,259776,259777,259830,259882,259915,260160,260449,260450,
260688,260888,260953,261269,261547,261551,261552,261553,261585:
Merge the vt(4) driver (newcons) to stable/10.

Approved by: ray


# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 242529 03-Nov-2012 ed

Add tty_set_winsize().

This removes some of the signalling magic from the Syscons driver and
puts it in the TTY layer, where it belongs.


# 242078 25-Oct-2012 ed

Correct SIGTTIN handling.

In the old TTY layer, SIGTTIN was correctly handled like this:

while (data should be read) {
send SIGTTIN if not foreground process group
read data
}

In the new TTY layer, however, this behaviour was changed, based on a
false interpretation of the standard:

send SIGTTIN if not foreground process group
while (data should be read) {
read data
}

Correct this by pushing tty_wait_background() into the ttydisc_read_*()
functions.

Reported by: koitsu
PR: kern/173010
MFC after: 2 weeks


# 233664 29-Mar-2012 hselasky

Move tty_opened_ns() into syscons.c which is currently the
only client of this macro.

Suggested by: ed @
MFC after: 1 week


# 233661 29-Mar-2012 hselasky

Fix for NULL-pointer panic during boot, if keys are pressed too early.

MFC after: 1 week


# 223722 02-Jul-2011 ed

Reintroduce the cioctl() hook in the TTY layer for digi(4).

The cioctl() hook can be used by drivers to add ioctls to the *.init and
*.lock devices. This commit breaks the ttydevsw ABI, since this
structure didn't provide any padding. To prevent ABI breakage in the
future, add a tsw_spare.

Submitted by: Peter Jeremy <peter jeremy alcatel lucent com>
Obtained from: kern/152254 (slightly modified)


# 201532 04-Jan-2010 ed

Make TIOCSTI work again.

It looks like I didn't implement this when I imported MPSAFE TTY.
Applications like mail(1) still use this. I think it's conceptually bad.

Tested by: Pete French <petefrench ticketswitch com>
MFC after: 2 weeks


# 199898 28-Nov-2009 ed

Decompose <sys/termios.h>.

The <sys/termios.h> header file is hardlinked to <termios.h>. It
contains both the structures and the flag definitions, but also the C
library interface that's implemented by the C library.

This header file has the typical problem of including too many random
things and being badly ordered. Instead of trying to fix this, decompose
it into two header files:

- <sys/_termios.h>, which contains struct termios and the flags.
- <termios.h>, which includes <sys/_termios.h> and contains the C
library interface.

This means userspace has to include <termios.h> for struct termios,
while kernelspace code has to include <sys/tty.h>. Also add a
<sys/termios.h>, which prints a warning message before including
<termios.h>. I am aware that there are some applications that use this
header file as well.


# 196886 06-Sep-2009 ed

Move ptmx into pty(4).

Now that pty(4) is a loadable kernel module, I'd better move /dev/ptmx
in there as well. This means that pty(4) now provides almost all
pseudo-terminal compatibility code. This means it's very easy to test
whether applications use the proper library interfaces when allocating
pseudo-terminals (namely posix_openpt and openpty).


# 194771 23-Jun-2009 ed

Improve my last commit: use a separate condvar to serialize.

The advantage of using a separate condvar is that we can just use
cv_signal(9) instead of cv_broadcast(9). It makes no sense to wake up
multiple threads. It also makes the TTY code easier to understand.
t_dcdwait sounds totally unrelated.


# 193018 29-May-2009 ed

Last minute TTY API change: remove mutex argument from tty_alloc().

I don't want people to override the mutex when allocating a TTY. It has
to be there, to keep drivers like syscons happy. So I'm creating a
tty_alloc_mutex() which can be used in those cases. tty_alloc_mutex()
should eventually be removed.

The advantage of this approach, is that we can just remove a function,
without breaking the regular API in the future.


# 188487 11-Feb-2009 ed

Serialize write() calls on TTYs.

Just like the old TTY layer, the current MPSAFE TTY layer does not make
any attempt to serialize calls of write(). Data is copied into the
kernel in 256 (TTY_STACKBUF) byte chunks. If a write() call occurs at
the same time, the data may interleave. This is especially likely when
the TTY starts blocking, because the output queue reaches the high
watermark.

I've implemented this by adding a new flag, TTY_BUSY_OUT, which is used
to mark a TTY as having a thread stuck in write(). Because I don't want
non-blocking processes to be possibly blocked by a sleeping thread, I'm
still allowing it to bypass the protection. According to this message,
the Linux kernel returns EAGAIN in such cases, but I think that's a
little too restrictive:

http://kerneltrap.org/index.php?q=mailarchive/linux-kernel/2007/5/2/85418/thread

PR: kern/118287


# 188147 05-Feb-2009 ed

Don't leave the console TTY constantly open.

When we leave the console TTY constantly open, we never reset the
termios attributes. This causes output processing, echoing, etc. not to
be reset to the proper values when going into single user mode after the
system has booted. It also causes nl-to-crnl-conversion not to take
place during shutdown, which causes a `staircase effect'.

This patch adds a new TTY flag, TF_OPENED_CONS, which is set when the
TTY is opened through /dev/console. Because the flags are only used by
the kernel and the pstat(8) utility, I've decided to renumber the TTY
flags. This shouldn't be an issue, because the TTY layer is not yet part
of a stable release.

Reported by: Mark Atkinson <atkin901 yahoo com>
Tested by: sepotvin


# 184521 01-Nov-2008 ed

Reimplement the /dev/console device node.

One of the pieces of code that I had left alone during the development
of the MPSAFE TTY layer, was tty_cons.c. This file actually has two
different functions:

- It contains low-level console input/output routines (cnputc(), etc).

- It creates /dev/console and wraps all its cdevsw calls to the
appropriate TTY.

This commit reimplements the second set of functions by moving it
directly into the TTY layer. /dev/console is now a character device node
that's basically a regular TTY, but does a lookup of `si_drv1' each time
you open it. d_write has also been changed to call log_console().
d_close() is not present, because we must make sure we don't revoke the
TTY after writing a log message to it.

Even though I'm not convinced this is in line with the future directions
of our console code, it is a good move for now. It removes recursive
locking from the top half of the TTY layer. The previous implementation
called into the TTY layer with Giant held.

I'm renaming tty_cons.c to kern_cons.c now. The code hardly contains any
TTY related bits, so we'd better give it a less misleading name.

Tested by: Andrzej Tobola <ato iem pw edu pl>,
Carlos A.M. dos Santos <unixmania gmail com>,
Eygene Ryabinkin <rea-fbsd codelabs ru>


# 183922 15-Oct-2008 ed

Import some improvements to the TTY code from the MPSAFE TTY branch.

- Change the ddb(4) commands to be more useful (by thompsa@):
- `show ttys' is now called `show all ttys'. This command will now
also display the address where the TTY data structure resides.
- Add `show tty <addr>', which dumps the TTY in a readable form.

- Place an upper bound on the TTY buffer sizes. Some drivers do not want
to care about baud rates. Protect these drivers by preventing the TTY
buffers from getting enormous. Right now we'll just clamp it to 64K,
which is pretty high, taking into account that these buffers are only
used by the built-in discipline.

- Only call ttydev_leave() when needed. Back in April/May the TTY
reference counting mechanism was a little different, which required us
to call ttydev_leave() each time we finished a cdev operation.
Nowadays we only need to call ttydev_leave() when we really mark it as
being closed.

- Improve return codes of read() and write() on TTY device nodes.

- Make sure we really wake up all blocked threads when the driver calls
tty_rel_gone(). There were some possible code paths where we didn't
properly wake up any readers/writers.

- Add extra assertions to prevent sleeping on a TTY that has been
abandoned by the driver.

- Use ttydev_cdevsw as a more reliable method to figure out whether a
device node is a real TTY device node.

Obtained from: //depot/projects/mpsafetty/...
Reviewed by: thompsa


# 183332 24-Sep-2008 ed

Add another TTY locking migration macro: tty_getlock().

Some subsystems (HPS-USB) like to lock down the TTY through a more
generic approach, namely the regular mtx(9) macro's. Allow the TTY lock
to be obtained through the new macro.

Discussed with: hps, thompsa


# 183276 22-Sep-2008 ed

Introduce a hooks layer for the MPSAFE TTY layer.

One of the features that prevented us from fixing some of the TTY
consumers to work once again, was an interface that allowed consumers to
do the following:

- `Sniff' incoming data, which is used by the snp(4) driver.

- Take direct control of the input and output paths of a TTY, which is
used by ng_tty(4), ppp(4), sl(4), etc.

There's no practical advantage in committing a hooks layer without
having any consumers. In P4 there is a preliminary port of snp(4) and
thompsa@ is busy porting ng_tty(4) to this interface. I already want to
have it in the tree, because this may stimulate others to work on the
remaining modules.

Discussed with: thompsa
Obtained from: //depot/projects/mpsafetty/...


# 183274 22-Sep-2008 ed

Fix style(9) issue in TTY header files: document function argument names.

According to style(9), function argument names should only be omitted
for prototypes that are exported to userspace. This means we should
document the function arguments in the TTY header files, because they
are only used in userspace.

While there, change the type of the buffer argument of
ttydisc_rint_bypass() to `const void *' instead of `char *'.

Requested by: attilio
Obtained from: //depot/projects/mpsafetty/...


# 182763 04-Sep-2008 ed

Fix an awful bug inside our COMPAT_43TTY code.

When I migrated tty_compat.c to MPSAFE TTY, I just hooked it up to the
build and fixed it until it compiled and somewhat worked. It turns out
this was not the smartest thing, because the old TTY layer also had a
field called t_flags, which contained a set of sgtty flags.

This means our current COMPAT_43TTY code overwrites the TTY flags,
causing all strange problems to occur. Fix this code to use a new struct
member called t_compatflags. This commit may cause kern/127054 to be
fixed, but this still has to be tested/confirmed by the originator. It
has to be fixed anyway.

PR: kern/127054


# 181907 20-Aug-2008 ed

Correct misbehaviour of patching sys/sys/tty.h.

For some reason, sys/sys/tty.h was only half patched. This went by
unnoticed, because the copyright notice on the top already displayed my
name, so I thought the file went in properly.

Reported by: kmacy


# 181905 20-Aug-2008 ed

Integrate the new MPSAFE TTY layer to the FreeBSD operating system.

The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:

- Improved driver model:

The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.

If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.

- Improved hotplugging:

With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).

The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.

- Improved performance:

One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.

Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.

Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan


# 179246 23-May-2008 ed

Move TTY unrelated bits out of <sys/tty.h>.

For some reason, the <sys/tty.h> header file also contains routines of the
clists and console that are used inside the TTY layer. Because the clists
are not only used by the TTY layer (example: various input drivers), we'd
better move the entire clist programming interface into <sys/clist.h>. Also
remove a declaration of nonexistent variable.

The <sys/tty.h> header also contains various definitions for the console
code (tty_cons.c). Also move these to <sys/cons.h>, because they are
not implemented inside the TTY layer.

While there, create separate malloc pools for the clist and console code.

Approved by: philip (mentor)


# 174646 16-Dec-2007 jeff

- Don't depend on header pollution to declare struct thread.


# 154018 04-Jan-2006 phk

Deorbit ttymalloc() in preference for ttyalloc()


# 151386 16-Oct-2005 phk

Make ttsetcompat() static


# 151385 16-Oct-2005 phk

Add a bunch of inline functions to call the drivers tty implementing methods.


# 151383 16-Oct-2005 phk

Eliminate two unused arguments to ttycreate().


# 136680 18-Oct-2004 phk

Add new function ttyinitmode() which sets our systemwide default
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.


# 135964 30-Sep-2004 phk

Assign a global unit number for the tty slave devices (init/lock) using
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.


# 135905 28-Sep-2004 phk

Add functions to create and free the "tty-ness" of a serial port in a
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.


# 135406 17-Sep-2004 phk

Fix an issue with ng_tty which (ab)used the tty->t_sc field which is
reserved for the device drivers:

Add a t_lsc field for line discipline private use.


# 135377 17-Sep-2004 phk

forward declare struct cdev, not cdevsw;


# 135368 17-Sep-2004 phk

Add various stuff to struct tty and surounding areas in preparation
for getting stuff from P4::phk_tty into -current.


# 135363 17-Sep-2004 phk

Add ttyalloc() which in due time will be the successor to ttymalloc(),
but without the "struct tty *" argument.


# 135297 16-Sep-2004 phk

Add fields to struct tty for the initial/lock * tty/cua states.


# 132226 15-Jul-2004 phk

Preparation commit for the tty cleanups that will follow in the near
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.


# 131981 11-Jul-2004 phk

Introduce ttygone() which indicates that the hardware is detached.

Move dtrwait logic to the generic TTY level.


# 131387 01-Jul-2004 marcel

Fix build: forward declare struct tty before defining the tty function
types.


# 131373 30-Jun-2004 phk

Define the tty methods as typedefs.

Change the return type for t_break to void.

Add t_ioctl (more about this later).


# 131134 26-Jun-2004 phk

Pick the hotchar out of the tty structure instead of caching private
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.


# 131130 26-Jun-2004 phk

Fix line discipline switching issues: If opening a new ldisc fails,
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.)


# 131092 25-Jun-2004 phk

Add two new methods to struct tty: One for manipulating BREAK condition
and one for fiddling modem-control signals.

Add generic code to deal with the relevant ioctls if these methods are
present.


# 130966 23-Jun-2004 phk

Since we grew struct xtty, t_dev doesn't have to be schizofrenic anymore.


# 130640 17-Jun-2004 phk

Second half of the dev_t cleanup.

The big lines are:
NODEV -> NULL
NOUDEV -> NODEV
udev_t -> dev_t
udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.


# 130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


# 130261 09-Jun-2004 phk

Reference count struct tty.

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.


# 130259 09-Jun-2004 phk

Move PTY private defines into PTY private files.


# 130096 04-Jun-2004 phk

Centralize the line discipline optimization determination in a function
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.


# 130075 04-Jun-2004 phk

Move the line discipline related stuff out of <sys/conf.h> and into
<sys/linedisc.h> (repocopied).

Temporarily use a nested include from <sys/tty.h> to get <sys/linedisc.h>
into relevant source files.

Introduce a set of inline functions named ttyld_...() to invoke
linedisc methods instead of groping around in the linesw array.


# 130056 04-Jun-2004 phk

Get rid of ttyregister(). All drivers now use ttymalloc() for struct
tty, so now we stand a chance of implementing refcounting and getting
rid of the damn things again.


# 129938 01-Jun-2004 phk

shift the four cdevsw functions for ttys to sys/conf.h and prototype
them with the correct typedef.


# 127976 07-Apr-2004 imp

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core


# 116663 22-Jun-2003 iedowse

Use a new message buffer `consmsgbuf' to forward messages to a
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


# 111900 05-Mar-2003 das

Raise the default value of TTYHOG from 1 kB to 8 kB. Since TTYHOG is
an administrative limit on the size of tty/pty input buffers, this is
mostly an inconsequential change. (slti(4) will allocate an 8 kB
static buffer instead of a 1 kB buffer due to a hack in the driver.)
The increase happens to kludge around a lame limitation of syscons,
which does not allow one to paste more than TTYHOG bytes.

PR: 42031
Reviewed by: mike (mentor)


# 110997 16-Feb-2003 phk

Declare tty related counters in a tty related .h file.


# 97402 28-May-2002 bde

Fixed some style bugs in recent commits.


# 97379 28-May-2002 des

Add NAI copyright.


# 97373 28-May-2002 des

Back out part of previous commit; the dev_t union trick is still useful in
the kvm case.


# 97366 28-May-2002 des

Introduce struct xtty, used when exporting tty information to userland.
Make kern.ttys export a struct xtty rather than struct tty. Since struct
tty is no longer exposed to userland, remove the dev_t / udev_t hack.

Sponsored by: DARPA, NAI Labs


# 93258 27-Mar-2002 bde

Fixed -Wshadow warnings by renaming ttysleep()'s `timeout' parameter to
`timo'. This also makes the parameter name in the prototype the same as
in the function.


# 92719 19-Mar-2002 alfred

Remove __P


# 84440 04-Oct-2001 bde

Fixed style bugs (indentation errors, missing punctuation, and unsorting)
in rev.1.61.


# 83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# 83300 10-Sep-2001 peter

Fix a warning on alpha (real problem) and make pstat -t work as a bonus.
'struct tty' was out of sync in user and kernel due to dev_t/udev_t
mixups. This takes advantage of the fact that dev_t changes type in
userland, so it isn't too pretty.


# 72557 17-Feb-2001 bde

Fixed unsorting of prototypes in previous commit. Is it too much to
ask for 1-line commits to be correctly ordered?


# 72521 15-Feb-2001 jlemon

Extend kqueue down to the device layer.

Backwards compatible approach suggested by: peter


# 72376 11-Feb-2001 jake

Implement a unified run queue and adjust priority levels accordingly.

- All processes go into the same array of queues, with different
scheduling classes using different portions of the array. This
allows user processes to have their priorities propogated up into
interrupt thread range if need be.
- I chose 64 run queues as an arbitrary number that is greater than
32. We used to have 4 separate arrays of 32 queues each, so this
may not be optimal. The new run queue code was written with this
in mind; changing the number of run queues only requires changing
constants in runq.h and adjusting the priority levels.
- The new run queue code takes the run queue as a parameter. This
is intended to be used to create per-cpu run queues. Implement
wrappers for compatibility with the old interface which pass in
the global run queue structure.
- Group the priority level, user priority, native priority (before
propogation) and the scheduling class into a struct priority.
- Change any hard coded priority levels that I found to use
symbolic constants (TTIPRI and TTOPRI).
- Remove the curpriority global variable and use that of curproc.
This was used to detect when a process' priority had lowered and
it should yield. We now effectively yield on every interrupt.
- Activate propogate_priority(). It should now have the desired
effect without needing to also propogate the scheduling class.
- Temporarily comment out the call to vm_page_zero_idle() in the
idle loop. It interfered with propogate_priority() because
the idle process needed to do a non-blocking acquire of Giant
and then other processes would try to propogate their priority
onto it. The idle process should not do anything except idle.
vm_page_zero_idle() will return in the form of an idle priority
kernel thread which is woken up at apprioriate times by the vm
system.
- Update struct kinfo_proc to the new priority interface. Deliberately
change its size by adjusting the spare fields. It remained the same
size, but the layout has changed, so userland processes that use it
would parse the data incorrectly. The size constraint should really
be changed to an arbitrary version number. Also add a debug.sizeof
sysctl node for struct kinfo_proc.


# 70834 09-Jan-2001 wollman

select() DKI is now in <sys/selinfo.h>.


# 60938 26-May-2000 jake

Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by: msmith and others


# 60833 23-May-2000 jake

Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by: phk
Reviewed by: phk
Approved by: mdodd


# 59288 16-Apr-2000 jlemon

Introduce kqueue() and kevent(), a kernel event notification facility.


# 55205 29-Dec-1999 peter

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


# 51861 02-Oct-1999 bde

Fixed style bugs in prototypes.


# 51756 28-Sep-1999 phk

Introduce ttyread() and ttywrite() which do the canonical thing.

Use them in many tty drivers.

Reviewed by: julian, bde


# 51658 25-Sep-1999 phk

Remove five now unused fields from struct cdevsw. They should never
have been there in the first place. A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags


# 51654 25-Sep-1999 phk

This patch clears the way for removing a number of tty related
fields in struct cdevsw:

d_stop moved to struct tty.
d_reset already unused.
d_devtotty linkage now provided by dev_t->si_tty.

These fields will be removed from struct cdevsw together with
d_params and d_maxio Real Soon Now.

The changes in this patch consist of:

initialize dev->si_tty in *_open()
initialize tty->t_stop
remove devtotty functions
rename ttpoll to ttypoll
a few adjustments to these changes in the generic code
a bump of __FreeBSD_version
add a couple of FreeBSD tags


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 49556 09-Aug-1999 jkh

This uses an SLIST_ENTRY and breaks the build without sys/queue.h. Commit
this until bde and friends finish arguing over what to do instead. :)


# 49542 08-Aug-1999 phk

Enable ttymalloc().


# 49540 08-Aug-1999 phk

Add new sysctl "kern.ttys" which return all the struct tty's which have
been registered with ttyregister().

register ptys with ttyregister().


# 41087 11-Nov-1998 truckman

I got another batch of suggestions for cosmetic changes from bde.


# 41086 11-Nov-1998 truckman

Installed the second patch attached to kern/7899 with some changes suggested
by bde, a few other tweaks to get the patch to apply cleanly again and
some improvements to the comments.

This change closes some fairly minor security holes associated with
F_SETOWN, fixes a few bugs, and removes some limitations that F_SETOWN
had on tty devices. For more details, see the description on the PR.

Because this patch increases the size of the proc and pgrp structures,
it is necessary to re-install the includes and recompile libkvm,
the vinum lkm, fstat, gcore, gdb, ipfilter, ps, top, and w.

PR: kern/7899
Reviewed by: bde, elvind


# 36735 07-Jun-1998 dfr

This commit fixes various 64bit portability problems required for
FreeBSD/alpha. The most significant item is to change the command
argument to ioctl functions from int to u_long. This change brings us
inline with various other BSD versions. Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.


# 34185 07-Mar-1998 bde

Set the input and output buffer sizes and the input buffer watermarks
dynamically depending on the line speed(s). This should give the old
sizes and watermarks until drivers are changed.

Display the input watermarks in pstat and sicontrol.


# 30354 12-Oct-1997 phk

Last major round (Unless Bruce thinks of somthing :-) of malloc changes.

Distribute all but the most fundamental malloc types. This time I also
remembered the trick to making things static: Put "static" in front of
them.

A couple of finer points by: bde


# 29350 14-Sep-1997 peter

Update interfaces for poll()


# 22975 22-Feb-1997 peter

Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.


# 22877 18-Feb-1997 bde

Changed type of t_line from u_char to int. The Lite2 merge blew away
rev.1.6 which changed it from char to int.


# 22521 10-Feb-1997 dyson

This is the kernel Lite/2 commit. There are some requisite userland
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>


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

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.


# 12841 14-Dec-1995 bde

Restored unused function ttrstrt(). It would be used if the low level
drivers supported inter-character delays.


# 12819 14-Dec-1995 phk

A Major staticize sweep. Generates a couple of warnings that I'll deal
with later.
A number of unused vars removed.
A number of unused procs removed or #ifdefed.


# 12675 08-Dec-1995 julian

Pass 3 of the great devsw changes
most devsw referenced functions are now static, as they are
in the same file as their devsw structure. I've also added DEVFS
support for nearly every device in the system, however
many of the devices have 'incorrect' names under DEVFS
because I couldn't quickly work out the correct naming conventions.
(but devfs won't be coming on line for a month or so anyhow so that doesn't
matter)

If you "OWN" a device which would normally have an entry in /dev
then search for the devfs_add_devsw() entries and munge to make them right..
check out similar devices to see what I might have done in them in you
can't see what's going on..
for a laugh compare conf.c conf.h defore and after... :)
I have not doen DEVFS entries for any DISKSLICE devices yet as that will be
a much more complicated job.. (pass 5 :)

pass 4 will be to make the devsw tables of type (cdevsw * )
rather than (cdevsw)
seems to work here..
complaints to the usual places.. :)


# 9833 31-Jul-1995 bde

Obtained from: partly from ancient patches of mine via 1.1.5

Change all short variables in `struct tty' to int. Shorts were only
right on ancient systems with ints optimized for vaxness over
efficiency.


# 9832 31-Jul-1995 bde

Obtained from: partly from ancient patches of mine via 1.1.5

Handle MDMBUF a little better. Prepare to handle 4 different kinds of
output flow control.


# 9824 31-Jul-1995 bde

Obtained from: partly from ancient patches of mine via 1.1.5

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.


# 9823 31-Jul-1995 bde

Assorted cosmetic changes:

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.


# 9822 31-Jul-1995 bde

Improve input flow control.

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.


# 9790 30-Jul-1995 bde

Split TS_ASLEEP (sleep on output [below low water])into TS_SO_OLOWAT (sleep
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.


# 9763 29-Jul-1995 bde

Obtained from: partly from ancient patches by ache and me via 1.1.5

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.


# 9639 22-Jul-1995 bde

Obtained from: partly from ancient patches of mine via 1.1.5

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.


# 9626 21-Jul-1995 bde

Move the inline code for waking up writers to a new function
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.


# 9625 21-Jul-1995 bde

Obtained from: partly from ancient patches of mine via 1.1.5

Move static termioschars() from a couple of drivers to tty.c. Now there
is only one copy of ttydefchars[].


# 9624 21-Jul-1995 bde

Obtained from: partly from ancient patches by ache and me via 1.1.5

Nuke `symbolic sleep message strings'. Use unique literal messages so that
`ps l' shows unambiguously where processes are sleeping.


# 9623 21-Jul-1995 bde

Obtained from: partly from an ancient patch of mine via 1.1.5

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.


# 9543 16-Jul-1995 joerg

Protect TTYHOG by #ifndef so it can be overridden from the config
file.

Submitted by: hsu@clinet.fi (Heikki Suonsivu)


# 7850 15-Apr-1995 bde

Define IBUFSIZ as 384. This goes with speeding up ttnread().

OBUFSIZ should be increased to the same value as IBUFSIZE (both are
smaller than desirable because they have to fit on the stack), but
there are currently problems with magic buffer limits and watermarks.

Remove unused #define of TTMASK.

Undo bogus exportation of ttnread().


# 7757 11-Apr-1995 ache

Add new ttsetcompat function (from tty_compat)


# 7552 01-Apr-1995 ache

Add TS_CAN_BYPASS_L_RINT state for serial devices


# 7467 29-Mar-1995 ache

Add TTY_OE for overrun error and TTY_BI for break condition


# 7430 28-Mar-1995 bde

Add and move declarations to fix all of the warnings from `gcc -Wimplicit'
(except in netccitt, netiso and netns) that I didn't notice when I fixed
"all" such warnings before.


# 7090 16-Mar-1995 bde

Add and move declarations to fix all of the warnings from `gcc -Wimplicit'
(except in netccitt, netiso and netns) and most of the warnings from
`gcc -Wnested-externs'. Fix all the bugs found. There were no serious
ones.


# 6782 27-Feb-1995 pst

Incorporate bde's code-review comments.

(a) bring back ttselect, now that we have xxxdevtotty() it isn't dangerous.
(b) remove all of the wrappers that have been replaced by ttselect
(c) fix formatting in syscons.c and definition in syscons.h
(d) add cxdevtotty

NOT DONE:
(e) make pcvt work... it was already broken...when someone fixes pcvt to
link properly, just rename get_pccons to xxxdevtotty and we're done


# 6712 25-Feb-1995 pst

(a) remove the pointer to each driver's tty structure array from cdevsw
(b) add a function callback vector to tty drivers that will return a pointer
to a valid tty structure based upon a dev_t
(c) make syscons structures the same size whether or not APM is enabled so
utilities don't crash if NAPM changes (and make the damn kernel compile!)
(d) rewrite /dev/snp ioctl interface so that it is device driver and i386
independant


# 6391 14-Feb-1995 ugen

TS_SNOOP flag added to identify tty is begin snoopped
snoop.h have all structures related to the snp device and stuff


# 6268 09-Feb-1995 jkh

Export ttnread().
Submitted by: Heikki Suonsivu <hsu@cs.hut.fi>


# 5396 04-Jan-1995 ache

Fight against hanging modems: add timeout to ttywait.
Reviewed by: Bruce


# 4825 26-Nov-1994 bde

Fix cblock starvation bugs by reserving enough cblocks for minimal
operation of each clist. Limit the growth of each clist. Clists
can only grow larger than the reserved minimum if there are free
cblocks in a shared pool. The size of this pool is now fixed
(this could be improved). The reserved and maximum sizes are more
carefully allocated for slip and ppp, depending on the mtu. A maximum
MTU of 16384 is now enforced for ppp.


# 3304 02-Oct-1994 phk

Prototypes, prototypes and even more prototypes. Not quite done yet, but
getting closer all the time.


# 2734 13-Sep-1994 dg

Added prototypes for cblock_alloc_cblocks and cblock_free_cblocks.


# 2165 21-Aug-1994 paul

Made them all idempotent.
Reviewed by:
Submitted by:


# 2112 18-Aug-1994 wollman

Fix up some sloppy coding practices:

- Delete redundant declarations.
- Add -Wredundant-declarations to Makefile.i386 so they don't come back.
- Delete sloppy COMMON-style declarations of uninitialized data in
header files.
- Add a few prototypes.
- Clean up warnings resulting from the above.

NB: ioconf.c will still generate a redundant-declaration warning, which
is unavoidable unless somebody volunteers to make `config' smarter.


# 1817 02-Aug-1994 dg

Added $Id$


# 1542 24-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1541,
which included commits to RCS files with non-trunk default branches.


# 1541 24-May-1994 rgrimes

BSD 4.4 Lite Kernel Sources