Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/snp/snp.c
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
static struct sx snp_register_lock; | static struct sx snp_register_lock; | ||||
SX_SYSINIT(snp_register_lock, &snp_register_lock, | SX_SYSINIT(snp_register_lock, &snp_register_lock, | ||||
"tty snoop registration"); | "tty snoop registration"); | ||||
#define SNP_LOCK() sx_xlock(&snp_register_lock) | #define SNP_LOCK() sx_xlock(&snp_register_lock) | ||||
#define SNP_UNLOCK() sx_xunlock(&snp_register_lock) | #define SNP_UNLOCK() sx_xunlock(&snp_register_lock) | ||||
#endif | #endif | ||||
#define SNPGTYY_32DEV _IOR('T', 89, uint32_t) | |||||
/* | /* | ||||
* There is no need to have a big input buffer. In most typical setups, | * There is no need to have a big input buffer. In most typical setups, | ||||
* we won't inject much data into the TTY, because users can't type | * we won't inject much data into the TTY, because users can't type | ||||
* really fast. | * really fast. | ||||
*/ | */ | ||||
#define SNP_INPUT_BUFSIZE 16 | #define SNP_INPUT_BUFSIZE 16 | ||||
/* | /* | ||||
* The output buffer has to be really big. Right now we don't support | * The output buffer has to be really big. Right now we don't support | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | case SNPSTTY: | ||||
return (0); | return (0); | ||||
case SNPGTTY: | case SNPGTTY: | ||||
/* Obtain device number of associated TTY. */ | /* Obtain device number of associated TTY. */ | ||||
if (ss->snp_tty == NULL) | if (ss->snp_tty == NULL) | ||||
*(dev_t *)data = NODEV; | *(dev_t *)data = NODEV; | ||||
else | else | ||||
*(dev_t *)data = tty_udev(ss->snp_tty); | *(dev_t *)data = tty_udev(ss->snp_tty); | ||||
return (0); | |||||
case SNPGTYY_32DEV: | |||||
if (ss->snp_tty == NULL) | |||||
*(uint32_t *)data = -1; | |||||
else | |||||
*(uint32_t *)data = tty_udev(ss->snp_tty); /* trunc */ | |||||
return (0); | return (0); | ||||
case FIONREAD: | case FIONREAD: | ||||
tp = ss->snp_tty; | tp = ss->snp_tty; | ||||
if (tp != NULL) { | if (tp != NULL) { | ||||
tty_lock(tp); | tty_lock(tp); | ||||
*(int *)data = ttyoutq_bytesused(&ss->snp_outq); | *(int *)data = ttyoutq_bytesused(&ss->snp_outq); | ||||
tty_unlock(tp); | tty_unlock(tp); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |