traptrace.h revision 023e71de9e5670cebc23dd51162833661d3d2d3b
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_TRAPTRACE_H
#define _SYS_TRAPTRACE_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Trap tracing. If TRAPTRACE is defined, every trap records info
* in a circular buffer. Define TRAPTRACE in Makefile.$ARCH.
*
* Trap trace records are TRAP_ENT_SIZE bytes, consisting of the
* %tick, %tl, %tt, %tpc, %tstate, %sp, and a few other words:
*
* struct trap_trace_record {
* ushort_t tl, tt;
* long pc;
* int64_t tstate, tick;
* long sp, tr, f1, f2, f3, f4;
* };
*
* Note that for UltraSparc III and beyond %stick is used in place of %tick
* unless compiled with TRAPTRACE_FORCE_TICK.
*
* Auxilliary entries (not of just a trap), have obvious non-%tt values in
* the TRAP_ENT_TT field
*/
#ifndef _ASM
struct trap_trace_record {
};
sizeof (struct trap_trace_record))
#else
#endif
#define HTRAP_TSIZE 0
/*
* Trap tracing buffer header.
*/
#ifndef _ASM
/*
* Example buffer header stored in locore.s:
*
* (the actual implementation could be .skip TRAPTR_SIZE*NCPU)
*/
typedef union {
struct {
} d;
char cache_linesize[64];
#ifdef _KERNEL
extern int trap_trace_bufsize; /* default buffer size */
extern char trap_tr0[]; /* prealloc buf for boot cpu */
extern int trap_freeze; /* freeze the trap trace */
extern int ttrace_index; /* index used */
extern size_t calc_traptrace_sz(void);
extern void mach_htraptrace_setup(int);
extern void mach_htraptrace_configure(int);
extern void mach_htraptrace_cleanup(int);
#endif
/*
* freeze the trap trace
*/
#define TRAPTRACE_UNFREEZE trap_freeze = 0;
#else /* _ASM */
#include <sys/machthread.h>
/*
* Offsets of words in trap_trace_ctl:
*/
/*
* XXX This should be done with genassym
*/
#define TRAPTR_VBASE 0 /* virtual address of buffer */
/*
* Use new %stick register for UltraSparc III and beyond for
* sane debugging of mixed speed CPU systems. Use TRAPTRACE_FORCE_TICK
* for finer granularity on same speed systems.
*
* Note the label-less branches used due to contraints of where
* and when trap trace macros are used.
*/
#ifdef TRAPTRACE_FORCE_TICK
#else
/* CSTYLED */ \
#endif
/*
* TRACE_PTR(ptr, scr1) - get trap trace entry physical pointer.
* ptr is the register to receive the trace pointer.
* scr1 is a different register to be used as scratch.
* TRACING now needs a known processor state. Hence the assertion.
* NOTE: this caches and resets %asi
*/
/* CSTYLED */ \
/* CSTYLED */ \
/* CSTYLED */ \
/* CSTYLED */ \
/*
* TRACE_NEXT(scr1, scr2, scr3) - advance the trap trace pointer.
* scr1, scr2, scr3 are scratch registers.
* This routine will skip updating the trap pointers if the
* global freeze register is set (e.g. in panic).
* (we also restore the asi register)
*/
/* CSTYLED */ \
/*
* macro to save %tl to trap trace record at addr
*/
/*
* macro to save tl to trap trace record at addr
*/
/*
* dummy macro
*/
/*
* Trace macro for sys_trap return entries:
* prom_rtt, priv_rtt, and user_rtt
* %l7 - regs
* %l6 - trap %pil for prom_rtt and priv_rtt; THREAD_REG for user_rtt
*/
/*
* Trace macro for spill and fill trap handlers
* tl and tt fields indicate which spill handler is entered
*/
#ifdef TRAPTRACE
#define SYSTRAP_TT 0x1300
#else /* TRAPTRACE */
#endif /* TRAPTRACE */
#endif /* _ASM */
/*
* Trap trace codes used in place of a %tbr value when more than one
* entry is made by a trap. The general scheme is that the trap-type is
* in the same position as in the TT, and the low-order bits indicate
* which precise entry is being made.
*/
#define TT_F32_SN0 0x1084
#define TT_F64_SN0 0x1088
#define TT_F32_NT0 0x1094
#define TT_F64_NT0 0x1098
#define TT_F32_SO0 0x10A4
#define TT_F64_SO0 0x10A8
#define TT_F32_FN0 0x10C4
#define TT_F64_FN0 0x10C8
#define TT_F32_SN1 0x1284
#define TT_F64_SN1 0x1288
#define TT_F32_NT1 0x1294
#define TT_F64_NT1 0x1298
#define TT_F32_SO1 0x12A4
#define TT_F64_SO1 0x12A8
#define TT_F32_FN1 0x12C4
#define TT_F64_FN1 0x12C8
#ifdef __cplusplus
}
#endif
#endif /* _SYS_TRAPTRACE_H */