History log of /haiku/src/add-ons/kernel/generic/tty/tty.cpp
Revision Date Author Comments
# ed574cce 30-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

TTY: Return success on partial writes.

Otherwise the calling program will think that
no part of the write succeeded, when in fact
it did.

tty_read() already did this correctly. Not sure
how this wasn't uncovered previously.

Fixes #18447.


# 4b02e067 11-Jul-2023 Augustin Cavalier <waddlesplash@gmail.com>

generic/tty: Add an assertion and a comment about references.

No functional change.


# 311dc3ca 02-Jul-2023 PulkoMandy <pulkomandy@pulkomandy.tk>

tty: notify read in addition to write when the other tty is closed

Reading a tty that's closed by the other side will return an end of file
error, but will not block.

Fixes #18486.

Change-Id: I8441becdcc8c83c08611684fa0a29216e9d04ec8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6665
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# b197dcba 09-May-2023 Trung Nguyen <trungnt282910@gmail.com>

tty: Implement exclusive mode

Implemented exclusive mode on Haiku and added the related `ioctl`
operations (`TIOCEXCL` and `TIOCNXCL`).

Change-Id: Iaa201ea20eec0e45d02dd5db9ba6aa35fd27dfb2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6387
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# d97ad7c4 09-May-2023 Trung Nguyen <trungnt282910@gmail.com>

termios: New ioctl: TIOCOUTQ

Change-Id: I86f2a7b007137e22cf7d6fc8ad6675ff5de267d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6386
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>


# 0c2a5bb5 09-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

Replace the "tty" driver with a "pty" driver.

This new driver uses the "generic" TTY layer, unlike the old driver
which had its own implementation (which the generic module was derived
from, originally.)

The remaining bits of support for controlling TTYs is added to the kernel &
generic layer at the same time, which should allow for serial interfaces
to be controlling terminals now, as well.

Tested with bash, nano, vim; all seems to still be working as expected.


# 7a27ef14 09-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

generic/tty: Add the undocumented BeOS 'ichr' ioctl.

This was used by the BeOS port of ncurses, as well as our own ncurses
port until not too long before the alpha1 days, so we should keep it
around for compatibility.

Implementation copied directly from the "legacy" TTY driver.


# bb57ea89 09-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

generic/tty: Combine settings structures.

It doesn't make much sense to have separate window sizes, termios, etc.
settings for the two halves of a TTY. Moreover, having separate settings
which can get out of sync breaks applications, e.g. double-printing
in shells.

The original TTY driver has unified settings. It seems likely that the
settings were separated as part of the locking simplification, however
the lock separation was reverted a while back, anyway.


# 2226d2ee 11-Aug-2022 Oscar Lesta <oscar.lesta@gmail.com>

tty: Fix TCFLSH and TCSBRK ioctls.

These two recieve integer values from userland (termios).
Cast them accordingly.

Should fix #17861. Tested on 32 and 64 bits.

Change-Id: Ic5eb53d2732354f86a82f59aab4917ad1851cfc5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5545
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 0f6f5adb 18-Oct-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

generic/tty: restore lock sharing between master and slave TTYs

The code in this module was derived from the one in driver/tty. However,
the driver uses a shared lock between the master and slave side of a
TTY, and this was changed to use two separate locks. The approach with
two locks does not work. It seems the change was unfinished and the
second TTY was never locked. But attempting to lock it will result in
lock inversion problems, unless we do complicated things (try to find
which of the two TTY is the master side, and lock that first, for
example). It is simpler to restore the shared lock as used in the
driver.

To set up the shared lock, I modified the tty_create function to take a
pointer to the master TTY when creating the slave. Maybe it makes more
sense to create both sides in the same call, create_tty_pair?

However, this does not work as easily as I wanted, because there is some
recursion going on: at least in one case, the tty_control function is
calling the driver's tty_service function, which in turns attempts to
call back into tty_control for the "other side" TTY. To handle this
case, replace the mutex with a recursive_lock.

Fixes #17091, where the root problem was access to
other_tty->select_pool without locking. This was also made unconvenient
to debug because select_pool objects are self-deleting, when the last
item in the pool is removed. As a result, the code accessing it without
log would suddenly find out that the data it was accessing had been
freed and erased.

This also makes the TTY code in driver/tty and generic/tty a bit more
similar than it was before, and brings us one step closer to merging the
two together. There are still two main differences and I don't know
enough about TTY to decide if they are important, and which version
should be kept:
- The driver has extra code for "background" read and write. I don't
know what this is used for.
- The driver has a single "settings" instance shared by a master and
slave TTY, while the module has two separate instances, but seems to
copy one to the other. I'm not sure which approach is correct.

Change-Id: Ie2daddd027859ce32ba395af76b4f109f8b984b0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4604
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# c0ec37dc 18-Oct-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

tty: fix construction/destruction

There is no need to construct and destruct nested objects. The new and
delete calls on the struct will take care of it. However, some fields
have C functions for construction/destruction and these should be
called.

Change-Id: I09d5930f499ef3fa4ff580d482c682172b00b6a3
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4603
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# e7a62c42 17-Oct-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

tty: synchronize the driver and module sourcecode a bit

The tty module started its life as a copy of the driver, and they
diverged over time as fixes and refactorings were not always brought to
both sides.

This commit does not improve the situation, but it tries to make the
two versions of the tty_private.h and tty.cpp files as similar as
possible to ease comparison.

Change-Id: I62255262b167ab81c9a0619c8f19b36b1a165fad
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4601
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# a52008cb 26-Apr-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

tty: implement TCFLSH to flush buffers

This is probably incomplete. Is locking needed? Should we notify the
next writer (if any) that the port is writable when flushing the output?

Change-Id: I2566e2d036a61af4819894a44f57603179aa27df
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2516
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 7f8f4c9c 28-Apr-2019 Jérôme Duval <jerome.duval@gmail.com>

tty: some improvements to pass posix_openpt_test.

WriterLocker::AcquireWriter(): don't fail when the other end isn't yet opened.
WriterLocker::_CheckBackgroundWrite(): don't fail when the pgrp_id differs.
ReaderLocker::AcquireReader(): fail when the other end isn't opened anymore.
ReaderLocker::AcquireReader(): check available bytes even in case of failure.
ReaderLocker::_CheckBackgroundRead(): don't fail when the pgrp_id differs.

Change-Id: Ice2bd119cbec2afc9ebd40714e4307856f540ea2
Reviewed-on: https://review.haiku-os.org/c/1418
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# aec644bf 23-Jul-2014 François Revol <revol@free.fr>

tty: Don't ignore errors when setting DTR

Instead we and the return value of both calls.

So if any fails we return an error.


# 0be89c15 23-Jul-2014 François Revol <revol@free.fr>

tty: Add bitmask ioctls TIOCMBIS and TIOCMBIC

Equivalent to TIOCMSET + bitmask + TIOCMGET but with a single call.

Gnokii uses that.


# 6eb97291 03-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

tty: fixed warnings about an uninitialized variable.


# 16c5a728 13-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Seperate out the tty_close_cookie from tty_destory_cookie and make the former
available as a module function as well.
* Remove some unneeded resetting from tty_destroy_cookie.
* Move the public module functions to the public API section of the file and
order them by their declaration order in the module info.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e72f897 10-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Remove the global lock and the documentation for it. It was specific to the tty
driver and doesn't apply to the generic module.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42086 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6f14f6ac 09-Dec-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Fix gcc4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91bcf08e 07-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Adding a generic tty module based largely on the tty driver. This has a new API
and doesn't come with BeOS backwards compatibility. It also has the BeOS
compatibility ioctl ops removed and such. I've actually made this back in april,
so I don't really remember any more details.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39760 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aec644bf854b489f05ad275c682ce60c5edb8d99 23-Jul-2014 François Revol <revol@free.fr>

tty: Don't ignore errors when setting DTR

Instead we and the return value of both calls.

So if any fails we return an error.


# 0be89c15ee9e12e1b0d7e592010af2c2eae1d952 23-Jul-2014 François Revol <revol@free.fr>

tty: Add bitmask ioctls TIOCMBIS and TIOCMBIC

Equivalent to TIOCMSET + bitmask + TIOCMGET but with a single call.

Gnokii uses that.


# 6eb9729145a303905294be0e32978b7c67643cea 03-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

tty: fixed warnings about an uninitialized variable.


# 16c5a72847d78da6bb6f81e6968bbabc59ea637c 13-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Seperate out the tty_close_cookie from tty_destory_cookie and make the former
available as a module function as well.
* Remove some unneeded resetting from tty_destroy_cookie.
* Move the public module functions to the public API section of the file and
order them by their declaration order in the module info.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42154 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6e72f897f4d3adb220c53482aa6133f13e0df4b1 10-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

Remove the global lock and the documentation for it. It was specific to the tty
driver and doesn't apply to the generic module.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42086 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6f14f6ac330640315fb18077900fe66733d207f0 09-Dec-2010 Philippe Houdoin <philippe.houdoin@gmail.com>

Fix gcc4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39787 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 91bcf08ee50af0da44d5d8631477e7c08c5e0255 07-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Adding a generic tty module based largely on the tty driver. This has a new API
and doesn't come with BeOS backwards compatibility. It also has the BeOS
compatibility ioctl ops removed and such. I've actually made this back in april,
so I don't really remember any more details.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39760 a95241bf-73f2-0310-859d-f6bbb57e9c96