summaryrefslogtreecommitdiff
path: root/tools/termios_linux.h
AgeCommit message (Collapse)Author
2025-07-08tools: termios_linux.h: Fix build error on ppc64Javier Martinez Canillas
Commit 93b55636b09f ("tools: kwboot: Allow any baudrate on Linux") added a tcgetattr() function to be used, instead of the libc's termios functions. This was done to allow using the raw TCGETS2/TCSETS2 ioctls that allow to support arbitrary baud rates. This breaks the build for PowerPC, because that architecture does not have a struct termios2 defined because the termios and ktermios are the same. On PowerPC, the termios ioctl() emulates the TCGETS2/TCSETS*2 ioctls with tcgetattr/tcsetattr using just the struct termios (that's as mentioned the same than what is defined as struct termios2 in other architectures). So there is no need to use the TCGETS2/TCSETS2 ioctls on that architecture and just TCGETS/TCSETS ioctls with termios as defined by PowerPC is enough. Fixes: 93b55636b09f ("tools: kwboot: Allow any baudrate on Linux") Signed-off-by: Javier Martinez Canillas <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2022-09-13tools: termios_linux.h: Fix compilation on non-glibc systemsPali Rohár
TCGETS2 is defined in header file asm/ioctls.h provided by linux kernel. On glib systems it is automatically included by some other glibc include header file and therefore TCGETS2 is present in termios_linux.h when linux kernel provides it. On non-glibc systems (e.g. musl) asm/ioctls.h is not automatically included which results in the strange error that BOTHER is supported, TCGETS2 not defined and struct termios does not provide c_ispeed member. tools/kwboot.c: In function 'kwboot_tty_change_baudrate': tools/kwboot.c:662:6: error: 'struct termios' has no member named 'c_ospeed' 662 | tio.c_ospeed = tio.c_ispeed = baudrate; | ^ Fix this issue by explicitly including asm/ioctls.h file which provides TCGETS2 macro (if supported on selected architecture) to not depending on glibc auto-include behavior and because termios_linux.h requires it. With this change it is possible compile kwboot with musl libc. Reported-by: Michal Vasilek <[email protected]> Signed-off-by: Pali Rohár <[email protected]>
2022-07-21treewide: Fix Marek's name and change my e-mail addressMarek Behún
Fix diacritics in some instances of my name and change my e-mail address to [email protected]. Add corresponding .mailmap entries. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-21tools: termios_linux.h: Fix tcsendbreak() implementationPali Rohár
There are two Linux ioctls which implements tcsendbreak() functionality: TCSBRK and TCSBRKP TCSBRK with non-zero parameter implements tcdrain() and with zero parameter implements tcsendbreak() for duration of 0.25s. TCSBRKP with zero parameter is same as TCSBRK and with non-zero parameter implements tcsendbreak() for duration in deciseconds specified by parameter. TCSBRKP does not have to be provided by older toolchain versions. So tcsendbreak() has to either use TCSBRK with zero parameter or TCSBRKP with any parameter. Fix code to use TCSBRKP and fallback to TCSBRK with 0. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Allow any baudrate on LinuxPali Rohár
The A38x platform supports more baudrates than just those defined by the Bn constants, and some of them are higher than the highest Bn baudrate (the highest is 4 MBd while A38x support 5.15 MBd). On Linux, add support for arbitrary baudrates. (Since there is no standard POSIX API to specify arbitrary baudrate for a tty device, this change is Linux-specific.) We need to use raw TCGETS2/TCSETS2 or TCGETS/TCSETS ioctls with the BOTHER flag in struct termios2/termios, defined in Linux headers <asm/ioctls.h> (included by <sys/ioctl.h>) and <asm/termbits.h>. Since these headers conflict with glibc's header file <termios.h>, it is not possible to use libc's termios functions and we need to reimplement them via ioctl() calls. Note that the Bnnn constants from <termios.h> need not be compatible with Bnnn constants from <asm/termbits.h>. Signed-off-by: Pali Rohár <[email protected]> [ termios macros rewritten to static inline functions (for type control) and moved to tools/termios_linux.h ] Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>