obpsym.c revision 75521904d7c3dbe11337904d9bead2518c94cc50
/*
* 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"
/*
* This module supports callbacks from the firmware
* such that address and name lookups can work and use kernel symbol names.
* For example "ctrace" will provide symbolic names, if they are available.
* Also, normal firmware name to address lookups should work, though be
* careful with clashing kernel names, such as "startup" and "reset" which
* may be the firmware names and *not* the kernel names.
*
* The module locks the symbol tables in memory, when it's installed,
* and unlocks them when it is removed. To install the module, you
*
* This file contains the actual code the does the lookups, and interfaces
* the firmware is handled in prom-dependent code.
*/
int obpsym_debug = 0;
extern int obpdebug;
/*
* name_to_value - translate a string into an address
*
* The string may be one of two forms - 'symname' or 'modname:symname'.
* (We also accept 'unix:symname' as a synonymn for 'symname'.)
* The latter form causes a kobj_lookup() to occur only in the given module,
* the former causes a kobj_getsymvalue() on the entire kernel symbol table.
*
* mod_lock locking is not needed for the &modules list because
* modctl structures are never unlinked from the &modules list.
*/
int
{
register char *modname = "";
char *p;
int retval = 0;
char c = (char)0;
/*
* we take names of the form: "modname:symbol", "unix:symbol", "symbol"
*/
symname = p + 1;
c = *p;
*p = (char)0;
}
if (*modname == (char)0) {
} else {
do {
break;
}
}
if (symvalue == 0)
retval = -1;
if (c != (char)0) /* Restore incoming cstr */
*p = c;
return (retval);
}
/*
* value_to_name - translate an address into a string + offset
*
* mod_lock locking is not needed fro the modules list because
* modctl structures are never unlinked from the &modules list.
*/
{
char *name;
do {
return (offset);
}
*symbol = (char)0;
return ((ulong_t)-1l);
}
/*
* loadable module wrapper
*/
&mod_miscops, "OBP symbol callbacks %I%"
};
static struct modlinkage modlinkage = {
};
/*ARGSUSED*/
static boolean_t
{
extern void set_sym_callbacks();
if (code == CB_CODE_CPR_RESUME)
return (B_TRUE);
}
int
_init(void)
{
int retval;
extern int install_callbacks(void);
extern void remove_callbacks(void);
if (install_callbacks() != 0)
return (ENXIO);
obpdebug = 1;
debug_enter("obpsym: halt flag (-h) is set.\n");
/*
* if load fails remove callback and unlock symbols
*/
if (retval) {
obpdebug = 0;
}
else
return (retval);
}
int
_fini(void)
{
int retval;
extern void remove_callbacks(void);
if (obpheld != 0)
return (EBUSY);
/*
* if unload succeeds remove callback and unlock symbols
*/
if (retval == 0) {
obpdebug = 0;
}
return (retval);
}
int
{
}