/* * 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 * or http://www.opensolaris.org/os/licensing. * 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. */ #ifndef _SYS_TRAPTRACE_H #define _SYS_TRAPTRACE_H #pragma ident "%Z%%M% %I% %E% SMI" #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 */ #define TRAP_TSIZE (2 * PAGESIZE) /* default size is two pages */ #ifndef _ASM struct trap_trace_record { uint16_t tt_tl; uint16_t tt_tt; uintptr_t tt_tpc; uint64_t tt_tstate; uint64_t tt_tick; uintptr_t tt_sp; uintptr_t tt_tr; uintptr_t tt_f1; uintptr_t tt_f2; uintptr_t tt_f3; uintptr_t tt_f4; }; #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 { caddr_t vaddr_base; /* virtual address of top of buffer */ uint64_t paddr_base; /* physical address of buffer */ uint_t last_offset; /* to "know" what trace completed */ uint_t offset; /* current index into buffer (bytes) */ uint_t limit; /* upper limit on index */ uchar_t asi; /* cache for real asi */ } d; char cache_linesize[64]; } TRAP_TRACE_CTL; #ifdef _KERNEL extern TRAP_TRACE_CTL trap_trace_ctl[]; /* allocated in locore.s */ 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 caddr_t ttrace_buf; /* kmem64 buffer */ 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_FREEZE trap_freeze = 1; #define TRAPTRACE_UNFREEZE trap_freeze = 0; #else /* _ASM */ #include /* * Offsets of words in trap_trace_ctl: */ /* * XXX This should be done with genassym */ #define TRAPTR_VBASE 0 /* virtual address of buffer */ #define TRAPTR_LAST_OFFSET 16 /* last completed trace entry */ #define TRAPTR_OFFSET 20 /* next trace entry pointer */ #define TRAPTR_LIMIT 24 /* pointer past end of buffer */ #define TRAPTR_PBASE 8 /* start of buffer */ #define TRAPTR_ASIBUF 28 /* cache of current asi */ #define TRAPTR_SIZE_SHIFT 6 /* shift count -- per CPU indexing */ #define TRAPTR_SIZE (1<