traptrace.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 (c) 1990-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#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.sun4m.
*
* Trap trace records are 8 words, consisting of the %tbr, %psr, %pc, %sp,
* %g7 (THREAD_REG), and up to three other words.
*
* Auxilliary entries (not of just a trap), have obvious non-%tbr values in
* the first word.
*/
#define TRAP_ENT_TBR 0x00
#define TRAP_ENT_PSR 0x04
#define TRAP_ENT_PC 0x08
#define TRAP_ENT_SP 0x0c
#define TRAP_ENT_G7 0x10
#define TRAP_ENT_TR 0x14
#define TRAP_ENT_F1 0x18
#define TRAP_ENT_F2 0x1c
#define TRAP_ENT_SIZE 32
/*
* Trap tracing buffer header.
*/
/*
* Example buffer header in locore.s:
*
* trap_trace_ctl:
* .word trap_tr0 ! next CPU 0
* .word trap_tr0 ! first
* .word trap_tr0 + TRAP_TSIZE ! limit
* .word 0 ! junk for alignment of prom dump
*
* .word trap_tr1 ! next CPU 1
* .word trap_tr1 ! first
* .word trap_tr1 + TRAP_TSIZE ! limit
* .word 0 ! junk for alignment of prom dump
*
* .word trap_tr2 ! next CPU 2
* .word trap_tr2 ! first
* .word trap_tr2 + TRAP_TSIZE ! limit
* .word 0 ! junk for alignment of prom dump
*
* .word trap_tr3 ! next CPU 3
* .word trap_tr3 ! first
* .word trap_tr3 + TRAP_TSIZE ! limit
* .word 0 ! junk for alignment of prom dump
* .align 16
*
* Offsets of words in trap_trace_ctl:
*/
#define TRAPTR_NEXT 0 /* next trace entry pointer */
#ifdef _ASM
/*
* TRACE_PTR(ptr, scr1) - get trap trace entry pointer.
* ptr is the register to receive the trace pointer.
* reg is a different register to be used as scratch.
*/
bz .+0xc; \
/*
* TRACE_NEXT(ptr, scr1, scr2) - advance the trap trace pointer.
* ptr is the register holding the current trace pointer (from TRACE_PTR).
* scr1, and scr2 are scratch registers (different from ptr).
*/
/* CSTYLED */ \
bgeu,a .+8; \
/* CSTYLED */ \
bz,a .+8; \
/*
* Macro to restore the %psr (thus enabling traps) while preserving
* cpu_base_spl. Note that the actual write to the %psr is broken into
* two writes to avoid the IU bug (one cannot raise PIL and enable traps
* in a single write to the %psr).
*/
/* CSTYLED */ \
bg,a 9f; \
nop; \
nop; \
/*
* Trace macro for underflow or overflow trap handler
*/
#ifdef TRAPTRACE
#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 TBR, and the low-order bits indicate
* which precise entry is being made.
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_TRAPTRACE_H */