+ case TDEV_TCGETATTR: {
+ struct termios* tios = va_arg(args, struct termios*);
+ *tios = (struct termios){.c_oflag = term->oflags,
+ .c_iflag = term->iflags,
+ .c_lflag = term->lflags,
+ .c_cflag = term->cflags};
+ memcpy(tios->c_cc, term->cc, _NCCS * sizeof(cc_t));
+ tios->c_baud = term->iospeed;
+ } break;
+ case TDEV_TCSETATTR: {
+ struct termios* tios = va_arg(args, struct termios*);
+ term->iflags = tios->c_iflag;
+ term->oflags = tios->c_oflag;
+ term->lflags = tios->c_lflag;
+ memcpy(term->cc, tios->c_cc, _NCCS * sizeof(cc_t));
+
+ tcflag_t old_cf = term->cflags;
+ term->cflags = tios->c_cflag;
+
+ if (!term->tp_cap) {
+ goto done;
+ }
+
+ if (tios->c_baud != term->iospeed) {
+ term->iospeed = tios->c_baud;
+
+ term->tp_cap->set_speed(term->chdev, tios->c_baud);
+ }
+
+ if (old_cf != tios->c_cflag) {
+ term->tp_cap->set_cntrl_mode(term->chdev, tios->c_cflag);
+ }
+ } break;