tty: Add bitmask ioctls TIOCMBIS and TIOCMBIC

Equivalent to TIOCMSET + bitmask + TIOCMGET but with a single call.

Gnokii uses that.
This commit is contained in:
François Revol 2014-07-23 21:17:27 +02:00
parent 970910c21e
commit 0be89c15ee
2 changed files with 22 additions and 0 deletions

View File

@ -185,6 +185,8 @@ struct termios {
#define TIOCMSET (TCGETA + 19) /* does TCSETDTR/TCSETRTS */
#define TIOCSBRK (TCGETA + 20) /* set txd pin */
#define TIOCCBRK (TCGETA + 21) /* both are a frontend to TCSBRK */
#define TIOCMBIS (TCGETA + 22) /* set bits in line state */
#define TIOCMBIC (TCGETA + 23) /* clear bits in line state */
/* Event codes. Returned from TCWAITEVENT */
#define EV_RING 0x0001

View File

@ -1756,6 +1756,26 @@ tty_control(tty_cookie* cookie, uint32 op, void* buffer, size_t length)
return user_memcpy(buffer, &bits, sizeof(bits));
}
case TIOCMBIS:
case TIOCMBIC:
{
// control line state setting, we only support DTR and RTS
int value;
if (user_memcpy(&value, buffer, sizeof(value)) != B_OK)
return B_BAD_ADDRESS;
bool result = false;
bool dtr = (op == TIOCMBIS);
if (value & TIOCM_DTR)
result = tty->service_func(tty, TTYSETDTR, &dtr, sizeof(dtr));
bool rts = (op == TIOCMBIS);
if (value & TIOCM_RTS)
result = tty->service_func(tty, TTYSETRTS, &rts, sizeof(rts));
return result ? B_OK : B_ERROR;
}
case TIOCSBRK:
case TIOCCBRK:
case TCSBRK: