xref: /titanic_41/usr/src/cmd/mdb/sparc/v9/kmdb/kaif_asmutil.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _KAIF_ASMUTIL_H
28 #define	_KAIF_ASMUTIL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include "mach_asmutil.h"
37 
38 #ifdef _ASM
39 
40 /*
41  * Each cpusave buffer has an area set aside for a ring buffer of breadcrumbs.
42  * The following macros manage the buffer.
43  */
44 
45 /* Advance the ring buffer */
46 #define	ADVANCE_CRUMB_POINTER(cpusave, tmp1, tmp2) 	\
47 	ld	[cpusave + KRS_CURCRUMBIDX], tmp1;	\
48 	cmp	tmp1, KAIF_NCRUMBS - 1;			\
49 	bge	1f;					\
50 	/* Advance the pointer and index */		\
51 	add	tmp1, 1, tmp1;				\
52 	st	tmp1, [cpusave + KRS_CURCRUMBIDX];	\
53 	ldx	[cpusave + KRS_CURCRUMB], tmp1;		\
54 	ba	2f;					\
55 	add	tmp1, KRM_SIZE, tmp1;			\
56 1:	/* Reset the pointer and index */		\
57 	st	%g0, [cpusave + KRS_CURCRUMBIDX];	\
58 	add	cpusave, KRS_CRUMBS, tmp1;		\
59 2:	stx	tmp1, [cpusave + KRS_CURCRUMB];		\
60 	/* Clear the new crumb */			\
61 	set	KRM_SIZE, tmp2;				\
62 3:	subcc	tmp2, 8, tmp2;				\
63 	bg	3b;					\
64 	stx	%g0, [tmp1 + tmp2]
65 
66 /* Set a value in the current breadcrumb buffer */
67 #define	ADD_CRUMB(cpusave, offset, value, tmp) 		\
68 	ldx	[cpusave + KRS_CURCRUMB], tmp;		\
69 	stx	value, [tmp + offset];
70 
71 #define	ADD_CRUMB_CONST(cpusave, offset, value, tmp1, tmp2) \
72 	ldx	[cpusave + KRS_CURCRUMB], tmp1;		\
73 	mov	value, tmp2;				\
74 	stx	tmp2, [tmp1 + offset]
75 
76 #define	ADD_CRUMB_FLAG(cpusave, flag, tmp1, tmp2, tmp3) \
77 	ldx	[cpusave + KRS_CURCRUMB], tmp1;		\
78 	ld	[tmp1 + KRM_FLAG], tmp2;		\
79 	set	flag, tmp3;				\
80 	or	tmp2, tmp3, tmp2;			\
81 	st	tmp2, [tmp1 + KRM_FLAG]
82 
83 #endif
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif /* _KAIF_ASMUTIL_H */
90