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 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
31 #include <sys/types.h>
32 #include <sys/param.h>
34 #include <sys/devops.h>
35 #include <sys/modctl.h>
36 #include <sys/cmn_err.h>
38 #include <sys/sunddi.h>
39 #include <sys/sunndi.h>
41 static int cpunex_attach(dev_info_t
*, ddi_attach_cmd_t
);
42 static int cpunex_detach(dev_info_t
*, ddi_detach_cmd_t
);
43 static int cpunex_bus_ctl(dev_info_t
*, dev_info_t
*, ddi_ctl_enum_t
,
46 static struct bus_ops cpunex_bus_ops
= {
65 static struct dev_ops cpunex_ops
= {
77 ddi_quiesce_not_needed
, /* quiesce */
80 static struct modldrv modldrv
= {
86 static struct modlinkage modlinkage
= {
94 * This routine implements nexus bus ctl operations. Of importance are
95 * DDI_CTLOPS_REPORTDEV, DDI_CTLOPS_INITCHILD, DDI_CTLOPS_UNINITCHILD
96 * and DDI_CTLOPS_POWER. For DDI_CTLOPS_INITCHILD, it tries to lookup
97 * reg property on the child node and builds and sets the name.
100 cpunex_bus_ctl(dev_info_t
*dip
, dev_info_t
*rdip
, ddi_ctl_enum_t op
, void *arg
,
104 case DDI_CTLOPS_REPORTDEV
: {
105 dev_info_t
*pdip
= ddi_get_parent(rdip
);
106 cmn_err(CE_CONT
, "?%s%d at %s%d",
107 ddi_node_name(rdip
), ddi_get_instance(rdip
),
108 ddi_node_name(pdip
), ddi_get_instance(pdip
));
109 return (DDI_SUCCESS
);
112 case DDI_CTLOPS_INITCHILD
: {
113 dev_info_t
*cdip
= (dev_info_t
*)arg
;
115 char caddr
[MAXNAMELEN
];
117 i
= ddi_prop_get_int(DDI_DEV_T_ANY
, cdip
,
118 DDI_PROP_DONTPASS
, "reg", -1);
121 cmn_err(CE_NOTE
, "!%s(%d): \"reg\" property "
122 "not found", ddi_node_name(cdip
),
123 ddi_get_instance(cdip
));
124 return (DDI_NOT_WELL_FORMED
);
127 (void) sprintf(caddr
, "%d", i
);
128 ddi_set_name_addr(cdip
, caddr
);
130 return (DDI_SUCCESS
);
133 case DDI_CTLOPS_UNINITCHILD
: {
134 ddi_prop_remove_all((dev_info_t
*)arg
);
135 ddi_set_name_addr((dev_info_t
*)arg
, NULL
);
136 return (DDI_SUCCESS
);
140 return (ddi_ctlops(dip
, rdip
, op
, arg
, result
));
147 cpunex_attach(dev_info_t
*dip
, ddi_attach_cmd_t cmd
)
154 return (DDI_FAILURE
);
157 return (DDI_SUCCESS
);
162 cpunex_detach(dev_info_t
*dip
, ddi_detach_cmd_t cmd
)
169 return (DDI_FAILURE
);
172 return (DDI_SUCCESS
);
180 error
= mod_install(&modlinkage
);
189 error
= mod_remove(&modlinkage
);
194 _info(struct modinfo
*modinfop
)
196 return (mod_info(&modlinkage
, modinfop
));