Lines Matching +full:otp +full:- +full:1
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
10 * 1. Redistributions of source code must retain the above copyright
35 * Pseudo-nulmodem driver
107 struct tty *otp; in nmdm_close() local
110 onp = np->np_other; in nmdm_close()
111 otp = onp->np_tty; in nmdm_close()
114 if (tty_opened(otp)) in nmdm_close()
122 onp = np->np_other; in nmdm_close()
125 otp = onp->np_tty; in nmdm_close()
126 tty_rel_gone(otp); in nmdm_close()
134 struct nmdmsoftc *ns = np->np_pair; in nmdm_free()
136 callout_drain(&np->np_callout); in nmdm_free()
137 taskqueue_drain(taskqueue_swi, &np->np_task); in nmdm_free()
144 mtx_lock(&ns->ns_mtx); in nmdm_free()
145 if (np->np_other != NULL) { in nmdm_free()
146 np->np_other->np_other = NULL; in nmdm_free()
147 mtx_unlock(&ns->ns_mtx); in nmdm_free()
150 mtx_destroy(&ns->ns_mtx); in nmdm_free()
152 atomic_subtract_int(&nmdm_count, 1); in nmdm_free()
173 end = name + strlen(name) - 1; in nmdm_clone()
179 mtx_init(&ns->ns_mtx, "nmdm", NULL, MTX_DEF); in nmdm_clone()
182 ns->ns_part1.np_pair = ns; in nmdm_clone()
183 ns->ns_part1.np_other = &ns->ns_part2; in nmdm_clone()
184 TASK_INIT(&ns->ns_part1.np_task, 0, nmdm_task_tty, &ns->ns_part1); in nmdm_clone()
185 callout_init_mtx(&ns->ns_part1.np_callout, &ns->ns_mtx, 0); in nmdm_clone()
187 ns->ns_part2.np_pair = ns; in nmdm_clone()
188 ns->ns_part2.np_other = &ns->ns_part1; in nmdm_clone()
189 TASK_INIT(&ns->ns_part2.np_task, 0, nmdm_task_tty, &ns->ns_part2); in nmdm_clone()
190 callout_init_mtx(&ns->ns_part2.np_callout, &ns->ns_mtx, 0); in nmdm_clone()
193 tp = ns->ns_part1.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part1, in nmdm_clone()
194 &ns->ns_mtx); in nmdm_clone()
200 mtx_destroy(&ns->ns_mtx); in nmdm_clone()
205 tp = ns->ns_part2.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part2, in nmdm_clone()
206 &ns->ns_mtx); in nmdm_clone()
212 mtx_lock(&ns->ns_mtx); in nmdm_clone()
214 ns->ns_part1.np_other = NULL; in nmdm_clone()
215 atomic_add_int(&nmdm_count, 1); in nmdm_clone()
216 tty_rel_gone(ns->ns_part1.np_tty); in nmdm_clone()
221 *dev = ns->ns_part1.np_tty->t_dev; in nmdm_clone()
223 *dev = ns->ns_part2.np_tty->t_dev; in nmdm_clone()
226 atomic_add_int(&nmdm_count, 1); in nmdm_clone()
234 if (np->np_rate == 0) in nmdm_timeout()
238 * Do a simple Floyd-Steinberg dither here to avoid FP math. in nmdm_timeout()
241 np->np_accumulator += np->np_credits; in nmdm_timeout()
242 np->np_quota = np->np_accumulator >> QS; in nmdm_timeout()
243 np->np_accumulator &= ((1 << QS) - 1); in nmdm_timeout()
245 taskqueue_enqueue(taskqueue_swi, &np->np_task); in nmdm_timeout()
246 callout_reset(&np->np_callout, np->np_rate, nmdm_timeout, np); in nmdm_timeout()
252 struct tty *tp, *otp; in nmdm_task_tty() local
256 tp = np->np_tty; in nmdm_task_tty()
263 otp = np->np_other->np_tty; in nmdm_task_tty()
264 KASSERT(otp != NULL, ("NULL otp in nmdmstart")); in nmdm_task_tty()
265 KASSERT(otp != tp, ("NULL otp == tp nmdmstart")); in nmdm_task_tty()
266 if (np->np_other->np_dcd) { in nmdm_task_tty()
268 np->np_other->np_dcd = 0; in nmdm_task_tty()
269 ttydisc_modem(otp, 0); in nmdm_task_tty()
273 np->np_other->np_dcd = 1; in nmdm_task_tty()
274 ttydisc_modem(otp, 1); in nmdm_task_tty()
279 if (tty_gone(otp)) { in nmdm_task_tty()
280 tty_unlock(otp); in nmdm_task_tty()
284 while (ttydisc_rint_poll(otp) > 0) { in nmdm_task_tty()
285 if (np->np_rate && !np->np_quota) in nmdm_task_tty()
287 if (ttydisc_getc(tp, &c, 1) != 1) in nmdm_task_tty()
289 np->np_quota--; in nmdm_task_tty()
290 ttydisc_rint(otp, c, 0); in nmdm_task_tty()
293 ttydisc_rint_done(otp); in nmdm_task_tty()
303 bits = 1; /* start bit */ in bits_per_char()
304 switch (t->c_cflag & CSIZE) { in bits_per_char()
311 if (t->c_cflag & PARENB) in bits_per_char()
313 if (t->c_cflag & CSTOPB) in bits_per_char()
325 tp2 = np->np_other->np_tty; in nmdm_param()
327 if (!((t->c_cflag | tp2->t_termios.c_cflag) & CDSR_OFLOW)) { in nmdm_param()
328 np->np_rate = 0; in nmdm_param()
329 np->np_other->np_rate = 0; in nmdm_param()
334 * DSRFLOW one either side enables rate-simulation for both in nmdm_param()
340 bpc = imax(bits_per_char(t), bits_per_char(&tp2->t_termios)); in nmdm_param()
344 speed = imin(tp2->t_termios.c_ospeed, t->c_ispeed); in nmdm_param()
346 np->np_rate = 0; in nmdm_param()
347 np->np_other->np_rate = 0; in nmdm_param()
355 rate = 1; in nmdm_param()
360 np->np_credits = speed; in nmdm_param()
361 np->np_rate = rate; in nmdm_param()
362 callout_reset(&np->np_callout, rate, nmdm_timeout, np); in nmdm_param()
368 np = np->np_other; in nmdm_param()
369 t = &tp2->t_termios; in nmdm_param()
384 np->np_other->np_dcd = 1; in nmdm_modem()
386 np->np_other->np_dcd = 0; in nmdm_modem()
388 ttydisc_modem(np->np_other->np_tty, np->np_other->np_dcd); in nmdm_modem()
392 if (np->np_dcd) in nmdm_modem()
394 if (np->np_other->np_dcd) in nmdm_modem()
407 taskqueue_enqueue(taskqueue_swi, &np->np_other->np_task); in nmdm_inwakeup()
416 taskqueue_enqueue(taskqueue_swi, &np->np_task); in nmdm_outwakeup()