kobj_kdi.c revision 986fd29a0dc13f7608ef7f508f6e700bd7bc2720
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The KDI is used to allow the kernel debugger to directly invoke various
* kernel functions. In some cases, such as with kdi_mod_iter(), the
* debugger needs to execute functions that use the kernel's linker bindings.
* In other cases, the implementation of the KDI functions vary by platform
* in the debugger, and can thus have a single debugger binary for all
* platforms.
*
* There are three classes of KDI function:
*
* 1. Normal - These are functions whose implementations are in the kernel for
* convenience. An example is the modctl iterator, kdi_mod_iter. Using the
* modules symbol, this function iterates through the kernel's modctl list,
* invoking a debugger-provided callback for each one. This function is in
* the KDI because the debugger needs to be able to execute it in order to
* enable symbol resolution. Without symbol resolution, the debugger can't
* locate the modules symbol. A chicken-and-egg problem results. We solve
* this problem by locating the module iterator in the kernel, where run-time
* linking solves the problem for us.
*
* 2. CPU-specific - Functions in this class have implementations that differ
* by CPU. For example, the crosscall delivery notification method differs
* between Cheetah and Jalapeno, necessitating a different implementation for
* each. By locating the KDI implementation of these functions in the
* cpumods, we automatically get the correct implementation, as krtld
* automatically loads the correct cpumod when it starts. The cpumods
* directly fill in their portion of the kdi_t, using the mandatory
* cpu_kdi_init cpumod entry point.
*
* 3. Platform-specific - Similar to the CPU-specific class, platform-specific
* KDI functions have implementations that differ from platform to platform.
* As such, the implementations live in the platmods. Further
* differentiating the platform-specific KDI functions from their
* CPU-dependent brethren, many directly invoke PROM functions. This poses
* a problem, as the platmods use the kernel's promif functions, rather than
* the lock-free kmdb versions. We provide an interposition layer for these
* platform-specific calls that disables the pre- and post-processing
* functions used by the kernel to implement kernel-specific functionality
* that must not be executed when kmdb has control of the machine. Platmods
* fill in a kdi_plat_t using their optional plat_kdi_init entry point.
* krtld provides wrapper functions which suspend the necessary functions in
* the promif layer before invoking the kdi_plat_t functions (if any).
*/
#include <sys/kdi_impl.h>
#include <krtld/kobj_kdi.h>
#define KOBJ_KDI_MOD_IDLE 0
#define KOBJ_KDI_MOD_CHANGING 1
#define KOBJ_KDI_MOD_CHANGED 2
static int kobj_kdi_mod_state = KOBJ_KDI_MOD_IDLE;
extern int standalone;
kobj_kdi_get_polled_io(void)
{
}
int
{
int rc;
if (standalone) {
return (rc);
}
}
} else {
do {
return (rc);
}
return (0);
}
int
{
}
int
kobj_kdi_mods_changed(void)
{
int state;
return (state != KOBJ_KDI_MOD_IDLE);
}
/*ARGSUSED1*/
void
{
switch (why) {
case KOBJ_NOTIFY_MODLOADING:
break;
case KOBJ_NOTIFY_MODLOADED:
break;
case KOBJ_NOTIFY_MODUNLOADING:
break;
case KOBJ_NOTIFY_MODUNLOADED:
break;
}
}
/*
* Compare two modctl and module snapshots, attempting to determine whether
* the module to which they both refer has changed between the time of the first
* and the time of the second. We can't do a straight bcmp, because there are
* fields that change in the normal course of operations. False positives
* aren't the end of the world, but it'd be nice to avoid flagging a module
* as changed every time someone holds or releases it.
*/
int
{
return (1);
return (0);
/* Take breath here. */
}
void
kobj_kdi_system_claim(void)
{
}
void
kobj_kdi_system_release(void)
{
}
void
kobj_kdi_init(void)
{
static const char *const initializers[] = {
};
int i;
for (i = 0; initializers[i] != NULL; i++) {
}
}
/*
* plat_kdi_init.
*/
NULL, /* kdi_plat_call */
NULL, /* kdi_kmdb_enter */
{ NULL }, /* kdi_arch */
{ NULL } /* kdi_plat */
};