Commit | Line | Data |
---|---|---|
4525e366 KB |
1 | /* |
2 | * Copyright (c) 1982, 1986, 1988 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
dbf0c423 | 5 | * %sccs.include.redist.c% |
4525e366 | 6 | * |
8c18e15f | 7 | * @(#)dev.c 7.14 (Berkeley) %G% |
4525e366 KB |
8 | */ |
9 | ||
92f6612c | 10 | #include <sys/param.h> |
3ec02e95 | 11 | #include <setjmp.h> |
92f6612c | 12 | #include "saio.h" |
4525e366 | 13 | |
9c540388 | 14 | /* |
3ec02e95 KB |
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. | |
9c540388 KB |
18 | */ |
19 | ||
3ec02e95 KB |
20 | jmp_buf exception; |
21 | ||
4525e366 KB |
22 | devread(io) |
23 | register struct iob *io; | |
24 | { | |
25 | int cc; | |
26 | ||
27 | io->i_flgs |= F_RDDATA; | |
28 | io->i_error = 0; | |
77c395b3 | 29 | cc = (*devsw[io->i_dev].dv_strategy)(io, F_READ); |
4525e366 | 30 | io->i_flgs &= ~F_TYPEMASK; |
8c18e15f | 31 | #ifndef SMALL |
3ec02e95 | 32 | if (scankbd()) |
0ed2d1b1 | 33 | _longjmp(exception, 1); |
8c18e15f | 34 | #endif |
4525e366 KB |
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; | |
3ec02e95 | 45 | cc = (*devsw[io->i_dev].dv_strategy)(io, F_WRITE); |
4525e366 | 46 | io->i_flgs &= ~F_TYPEMASK; |
8c18e15f | 47 | #ifndef SMALL |
3ec02e95 | 48 | if (scankbd()) |
0ed2d1b1 | 49 | _longjmp(exception, 1); |
8c18e15f | 50 | #endif |
4525e366 KB |
51 | return (cc); |
52 | } | |
53 | ||
54 | devopen(io) | |
55 | register struct iob *io; | |
56 | { | |
9c540388 KB |
57 | int ret; |
58 | ||
ed632c38 | 59 | if (!(ret = (*devsw[io->i_dev].dv_open)(io))) |
9c540388 | 60 | return (0); |
8c18e15f KB |
61 | #ifdef SMALL |
62 | printf("open error\n"); | |
63 | #else | |
ed632c38 | 64 | printf("%s(%d,%d,%d,%d): ", devsw[io->i_dev].dv_name, |
9c540388 KB |
65 | io->i_adapt, io->i_ctlr, io->i_unit, io->i_part); |
66 | switch(ret) { | |
782124fb MK |
67 | case EIO: |
68 | break; /* already reported */ | |
9c540388 | 69 | case EADAPT: |
782124fb | 70 | printf("bad adaptor number\n"); |
9c540388 KB |
71 | break; |
72 | case ECTLR: | |
782124fb | 73 | printf("bad controller number\n"); |
9c540388 KB |
74 | break; |
75 | case EUNIT: | |
782124fb | 76 | printf("bad drive number\n"); |
9c540388 KB |
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: | |
9c540388 | 88 | printf("bad device specification\n"); |
782124fb MK |
89 | break; |
90 | default: | |
91 | printf("unknown open error\n"); | |
92 | break; | |
9c540388 | 93 | } |
8c18e15f | 94 | #endif |
9c540388 | 95 | return (ret); |
4525e366 KB |
96 | } |
97 | ||
98 | devclose(io) | |
99 | register struct iob *io; | |
100 | { | |
ed632c38 | 101 | (*devsw[io->i_dev].dv_close)(io); |
4525e366 KB |
102 | } |
103 | ||
104 | devioctl(io, cmd, arg) | |
105 | register struct iob *io; | |
106 | int cmd; | |
107 | caddr_t arg; | |
108 | { | |
ed632c38 | 109 | return ((*devsw[io->i_dev].dv_ioctl)(io, cmd, arg)); |
4525e366 KB |
110 | } |
111 | ||
3ec02e95 | 112 | /* ARGSUSED */ |
4525e366 KB |
113 | nullsys(io) |
114 | struct iob *io; | |
115 | {} | |
116 | ||
3ec02e95 | 117 | /* ARGSUSED */ |
4525e366 KB |
118 | nodev(io) |
119 | struct iob *io; | |
120 | { | |
121 | errno = EBADF; | |
92f6612c | 122 | return(-1); |
4525e366 KB |
123 | } |
124 | ||
3ec02e95 | 125 | /* ARGSUSED */ |
4525e366 KB |
126 | noioctl(io, cmd, arg) |
127 | struct iob *io; | |
128 | int cmd; | |
129 | caddr_t arg; | |
130 | { | |
131 | return (ECMD); | |
132 | } |