mirror of
https://review.haiku-os.org/haiku
synced 2025-01-18 12:38:51 +01:00
a38c3c0384
Fixes the code I introduced in hrev50114 for custom serial port baudrates. The idea there was based on FreeBSD implementation, but I missed a key detail: speed_t in BeOS (and Haiku) is only an 8 bit value. Note that BeOS does not have c_ispeed and c_ospeed fields, instead they are named c_ixxxxx and c_oxxxxx with a comment in termios.h saying that they are not used. So the renaming and moving of these fields isn't a problem. This means the previous code worked only for speed between 20 and 255 baud, quite the opposite of what I wanted to do, which is to enable access to fast baudrates. This new implementation exploits the fact that tcflag_t is 32 bit, but we never actually use more than 16 bits. Therefore, the high bits of each value were unused, and can be reclaimed to store the speed, by changing tcflag_t to 16 bits. The speed is then inserted as two 16 bit values that can be combined as a 32 bit one. The flag bits are not moved (on little endian systems), and the extra values are guaranteed to be set to 0 by any previous code that was compiled with 32 bit tcflag_t. Support for different speeds for input and output is now also possible (POSIX specifies separate functions for setting the input and output speeds, which is useful for some old terminals and modems, where it was useful to have a high baudrate for data to display on the screen, but things typed on the keyboard aren't quite as fast). If desired, we could now properly implement this in our serial drivers, but it isn't done here yet. Additional changes: - speed_t is now a 32bit type, allowing to pass large values to cfset(i,o)speed - fix some places where a baudrate enum value was incorrectly put in the c_ispeed and c_ospeed fields, this is not how they were meant to be used (it meant the default was to use a speed of 0, that means "hangup" the line, which I think no serial driver really implemented). - do not put baudrate enumeration values in c_iflag and c_oflag, they are meant to be used in c_cflag only, and conflict with other bits. Separate speeds for input and output can be done by setting the c_cflag value to CBAUD (indicating custom baudrates) and then setting the values in c_ispeed and c_ospeed. Fixes #18483 Change-Id: If63a24b5ced5edf6d051d921197db194def0c614 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7068 Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk> |
||
---|---|---|
.. | ||
build | ||
compatibility | ||
config | ||
cpp | ||
glibc | ||
libs | ||
os | ||
posix | ||
private | ||
tools |