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