History log of /haiku/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp
Revision Date Author Comments
# 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>


# 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>


# 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>


# a9ccc3a5 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: mask THRE again when we're out of data


# b6708d7c 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: wait for writes to complete on a sem

This avoids close being called too early and discarding output.


# 6e7189d9 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: toggle THRE in IER to make VirtualBox happy

Not sure it's needed on real hardware yet.


# e9bbba8b 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: cache IER and temporarily mask IRQs until dpc done

No need to be flooded by IRQs while filling in the FIFO...


# 9ab49705 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: apply lcr parameters even when unmasking latch reg

No need to change line params even more if it was already the same before.


# 02f6c664 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: try to enable 64 byte FIFO

We should probably detect the UART type properly first,
but the IRQ handler also checks for the available FIFO length anyway.


# efbc8946 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: skip waiting for pending DPC in free hook

Since it's possible to fail queuing them, the count doesn't go down to 0,
and the process just hangs forever on exit. It might not be necessary anyway.


# aa05d85c 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: break instead of continue in irq handler

We don't want to busy loop, do we?


# f71a01ad 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: add a termios member to store config across open cycles


# c5c041a5 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: fix KDL on close

It's working \o/
Just need to figure out why it waits for \n to transmit.

We now only destroy the cookies in the free hook.

Mention pending DPC as soon as when inside the irq handler.

Also limit the number of loops in the IRQ handler to avoid busy looping.
It only happened when testing with normal priority but you never know...


# 7b97fd6d 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: use the tty module directly from the deferred IRQ

It still crashes on close sometimes but writing seems to work.


# 1a6072a0 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: manually probe the default ISA ports

Since config_manager is basically a stub, and even VirtualBox
doesn't publish the serial ports as PCI devices, we must probe for them.

Ideally config_manager would find them in the device manager tree
which would have been populated from the PnP BIOS or even ACPI tables...


# 7e613b47 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: convert irq handler to use DPC

Let's hope we won't loose data because it.

We have to cache the value of IIR read from IsInterruptPending(),
because some conditions are acknowledged only by reading it...


# c6870d53 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: WIP: kinda supports writes through tty module

It's still not fully working, and the tty module doesn't help
since it's not callable from an irq handler.


# d78faaaf 19-Aug-2014 François Revol <revol@free.fr>

pc_serial: replace contiguous area by arrays as buffers

We don't need to DMA unlike usb_serial.


# 5925b1ba 19-Aug-2014 François Revol <revol@free.fr>

pc_serial: Remove read and write lock

As with hrev42089 for usb_serial.


# ab325d98 16-Aug-2014 François Revol <revol@free.fr>

pc_serial: Drop BeOS stuff

Even I don't use it anymore...


# 2ab4db47 16-Aug-2014 François Revol <revol@free.fr>

pc_serial: Use two tty cookies


# 8e03cf4b 16-Aug-2014 François Revol <revol@free.fr>

pc_serial: Fix TTYSETRTS

Same fix as hrev42151 for usb_serial:
When determining the bit to be set for RTS/DTR there was a missing comparison
to op which would've caused a wrong line state to be set.


# 5f5d09f9 09-Dec-2010 François Revol <revol@free.fr>

Port pc_serial to the new tty module.
Builds but won't work because the tty module lacks essential calls to read and write data :^)
Lots of ifdef since I need the R5 code around for now.


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


# 1d62878c 26-Mar-2010 François Revol <revol@free.fr>

Update copyrights. Mention TuneTracker Systems as a sponsor.
Add several ways to restrict UART probing when matching devices:
- max port count,
- PCI subsystem ID mask (some cards encode the port count there),
- Base Address Register mask (some cards only have UART in the first 2 ranges).
Use those to match 2 specific NetMos chips, and avoid screwing up when input_server tries to access UARTs at boggus ranges.


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


# f878f096 23-Mar-2010 François Revol <revol@free.fr>

Less tracing by default...


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


# 50015543 08-Dec-2009 François Revol <revol@free.fr>

Change dprintfs to TRACE(), and make always on tracing less verbose.


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


# bbc84914 26-Feb-2009 François Revol <revol@free.fr>

Working version of the driver. At least it does seem to work with my onboard com port, but not the OxfordSemi PCI card I have here. Still requires tty_manager, and config_manager too, so won't work in Haiku yet. Needs cleanup.


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


# 3cdf783e 21-Aug-2008 François Revol <revol@free.fr>

Start of a PC-style serial port driver. For now it's mostly just copied parts of usb_serial, not yet usable.


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


# a9ccc3a5ec748d2dc296cadb376f54baa7272c3b 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: mask THRE again when we're out of data


# b6708d7c47109f3e03d80211cdba141c43b95b43 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: wait for writes to complete on a sem

This avoids close being called too early and discarding output.


# 6e7189d9b2b41e673c79e0fe9056543ded7c3c82 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: toggle THRE in IER to make VirtualBox happy

Not sure it's needed on real hardware yet.


# e9bbba8b847ca4ca5d13493a08dad81c33b9d443 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: cache IER and temporarily mask IRQs until dpc done

No need to be flooded by IRQs while filling in the FIFO...


# 9ab497059d919d817f65dbcb881a72f99bcb1f41 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: apply lcr parameters even when unmasking latch reg

No need to change line params even more if it was already the same before.


# 02f6c664cc2ea904245a890fe4447168894502aa 29-Aug-2014 François Revol <revol@free.fr>

pc_serial: try to enable 64 byte FIFO

We should probably detect the UART type properly first,
but the IRQ handler also checks for the available FIFO length anyway.


# efbc894614f3e5d3e31d1886a443928292a164d6 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: skip waiting for pending DPC in free hook

Since it's possible to fail queuing them, the count doesn't go down to 0,
and the process just hangs forever on exit. It might not be necessary anyway.


# aa05d85ca61d21501714d483f1d8bff8ca909dcd 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: break instead of continue in irq handler

We don't want to busy loop, do we?


# f71a01ad56085476b025b1b3d213b6436a76c745 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: add a termios member to store config across open cycles


# c5c041a5ba9b5d05013436b29e741b6fc0b26b65 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: fix KDL on close

It's working \o/
Just need to figure out why it waits for \n to transmit.

We now only destroy the cookies in the free hook.

Mention pending DPC as soon as when inside the irq handler.

Also limit the number of loops in the IRQ handler to avoid busy looping.
It only happened when testing with normal priority but you never know...


# 7b97fd6dd88917454bca5e300a60e91054c7f19b 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: use the tty module directly from the deferred IRQ

It still crashes on close sometimes but writing seems to work.


# 1a6072a0a1bf9c57347963a44fd415235c36c63a 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: manually probe the default ISA ports

Since config_manager is basically a stub, and even VirtualBox
doesn't publish the serial ports as PCI devices, we must probe for them.

Ideally config_manager would find them in the device manager tree
which would have been populated from the PnP BIOS or even ACPI tables...


# 7e613b4759303d69a721d012dac36a87d75001a3 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: convert irq handler to use DPC

Let's hope we won't loose data because it.

We have to cache the value of IIR read from IsInterruptPending(),
because some conditions are acknowledged only by reading it...


# c6870d53dc268bd27ba6488c62c461c8ac765c2b 28-Aug-2014 François Revol <revol@free.fr>

pc_serial: WIP: kinda supports writes through tty module

It's still not fully working, and the tty module doesn't help
since it's not callable from an irq handler.


# d78faaaf707d568f5f9d748b02133c756aaed9e8 19-Aug-2014 François Revol <revol@free.fr>

pc_serial: replace contiguous area by arrays as buffers

We don't need to DMA unlike usb_serial.


# 5925b1badc672f7f06e8e404ead5c3698d585ae5 19-Aug-2014 François Revol <revol@free.fr>

pc_serial: Remove read and write lock

As with hrev42089 for usb_serial.


# ab325d984f46398102dc5de8f1c2ccf494a41b27 16-Aug-2014 François Revol <revol@free.fr>

pc_serial: Drop BeOS stuff

Even I don't use it anymore...


# 2ab4db4781b09bdc39bdf6e11e03b2700ff7712b 16-Aug-2014 François Revol <revol@free.fr>

pc_serial: Use two tty cookies


# 8e03cf4b31d71334c51811504cb306883a167a5a 16-Aug-2014 François Revol <revol@free.fr>

pc_serial: Fix TTYSETRTS

Same fix as hrev42151 for usb_serial:
When determining the bit to be set for RTS/DTR there was a missing comparison
to op which would've caused a wrong line state to be set.


# 5f5d09f948eaf77cace673812b5824d2c12bd6ef 09-Dec-2010 François Revol <revol@free.fr>

Port pc_serial to the new tty module.
Builds but won't work because the tty module lacks essential calls to read and write data :^)
Lots of ifdef since I need the R5 code around for now.


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


# 1d62878c784211efa8979652a4ecd12b0ab4f9fb 26-Mar-2010 François Revol <revol@free.fr>

Update copyrights. Mention TuneTracker Systems as a sponsor.
Add several ways to restrict UART probing when matching devices:
- max port count,
- PCI subsystem ID mask (some cards encode the port count there),
- Base Address Register mask (some cards only have UART in the first 2 ranges).
Use those to match 2 specific NetMos chips, and avoid screwing up when input_server tries to access UARTs at boggus ranges.


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


# f878f09673e30965da0d7932b28ee3afd799f8c4 23-Mar-2010 François Revol <revol@free.fr>

Less tracing by default...


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


# 50015543bbd6fb6d336e1aae3faf6f2b7e736624 08-Dec-2009 François Revol <revol@free.fr>

Change dprintfs to TRACE(), and make always on tracing less verbose.


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


# bbc84914d4e340a18214a1a92b17deb03254169b 26-Feb-2009 François Revol <revol@free.fr>

Working version of the driver. At least it does seem to work with my onboard com port, but not the OxfordSemi PCI card I have here. Still requires tty_manager, and config_manager too, so won't work in Haiku yet. Needs cleanup.


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


# 3cdf783e2b2b56c04a415a14db42f23c7caba657 21-Aug-2008 François Revol <revol@free.fr>

Start of a PC-style serial port driver. For now it's mostly just copied parts of usb_serial, not yet usable.


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