tty_conf.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* $OpenBSD: tty_conf.c,v 1.21 2015/03/14 03:38:51 jsg Exp $ */
  2. /* $NetBSD: tty_conf.c,v 1.18 1996/05/19 17:17:55 jonathan Exp $ */
  3. /*-
  4. * Copyright (c) 1982, 1986, 1991, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. * (c) UNIX System Laboratories, Inc.
  7. * All or some portions of this file are derived from material licensed
  8. * to the University of California by American Telephone and Telegraph
  9. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  10. * the permission of UNIX System Laboratories, Inc.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. * 1. Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright
  18. * notice, this list of conditions and the following disclaimer in the
  19. * documentation and/or other materials provided with the distribution.
  20. * 3. Neither the name of the University nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. * SUCH DAMAGE.
  35. *
  36. * @(#)tty_conf.c 8.4 (Berkeley) 1/21/94
  37. */
  38. #include <sys/param.h>
  39. #include <sys/systm.h>
  40. #include <sys/tty.h>
  41. #include <sys/conf.h>
  42. #define ttynodisc ((int (*)(dev_t, struct tty *, struct proc *))enodev)
  43. #define ttyerrclose ((int (*)(struct tty *, int flags, struct proc *))enodev)
  44. #define ttyerrio ((int (*)(struct tty *, struct uio *, int))enodev)
  45. #define ttyerrinput ((int (*)(int c, struct tty *))enodev)
  46. #define ttyerrstart ((int (*)(struct tty *))enodev)
  47. int nullioctl(struct tty *, u_long, caddr_t, int, struct proc *);
  48. #include "ppp.h"
  49. #if NPPP > 0
  50. int pppopen(dev_t dev, struct tty *tp, struct proc *);
  51. int pppclose(struct tty *tp, int flags, struct proc *);
  52. int ppptioctl(struct tty *tp, u_long cmd, caddr_t data,
  53. int flag, struct proc *p);
  54. int pppinput(int c, struct tty *tp);
  55. int pppstart(struct tty *tp);
  56. int pppread(struct tty *tp, struct uio *uio, int flag);
  57. int pppwrite(struct tty *tp, struct uio *uio, int flag);
  58. #endif
  59. #include "nmea.h"
  60. #if NNMEA > 0
  61. int nmeaopen(dev_t, struct tty *, struct proc *);
  62. int nmeaclose(struct tty *, int, struct proc *);
  63. int nmeainput(int, struct tty *);
  64. #endif
  65. #include "msts.h"
  66. #if NMSTS > 0
  67. int mstsopen(dev_t, struct tty *, struct proc *);
  68. int mstsclose(struct tty *, int, struct proc *);
  69. int mstsinput(int, struct tty *);
  70. #endif
  71. #include "endrun.h"
  72. #if NENDRUN > 0
  73. int endrunopen(dev_t, struct tty *, struct proc *);
  74. int endrunclose(struct tty *, int, struct proc *);
  75. int endruninput(int, struct tty *);
  76. #endif
  77. struct linesw linesw[] =
  78. {
  79. { ttyopen, ttylclose, ttread, ttwrite, nullioctl,
  80. ttyinput, ttstart, ttymodem }, /* 0- termios */
  81. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  82. ttyerrinput, ttyerrstart, nullmodem }, /* 1- defunct */
  83. /* 2- old NTTYDISC (defunct) */
  84. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  85. ttyerrinput, ttyerrstart, nullmodem },
  86. /* 3- TABLDISC (defunct) */
  87. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  88. ttyerrinput, ttyerrstart, nullmodem },
  89. /* 4- SLIPDISC (defunct) */
  90. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  91. ttyerrinput, ttyerrstart, nullmodem },
  92. #if NPPP > 0
  93. { pppopen, pppclose, pppread, pppwrite, ppptioctl,
  94. pppinput, pppstart, ttymodem }, /* 5- PPPDISC */
  95. #else
  96. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  97. ttyerrinput, ttyerrstart, nullmodem },
  98. #endif
  99. /* 6- STRIPDISC (defunct) */
  100. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  101. ttyerrinput, ttyerrstart, nullmodem },
  102. #if NNMEA > 0
  103. { nmeaopen, nmeaclose, ttread, ttwrite, nullioctl,
  104. nmeainput, ttstart, ttymodem }, /* 7- NMEADISC */
  105. #else
  106. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  107. ttyerrinput, ttyerrstart, nullmodem },
  108. #endif
  109. #if NMSTS > 0
  110. { mstsopen, mstsclose, ttread, ttwrite, nullioctl,
  111. mstsinput, ttstart, ttymodem }, /* 8- MSTSDISC */
  112. #else
  113. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  114. ttyerrinput, ttyerrstart, nullmodem },
  115. #endif
  116. #if NENDRUN > 0
  117. { endrunopen, endrunclose, ttread, ttwrite, nullioctl,
  118. endruninput, ttstart, ttymodem }, /* 9- ENDRUNDISC */
  119. #else
  120. { ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
  121. ttyerrinput, ttyerrstart, nullmodem },
  122. #endif
  123. };
  124. int nlinesw = sizeof (linesw) / sizeof (linesw[0]);
  125. /*
  126. * Do nothing specific version of line
  127. * discipline specific ioctl command.
  128. */
  129. int
  130. nullioctl(struct tty *tp, u_long cmd, char *data, int flags, struct proc *p)
  131. {
  132. return (-1);
  133. }