|
|
1.1 root 1: #define _DDI_DKI 1
2: #define _SYSV3 1
3:
4: /*
5: * This file contains supplementary definitions used to deal with or aid the
6: * implementation of the automatically generated device configuration code
7: * in the "conf.c" file.
8: *
9: * Note that we are in the _SYSV3 world because we touch <sys/uproc.h>
10: */
11: /*
12: *-IMPORTS:
13: * <common/ccompat.h>
14: * __USE_PROTO__
15: * __ARGS ()
16: * <common/xdebug.h>
17: * __LOCAL__
18: * <kernel/ddi_base.h>
19: * DESTROY_UIO ()
20: * MAKE_CRED ()
21: * MAKE_UIO ()
22: * <sys/debug.h>
23: * ASSERT ()
24: * <sys/types.h>
25: * cred_t
26: * n_dev_t
27: * o_dev_t
28: * makedevice ()
29: * <sys/cmn_err.h>
30: * CE_PANIC
31: * cmn_err ()
32: * <sys/file.h>
33: * FREAD
34: * FWRITE
35: * FNDELAY
36: * FNONBLOCK
37: * FEXCL
38: * <sys/open.h>
39: * OTYP_BLK
40: * OTYP_CHR
41: * OTYP_LYR
42: * <sys/uio.h>
43: * iovec_t
44: * uio_t
45: * <stddef.h>
46: * NULL
47: * <sys/errno.h>
48: * ENXIO
49: */
50:
51: #include <common/ccompat.h>
52: #include <common/xdebug.h>
53: #include <kernel/ddi_base.h>
54: #include <kernel/strmlib.h>
55: #include <sys/debug.h>
56: #include <sys/types.h>
57: #include <sys/cmn_err.h>
58: #include <sys/file.h>
59: #include <sys/open.h>
60: #include <sys/uio.h>
61: #include <sys/errno.h>
62: #include <stddef.h>
63:
64: #include <sys/confinfo.h>
65:
66: /*
67: * These are Coherent header files! Treat with all the caution you would
68: * normally use for handling toxic waste!
69: *
70: * <sys/stat.h>
71: * major ()
72: * minor ()
73: * <sys/uproc.h>
74: * u.u_uid
75: * u.u_gid
76: * <sys/con.h>
77: * DFBLK
78: *
79: * The following values which used to be in Coherent <sys/inode.h> have been
80: * moved here so we can use them. <sys/inode.h> is too much of a mess.
81: *
82: * <sys/file.h>
83: * IPR
84: * IPW
85: * IPNDLY
86: * IPEXCL
87: *
88: * Note that the actual magic u area variable 'u' is extern'ed in
89: * <sys/coherent.h>.
90: */
91:
92: #include <sys/stat.h>
93:
94: #if __COHERENT__
95:
96: #define SETUERROR(e) u.u_error = (e)
97:
98: #else
99:
100: #define SETUERROR(e) ASSERT (e == 0 || "Hit error" == NULL)
101:
102: #endif
103:
104:
105: /*
106: * Forward Coh open request to actual STREAMS driver-request-processing code.
107: */
108:
109: #if __USE_PROTO__
110: int (_streams_open) (o_dev_t dev, int mode, int __NOTUSED (flags),
111: struct streamtab * stabp)
112: #else
113: int
114: _streams_open __ARGS ((dev, mode, flags, stabp))
115: o_dev_t dev;
116: int mode;
117: int flags;
118: struct streamtab
119: * stabp;
120: #endif
121: {
122: n_dev_t newdev = makedevice (major (dev), minor (dev));
123: n_dev_t olddev = newdev;
124: cred_t cred;
125: int newmode;
126: int ret;
127:
128: newmode = 0;
129:
130: if ((mode & IPR) != 0)
131: newmode |= FREAD;
132: if ((mode & IPW) != 0)
133: newmode |= FWRITE;
134: if ((mode & IPEXCL) != 0)
135: newmode |= FEXCL;
136: if ((mode & IPNDLY) != 0)
137: newmode |= FNDELAY;
138:
139: ret = STREAMS_OPEN (& newdev, stabp, newmode, MAKE_CRED (& cred));
140:
141: if (olddev != newdev)
142: cmn_err (CE_PANIC, "No cloning permitted through the Coherent driver system");
143:
144: SETUERROR (ret);
145: return ret;
146: }
147:
148:
149: /*
150: * Forward Coh close request to actual STREAMS driver-request-processing code.
151: */
152:
153: #if __USE_PROTO__
154: int (_streams_close) (o_dev_t dev, int mode, int __NOTUSED (flags),
155: struct streamtab * __NOTUSED (stabp))
156: #else
157: int
158: _streams_close __ARGS ((dev, mode, flags, stabp))
159: o_dev_t dev;
160: int mode;
161: int flags;
162: struct streamtab
163: * stabp;
164: #endif
165: {
166: shead_t * sheadp;
167: cred_t cred;
168: int newmode;
169: int ret;
170:
171: if ((sheadp = SHEAD_FIND (makedevice (major (dev), minor (dev)),
172: DEV_SLIST)) == NULL) {
173: SETUERROR (ENXIO);
174: return -1;
175: }
176:
177: newmode = 0;
178:
179: if ((mode & IPR) != 0)
180: newmode |= FREAD;
181: if ((mode & IPW) != 0)
182: newmode |= FWRITE;
183: if ((mode & IPEXCL) != 0)
184: newmode |= FEXCL;
185: if ((mode & IPNDLY) != 0)
186: newmode |= FNDELAY;
187:
188: ret = STREAMS_CLOSE (sheadp, newmode, MAKE_CRED (& cred));
189:
190: SETUERROR (ret);
191: return ret;
192: }
193:
194:
195: /*
196: * Forward Coh read request to actual STREAMS driver-request-processing code.
197: */
198:
199: #if __USE_PROTO__
200: int (_streams_read) (o_dev_t dev, IO * iop,
201: struct streamtab * __NOTUSED (stabp))
202: #else
203: int
204: _streams_read __ARGS ((dev, iop, stabp))
205: o_dev_t dev;
206: IO * iop;
207: struct streamtab
208: * stabp;
209: #endif
210: {
211: iovec_t iov;
212: uio_t uio;
213: int ret;
214: shead_t * sheadp;
215:
216: if ((sheadp = SHEAD_FIND (makedevice (major (dev), minor (dev)),
217: DEV_SLIST)) == NULL) {
218: SETUERROR (ENXIO);
219: return -1;
220: }
221:
222: ret = STREAMS_READ (sheadp, MAKE_UIO (& uio, & iov, FREAD, iop));
223:
224: DESTROY_UIO (& uio, iop);
225: SETUERROR (ret);
226: return ret;
227: }
228:
229:
230: /*
231: * Forward Coh write request to actual STREAMS driver-request-processing code.
232: */
233:
234: #if __USE_PROTO__
235: int (_streams_write) (o_dev_t dev, IO * iop,
236: struct streamtab * __NOTUSED (stabp))
237: #else
238: int
239: _streams_write __ARGS ((dev, iop, stabp))
240: o_dev_t dev;
241: IO * iop;
242: struct streamtab
243: * stabp;
244: #endif
245: {
246: iovec_t iov;
247: uio_t uio;
248: int ret;
249: shead_t * sheadp;
250:
251: if ((sheadp = SHEAD_FIND (makedevice (major (dev), minor (dev)),
252: DEV_SLIST)) == NULL) {
253: SETUERROR (ENXIO);
254: return -1;
255: }
256:
257: ret = STREAMS_WRITE (sheadp, MAKE_UIO (& uio, & iov, FWRITE, iop));
258:
259: DESTROY_UIO (& uio, iop);
260: SETUERROR (ret);
261: return ret;
262: }
263:
264:
265: /*
266: * Forward Coh ioctl request to actual STREAMS driver-request-processing code.
267: */
268:
269: #if __USE_PROTO__
270: int (_streams_ioctl) (o_dev_t dev, int cmd, _VOID * arg, int mode,
271: struct streamtab * __NOTUSED (stabp))
272: #else
273: int
274: _streams_ioctl __ARGS ((dev, cmd, arg, mode, stabp))
275: o_dev_t dev;
276: int cmd;
277: _VOID * arg;
278: int mode;
279: struct streamtab
280: * stabp;
281: #endif
282: {
283: cred_t cred;
284: int rval;
285: int newmode;
286: int ret;
287: shead_t * sheadp;
288:
289: if ((sheadp = SHEAD_FIND (makedevice (major (dev), minor (dev)),
290: DEV_SLIST)) == NULL) {
291: SETUERROR (ENXIO);
292: return -1;
293: }
294:
295: newmode = 0;
296:
297: if ((mode & IPR) != 0)
298: newmode |= FREAD;
299: if ((mode & IPW) != 0)
300: newmode |= FWRITE;
301: if ((mode & IPEXCL) != 0)
302: newmode |= FEXCL;
303: if ((mode & IPNDLY) != 0)
304: newmode |= FNDELAY;
305:
306: ret = STREAMS_IOCTL (sheadp, cmd, arg, newmode, MAKE_CRED (& cred),
307: & rval);
308:
309: SETUERROR (ret);
310: return rval;
311:
312: }
313:
314:
315: /*
316: * Forward Coh poll request to actual STRAAMS driver-request-processing code.
317: */
318:
319: #if __USE_PROTO__
320: int (_streams_chpoll) (o_dev_t dev, int events, int msec,
321: struct streamtab * stabp)
322: #else
323: int
324: _streams_chpoll __ARGS ((dev, events, msec, stabp))
325: o_dev_t dev;
326: int events;
327: int msec;
328: struct streamtab
329: * stabp;
330: #endif
331: {
332: int ret;
333:
334: cmn_err (CE_PANIC, "DDI/DKI polling not yet supported");
335:
336: #if 0
337: ret = (* funcp) (newdev, events, msec == 0, & revents, pollhead)
338: #else
339: ret = EIO;
340: #endif
341: SETUERROR (ret);
342: return ret;
343: }
344:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.