Lines Matching refs:dev

93 #define	Online(dev)	((dev)->mbits & TIOCM_CD)  argument
96 struct device dev; /* What struct physical knows about */ member
128 struct ttydevice *dev = device2tty(p->handler); in tty_Timeout() local
131 timer_Stop(&dev->Timer); in tty_Timeout()
132 dev->Timer.load = SECTICKS; /* Once a second please */ in tty_Timeout()
133 timer_Start(&dev->Timer); in tty_Timeout()
134 ombits = dev->mbits; in tty_Timeout()
137 if (ioctl(p->fd, TIOCMGET, &dev->mbits) < 0) { in tty_Timeout()
142 timer_Stop(&dev->Timer); in tty_Timeout()
143 dev->mbits = TIOCM_CD; in tty_Timeout()
147 dev->mbits = 0; in tty_Timeout()
151 if (Online(dev)) in tty_Timeout()
153 else if (++dev->carrier_seconds >= dev->dev.cd.delay) { in tty_Timeout()
154 if (dev->dev.cd.necessity == CD_REQUIRED) in tty_Timeout()
160 dev->mbits = TIOCM_CD; /* Dodgy null-modem cable ? */ in tty_Timeout()
162 timer_Stop(&dev->Timer); in tty_Timeout()
167 p->link.name, p->name.full, dev->carrier_seconds, in tty_Timeout()
168 dev->dev.cd.delay); in tty_Timeout()
169 dev->mbits = -1; in tty_Timeout()
172 change = ombits ^ dev->mbits; in tty_Timeout()
174 if (dev->mbits & TIOCM_CD) in tty_Timeout()
180 timer_Stop(&dev->Timer); in tty_Timeout()
184 Online(dev) ? "on" : "off"); in tty_Timeout()
191 struct ttydevice *dev = device2tty(p->handler); in tty_StartTimer() local
193 timer_Stop(&dev->Timer); in tty_StartTimer()
194 dev->Timer.load = SECTICKS; in tty_StartTimer()
195 dev->Timer.func = tty_Timeout; in tty_StartTimer()
196 dev->Timer.name = "tty CD"; in tty_StartTimer()
197 dev->Timer.arg = p; in tty_StartTimer()
200 timer_Start(&dev->Timer); in tty_StartTimer()
206 struct ttydevice *dev = device2tty(p->handler); in tty_AwaitCarrier() local
208 if (dev->dev.cd.necessity == CD_NOTREQUIRED || physical_IsSync(p)) in tty_AwaitCarrier()
211 if (dev->mbits == -1) { in tty_AwaitCarrier()
212 if (dev->Timer.state == TIMER_STOPPED) { in tty_AwaitCarrier()
213 dev->carrier_seconds = 0; in tty_AwaitCarrier()
219 return Online(dev) ? CARRIER_OK : CARRIER_LOST; in tty_AwaitCarrier()
229 isngtty(struct ttydevice *dev) in isngtty() argument
231 return dev->real.fd != -1; in isngtty()
237 struct ttydevice *dev = device2tty(p->handler); in tty_SetAsyncParams() local
241 if (isngtty(dev)) { in tty_SetAsyncParams()
244 snprintf(asyncpath, sizeof asyncpath, ".:%s", dev->hook); in tty_SetAsyncParams()
251 if (NgSendMsg(dev->cs, asyncpath, NGM_ASYNC_COOKIE, in tty_SetAsyncParams()
263 struct ttydevice *dev = device2tty(p->handler); in LoadLineDiscipline() local
288 if (ioctl(p->fd, TIOCGETD, &dev->real.disc) < 0) { in LoadLineDiscipline()
304 ID0ioctl(p->fd, TIOCSETD, &dev->real.disc); in LoadLineDiscipline()
313 ID0ioctl(p->fd, TIOCSETD, &dev->real.disc); in LoadLineDiscipline()
366 snprintf(dev->hook, sizeof dev->hook, "%s", ngc.ourhook); in LoadLineDiscipline()
367 dev->cs = cs; in LoadLineDiscipline()
368 dev->real.fd = p->fd; in LoadLineDiscipline()
370 dev->real.speed = speed; in LoadLineDiscipline()
374 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); in LoadLineDiscipline()
381 ID0ioctl(p->fd, TIOCSETD, &dev->real.disc); in LoadLineDiscipline()
391 struct ttydevice *dev = device2tty(p->handler); in UnloadLineDiscipline() local
393 if (isngtty(dev)) { in UnloadLineDiscipline()
394 log_Printf(LogPHASE, "back to speed %d\n", dev->real.speed); in UnloadLineDiscipline()
395 if (!physical_SetSpeed(p, dev->real.speed)) in UnloadLineDiscipline()
396 log_Printf(LogWARN, "Couldn't reset tty speed to %d\n", dev->real.speed); in UnloadLineDiscipline()
397 dev->real.speed = 0; in UnloadLineDiscipline()
399 p->fd = dev->real.fd; in UnloadLineDiscipline()
400 dev->real.fd = -1; in UnloadLineDiscipline()
401 close(dev->cs); in UnloadLineDiscipline()
402 dev->cs = -1; in UnloadLineDiscipline()
403 *dev->hook = '\0'; in UnloadLineDiscipline()
404 if (ID0ioctl(p->fd, TIOCSETD, &dev->real.disc) == 0) { in UnloadLineDiscipline()
405 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); in UnloadLineDiscipline()
417 struct ttydevice *dev = device2tty(p->handler); in tty_Write() local
419 if (isngtty(dev)) in tty_Write()
420 return NgSendData(p->fd, dev->hook, v, n) == -1 ? -1 : (ssize_t)n; in tty_Write()
428 struct ttydevice *dev = device2tty(p->handler); in tty_Read() local
431 if (isngtty(dev)) in tty_Read()
442 struct ttydevice *dev = device2tty(p->handler); in tty_Raw() local
448 if (p->type != PHYS_DIRECT && p->fd >= 0 && !Online(dev)) in tty_Raw()
450 p->link.name, p->fd, dev->mbits); in tty_Raw()
484 struct ttydevice *dev = device2tty(p->handler); in tty_Offline() local
487 timer_Stop(&dev->Timer); in tty_Offline()
488 dev->mbits &= ~TIOCM_DTR; /* XXX: Hmm, what's this supposed to do ? */ in tty_Offline()
489 if (Online(dev)) { in tty_Offline()
503 struct ttydevice *dev = device2tty(p->handler); in tty_Cooked() local
510 if (!physical_IsSync(p) && tcsetattr(p->fd, TCSAFLUSH, &dev->ios) == -1) in tty_Cooked()
525 struct ttydevice *dev = device2tty(p->handler); in tty_StopTimer() local
527 timer_Stop(&dev->Timer); in tty_StopTimer()
533 struct ttydevice *dev = device2tty(p->handler); in tty_Free() local
536 free(dev); in tty_Free()
553 struct ttydevice *dev = device2tty(p->handler); in tty_OpenInfo() local
556 if (Online(dev)) in tty_OpenInfo()
586 struct ttydevice *dev = device2tty(d); in tty_device2iov() local
598 if (dev->cs >= 0) { in tty_device2iov()
599 *auxfd = dev->cs; in tty_device2iov()
604 if (dev->Timer.state != TIMER_STOPPED) { in tty_device2iov()
605 timer_Stop(&dev->Timer); in tty_device2iov()
606 dev->Timer.state = TIMER_RUNNING; in tty_device2iov()
636 struct ttydevice *dev = (struct ttydevice *)iov[(*niov)++].iov_base; in tty_iov2device() local
638 dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ in tty_iov2device()
639 if (dev == NULL) { in tty_iov2device()
641 (int)(sizeof *dev)); in tty_iov2device()
647 dev->cs = *auxfd; in tty_iov2device()
650 dev->cs = -1; in tty_iov2device()
654 memcpy(&dev->dev, &basettydevice, sizeof dev->dev); in tty_iov2device()
656 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); in tty_iov2device()
657 if (dev->Timer.state != TIMER_STOPPED) { in tty_iov2device()
658 dev->Timer.state = TIMER_STOPPED; in tty_iov2device()
659 p->handler = &dev->dev; /* For the benefit of StartTimer */ in tty_iov2device()
662 return &dev->dev; in tty_iov2device()
671 struct ttydevice *dev; in tty_Create() local
688 if ((dev = malloc(sizeof *dev)) == NULL) { in tty_Create()
695 memcpy(&dev->dev, &basettydevice, sizeof dev->dev); in tty_Create()
696 memset(&dev->Timer, '\0', sizeof dev->Timer); in tty_Create()
697 dev->mbits = -1; in tty_Create()
699 dev->real.speed = 0; in tty_Create()
700 dev->real.fd = -1; in tty_Create()
701 dev->real.disc = -1; in tty_Create()
702 *dev->hook = '\0'; in tty_Create()
705 dev->ios = ios; in tty_Create()
709 dev->dev.cd = p->cfg.cd; in tty_Create()
756 free(dev); in tty_Create()
761 physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); in tty_Create()
763 return &dev->dev; in tty_Create()