/sys/conf.h

http://rtems-atapi.googlecode.com/ · C++ Header · 255 lines · 166 code · 34 blank · 55 comment · 0 complexity · a3ed8353a795aacc92c3f2280cd3a7a4 MD5 · raw file

  1. /* $NetBSD: conf.h,v 1.131.8.1 2009/06/23 06:56:51 snj Exp $ */
  2. /*-
  3. * Copyright (c) 1990, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. * (c) UNIX System Laboratories, Inc.
  6. * All or some portions of this file are derived from material licensed
  7. * to the University of California by American Telephone and Telegraph
  8. * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  9. * the permission of UNIX System Laboratories, Inc.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. Neither the name of the University nor the names of its contributors
  20. * may be used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * @(#)conf.h 8.5 (Berkeley) 1/9/95
  36. */
  37. #ifndef _SYS_CONF_H_
  38. #define _SYS_CONF_H_
  39. /*from kern/sys_generic.c -cdcs*/
  40. int seltrue(__unused dev_t dev, __unused int flag, __unused struct proc *p); /*Return 0;*/
  41. int enodev(void); /*Return ENODEV;*/
  42. /*
  43. * Definitions of device driver entry switches
  44. */
  45. #include <rtems/bsd/sys/queue.h>
  46. struct buf;
  47. struct knote;
  48. struct lwp;
  49. struct tty;
  50. struct uio;
  51. struct vnode;
  52. /*
  53. * Types for d_type
  54. */
  55. #define D_OTHER 0x0000
  56. #define D_TAPE 0x0001
  57. #define D_DISK 0x0002
  58. #define D_TTY 0x0003
  59. #define D_TYPEMASK 0x00ff
  60. #define D_MPSAFE 0x0100
  61. #define D_NEGOFFSAFE 0x0200
  62. /*
  63. * Block device switch table
  64. */
  65. struct bdevsw {
  66. int (*d_open)(dev_t, int, int, struct lwp *);
  67. int (*d_close)(dev_t, int, int, struct lwp *);
  68. void (*d_strategy)(struct buf *);
  69. int (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
  70. int (*d_dump)(dev_t, daddr_t, void *, size_t);
  71. int (*d_psize)(dev_t);
  72. int d_flag;
  73. };
  74. /*
  75. * Character device switch table
  76. */
  77. struct cdevsw {
  78. int (*d_open)(dev_t, int, int, struct lwp *);
  79. int (*d_close)(dev_t, int, int, struct lwp *);
  80. int (*d_read)(dev_t, struct uio *, int);
  81. int (*d_write)(dev_t, struct uio *, int);
  82. int (*d_ioctl)(dev_t, u_long, void *, int, struct lwp *);
  83. void (*d_stop)(struct tty *, int);
  84. struct tty * (*d_tty)(dev_t);
  85. int (*d_poll)(dev_t, int, struct lwp *);
  86. paddr_t (*d_mmap)(dev_t, off_t, int);
  87. int (*d_kqfilter)(dev_t, struct knote *);
  88. int d_flag;
  89. };
  90. #ifdef _KERNEL
  91. int devsw_attach(const char *, const struct bdevsw *, int *,
  92. const struct cdevsw *, int *);
  93. int devsw_detach(const struct bdevsw *, const struct cdevsw *);
  94. const struct bdevsw *bdevsw_lookup(dev_t);
  95. const struct cdevsw *cdevsw_lookup(dev_t);
  96. int bdevsw_lookup_major(const struct bdevsw *);
  97. int cdevsw_lookup_major(const struct cdevsw *);
  98. #define dev_type_open(n) int n (dev_t, int, int, struct lwp *)
  99. #define dev_type_close(n) int n (dev_t, int, int, struct lwp *)
  100. #define dev_type_read(n) int n (dev_t, struct uio *, int)
  101. #define dev_type_write(n) int n (dev_t, struct uio *, int)
  102. #define dev_type_ioctl(n) \
  103. int n (dev_t, u_long, void *, int, struct lwp *)
  104. #define dev_type_stop(n) void n (struct tty *, int)
  105. #define dev_type_tty(n) struct tty * n (dev_t)
  106. #define dev_type_poll(n) int n (dev_t, int, struct lwp *)
  107. #define dev_type_mmap(n) paddr_t n (dev_t, off_t, int)
  108. #define dev_type_strategy(n) void n (struct buf *)
  109. #define dev_type_dump(n) int n (dev_t, daddr_t, void *, size_t)
  110. #define dev_type_size(n) int n (dev_t)
  111. #define dev_type_kqfilter(n) int n (dev_t, struct knote *)
  112. #define noopen ((dev_type_open((*)))enodev)
  113. #define noclose ((dev_type_close((*)))enodev)
  114. #define noread ((dev_type_read((*)))enodev)
  115. #define nowrite ((dev_type_write((*)))enodev)
  116. #define noioctl ((dev_type_ioctl((*)))enodev)
  117. #define nostop ((dev_type_stop((*)))enodev)
  118. #define notty NULL
  119. #define nopoll seltrue
  120. #define nommap ((dev_type_mmap((*)))enodev)
  121. #define nodump ((dev_type_dump((*)))enodev)
  122. #define nosize NULL
  123. #define nokqfilter seltrue_kqfilter
  124. #define nullopen ((dev_type_open((*)))nullop)
  125. #define nullclose ((dev_type_close((*)))nullop)
  126. #define nullread ((dev_type_read((*)))nullop)
  127. #define nullwrite ((dev_type_write((*)))nullop)
  128. #define nullioctl ((dev_type_ioctl((*)))nullop)
  129. #define nullstop ((dev_type_stop((*)))nullop)
  130. #define nullpoll ((dev_type_poll((*)))nullop)
  131. #define nullmmap ((dev_type_mmap((*)))nullop)
  132. #define nulldump ((dev_type_dump((*)))nullop)
  133. #define nullkqfilter ((dev_type_kqfilter((*)))eopnotsupp)
  134. /* device access wrappers. */
  135. dev_type_open(bdev_open);
  136. dev_type_close(bdev_close);
  137. dev_type_strategy(bdev_strategy);
  138. dev_type_ioctl(bdev_ioctl);
  139. dev_type_dump(bdev_dump);
  140. dev_type_open(cdev_open);
  141. dev_type_close(cdev_close);
  142. dev_type_read(cdev_read);
  143. dev_type_write(cdev_write);
  144. dev_type_ioctl(cdev_ioctl);
  145. dev_type_stop(cdev_stop);
  146. dev_type_tty(cdev_tty);
  147. dev_type_poll(cdev_poll);
  148. dev_type_mmap(cdev_mmap);
  149. dev_type_kqfilter(cdev_kqfilter);
  150. int cdev_type(dev_t);
  151. int bdev_type(dev_t);
  152. /* symbolic sleep message strings */
  153. extern const char devopn[], devio[], devwait[], devin[], devout[];
  154. extern const char devioc[], devcls[];
  155. #endif /* _KERNEL */
  156. /*
  157. * Line discipline switch table
  158. */
  159. struct linesw {
  160. const char *l_name; /* Linesw name */
  161. LIST_ENTRY(linesw) l_list;
  162. u_int l_refcnt; /* locked by ttyldisc_list_slock */
  163. int l_no; /* legacy discipline number (for TIOCGETD) */
  164. int (*l_open) (dev_t, struct tty *);
  165. int (*l_close) (struct tty *, int);
  166. int (*l_read) (struct tty *, struct uio *, int);
  167. int (*l_write) (struct tty *, struct uio *, int);
  168. int (*l_ioctl) (struct tty *, u_long, void *, int,
  169. struct lwp *);
  170. int (*l_rint) (int, struct tty *);
  171. int (*l_start) (struct tty *);
  172. int (*l_modem) (struct tty *, int);
  173. int (*l_poll) (struct tty *, int, struct lwp *);
  174. };
  175. #ifdef _KERNEL
  176. void ttyldisc_init(void);
  177. int ttyldisc_attach(struct linesw *);
  178. int ttyldisc_detach(struct linesw *);
  179. struct linesw *ttyldisc_lookup(const char *);
  180. struct linesw *ttyldisc_lookup_bynum(int);
  181. struct linesw *ttyldisc_default(void);
  182. void ttyldisc_release(struct linesw *);
  183. /* For those defining their own line disciplines: */
  184. #define ttynodisc ((int (*)(dev_t, struct tty *))enodev)
  185. #define ttyerrclose ((int (*)(struct tty *, int))enodev)
  186. #define ttyerrio ((int (*)(struct tty *, struct uio *, int))enodev)
  187. #define ttyerrinput ((int (*)(int, struct tty *))enodev)
  188. #define ttyerrstart ((int (*)(struct tty *))enodev)
  189. int ttyerrpoll (struct tty *, int, struct lwp *);
  190. int ttynullioctl(struct tty *, u_long, void *, int, struct lwp *);
  191. int iskmemdev(dev_t);
  192. int seltrue_kqfilter(dev_t, struct knote *);
  193. #endif
  194. #ifdef _KERNEL
  195. #define DEV_MEM 0 /* minor device 0 is physical memory */
  196. #define DEV_KMEM 1 /* minor device 1 is kernel memory */
  197. #define DEV_NULL 2 /* minor device 2 is EOF/rathole */
  198. #ifdef COMPAT_16
  199. #define _DEV_ZERO_oARM 3 /* reserved: old ARM /dev/zero minor */
  200. #endif
  201. #define DEV_ZERO 12 /* minor device 12 is '\0'/rathole */
  202. #endif /* _KERNEL */
  203. struct devsw_conv {
  204. const char *d_name;
  205. int d_bmajor;
  206. int d_cmajor;
  207. };
  208. #ifdef _KERNEL
  209. void devsw_init(void);
  210. const char *devsw_blk2name(int);
  211. int devsw_name2blk(const char *, char *, size_t);
  212. int devsw_name2chr(const char *, char *, size_t);
  213. dev_t devsw_chr2blk(dev_t);
  214. dev_t devsw_blk2chr(dev_t);
  215. #endif /* _KERNEL */
  216. #ifdef _KERNEL
  217. struct device;
  218. void setroot(struct device *, int);
  219. void swapconf(void);
  220. #endif /* _KERNEL */
  221. #endif /* !_SYS_CONF_H_ */