17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*a35baf17Shyw  * Common Development and Distribution License (the "License").
6*a35baf17Shyw  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*a35baf17Shyw  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _KAIF_REGS_H
277c478bd9Sstevel@tonic-gate #define	_KAIF_REGS_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifndef _ASM
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate #include <sys/regset.h>
347c478bd9Sstevel@tonic-gate #include <sys/stack.h>
357c478bd9Sstevel@tonic-gate #include <sys/kdi_impl.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <mdb/mdb_kreg_impl.h>
387c478bd9Sstevel@tonic-gate #include <mdb/mdb_target.h>
397c478bd9Sstevel@tonic-gate #include <mdb/mdb.h>
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef __cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #define	KAIF_CPU_STKSZ	((MINFRAME64 * 20) + STACK_ALIGN64)
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #define	KAIF_NCRUMBS	5
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_SRC_OBP	1
517c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_SRC_IVEC	2
527c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_SRC_MAIN	3
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_MAIN_OBPWAPT	0x01
557c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_MAIN_OBPPENT	0x02
567c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_MAIN_NORMAL	0x04
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_IVEC_REENTER	0x08
597c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_IVEC_INOBP		0x10
607c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_IVEC_NORMAL	0x20
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_OBP_NORMAL		0x40
637c478bd9Sstevel@tonic-gate #define	KAIF_CRUMB_F_OBP_REVECT		0x80
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #ifndef _ASM
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * We maintain a ring buffer of bread crumbs for debugging purposes.  The
697c478bd9Sstevel@tonic-gate  * current buffer pointer is advanced along the ring with each intercepted
707c478bd9Sstevel@tonic-gate  * trap (debugger entry, invalid memory access, etc).  The structure must have a
717c478bd9Sstevel@tonic-gate  * size equal to a multiple of 8.
727c478bd9Sstevel@tonic-gate  */
737c478bd9Sstevel@tonic-gate typedef struct kaif_crumb {
747c478bd9Sstevel@tonic-gate 	uint64_t krm_src;
757c478bd9Sstevel@tonic-gate 	uint64_t krm_pc;
767c478bd9Sstevel@tonic-gate 	uint64_t krm_tt;
777c478bd9Sstevel@tonic-gate 	uint32_t krm_flag;
787c478bd9Sstevel@tonic-gate 	uint32_t krm_pad;
797c478bd9Sstevel@tonic-gate } kaif_crumb_t;
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /* Keep in sync with kaif_regs.in */
827c478bd9Sstevel@tonic-gate typedef struct kaif_cpusave {
837c478bd9Sstevel@tonic-gate 	mdb_tgt_gregset_t	krs_gregs;	/* Saved registers */
847c478bd9Sstevel@tonic-gate 	struct rwindow		*krs_rwins;	/* Saved register windows */
857c478bd9Sstevel@tonic-gate 	kfpu_t			krs_fpregs;	/* Saved FP registers */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 	kreg_t			krs_tstate;	/* Saved %tstate */
887c478bd9Sstevel@tonic-gate 	kreg_t			krs_mmu_pcontext; /* Context # at kmdb entry */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	uint_t			krs_cpu_state;	/* KAIF_CPU_STATE_* */
917c478bd9Sstevel@tonic-gate 	uint_t			krs_cpu_flushed; /* Have caches been flushed? */
927c478bd9Sstevel@tonic-gate 	uint_t			krs_cpu_id;	/* this CPU's ID */
93*a35baf17Shyw 	uint_t			krs_cpu_acked;	/* for slave to ack master */
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	uint64_t		krs_lsucr_save;	/* LSUCR for wapt step */
967c478bd9Sstevel@tonic-gate 	uint32_t		krs_instr_save;	/* OBP instr for wapt step */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate 	/* Bread crumb ring buffer */
997c478bd9Sstevel@tonic-gate 	uint_t			krs_curcrumbidx; /* Current krs_crumbs idx */
1007c478bd9Sstevel@tonic-gate 	kaif_crumb_t		*krs_curcrumb;	/* Current crumb */
1017c478bd9Sstevel@tonic-gate 	kaif_crumb_t		krs_crumbs[KAIF_NCRUMBS];  /* Crumbs */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	char			krs_cpustack[KAIF_CPU_STKSZ];
1047c478bd9Sstevel@tonic-gate } kaif_cpusave_t;
1057c478bd9Sstevel@tonic-gate #endif
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1087c478bd9Sstevel@tonic-gate }
1097c478bd9Sstevel@tonic-gate #endif
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #endif /* _KAIF_REGS_H */
112