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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_DDI_HP_IMPL_H
27 #define _SYS_DDI_HP_IMPL_H
30 * Sun DDI hotplug implementation specific definitions
39 /* Flags for sync request and async hotplug request */
40 #define DDI_HP_REQ_SYNC 0x0001
41 #define DDI_HP_REQ_ASYNC 0x0002
43 /* Check if a handle represents a port or a connector */
44 #define DDI_HP_IS_VIRTUAL_PORT(hdlp) \
45 (hdlp->cn_info.cn_type == DDI_HP_CN_TYPE_VIRTUAL_PORT)
50 * DDI handle for a registered Hotplug Connection (CN)
52 typedef struct ddi_hp_cn_handle
{
53 dev_info_t
*cn_dip
; /* The dip that the handle is linked */
54 ddi_hp_cn_info_t cn_info
; /* Connection info */
55 struct ddi_hp_cn_handle
*next
; /* Next Connector/Port. */
58 typedef struct ddi_hp_cn_async_event_entry
{
61 ddi_hp_cn_state_t target_state
;
62 } ddi_hp_cn_async_event_entry_t
;
67 * Typedef for Hotplug OPS commands used with bus_hp_op()
70 DDI_HPOP_CN_GET_STATE
= 1, /* Get Connection state */
71 DDI_HPOP_CN_CHANGE_STATE
, /* Change Connection state */
72 DDI_HPOP_CN_PROBE
, /* Probe Connection */
73 DDI_HPOP_CN_UNPROBE
, /* Unprobe Connection */
74 DDI_HPOP_CN_GET_PROPERTY
, /* Get bus specific property */
75 DDI_HPOP_CN_SET_PROPERTY
, /* Set bus specific property */
76 DDI_HPOP_CN_CREATE_PORT
, /* Create a port for virtual hotplug */
77 DDI_HPOP_CN_REMOVE_PORT
/* Remove an empty port */
80 #define DDIHP_CN_OPS(hdlp, op, arg, result, ret) \
81 if (DDI_HP_IS_VIRTUAL_PORT(hdlp)) \
82 ret = ddihp_port_ops(hdlp, op, arg, result); \
84 ret = ddihp_connector_ops(hdlp, op, arg, result);
86 #define NEXUS_HAS_HP_OP(dip) \
87 ((DEVI(dip)->devi_ops->devo_bus_ops) && \
88 (DEVI(dip)->devi_ops->devo_bus_ops->busops_rev >= BUSO_REV_10) && \
89 (DEVI(dip)->devi_ops->devo_bus_ops->bus_hp_op))
92 * ddi_hp_cn_sysevent_t
94 * The following correspond to sysevent defined subclasses
97 DDI_HP_CN_STATE_CHANGE
,
99 } ddi_hp_cn_sysevent_t
;
105 /* Append a node to list */
106 #define DDIHP_LIST_APPEND(type, head, node) \
108 type *curr, *prev = NULL; \
109 (node)->next = NULL; \
110 for (curr = (head); curr; prev = curr, curr = curr->next); \
114 prev->next = (node); \
117 /* Remove a node from a list */
118 #define DDIHP_LIST_REMOVE(type, head, node) \
120 type *curr, *prev = NULL; \
121 for (curr = (head); curr; prev = curr, curr = curr->next) { \
122 if (curr == (node)) \
127 (head) = (head)->next; \
129 prev->next = curr->next; \
133 int ddihp_modctl(int hp_op
, char *path
, char *cn_name
, uintptr_t arg
,
135 ddi_hp_cn_handle_t
*ddihp_cn_name_to_handle(dev_info_t
*dip
, char *cn_name
);
136 int ddihp_cn_getstate(ddi_hp_cn_handle_t
*hdlp
);
137 int ddihp_port_ops(ddi_hp_cn_handle_t
*hdlp
, ddi_hp_op_t op
,
138 void *arg
, void *result
);
139 int ddihp_connector_ops(ddi_hp_cn_handle_t
*hdlp
,
140 ddi_hp_op_t op
, void *arg
, void *result
);
141 void ddihp_cn_gen_sysevent(ddi_hp_cn_handle_t
*hdlp
,
142 ddi_hp_cn_sysevent_t event_sub_class
, int hint
, int kmflag
);
143 int ddihp_cn_unregister(ddi_hp_cn_handle_t
*hdlp
);
151 #endif /* _SYS_DDI_HP_IMPL_H */