1 /* 2 * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)dev.c 7.7 (Berkeley) 04/04/90 18 */ 19 20 #include "sys/param.h" 21 #include "saio.h" 22 23 /* 24 * NB: the value "io->i_dev", used to offset the devsw[] array 25 * in the routines below, is munged by the vaxstand Makefile to work 26 * for certain boots. 27 */ 28 29 devread(io) 30 register struct iob *io; 31 { 32 int cc; 33 34 io->i_flgs |= F_RDDATA; 35 io->i_error = 0; 36 cc = (*devsw[io->i_dev].dv_strategy)(io, READ); 37 io->i_flgs &= ~F_TYPEMASK; 38 return (cc); 39 } 40 41 devwrite(io) 42 register struct iob *io; 43 { 44 int cc; 45 46 io->i_flgs |= F_WRDATA; 47 io->i_error = 0; 48 cc = (*devsw[io->i_dev].dv_strategy)(io, WRITE); 49 io->i_flgs &= ~F_TYPEMASK; 50 return (cc); 51 } 52 53 devopen(io) 54 register struct iob *io; 55 { 56 int ret; 57 58 if (!(ret = (*devsw[io->i_dev].dv_open)(io))) 59 return (0); 60 printf("%s(%d,%d,%d,%d): ", devsw[io->i_dev].dv_name, 61 io->i_adapt, io->i_ctlr, io->i_unit, io->i_part); 62 switch(ret) { 63 case EIO: 64 break; /* already reported */ 65 case EADAPT: 66 printf("bad adaptor number\n"); 67 break; 68 case ECTLR: 69 printf("bad controller number\n"); 70 break; 71 case EUNIT: 72 printf("bad drive number\n"); 73 break; 74 case EPART: 75 printf("bad partition\n"); 76 break; 77 case ERDLAB: 78 printf("can't read disk label\n"); 79 break; 80 case EUNLAB: 81 printf("unlabeled\n"); 82 break; 83 case ENXIO: 84 printf("bad device specification\n"); 85 break; 86 default: 87 printf("unknown open error\n"); 88 break; 89 } 90 return (ret); 91 } 92 93 devclose(io) 94 register struct iob *io; 95 { 96 (*devsw[io->i_dev].dv_close)(io); 97 } 98 99 devioctl(io, cmd, arg) 100 register struct iob *io; 101 int cmd; 102 caddr_t arg; 103 { 104 return ((*devsw[io->i_dev].dv_ioctl)(io, cmd, arg)); 105 } 106 107 /*ARGSUSED*/ 108 nullsys(io) 109 struct iob *io; 110 {} 111 112 /*ARGSUSED*/ 113 nodev(io) 114 struct iob *io; 115 { 116 errno = EBADF; 117 } 118 119 /*ARGSUSED*/ 120 noioctl(io, cmd, arg) 121 struct iob *io; 122 int cmd; 123 caddr_t arg; 124 { 125 return (ECMD); 126 } 127