xref: /illumos-gate/usr/src/uts/common/sys/ddi_hp.h (revision ffb6483089015eb90be1f5e7fc2a96c9929546a6)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Copyright 2019 Joyent, Inc.
26  */
27 
28 #ifndef	_SYS_DDI_HP_H
29 #define	_SYS_DDI_HP_H
30 
31 /*
32  * Sun DDI hotplug support definitions
33  *
34  * See the big theory statement in uts/common/os/ddi_hp_impl.c for more
35  * information.
36  */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * ddi_hp_cn_state_t
44  *
45  * Typedef of generic hotplug state machine for Hotplug Connection (CN)
46  */
47 typedef enum {
48 	DDI_HP_CN_STATE_EMPTY		= 0x1000, /* Empty */
49 	DDI_HP_CN_STATE_PRESENT		= 0x2000, /* A Device Present */
50 	DDI_HP_CN_STATE_POWERED		= 0x3000, /* Powered */
51 	DDI_HP_CN_STATE_ENABLED		= 0x4000, /* Enabled */
52 	DDI_HP_CN_STATE_PORT_EMPTY	= 0x5000, /* PORT Empty */
53 	DDI_HP_CN_STATE_PORT_PRESENT	= 0x6000, /* A Device Node Present */
54 	DDI_HP_CN_STATE_OFFLINE		= 0x7000, /* Driver not attached */
55 	DDI_HP_CN_STATE_ATTACHED	= 0x8000, /* Device driver attached */
56 	DDI_HP_CN_STATE_MAINTENANCE	= 0x9000, /* Device in maintenance */
57 	DDI_HP_CN_STATE_ONLINE		= 0xa000  /* Device is ready */
58 } ddi_hp_cn_state_t;
59 
60 /*
61  * ddi_hp_cn_type_t
62  *
63  * Typedef for Hotplug Connection (CN) types.
64  */
65 typedef enum {
66 	DDI_HP_CN_TYPE_VIRTUAL_PORT	= 0x1,	/* Virtual Hotplug Port */
67 	DDI_HP_CN_TYPE_PCI		= 0x2,	/* PCI bus slot */
68 	DDI_HP_CN_TYPE_PCIE		= 0x3	/* PCI Express slot */
69 } ddi_hp_cn_type_t;
70 
71 #define	DDI_HP_CN_TYPE_STR_PORT "Virtual-Port"
72 /*
73  * The value set to ddi_hp_cn_info_t->cn_num_dpd_on in the case of the
74  * connection does not depend on any other connections.
75  */
76 #define	DDI_HP_CN_NUM_NONE	-1
77 
78 /*
79  * ddi_hp_cn_info_t
80  *
81  * Hotplug Connection (CN) information structure.
82  * A Connection is either a Connector or a Port.
83  */
84 typedef struct ddi_hp_cn_info {
85 	char			*cn_name;	/* Name of the Connection */
86 	/*
87 	 * Connection number.
88 	 */
89 	int			cn_num;
90 	/*
91 	 * Depend-on connection number;
92 	 * The connection number on which this connection is depending on.
93 	 * If this connection does not depend on any other connections
94 	 * under the same parent node, then it's cn_num_dpd_on is set to
95 	 * DDI_HP_CN_NUM_NONE.
96 	 */
97 	int			cn_num_dpd_on;
98 
99 	ddi_hp_cn_type_t	cn_type;	/* Type: Port, PCI, PCIE, ... */
100 
101 	/*
102 	 * Description string for types of Connection. Set by bus software
103 	 * and read by users only.
104 	 */
105 	char			*cn_type_str;
106 	/*
107 	 * The child device of this Port.
108 	 * It is NULL if this is a Connector.
109 	 */
110 	dev_info_t		*cn_child;
111 
112 	ddi_hp_cn_state_t	cn_state;	/* Hotplug Connection state */
113 	time32_t		cn_last_change;	/* Last time state changed. */
114 } ddi_hp_cn_info_t;
115 
116 typedef struct ddi_hp_property {
117 	char	*nvlist_buf;
118 	size_t	buf_size;
119 } ddi_hp_property_t;
120 
121 #if defined(_SYSCALL32)
122 typedef struct ddi_hp_property32 {
123 	caddr32_t	nvlist_buf;
124 	uint32_t	buf_size;
125 } ddi_hp_property32_t;
126 #endif
127 
128 #ifdef	__cplusplus
129 }
130 #endif
131 
132 #endif	/* _SYS_DDI_HP_H */
133