/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* "Resident" part of TNF -- this has to be around even when the
* driver is not loaded.
*/
#ifndef NPROBE
#include <sys/tnf_writer.h>
#include <sys/tnf_probe.h>
#include "tnf_buf.h"
#include "tnf_types.h"
#include "tnf_trace.h"
/*
* Defines
*/
/*
* Declarations
*/
/*
* TNF kernel probe management externs
*/
extern tnf_probe_control_t *__tnf_probe_list_head;
extern tnf_tag_data_t *__tnf_tag_list_head;
extern int tnf_changed_probe_list;
/*
* This makes the state of the TNFW_B_STOPPED bit externally visible
* in the kernel.
*/
volatile int tnf_tracing_active = 0;
/*
* The trace buffer pointer
*/
/*
* Stub definitions for tag data pointers
*/
/* tnf_writer module */
/* tnf_trace module */
/* Exported properties */
/*
* tnf_thread_create()
* Called from thread_create() to initialize thread's tracing state.
* XXX Do this when tracing is first turned on
*/
void
{
/* If the allocation fails, this thread doesn't trace */
tnf_kthread_id, tid, t,
}
/*
* tnf_thread_exit()
* Called from thread_exit() and lwp_exit() if thread has a tpdp.
* From this point on, we're off the allthreads list
*/
void
tnf_thread_exit(void)
{
/* LINTED pointer cast may result in improper alignment */
/*
* Mark ops as busy from now on, so it will never be used
* again. If we fail on the busy lock, the buffer
* deallocation code is cleaning our ops, so we don't need to
* do anything. If we get the lock and the buffer exists,
* release all blocks we hold. Once we're off allthreads,
* the deallocator will not examine our ops.
*/
return;
/* Release any A-locks held */
}
}
/*
* Called from thread_free() if thread has tpdp.
*/
void
{
/* LINTED pointer cast may result in improper alignment */
t->t_tnf_tpdp = NULL;
}
/*
* tnf_thread_queue()
* Probe wrapper called when tracing is enabled and a thread is
* placed on some dispatch queue.
*/
void
{
tnf_kthread_id, tid, t,
/* cp->cpu_disp->disp_q[tpri].dq_sruncnt */
tnf_kthread_id, tid, t,
}
/*
* pcstack(): fill in, NULL-terminate and return pc stack.
*/
static pc_t *
{
uint_t n;
pcs[n] = 0;
return (pcs);
}
/*
* tnf_thread_switch()
* Probe wrapper called when tracing enabled and curthread is about to
* switch to the next thread.
* XXX Simple sleepstate and runstate calculations
*/
void
{
kthread_t *t;
int borrow;
t = curthread;
/*
* If we're a zombie, borrow idle thread's tpdp. This lets
* the driver decide whether the buffer is busy by examining
* allthreads (idle threads are always on the list).
*/
ztpdp = t->t_tnf_tpdp;
goto do_next;
}
/*
* If we're blocked, test the blockage probe
*/
#if defined(__sparc)
#else /* defined(__sparc) */
#endif /* defined(__sparc) */
/*
* Record outgoing thread's state
* Kernel thread ID is implicit in schedule record
* supress lint: cast from 32-bit integer to 8-bit integer
* tnf_microstate_t = tnf_uint8_t
*/
#if defined(_LP64)
/* LINTED */
#else
#endif
/*
* Record incoming thread's state
*
* supress lint: cast from 32-bit integer to 8-bit integer
* tnf_microstate_t = tnf_uint8_t
*/
#if defined(_LP64)
/* LINTED */
#else
#endif
/*
* If we borrowed idle thread's tpdp above, restore the zombies
* tpdp so that it will be freed from tnf_thread_free().
*/
if (borrow)
t->t_tnf_tpdp = ztpdp;
}
#endif /* NPROBE */
/*
* tnf_mod_load (and tnf_mod_unload), when called from a client module's _init
* (and _fini) entry points are insufficient mechanisms for maintaining the
* consistency of __tnf_probe_list_head and __tnf_tag_list_head whenever that
* module is loaded or unloaded. The problem occurs because loading a module,
* at which time the modules probes are linked into the two lists, and
* installing that module are separate operations. This means that it is
* possible for a module to be loaded, not installed, and unloaded without
* calling _init and _fini. If the module contains TNF probes, the probe and
* tag lists will contain references to data addresses freed when the module
* is unloaded.
*
* The implemented solution for maintaining the lists is to perform the
* unsplicing when the module is unloaded. (Splicing into the lists, "probe
* discovery", is done when krtld processes relocation references when it
* loads the module; this information is not available for subsequent
* operations on the module.
*/
int
{
return (0);
}
/* ARGSUSED */
int
{
return (0);
}