cons.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* $OpenBSD: cons.h,v 1.17 2013/09/29 12:56:31 kettenis Exp $ */
  2. /* $NetBSD: cons.h,v 1.14 1996/03/14 19:08:35 christos Exp $ */
  3. /*
  4. * Copyright (c) 1988 University of Utah.
  5. * Copyright (c) 1990, 1993
  6. * The Regents of the University of California. All rights reserved.
  7. *
  8. * This code is derived from software contributed to Berkeley by
  9. * the Systems Programming Group of the University of Utah Computer
  10. * Science Department.
  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. * from: Utah $Hdr: cons.h 1.6 92/01/21$
  37. *
  38. * @(#)cons.h 8.1 (Berkeley) 6/10/93
  39. */
  40. struct consdev {
  41. /* probe hardware and fill in consdev info */
  42. void (*cn_probe)(struct consdev *);
  43. /* turn on as console */
  44. void (*cn_init)(struct consdev *);
  45. /* kernel getchar interface */
  46. int (*cn_getc)(dev_t);
  47. /* kernel putchar interface */
  48. void (*cn_putc)(dev_t, int);
  49. /* turn on and off polling */
  50. void (*cn_pollc)(dev_t, int);
  51. /* ring bell */
  52. void (*cn_bell)(dev_t, u_int, u_int, u_int);
  53. dev_t cn_dev; /* major/minor of device */
  54. u_int cn_pri; /* picking order; the higher the better */
  55. };
  56. /* Values for cn_pri - policy for console selection. */
  57. #define CN_DEAD 0 /* Device does not exist. */
  58. #define CN_LOWPRI 1 /* Device exists and is low priority. */
  59. #define CN_MIDPRI 2 /* Device exists and is medium priority. */
  60. #define CN_HIGHPRI 3 /* Device exists and is high priority. */
  61. #define CN_FORCED 4 /* Use this device. */
  62. /* XXX */
  63. #define CONSMAJOR 0
  64. #ifdef _KERNEL
  65. extern struct consdev constab[];
  66. extern struct consdev *cn_tab;
  67. struct knote;
  68. void cninit(void);
  69. int cnopen(dev_t, int, int, struct proc *);
  70. int cnclose(dev_t, int, int, struct proc *);
  71. int cnread(dev_t, struct uio *, int);
  72. int cnwrite(dev_t, struct uio *, int);
  73. int cnioctl(dev_t, u_long, caddr_t, int, struct proc *);
  74. int cnpoll(dev_t, int, struct proc *);
  75. int cnkqfilter(dev_t, struct knote *);
  76. int cngetc(void);
  77. void cnputc(int);
  78. void cnpollc(int);
  79. void cnbell(u_int, u_int, u_int);
  80. void cnrint(void);
  81. void nullcnpollc(dev_t, int);
  82. /* console-specific types */
  83. #define dev_type_cnprobe(n) void n(struct consdev *)
  84. #define dev_type_cninit(n) void n(struct consdev *)
  85. #define dev_type_cngetc(n) int n(dev_t)
  86. #define dev_type_cnputc(n) void n(dev_t, int)
  87. #define dev_type_cnpollc(n) void n(dev_t, int)
  88. #define dev_type_cnbell(n) void n(dev_t, u_int, u_int, u_int)
  89. #define cons_decl(n) \
  90. dev_decl(n,cnprobe); dev_decl(n,cninit); dev_decl(n,cngetc); \
  91. dev_decl(n,cnputc); dev_decl(n,cnpollc); dev_decl(n,cnbell);
  92. #define cons_init(n) { \
  93. dev_init(1,n,cnprobe), dev_init(1,n,cninit), dev_init(1,n,cngetc), \
  94. dev_init(1,n,cnputc), dev_init(1,n,cnpollc), NULL, \
  95. NODEV, CN_DEAD }
  96. #define cons_init_bell(n) { \
  97. dev_init(1,n,cnprobe), dev_init(1,n,cninit), dev_init(1,n,cngetc), \
  98. dev_init(1,n,cnputc), dev_init(1,n,cnpollc), dev_init(1,n,cnbell), \
  99. NODEV, CN_DEAD }
  100. #endif