xref: /titanic_50/usr/src/uts/common/sys/contract/device_impl.h (revision 4445fffbbb1ea25fd0e9ea68b9380dd7a6709025)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_CONTRACT_DEVICE_IMPL_H
27 #define	_SYS_CONTRACT_DEVICE_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/contract_impl.h>
32 #include <sys/dditypes.h>
33 #include <sys/contract/device.h>
34 #include <sys/fs/snode.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Result of negotiation end: event successfully occurred or not
42  */
43 #define	CT_EV_SUCCESS	150
44 #define	CT_EV_FAILURE	151
45 
46 struct ctmpl_device {
47 	ct_template_t	ctd_ctmpl;
48 	uint_t		ctd_aset;
49 	uint_t		ctd_noneg;
50 	char		*ctd_minor;
51 };
52 
53 struct cont_device {
54 	contract_t	cond_contract;	/* common contract data */
55 	char		*cond_minor;  /* minor node resource in contract */
56 	dev_info_t	*cond_dip;	/* dip for minor node */
57 	dev_t		cond_devt;	/* dev_t of minor node */
58 	uint_t		cond_spec;	/* spec type of minor node */
59 	uint_t		cond_aset;	/* acceptable state set */
60 	uint_t		cond_noneg;	/* no negotiation if set */
61 	uint_t		cond_state;	/* current state of device */
62 	uint_t		cond_neg;	/* contract undergoing negotiation */
63 	uint64_t	cond_currev_id;	/* id of event being negotiated */
64 	uint_t		cond_currev_type;  /* type of event being negotiated */
65 	uint_t		cond_currev_ack; /* ack/nack status of ev negotiation */
66 	list_node_t	cond_next;	/* linkage - devinfo's contracts */
67 };
68 
69 /*
70  * Kernel APIs
71  */
72 extern ct_type_t *device_type;
73 /*
74  * struct proc;
75  */
76 void contract_device_init(void);
77 ct_ack_t contract_device_offline(dev_info_t *dip, dev_t dev, int spec_type);
78 void contract_device_degrade(dev_info_t *dip, dev_t dev, int spec_type);
79 void contract_device_undegrade(dev_info_t *dip, dev_t dev, int spec_type);
80 int contract_device_open(dev_t dev, int spec_type, contract_t **ctpp);
81 void contract_device_remove_dip(dev_info_t *dip);
82 ct_ack_t contract_device_negotiate(dev_info_t *dip, dev_t dev, int spec_type,
83     uint_t evtype);
84 void contract_device_finalize(dev_info_t *dip, dev_t dev, int spec_type,
85     uint_t evtype, int ct_result);
86 void contract_device_negend(dev_info_t *dip, dev_t dev, int spec_type,
87     int result);
88 
89 #ifdef	__cplusplus
90 }
91 #endif
92 
93 #endif	/* _SYS_CONTRACT_DEVICE_IMPL_H */
94