1 /* 2 * Copyright (c) 1982, 1986, 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)dev.c 8.1 (Berkeley) 06/11/93 8 */ 9 10 #include <sys/param.h> 11 #include <setjmp.h> 12 #include <stand.att/saio.h> 13 14 /* 15 * NB: the value "io->i_dev", used to offset the devsw[] array in the 16 * routines below, is munged by the machine specific stand Makefiles 17 * to work for certain boots. 18 */ 19 20 jmp_buf exception; 21 22 devread(io) 23 register struct iob *io; 24 { 25 int cc; 26 27 io->i_flgs |= F_RDDATA; 28 io->i_error = 0; 29 cc = (*devsw[io->i_dev].dv_strategy)(io, F_READ); 30 io->i_flgs &= ~F_TYPEMASK; 31 #ifndef SMALL 32 if (scankbd()) 33 _longjmp(exception, 1); 34 #endif 35 return (cc); 36 } 37 38 devwrite(io) 39 register struct iob *io; 40 { 41 int cc; 42 43 io->i_flgs |= F_WRDATA; 44 io->i_error = 0; 45 cc = (*devsw[io->i_dev].dv_strategy)(io, F_WRITE); 46 io->i_flgs &= ~F_TYPEMASK; 47 #ifndef SMALL 48 if (scankbd()) 49 _longjmp(exception, 1); 50 #endif 51 return (cc); 52 } 53 54 devopen(io) 55 register struct iob *io; 56 { 57 int ret; 58 59 if (!(ret = (*devsw[io->i_dev].dv_open)(io))) 60 return (0); 61 #ifdef SMALL 62 printf("open error\n"); 63 #else 64 printf("%s(%d,%d,%d,%d): ", devsw[io->i_dev].dv_name, 65 io->i_adapt, io->i_ctlr, io->i_unit, io->i_part); 66 switch(ret) { 67 case EIO: 68 break; /* already reported */ 69 case EADAPT: 70 printf("bad adaptor number\n"); 71 break; 72 case ECTLR: 73 printf("bad controller number\n"); 74 break; 75 case EUNIT: 76 printf("bad drive number\n"); 77 break; 78 case EPART: 79 printf("bad partition\n"); 80 break; 81 case ERDLAB: 82 printf("can't read disk label\n"); 83 break; 84 case EUNLAB: 85 printf("unlabeled\n"); 86 break; 87 case ENXIO: 88 printf("bad device specification\n"); 89 break; 90 default: 91 printf("unknown open error\n"); 92 break; 93 } 94 #endif 95 return (ret); 96 } 97 98 devclose(io) 99 register struct iob *io; 100 { 101 (*devsw[io->i_dev].dv_close)(io); 102 } 103 104 devioctl(io, cmd, arg) 105 register struct iob *io; 106 int cmd; 107 caddr_t arg; 108 { 109 return ((*devsw[io->i_dev].dv_ioctl)(io, cmd, arg)); 110 } 111 112 /* ARGSUSED */ 113 nullsys(io) 114 struct iob *io; 115 {} 116 117 /* ARGSUSED */ 118 nodev(io) 119 struct iob *io; 120 { 121 errno = EBADF; 122 return(-1); 123 } 124 125 /* ARGSUSED */ 126 noioctl(io, cmd, arg) 127 struct iob *io; 128 int cmd; 129 caddr_t arg; 130 { 131 return (ECMD); 132 } 133