objmgr.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Local static data
*/
#ifdef OBJMGR_DEBUG
#define DENT 0x0001
#define DERR 0x0002
#endif /* OBJMGR_DEBUG */
static dev_info_t *objmgr_dip;
static kmutex_t objmgr_mutex;
/*
* external interface
*/
/*
* local functions protocol
*/
/*
* Config information
*/
static int
static int
struct bus_ops objmgr_bus_ops = {
NULL, /* NO OP */
NULL, /* NO OP */
NULL, /* NO OP */
NULL, /* get_eventcookie */
NULL, /* add_eventcall */
NULL, /* remove_eventcall */
NULL, /* post_event */
NULL, /* interrupt control */
0, /* bus_config */
0, /* bus_unconfig */
0, /* bus_fm_init */
0, /* bus_fm_fini */
0, /* bus_fm_access_enter */
0, /* bus_fm_access_exit */
0, /* bus_power */
objmgr_intr_op /* bus_intr_op */
};
struct dev_ops objmgr_ops = {
DEVO_REV, /* devo_rev, */
0, /* refcnt */
ddi_no_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
objmgr_attach, /* attach */
objmgr_detach, /* detach */
nodev, /* reset */
(struct cb_ops *)0, /* driver operations */
&objmgr_bus_ops /* bus operations */
};
/*
* This is the loadable module wrapper.
*/
extern struct mod_ops mod_driverops;
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module. This one is a pseudo driver */
"Object Manager %I%",
&objmgr_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
(void *)&modldrv,
};
int
_init(void)
{
#ifdef OBJMGR_DEBUG
if (objmgr_debug & DENT)
PRF("objmgr_init: call\n");
#endif
return (mod_install(&modlinkage));
}
int
_fini(void)
{
int ret;
if (ret == 0)
return (ret);
}
int
{
}
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
objmgr_dip = devi;
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
/* check for any registered objects */
return (DDI_FAILURE);
}
objmgr_dip = NULL;
return (DDI_SUCCESS);
}
/*
* objmgr_intr_op: objmgr convert an interrupt number to an
* interrupt. NO OP for objmgr drivers.
*/
/*ARGSUSED*/
static int
{
return (DDI_FAILURE);
}
/*ARGSUSED*/
static int
{
switch (ctlop) {
case DDI_CTLOPS_REPORTDEV:
if (rdip == (dev_info_t *)0)
return (DDI_FAILURE);
return (DDI_SUCCESS);
case DDI_CTLOPS_INITCHILD:
{
return (DDI_SUCCESS);
}
default:
return (DDI_FAILURE);
}
}
static struct obj_entry *
objmgr_scan_entry(char *obj_keyp)
{
if (obj_lstentp) {
return (obj_lstentp);
}
return (obj_ep);
}
}
obj_lstentp = NULL;
return (NULL);
}
int
{
/* search to the end of the list */
if (obj_ep) {
return (DDI_SUCCESS);
}
return (DDI_SUCCESS);
}
int
objmgr_del_entry(char *obj_keyp)
{
if (!obj_ep) {
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
/* check for reference counts of other modules in the same group */
0) {
return (DDI_FAILURE);
}
}
}
}
/* unlink entry */
obj_lstentp = NULL;
return (DDI_SUCCESS);
}
int
objmgr_load_obj(char *obj_keyp)
{
int modid;
char obj_keypath[OBJNAMELEN];
int obj_keylen;
/* search to the end of the list */
if (obj_ep)
return (DDI_SUCCESS);
obj_keylen = sizeof (obj_keypath);
#ifdef OBJMGR_DEBUG
if (objmgr_debug & DERR)
PRF("objmgr_load_entry: prop undefined= %s\n",
obj_keyp);
#endif
return (DDI_FAILURE);
}
obj_keypath[obj_keylen] = (char)0;
return (DDI_FAILURE);
/* scan the new list */
/* check for insertion of entry failure */
if (!obj_ep) {
return (DDI_FAILURE);
}
/* assign module id for other modules in the same group */
0))
}
}
return (DDI_SUCCESS);
}
void
objmgr_unload_obj(char *obj_keyp)
{
int modid;
/* search to the end of the list */
if (obj_ep) {
return;
}
}
return;
}
objmgr_create_obj(char *obj_keyp)
{
/* search to the end of the list */
if (obj_ep) {
if (objp)
return (objp);
}
return (NULL);
}
int
objmgr_destroy_obj(char *obj_keyp)
{
/* search to the end of the list */
if (obj_ep)
return (DDI_SUCCESS);
}