1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 /*
30 * The sole purpose of this file is to document our violations of the DDI
31 * in Solaris and to get ddict to run on the data services stack.
32 * Definitions and declarations contained in this file are never compiled
33 * into the code. It is only included if we are running ddict on our src.
34 *
35 * IMPORTANT NOTE:
36 * Many of the declarations are not correct. It does not matter.
37 * Structure declarations only define the fields we require.
38 * Structures which we use in an opaque manner are defined as void *
39 */
40
41 #ifndef _SYS_CONTRACT_H
42 #define _SYS_CONTRACT_H
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /*
49 * Define our interfaces for nsctl because ddict is stupid
50 * about intermodule dependencies
51 */
52 #include <sys/nsctl/nsctl_inter.h>
53
54 /*
55 * Define our ncall interfaces
56 */
57 #include <sys/nsctl/ncall_inter.h>
58
59 /*
60 * The STRUCT_DECL definitions in the ddict headers are fouled up
61 * we include our own model.h here to redefine it to avoid errors.
62 */
63 #if !defined(_SunOS_5_6)
64 #include <sys/nsctl/model.h>
65 #endif
66
67 /*
68 * General violations
69 * Everybody violates these
70 * Why are they called ddi if it is not part of it?
71 */
72
73 #define DDI_PROP_NOTPROM 0
74
75 int ddi_rele_driver(void) { }
76 int ddi_hold_installed_driver(void) { }
77
78 /*
79 * SV module violations
80 */
81 void *curthread;
82 int devcnt;
83
84 /*
85 * The following from vnode.h
86 */
87 typedef struct vode {
88 int v_lock; /* SDBC uses this too */
89 int v_type; /* nskern too */
90 int v_rdev; /* nskern too */
91 } vnode_t;
92
93 #define FOLLOW 0
94 #define NULLVPP NULL
95 #define AT_RDEV 0
96 #define VOP_GETATTR(vp, vap, f, cr) ((void)0)
97 #define VN_RELE(vp) ((void)0)
98
99 /*
100 * The fields we use from vattr_t
101 */
102 typedef struct vattr {
103 uint_t va_mask;
104 dev_t va_rdev;
105 int va_size; /* nskern */
106 } vattr_t;
107
108 int lookupname(void, void, void, void, void) { }
109
110 /*
111 * End of SV module violations
112 */
113
114 /*
115 * DSW/II module violations
116 */
117
118 /*
119 * This is really bogus that ddict does not understand sys/inttypes.h
120 */
121 #define INT32_MIN 0
122 #define INT32_MAX 0
123 #define INT64_MAX 0
124
125 /*
126 * End of DSW/II module violations
127 */
128
129 /*
130 * UNISTAT module violations
131 */
132
133 void mod_miscops;
134 typedef enum { B_FALSE, B_TRUE } boolean_t;
135
136 /*
137 * End of UNISTAT module violations
138 */
139
140 /*
141 * NSCTL module violations
142 */
143 #define ERESTART 0
144 #define EUSERS 0
145 #define ENAMETOOLONG 0
146 #define ENOSYS 0
147 #define FOPEN 0
148 int ddi_name_to_major() { }
149 /*
150 * End of NSCTL module violations
151 */
152
153 /*
154 * NSKERN module violations
155 */
156 #define UL_GETFSIZE 0
157 #define USHRT_MAX 0
158
159 typedef u_longlong_t rlim64_t;
160 int ulimit() { }
161 volatile int maxphys;
162
163 #define AT_SIZE 0
164 #define VBLK 0
165 #define VCHR 0
166 #define VREG 0
167 #define VLNK 0
168
169 #define VOP_CLOSE(vp, f, c, o, cr) ((void)0)
170 #define VOP_RWLOCK(vp, w) ((void)0)
171 #define VOP_RWUNLOCK(vp, w) ((void)0)
172 #define VOP_READ(vp, uiop, iof, cr) ((void)0)
173 #define VOP_WRITE(vp, uiop, iof, cr) ((void)0)
174
175 int vn_open(char *pnamep, void seg, int filemode, int createmode,
176 struct vnode **vpp, void crwhy, mode_t umask) { }
177
178 /*
179 * End of NSKERN module violations
180 */
181
182 /*
183 * NVRAM module violations
184 */
185 #define MMU_PAGESIZE 0
186
187 #ifndef MAXNAMELEN
188 #define MAXNAMELEN 1
189 #endif
190
191 #define DEVMAP_DEFAULTS 0
192 #define PFN_INVALID -1
193
194 char hw_serial[1];
195 int mmu_ptob(void arg) { }
196 int roundup(void arg) { }
197
198 /*
199 * End of NVRAM module violations
200 */
201
202 /*
203 * RDCSVR (SNDR) module
204 * Contract PSARC 2001/699
205 */
206 #define DUP_DONE 0
207 #define DUP_ERROR 0
208 #define DUP_INPROGRESS 0
209 #define DUP_NEW 0
210 #define DUP_DROP 0
211
212 #define RPC_MAXDATASIZE 0
213
214
215 typedef void * file_t; /* opaque */
216 typedef void SVCXPRT; /* opaque */
217 typedef void SVCMASTERXPRT; /* opaque */
218 typedef void xdrproc_t; /* opaque */
219 typedef int enum_t;
220
221 typedef struct svc_req { /* required fields */
222 int rq_vers;
223 int rq_proc;
224 } svc_req_t;
225
226 void SVC_FREEARGS(void xprt, void a, void *b) { }
227 void SVC_DUP(void xprt, void req, void i, void j, void *dr) { }
228 void svcerr_systemerr(void xprt) { }
229 void svcerr_noproc(void xprt) { }
230 void SVC_DUPDONE(void xprt, void dr, void a, void b, void c) { }
231
232 SVCXPRT *svc_tli_kcreate(void *f, void *n, void *b, void **x, void *t,
233 uint_t c, uint_t d) { }
234
235 /*
236 * non-ddi not under contracts
237 */
238 struct netbuf {
239 int maxlen;
240 int len;
241 char *buf;
242 }
243
244 /*
245 * End of RDCSRV module Contracts
246 */
247
248 /*
249 * RDC (SNDR) module
250 * Contract PSARC 2001/699
251 */
252
253 typedef u_longlong_t rpcproc_t;
254 typedef u_longlong_t xdrproc_t;
255 typedef u_longlong_t rpcvers_t;
256 #define __dontcare__ -1
257 #define RPC_INTR 0
258 #define RPC_SUCCESS 0
259 #define RPC_TLIERROR 0
260 #define RPC_XPRTFAILED 0
261 #define RPC_VERSMISMATCH 0
262 #define RPC_PROGVERSMISMATCH 0
263 #define RPC_INPROGRESS 0
264
265 #define ENOEXEC 0
266 #define EBADF 0
267
268 /*
269 * XDR routines
270 * from rpc/xdr.h
271 */
272 typedef void * XDR; /* opaque */
273 int xdr_void() { }
274 int xdr_int() { }
275 int xdr_union() { }
276 int xdr_enum() { }
277 int xdr_u_int() { }
278 int xdr_u_longlong_t() { }
279 int xdr_opaque() { }
280 int xdr_bytes() { }
281 int xdr_array() { }
282 #define NULL_xdrproc_t ((xdrproc_t)0)
283
284 /*
285 * The following imported rpc/clnt.h
286 */
287
288 /* Client is mostly opaque exccept for the following */
289
290 typedef struct __client { /* required fields */
291 void *cl_auth;
292 bool_t cl_nosignal;
293 } CLIENT;
294
295 #define CLSET_PROGRESS 0
296 #define KNC_STRSIZE 128
297 struct knetconfig {
298 unsigned int knc_semantics;
299 caddr_t knc_protofmly;
300 caddr_t knc_proto;
301 dev_t knc_rdev;
302 };
303
304 void *clnt_sperrno() { }
305 void IS_UNRECOVERABLE_RPC(a) { }
306 void CLNT_CONTROL(cl, request, info) { }
307 void AUTH_DESTROY(void *a) { }
308 void CLNT_DESTROY(void *a) { }
309
310 int clnt_tli_kcreate(void *a, void *b, void c, void d, void e, void f,
311 void *g, void **h) { }
312
313 int clnt_tli_kinit(void *h, void *config, void *addr, uint_t a, int b,
314 void *c) { }
315
316 void CLNT_CALL(void, void, void, void, void, void, void) { }
317
318 /*
319 * The following imported from rpc/svc.h
320 */
321 void svc_sendreply() { }
322 void svcerr_decode() { }
323 void SVC_GETARGS() { }
324
325 /*
326 * The following imported from sys/file.h
327 */
328
329 void getf(void) { }
330 void releasef(void) { }
331
332 /*
333 * Not under contract
334 */
335 void sigintr(void) { }
336 void sigunintr(void) { }
337 dev_t expldev() { }
338
339 /*
340 * End of RDC module
341 */
342
343 /*
344 * SDBC module violations
345 */
346
347 /*
348 * devid uses internal structure
349 * from sys/ddi_impldefs.h
350 */
351 typedef struct impl_devid {
352 uchar_t did_type_hi;
353 uchar_t did_type_lo;
354 } impl_devid_t;
355
356 #define DEVID_GETTYPE(devid) 0
357 #define DEVID_SCSI_SERIAL 0
358
359 #define ENOLINK 0 /* NCALL too */
360 #define E2BIG 0
361 #define ENOENT 0
362 #define EIDRM 0
363
364 #define B_KERNBUF 0
365 #define KSTAT_TYPE_RAW 0
366 #define MAXPATHLEN 0
367
368 #define VN_HOLD(bp) ((void)0)
369
370 /* Page list IO stuff */
371 typedef struct page {
372 int v_count; /* sdbc */
373 } page_t;
374 page_t kvp; /* We use the kernel segment */
375 int page_add(void) { }
376 int page_find(void) { }
377 int page_list_concat(void) { }
378 int pageio_setup(void) { }
379 int pageio_done(void) { }
380
381 void kobj_getsymvalue(void) { }
382 int ddi_dev_pathname(void) { }
383
384 /*
385 * HACK ALERT
386 * struct buf hack for ddict.
387 * SDBC currently violates in struct buf
388 * b_pages
389 * b_proc
390 * which we will define as the pad fields for ddict since
391 * we can not overload the definition of struct buf with our own stuff.
392 */
393
394 #define b_pages b_pad7 /* b_pages in struct buf */
395 #define b_proc b_pad8 /* b_proc in struct buf */
396 #define b_forw b_pad1 /* b_forw in struct buf */
397 #define b_back b_pad2 /* b_back in struct buf */
398
399 /*
400 * End of SDBC moduel violations
401 */
402
403 /*
404 * SCMTEST module violations
405 */
406
407 #define ESRCH 0 /* NCALL too */
408
409 /*
410 * End of SCMTEST module violations
411 */
412 /*
413 * SFTM module violations
414 * Note: XXX This list is currently incomplete
415 */
416
417 typedef void * cqe_t; /* opaque */
418 typedef void * fcal_packet_t; /* opaque */
419 typedef void * soc_response_t; /* opaque */
420 typedef void * la_els_logi_t; /* opaque */
421 typedef void * la_els_adisc_t; /* opaque */
422 typedef void * fcp_rsp_t; /* opaque */
423 typedef void * soc_request_t; /* opaque */
424 typedef void * els_payload_t; /* opaque */
425 typedef void * la_els_logo_t; /* opaque */
426 typedef void * fc_frame_header_t; /* opaque */
427
428 typedef struct la_els_prli_s {
429 uchar_t ls_code;
430 uchar_t page_length;
431 ushort_t payload_length;
432 uchar_t service_params[1];
433 } la_els_prli_t;
434
435 typedef la_els_prli_t la_els_prli_reply_t;
436 typedef la_els_prli_t la_els_prlo_t;
437 typedef la_els_prli_t la_els_prlo_reply_t;
438
439 /*
440 * The following from /usr/include/sys/fc4/fcp.h
441 */
442 typedef struct fcp_cntl {
443 uchar_t cntl_reserved_1 : 5,
444 cntl_qtype : 3;
445 uchar_t cntl_kill_tsk : 1,
446 cntl_clr_aca : 1,
447 cntl_reset : 1,
448 cntl_reserved_2 : 2,
449 cntl_clr_tsk : 1,
450 cntl_abort_tsk : 1,
451 cntl_reserved_3 : 1;
452 uchar_t cntl_reserved_4 : 6,
453 cntl_read_data : 1,
454 cntl_write_data : 1;
455 } fcp_cntl_t;
456
457 typedef struct fcp_ent_addr {
458 ushort_t ent_addr_0;
459 ushort_t ent_addr_1;
460 ushort_t ent_addr_2;
461 ushort_t ent_addr_3;
462 } fcp_ent_addr_t;
463
464 typedef struct fcp_cmd_s {
465 fcp_ent_addr_t fcp_ent_addr;
466 fcp_cntl_t fcp_cntl;
467 uchar_t fcp_cdb[1];
468 int fcp_data_len;
469 } fcp_cmd_t;
470
471 typedef struct fcal_transport {
472 uchar_t dummy1;
473 uchar_t dummy2;
474 } fcal_transport_t;
475
476 /*
477 * End of SFTM module violations
478 */
479
480 /*
481 * STE module violations
482 */
483
484 typedef void la_wwn_t; /* opaque */
485 /* WWN formats from sys/fcal/fcal_linkapp.h */
486 typedef union la_wwn {
487 uchar_t raw_wwn[8];
488 struct {
489 uint_t naa_id : 4;
490 uint_t nport_id : 12;
491 uint_t wwn_hi : 16;
492 uint_t wwn_lo;
493 } w;
494 } la_wwn_t;
495
496 insque(void) { }
497 remque(void) { }
498 snprintf(void) { }
499
500 /*
501 * STE uses inq_serial and inq_ackqreqq from struct scsi_inquiry
502 */
503 #define inq_serial inq_pid
504 #define inq_ackqreqq inq_pid
505 /*
506 * End of STE module violations
507 */
508
509 /*
510 * NCALL module violations
511 */
512 #define ENONET 0
513
514 /* NCALLSRV */
515 typedef int bool_t;
516
517 /* NCALLIP */
518 #ifndef TRUE
519 #define TRUE 1
520 #endif
521
522 #ifndef FALSE
523 #define FALSE 0
524 #endif
525
526 #define ERANGE 0
527 #define ENODATA 0
528
529 #define RPC_TIMEDOUT 0
530
531 /*
532 * End of NCALL violations
533 */
534 #ifdef __cplusplus
535 }
536 #endif
537
538 #endif /* _SYS_CONTRACT_H */