1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * %sccs.include.redist.c% 9 * 10 * @(#)conf.c 5.8 (Berkeley) 05/12/91 11 */ 12 13 #include "param.h" 14 #include "systm.h" 15 #include "buf.h" 16 #include "ioctl.h" 17 #include "tty.h" 18 #include "conf.h" 19 20 int nullop(), enxio(), enodev(), rawread(), rawwrite(), swstrategy(); 21 int rawread(), rawwrite(), swstrategy(); 22 23 #include "wd.h" 24 #if NWD > 0 25 int wdopen(),wdclose(),wdstrategy(),wdread(),wdwrite(),wdioctl(); 26 int wddump(),wdsize(); 27 #else 28 #define wdopen enxio 29 #define wdclose enxio 30 #define wdstrategy enxio 31 #define wdread enxio 32 #define wdwrite enxio 33 #define wdioctl enxio 34 #define wddump enxio 35 #define wdsize NULL 36 #endif 37 38 #include "xd.h" 39 #if NXD > 0 40 int xdopen(),xdclose(),xdstrategy(),xdread(),xdwrite(),xdioctl(); 41 int xddump(),xdsize(); 42 #else 43 #define xdopen enxio 44 #define xdclose enxio 45 #define xdstrategy enxio 46 #define xdread enxio 47 #define xdwrite enxio 48 #define xdioctl enxio 49 #define xddump enxio 50 #define xdsize NULL 51 #endif 52 53 #include "wt.h" 54 #if NWT > 0 55 int wtopen(),wtclose(),wtstrategy(),wtread(),wtwrite(),wtioctl(); 56 int wtdump(),wtsize(); 57 #else 58 #define wtopen enxio 59 #define wtclose enxio 60 #define wtstrategy enxio 61 #define wtread enxio 62 #define wtwrite enxio 63 #define wtioctl enxio 64 #define wtdump enxio 65 #define wtsize NULL 66 #endif 67 68 #include "fd.h" 69 #if NFD > 0 70 int Fdopen(),fdclose(),fdstrategy(),fdread(),fdwrite(); 71 #define fdioctl enxio 72 #define fddump enxio 73 #define fdsize NULL 74 #else 75 #define Fdopen enxio 76 #define fdclose enxio 77 #define fdstrategy enxio 78 #define fdread enxio 79 #define fdwrite enxio 80 #define fdioctl enxio 81 #define fddump enxio 82 #define fdsize NULL 83 #endif 84 85 int swstrategy(),swread(),swwrite(); 86 87 struct bdevsw bdevsw[] = 88 { 89 { wdopen, wdclose, wdstrategy, wdioctl, /*0*/ 90 wddump, wdsize, NULL }, 91 { enodev, enodev, swstrategy, enodev, /*1*/ 92 enodev, enodev, NULL }, 93 { Fdopen, fdclose, fdstrategy, fdioctl, /*2*/ 94 fddump, fdsize, NULL }, 95 { wtopen, wtclose, wtstrategy, wtioctl, /*3*/ 96 wtdump, wtsize, B_TAPE }, 97 { xdopen, xdclose, xdstrategy, xdioctl, /*4*/ 98 xddump, xdsize, NULL } 99 }; 100 int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]); 101 102 int cnopen(),cnclose(),cnread(),cnwrite(),cnioctl(),cnselect(); 103 104 int pcopen(),pcclose(),pcread(),pcwrite(),pcioctl(); 105 extern struct tty pccons; 106 107 int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect(); 108 109 int mmrw(); 110 #define mmselect seltrue 111 112 #include "pty.h" 113 #if NPTY > 0 114 int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop(); 115 int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect(); 116 int ptyioctl(); 117 struct tty pt_tty[]; 118 #else 119 #define ptsopen enxio 120 #define ptsclose enxio 121 #define ptsread enxio 122 #define ptswrite enxio 123 #define ptcopen enxio 124 #define ptcclose enxio 125 #define ptcread enxio 126 #define ptcwrite enxio 127 #define ptyioctl enxio 128 #define pt_tty NULL 129 #define ptcselect enxio 130 #define ptsstop nullop 131 #endif 132 133 #include "com.h" 134 #if NCOM > 0 135 int comopen(),comclose(),comread(),comwrite(),comioctl(); 136 #define comreset enxio 137 extern struct tty com_tty[]; 138 #else 139 #define comopen enxio 140 #define comclose enxio 141 #define comread enxio 142 #define comwrite enxio 143 #define comioctl enxio 144 #define comreset enxio 145 #define com_tty NULL 146 #endif 147 148 int logopen(),logclose(),logread(),logioctl(),logselect(); 149 150 int ttselect(), seltrue(); 151 152 153 struct cdevsw cdevsw[] = 154 { 155 { cnopen, cnclose, cnread, cnwrite, /*0*/ 156 cnioctl, nullop, nullop, NULL, 157 cnselect, enodev, NULL }, 158 { cttyopen, nullop, cttyread, cttywrite, /*1*/ 159 cttyioctl, nullop, nullop, NULL, 160 cttyselect, enodev, NULL }, 161 { nullop, nullop, mmrw, mmrw, /*2*/ 162 enodev, nullop, nullop, NULL, 163 mmselect, enodev, NULL }, 164 { wdopen, wdclose, wdread, wdwrite, /*3*/ 165 wdioctl, enodev, nullop, NULL, 166 seltrue, enodev, wdstrategy }, 167 { nullop, nullop, rawread, rawwrite, /*4*/ 168 enodev, enodev, nullop, NULL, 169 enodev, enodev, swstrategy }, 170 { ptsopen, ptsclose, ptsread, ptswrite, /*5*/ 171 ptyioctl, ptsstop, nullop, pt_tty, 172 ttselect, enodev, NULL }, 173 { ptcopen, ptcclose, ptcread, ptcwrite, /*6*/ 174 ptyioctl, nullop, nullop, pt_tty, 175 ptcselect, enodev, NULL }, 176 { logopen, logclose, logread, enodev, /*7*/ 177 logioctl, enodev, nullop, NULL, 178 logselect, enodev, NULL }, 179 { comopen, comclose, comread, comwrite, /*8*/ 180 comioctl, enodev, comreset, com_tty, 181 ttselect, enodev, NULL }, 182 { Fdopen, fdclose, fdread, fdwrite, /*9*/ 183 fdioctl, enodev, nullop, NULL, 184 seltrue, enodev, fdstrategy }, 185 { wtopen, wtclose, wtread, wtwrite, /*A*/ 186 wtioctl, enodev, nullop, NULL, 187 seltrue, enodev, wtstrategy }, 188 { xdopen, xdclose, xdread, xdwrite, /*B*/ 189 xdioctl, enodev, nullop, NULL, 190 seltrue, enodev, xdstrategy }, 191 { pcopen, pcclose, pcread, pcwrite, /*C*/ 192 pcioctl, nullop, nullop, &pccons, 193 ttselect, enodev, NULL }, 194 }; 195 int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]); 196 197 int mem_no = 2; /* major device number of memory special file */ 198 199 /* 200 * Swapdev is a fake device implemented 201 * in sw.c used only internally to get to swstrategy. 202 * It cannot be provided to the users, because the 203 * swstrategy routine munches the b_dev and b_blkno entries 204 * before calling the appropriate driver. This would horribly 205 * confuse, e.g. the hashing routines. Instead, /dev/drum is 206 * provided as a character (raw) device. 207 */ 208 dev_t swapdev = makedev(1, 0); 209