4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * Generic x86 CPU MCA poller - support functions for native and xpv pollers.
31 #include <sys/types.h>
32 #include <sys/sysmacros.h>
34 #include <sys/cmn_err.h>
38 uint_t gcpu_poll_trace_nent
= 100;
41 int gcpu_poll_trace_always
= 1;
43 int gcpu_poll_trace_always
= 0;
47 gcpu_poll_trace(gcpu_poll_trace_ctl_t
*ptc
, uint8_t what
, uint8_t nerr
)
49 gcpu_poll_trace_t
*pt
;
52 DTRACE_PROBE2(gcpu__mca__poll__trace
, uint32_t, what
, uint32_t, nerr
);
54 if (ptc
->mptc_tbufs
== NULL
)
55 return; /* poll trace buffer is disabled */
57 next
= (ptc
->mptc_curtrace
+ 1) % gcpu_poll_trace_nent
;
58 pt
= &ptc
->mptc_tbufs
[next
];
63 pt
->mpt_nerr
= MIN(nerr
, UINT8_MAX
);
65 pt
->mpt_when
= gethrtime_waitfree();
66 ptc
->mptc_curtrace
= next
;
70 gcpu_poll_trace_init(gcpu_poll_trace_ctl_t
*ptc
)
72 gcpu_poll_trace_t
*tbufs
= NULL
;
74 if (gcpu_poll_trace_always
) {
75 tbufs
= kmem_zalloc(sizeof (gcpu_poll_trace_t
) *
76 gcpu_poll_trace_nent
, KM_SLEEP
);
79 ptc
->mptc_tbufs
= tbufs
;
80 ptc
->mptc_curtrace
= 0;