conf.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /* $OpenBSD: conf.h,v 1.133 2015/06/25 06:43:46 ratchov Exp $ */
  2. /* $NetBSD: conf.h,v 1.33 1996/05/03 20:03:32 christos Exp $ */
  3. /*-
  4. * Copyright (c) 1990, 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. * @(#)conf.h 8.3 (Berkeley) 1/21/94
  37. */
  38. #ifndef _SYS_CONF_H_
  39. #define _SYS_CONF_H_
  40. /*
  41. * Definitions of device driver entry switches
  42. */
  43. struct buf;
  44. struct proc;
  45. struct tty;
  46. struct uio;
  47. struct vnode;
  48. struct knote;
  49. /*
  50. * Types for d_type
  51. */
  52. #define D_TAPE 1
  53. #define D_DISK 2
  54. #define D_TTY 3
  55. /*
  56. * Flags for d_flags
  57. */
  58. #define D_CLONE 0x0001 /* clone upon open */
  59. #ifdef _KERNEL
  60. #define dev_type_open(n) int n(dev_t, int, int, struct proc *)
  61. #define dev_type_close(n) int n(dev_t, int, int, struct proc *)
  62. #define dev_type_strategy(n) void n(struct buf *)
  63. #define dev_type_ioctl(n) \
  64. int n(dev_t, u_long, caddr_t, int, struct proc *)
  65. #define dev_decl(n,t) __CONCAT(dev_type_,t)(__CONCAT(n,t))
  66. #define dev_init(c,n,t) \
  67. ((c) > 0 ? __CONCAT(n,t) : (__CONCAT(dev_type_,t)((*))) enxio)
  68. #endif /* _KERNEL */
  69. /*
  70. * Block device switch table
  71. */
  72. struct bdevsw {
  73. int (*d_open)(dev_t dev, int oflags, int devtype,
  74. struct proc *p);
  75. int (*d_close)(dev_t dev, int fflag, int devtype,
  76. struct proc *p);
  77. void (*d_strategy)(struct buf *bp);
  78. int (*d_ioctl)(dev_t dev, u_long cmd, caddr_t data,
  79. int fflag, struct proc *p);
  80. int (*d_dump)(dev_t dev, daddr_t blkno, caddr_t va,
  81. size_t size);
  82. daddr_t (*d_psize)(dev_t dev);
  83. u_int d_type;
  84. /* u_int d_flags; */
  85. };
  86. #ifdef _KERNEL
  87. extern struct bdevsw bdevsw[];
  88. /* bdevsw-specific types */
  89. #define dev_type_dump(n) int n(dev_t, daddr_t, caddr_t, size_t)
  90. #define dev_type_size(n) daddr_t n(dev_t)
  91. /* bdevsw-specific initializations */
  92. #define dev_size_init(c,n) (c > 0 ? __CONCAT(n,size) : 0)
  93. #define bdev_decl(n) \
  94. dev_decl(n,open); dev_decl(n,close); dev_decl(n,strategy); \
  95. dev_decl(n,ioctl); dev_decl(n,dump); dev_decl(n,size)
  96. #define bdev_disk_init(c,n) { \
  97. dev_init(c,n,open), dev_init(c,n,close), \
  98. dev_init(c,n,strategy), dev_init(c,n,ioctl), \
  99. dev_init(c,n,dump), dev_size_init(c,n), D_DISK }
  100. #define bdev_tape_init(c,n) { \
  101. dev_init(c,n,open), dev_init(c,n,close), \
  102. dev_init(c,n,strategy), dev_init(c,n,ioctl), \
  103. dev_init(c,n,dump), 0, D_TAPE }
  104. #define bdev_swap_init(c,n) { \
  105. (dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
  106. dev_init(c,n,strategy), (dev_type_ioctl((*))) enodev, \
  107. (dev_type_dump((*))) enodev, 0 }
  108. #define bdev_notdef() { \
  109. (dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
  110. (dev_type_strategy((*))) enodev, (dev_type_ioctl((*))) enodev, \
  111. (dev_type_dump((*))) enodev, 0 }
  112. #endif
  113. /*
  114. * Character device switch table
  115. */
  116. struct cdevsw {
  117. int (*d_open)(dev_t dev, int oflags, int devtype,
  118. struct proc *p);
  119. int (*d_close)(dev_t dev, int fflag, int devtype,
  120. struct proc *);
  121. int (*d_read)(dev_t dev, struct uio *uio, int ioflag);
  122. int (*d_write)(dev_t dev, struct uio *uio, int ioflag);
  123. int (*d_ioctl)(dev_t dev, u_long cmd, caddr_t data,
  124. int fflag, struct proc *p);
  125. int (*d_stop)(struct tty *tp, int rw);
  126. struct tty *
  127. (*d_tty)(dev_t dev);
  128. int (*d_poll)(dev_t dev, int events, struct proc *p);
  129. paddr_t (*d_mmap)(dev_t, off_t, int);
  130. u_int d_type;
  131. u_int d_flags;
  132. int (*d_kqfilter)(dev_t dev, struct knote *kn);
  133. };
  134. #ifdef _KERNEL
  135. extern struct cdevsw cdevsw[];
  136. /* cdevsw-specific types */
  137. #define dev_type_read(n) int n(dev_t, struct uio *, int)
  138. #define dev_type_write(n) int n(dev_t, struct uio *, int)
  139. #define dev_type_stop(n) int n(struct tty *, int)
  140. #define dev_type_tty(n) struct tty *n(dev_t)
  141. #define dev_type_poll(n) int n(dev_t, int, struct proc *)
  142. #define dev_type_mmap(n) paddr_t n(dev_t, off_t, int)
  143. #define dev_type_kqfilter(n) int n(dev_t, struct knote *)
  144. #define cdev_decl(n) \
  145. dev_decl(n,open); dev_decl(n,close); dev_decl(n,read); \
  146. dev_decl(n,write); dev_decl(n,ioctl); dev_decl(n,stop); \
  147. dev_decl(n,tty); dev_decl(n,poll); dev_decl(n,mmap); \
  148. dev_decl(n,kqfilter)
  149. /* open, close, read, write, ioctl */
  150. #define cdev_disk_init(c,n) { \
  151. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  152. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  153. 0, seltrue, (dev_type_mmap((*))) enodev, \
  154. D_DISK, 0, seltrue_kqfilter }
  155. /* open, close, read, write, ioctl */
  156. #define cdev_tape_init(c,n) { \
  157. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  158. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  159. 0, seltrue, (dev_type_mmap((*))) enodev, \
  160. D_TAPE, 0, seltrue_kqfilter }
  161. /* open, close, read, write, ioctl, stop, tty */
  162. #define cdev_tty_init(c,n) { \
  163. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  164. dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
  165. dev_init(c,n,tty), ttpoll, (dev_type_mmap((*))) enodev, \
  166. D_TTY, 0, ttkqfilter }
  167. /* open, close, read, ioctl, poll, nokqfilter */
  168. #define cdev_mouse_init(c,n) { \
  169. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  170. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  171. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  172. (dev_type_mmap((*))) enodev }
  173. /* open, close, read, write, ioctl, poll, nokqfilter */
  174. #define cdev_mousewr_init(c,n) { \
  175. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  176. dev_init(c,n,write), dev_init(c,n,ioctl), \
  177. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  178. (dev_type_mmap((*))) enodev }
  179. #define cdev_notdef() { \
  180. (dev_type_open((*))) enodev, (dev_type_close((*))) enodev, \
  181. (dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
  182. (dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
  183. 0, seltrue, (dev_type_mmap((*))) enodev }
  184. /* open, close, read, write, ioctl, poll, kqfilter -- XXX should be a tty */
  185. #define cdev_cn_init(c,n) { \
  186. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  187. dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
  188. 0, dev_init(c,n,poll), (dev_type_mmap((*))) enodev, \
  189. D_TTY, 0, dev_init(c,n,kqfilter) }
  190. /* open, read, write, ioctl, poll, kqfilter -- XXX should be a tty */
  191. #define cdev_ctty_init(c,n) { \
  192. dev_init(c,n,open), (dev_type_close((*))) nullop, dev_init(c,n,read), \
  193. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
  194. 0, dev_init(c,n,poll), (dev_type_mmap((*))) enodev, \
  195. D_TTY, 0, dev_init(c,n,kqfilter) }
  196. /* open, close, read, write, ioctl, mmap */
  197. #define cdev_mm_init(c,n) { \
  198. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  199. dev_init(c,n,write), dev_init(c,n,ioctl), \
  200. (dev_type_stop((*))) enodev, 0, seltrue, dev_init(c,n,mmap), \
  201. 0, 0, seltrue_kqfilter }
  202. /* open, close, read, write, ioctl */
  203. #define cdev_systrace_init(c,n) { \
  204. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  205. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  206. 0, selfalse, (dev_type_mmap((*))) enodev }
  207. /* open, close, read, write, ioctl, tty, poll, kqfilter */
  208. #define cdev_ptc_init(c,n) { \
  209. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  210. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) nullop, \
  211. dev_init(c,n,tty), dev_init(c,n,poll), (dev_type_mmap((*))) enodev, \
  212. D_TTY, 0, dev_init(c,n,kqfilter) }
  213. /* open, close, read, write, ioctl, mmap */
  214. #define cdev_ptm_init(c,n) { \
  215. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  216. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  217. (dev_type_stop((*))) enodev, 0, selfalse, (dev_type_mmap((*))) enodev }
  218. /* open, close, read, ioctl, poll, kqfilter XXX should be a generic device */
  219. #define cdev_log_init(c,n) { \
  220. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  221. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  222. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  223. (dev_type_mmap((*))) enodev, 0, 0, dev_init(c,n,kqfilter) }
  224. /* open */
  225. #define cdev_fd_init(c,n) { \
  226. dev_init(c,n,open), (dev_type_close((*))) enodev, \
  227. (dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
  228. (dev_type_ioctl((*))) enodev, (dev_type_stop((*))) enodev, \
  229. 0, selfalse, (dev_type_mmap((*))) enodev }
  230. /* open, close, read, write, ioctl, poll, kqfilter -- XXX should be generic device */
  231. #define cdev_tun_init(c,n) { \
  232. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  233. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  234. 0, dev_init(c,n,poll), (dev_type_mmap((*))) enodev, \
  235. 0, 0, dev_init(c,n,kqfilter) }
  236. /* open, close, ioctl, poll, kqfilter -- XXX should be generic device */
  237. #define cdev_vscsi_init(c,n) { \
  238. dev_init(c,n,open), dev_init(c,n,close), \
  239. (dev_type_read((*))) enodev, (dev_type_write((*))) enodev, \
  240. dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  241. 0, dev_init(c,n,poll), (dev_type_mmap((*))) enodev, \
  242. 0, 0, dev_init(c,n,kqfilter) }
  243. /* open, close, read, write, ioctl, poll, kqfilter -- XXX should be generic device */
  244. #define cdev_pppx_init(c,n) { \
  245. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  246. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  247. 0, dev_init(c,n,poll), (dev_type_mmap((*))) enodev, \
  248. 0, 0, dev_init(c,n,kqfilter) }
  249. /* open, close, read, write, ioctl, poll, kqfilter, cloning -- XXX should be generic device */
  250. #define cdev_bpf_init(c,n) { \
  251. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  252. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  253. 0, dev_init(c,n,poll), (dev_type_mmap((*))) enodev, \
  254. 0, 0, dev_init(c,n,kqfilter) }
  255. /* open, close, ioctl */
  256. #define cdev_ch_init(c,n) { \
  257. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  258. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  259. (dev_type_stop((*))) enodev, 0, selfalse, \
  260. (dev_type_mmap((*))) enodev }
  261. /* open, close, ioctl */
  262. #define cdev_uk_init(c,n) { \
  263. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  264. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  265. (dev_type_stop((*))) enodev, 0, selfalse, \
  266. (dev_type_mmap((*))) enodev }
  267. /* open, close, ioctl, mmap */
  268. #define cdev_fb_init(c,n) { \
  269. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  270. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  271. (dev_type_stop((*))) enodev, 0, selfalse, \
  272. dev_init(c,n,mmap) }
  273. /* open, close, read, write, ioctl, poll, kqfilter */
  274. #define cdev_audio_init(c,n) { \
  275. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  276. dev_init(c,n,write), dev_init(c,n,ioctl), \
  277. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  278. (dev_type_mmap((*))) enodev }
  279. /* open, close, read, write, ioctl, poll, kqfilter */
  280. #define cdev_midi_init(c,n) { \
  281. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  282. dev_init(c,n,write), dev_init(c,n,ioctl), \
  283. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  284. (dev_type_mmap((*))) enodev, 0, 0, dev_init(c,n,kqfilter) }
  285. /* open, close, read */
  286. #define cdev_ksyms_init(c,n) { \
  287. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  288. (dev_type_write((*))) enodev, (dev_type_ioctl((*))) enodev, \
  289. (dev_type_stop((*))) enodev, 0, seltrue, \
  290. (dev_type_mmap((*))) enodev, 0, 0, seltrue_kqfilter }
  291. /* open, close, read, write, ioctl, stop, tty, poll, mmap, kqfilter */
  292. #define cdev_wsdisplay_init(c,n) { \
  293. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  294. dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
  295. dev_init(c,n,tty), dev_init(c,n,poll), dev_init(c,n,mmap), \
  296. D_TTY, 0, dev_init(c,n,kqfilter) }
  297. /* open, close, read, write, ioctl, poll, kqfilter */
  298. #define cdev_random_init(c,n) { \
  299. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  300. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  301. 0, seltrue, (dev_type_mmap((*))) enodev, \
  302. 0, 0, dev_init(c,n,kqfilter) }
  303. /* open, close, ioctl, poll, nokqfilter */
  304. #define cdev_usb_init(c,n) { \
  305. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  306. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  307. (dev_type_stop((*))) enodev, 0, selfalse, \
  308. (dev_type_mmap((*))) enodev }
  309. /* open, close, write */
  310. #define cdev_ulpt_init(c,n) { \
  311. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  312. dev_init(c,n,write), (dev_type_ioctl((*))) enodev, \
  313. (dev_type_stop((*))) enodev, 0, selfalse, (dev_type_mmap((*))) enodev }
  314. /* open, close, ioctl */
  315. #define cdev_pf_init(c,n) { \
  316. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  317. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  318. (dev_type_stop((*))) enodev, 0, selfalse, \
  319. (dev_type_mmap((*))) enodev }
  320. /* open, close, read, write, ioctl, poll, kqfilter */
  321. #define cdev_usbdev_init(c,n) { \
  322. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  323. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  324. 0, dev_init(c,n,poll), (dev_type_mmap((*))) enodev, 0, 0, \
  325. dev_init(c,n,kqfilter) }
  326. /* open, close, init */
  327. #define cdev_pci_init(c,n) { \
  328. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  329. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  330. (dev_type_stop((*))) enodev, 0, selfalse, \
  331. (dev_type_mmap((*))) enodev }
  332. /* open, close, ioctl */
  333. #define cdev_radio_init(c,n) { \
  334. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  335. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  336. (dev_type_stop((*))) enodev, 0, selfalse, \
  337. (dev_type_mmap((*))) enodev }
  338. /* open, close, ioctl, read, mmap, poll */
  339. #define cdev_video_init(c,n) { \
  340. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  341. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  342. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  343. dev_init(c,n,mmap) }
  344. /* open, close, write, ioctl */
  345. #define cdev_spkr_init(c,n) { \
  346. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  347. dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  348. 0, seltrue, (dev_type_mmap((*))) enodev, \
  349. 0, 0, seltrue_kqfilter }
  350. /* open, close, write */
  351. #define cdev_lpt_init(c,n) { \
  352. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  353. dev_init(c,n,write), (dev_type_ioctl((*))) enodev, \
  354. (dev_type_stop((*))) enodev, 0, seltrue, (dev_type_mmap((*))) enodev, \
  355. 0, 0, seltrue_kqfilter }
  356. /* open, close, read, ioctl, mmap */
  357. #define cdev_bktr_init(c, n) { \
  358. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  359. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  360. (dev_type_stop((*))) enodev, 0, seltrue, dev_init(c,n,mmap), \
  361. 0, 0, seltrue_kqfilter }
  362. /* open, close, read, ioctl, poll, kqfilter */
  363. #define cdev_hotplug_init(c,n) { \
  364. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  365. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  366. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  367. (dev_type_mmap((*))) enodev, 0, 0, dev_init(c,n,kqfilter) }
  368. /* open, close, ioctl */
  369. #define cdev_gpio_init(c,n) { \
  370. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  371. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  372. (dev_type_stop((*))) enodev, 0, selfalse, \
  373. (dev_type_mmap((*))) enodev }
  374. /* open, close, ioctl */
  375. #define cdev_bio_init(c,n) { \
  376. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  377. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  378. (dev_type_stop((*))) enodev, 0, selfalse, \
  379. (dev_type_mmap((*))) enodev }
  380. /* open, close, read, ioctl, poll, mmap, nokqfilter */
  381. #define cdev_drm_init(c,n) { \
  382. dev_init(c,n,open), dev_init(c,n,close), dev_init(c, n, read), \
  383. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  384. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  385. dev_init(c,n,mmap), 0, D_CLONE }
  386. /* open, close, ioctl */
  387. #define cdev_amdmsr_init(c,n) { \
  388. dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  389. (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
  390. (dev_type_stop((*))) enodev, 0, selfalse, \
  391. (dev_type_mmap((*))) enodev }
  392. /* open, close, read, write, poll, ioctl */
  393. #define cdev_fuse_init(c,n) { \
  394. dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
  395. dev_init(c,n,write), dev_init(c,n,ioctl), \
  396. (dev_type_stop((*))) enodev, 0, dev_init(c,n,poll), \
  397. (dev_type_mmap((*))) enodev, 0, D_CLONE, dev_init(c,n,kqfilter) }
  398. #endif
  399. /*
  400. * Line discipline switch table
  401. */
  402. struct linesw {
  403. int (*l_open)(dev_t dev, struct tty *tp, struct proc *p);
  404. int (*l_close)(struct tty *tp, int flags, struct proc *p);
  405. int (*l_read)(struct tty *tp, struct uio *uio,
  406. int flag);
  407. int (*l_write)(struct tty *tp, struct uio *uio,
  408. int flag);
  409. int (*l_ioctl)(struct tty *tp, u_long cmd, caddr_t data,
  410. int flag, struct proc *p);
  411. int (*l_rint)(int c, struct tty *tp);
  412. int (*l_start)(struct tty *tp);
  413. int (*l_modem)(struct tty *tp, int flag);
  414. };
  415. #ifdef _KERNEL
  416. extern struct linesw linesw[];
  417. #endif
  418. /*
  419. * Swap device table
  420. */
  421. struct swdevt {
  422. dev_t sw_dev;
  423. int sw_flags;
  424. };
  425. #define SW_FREED 0x01
  426. #define SW_SEQUENTIAL 0x02
  427. #define sw_freed sw_flags /* XXX compat */
  428. #ifdef _KERNEL
  429. extern struct swdevt swdevt[];
  430. extern int chrtoblktbl[];
  431. extern int nchrtoblktbl;
  432. struct bdevsw *bdevsw_lookup(dev_t);
  433. struct cdevsw *cdevsw_lookup(dev_t);
  434. dev_t chrtoblk(dev_t);
  435. dev_t blktochr(dev_t);
  436. int iskmemdev(dev_t);
  437. int iszerodev(dev_t);
  438. dev_t getnulldev(void);
  439. cdev_decl(filedesc);
  440. cdev_decl(log);
  441. #define ptstty ptytty
  442. #define ptsioctl ptyioctl
  443. cdev_decl(pts);
  444. #define ptctty ptytty
  445. #define ptcioctl ptyioctl
  446. cdev_decl(ptc);
  447. cdev_decl(ptm);
  448. cdev_decl(ctty);
  449. cdev_decl(audio);
  450. cdev_decl(midi);
  451. cdev_decl(radio);
  452. cdev_decl(video);
  453. cdev_decl(cn);
  454. bdev_decl(sw);
  455. bdev_decl(vnd);
  456. cdev_decl(vnd);
  457. cdev_decl(ch);
  458. bdev_decl(sd);
  459. cdev_decl(sd);
  460. cdev_decl(ses);
  461. bdev_decl(st);
  462. cdev_decl(st);
  463. bdev_decl(cd);
  464. cdev_decl(cd);
  465. bdev_decl(rd);
  466. cdev_decl(rd);
  467. bdev_decl(uk);
  468. cdev_decl(uk);
  469. cdev_decl(diskmap);
  470. cdev_decl(bpf);
  471. cdev_decl(pf);
  472. cdev_decl(tun);
  473. cdev_decl(pppx);
  474. cdev_decl(random);
  475. cdev_decl(wsdisplay);
  476. cdev_decl(wskbd);
  477. cdev_decl(wsmouse);
  478. cdev_decl(wsmux);
  479. cdev_decl(ksyms);
  480. cdev_decl(systrace);
  481. cdev_decl(bio);
  482. cdev_decl(vscsi);
  483. cdev_decl(gpr);
  484. cdev_decl(bktr);
  485. cdev_decl(usb);
  486. cdev_decl(ugen);
  487. cdev_decl(uhid);
  488. cdev_decl(ucom);
  489. cdev_decl(ulpt);
  490. cdev_decl(urio);
  491. cdev_decl(hotplug);
  492. cdev_decl(gpio);
  493. cdev_decl(amdmsr);
  494. cdev_decl(fuse);
  495. #endif
  496. #endif /* _SYS_CONF_H_ */