4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1997 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Kernel Basic Block Profiling - profiling initialization hooks
33 #include <sys/param.h>
34 #include <sys/types.h>
35 #include <sys/t_lock.h>
36 #include <sys/cpuvar.h>
37 #include <sys/systm.h>
39 #include <sys/unix_bb_info.h>
44 * routines to do kernel basic block coverage.
47 struct bb_info
*unix_bb_list
;
51 * There is the potential that we will be called by any C routine.
52 * So we avoid calling any C routines from here, as we'll get
54 * Also, we wish to avoid a deadlock due to being called by
55 * an interrupt handler, so we lock at the NMI level.
56 * Of course, that leaves the possibility that we'll
57 * be called from an NMI handler. If the lock is available,
58 * fine, otherwise, if we're on the interrupt stack at the
59 * NMI level, we just return.
61 * We will probably get another chance to add the bb_info structure
62 * to the list, since the bb_info structure is for the entire object file.
65 int unix_bb_a
, unix_bb_b
, unix_bb_c
;
66 int unix_bb_d
, unix_bb_e
, unix_bb_f
, unix_bb_g
;
67 processorid_t bb_last_who
;
72 __bb_init_func(struct bb_info
*bb
)
90 * Raise the pil and try to get the lock.
97 if (!lock_try(&unix_bb_lock
)) {
99 * If we're on the interrrupt stack, we just return
100 * in case it's an NMI and we're looking at a deadlock
101 * situation. Otherwise, we use lock_set_spl()
106 if (CPU_ON_INTR(CPU
)) {
117 lock_set_spl(&unix_bb_lock
, ipltospl(NMI_LEVEL
), &s
);
121 bb_last_who
= CPU
->cpu_id
;
122 bb_last_where
= bb
->bb_filename
;
126 * We've got the lock. If we have not been initialized, add us
127 * to the list and set the initialized flag.
130 if (bb
->bb_next
== 0) {
133 if (bb
->bb_initflag
== 0) {
136 bb
->bb_next
= unix_bb_list
;
143 lock_clear_splx(&unix_bb_lock
, s
);