1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

USE_CUSTOM_BAUD support for linux/powerpc[64le].

The powerpc[64le] arch uses different ioctls for custom baud setting: It
uses the old TCSETS*, TCGETS ioctls, not the new TCSETS*2, TCGETS2 ones.

Cross-compiles cleanly, not tested (no h/w currently available).
This commit is contained in:
Nick Patavalis
2015-08-27 23:22:56 +03:00
parent bc9ab1fdf5
commit a65e9e1e3a
2 changed files with 41 additions and 6 deletions

View File

@ -71,9 +71,34 @@
the kernel header file in here, recompile, test, and send me a
patch. */
#if defined (__powerpc__) || defined (__alpha__)
#if defined (__alpha__)
#error "Architecure has no termios2"
#error "Architecure has no termios2 support"
#elif defined (__powerpc__) || defined (__powerpc64__)
#define K_NCCS 19
/* The "old" termios is the same with termios2 for powerpc's */
struct termios2 {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_cc[K_NCCS]; /* control characters */
cc_t c_line; /* line discipline */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
#define BOTHER 00037
#define IBSHIFT 16
/* Use "old" ioctls for powerpc's as there are no TC*2 ones */
#define IOCTL_SETS TCSETS
#define IOCTL_SETSW TCSETSW
#define IOCTL_SETSF TCSETSF
#define IOCTL_GETS TCGETS
#elif defined (__mips__)
@ -93,6 +118,11 @@ struct termios2 {
#define BOTHER CBAUDEX
#define IBSHIFT 16
#define IOCTL_SETS TCSETS2
#define IOCTL_SETSW TCSETSW2
#define IOCTL_SETSF TCSETSF2
#define IOCTL_GETS TCGETS2
#else /* All others */
@ -111,6 +141,11 @@ struct termios2 {
#define BOTHER CBAUDEX
#define IBSHIFT 16
#define IOCTL_SETS TCSETS2
#define IOCTL_SETSW TCSETSW2
#define IOCTL_SETSF TCSETSF2
#define IOCTL_GETS TCGETS2
#endif /* of architectures */
/***************************************************************************/

View File

@ -56,13 +56,13 @@ tc2setattr(int fd, int optional_actions, const struct termios *tios)
switch (optional_actions) {
case TCSANOW:
cmd = TCSETS2;
cmd = IOCTL_SETS;
break;
case TCSADRAIN:
cmd = TCSETSW2;
cmd = IOCTL_SETSW;
break;
case TCSAFLUSH:
cmd = TCSETSF2;
cmd = IOCTL_SETSF;
break;
default:
errno = EINVAL;
@ -88,7 +88,7 @@ tc2getattr(int fd, struct termios *tios)
size_t i;
int r;
r = ioctl(fd, TCGETS2, &t2);
r = ioctl(fd, IOCTL_GETS, &t2);
if (r < 0) return r;
tios->c_iflag = t2.c_iflag;