xref: /titanic_50/usr/src/uts/intel/sys/debugreg.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1999 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_DEBUGREG_H
31*7c478bd9Sstevel@tonic-gate #define	_SYS_DEBUGREG_H
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
36*7c478bd9Sstevel@tonic-gate extern "C" {
37*7c478bd9Sstevel@tonic-gate #endif
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate /*
40*7c478bd9Sstevel@tonic-gate  * Specify masks for accessing the i386 debug registers.
41*7c478bd9Sstevel@tonic-gate  */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*
44*7c478bd9Sstevel@tonic-gate  * The debug registers are found in an array (debugreg) in the u block.
45*7c478bd9Sstevel@tonic-gate  * On the i386, there are 4 registers to specify linear addresses.
46*7c478bd9Sstevel@tonic-gate  * dr4 and dr5 are reserved.
47*7c478bd9Sstevel@tonic-gate  */
48*7c478bd9Sstevel@tonic-gate #define	DR_FIRSTADDR	0	/* u.u_debugreg[DR_FIRSTADDR] */
49*7c478bd9Sstevel@tonic-gate #define	DR_LASTADDR	3	/* u.u_debugreg[DR_LASTADDR]  */
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /*
52*7c478bd9Sstevel@tonic-gate  * The debug status is found in dr6 after a debug trap.
53*7c478bd9Sstevel@tonic-gate  */
54*7c478bd9Sstevel@tonic-gate #define	DR_STATUS	6	/* u.u_debugreg[DR_STATUS] */
55*7c478bd9Sstevel@tonic-gate #define	DR_TRAP0	0x1	/* Trap from debug register #0 */
56*7c478bd9Sstevel@tonic-gate #define	DR_TRAP1	0x2	/* Trap from debug register #1 */
57*7c478bd9Sstevel@tonic-gate #define	DR_TRAP2	0x4	/* Trap from debug register #2 */
58*7c478bd9Sstevel@tonic-gate #define	DR_TRAP3	0x8	/* Trap from debug register #3 */
59*7c478bd9Sstevel@tonic-gate #define	DR_ICEALSO	0x2000	/* Flag bit reserved for in-circuit-emulator */
60*7c478bd9Sstevel@tonic-gate #define	DR_SINGLESTEP	0x4000	/* Trap resulting from the single-step flag */
61*7c478bd9Sstevel@tonic-gate #define	DR_TASKSWITCH	0x8000	/* Trap resulting from a task-switch */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * dr7 controls the rest of the debug registers.
65*7c478bd9Sstevel@tonic-gate  * use shifts and masks because arrays of fields tend to get aligned.
66*7c478bd9Sstevel@tonic-gate  * For example,
67*7c478bd9Sstevel@tonic-gate  *    dr7 & DR_LOCAL_ENABLE_MASK
68*7c478bd9Sstevel@tonic-gate  *    dr7 >> (DR_LOCAL_ENABLE_SHIFT + r# * DR_ENABLE_SIZE) & 0x1
69*7c478bd9Sstevel@tonic-gate  *    dr7 >> (DR_CONTROL_SHIFT + r# * DR_CONTROL_SIZE) & DR_RW_MASK
70*7c478bd9Sstevel@tonic-gate  * Note that the GLOBAL bits below and always turned off by the kernel.
71*7c478bd9Sstevel@tonic-gate  */
72*7c478bd9Sstevel@tonic-gate #define	DR_CONTROL		7	/* u.u_debugreg[DR_CONTROL] */
73*7c478bd9Sstevel@tonic-gate #define	DR_LOCAL_ENABLE_MASK	0x55	/* Enable all 4 regs for ldt addrs */
74*7c478bd9Sstevel@tonic-gate #define	DR_GLOBAL_ENABLE_MASK	0xAA	/* Enable all 4 regs for gdt addrs */
75*7c478bd9Sstevel@tonic-gate #define	DR_CONTROL_RESERVED	0xFC00	/* Bits reserved by Intel */
76*7c478bd9Sstevel@tonic-gate #define	DR_LOCAL_SLOWDOWN	0x100	/* Slow the pipeline for ldt addrs */
77*7c478bd9Sstevel@tonic-gate #define	DR_GLOBAL_SLOWDOWN	0x200	/* Slow the pipeline for gdt addrs */
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate #define	DR_LOCAL_ENABLE_SHIFT	0	/* Additional shift: local enable  */
80*7c478bd9Sstevel@tonic-gate #define	DR_GLOBAL_ENABLE_SHIFT	1	/* Additional shift: global enable */
81*7c478bd9Sstevel@tonic-gate #define	DR_ENABLE_SIZE		2	/* 2 enable bits per register  */
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate #define	DR_TRAPS	(DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)
84*7c478bd9Sstevel@tonic-gate #define	DR_ENABLE0	0x03	/* Local or Global enable of trap 0 */
85*7c478bd9Sstevel@tonic-gate #define	DR_ENABLE1	0x0C	/* Local or Global enable of trap 1 */
86*7c478bd9Sstevel@tonic-gate #define	DR_ENABLE2	0x30	/* Local or Global enable of trap 2 */
87*7c478bd9Sstevel@tonic-gate #define	DR_ENABLE3	0xC0	/* Local or Global enable of trap 3 */
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate #define	DR_CONTROL_SHIFT	16	/* Shift to register control bits */
90*7c478bd9Sstevel@tonic-gate #define	DR_CONTROL_SIZE		4	/* 4 control bits per register */
91*7c478bd9Sstevel@tonic-gate #define	DR_RW_MASK		0x3	/* Two bits specify r/w access */
92*7c478bd9Sstevel@tonic-gate #define	DR_RW_EXECUTE		0x0	/* Settings for the read/write mask */
93*7c478bd9Sstevel@tonic-gate #define	DR_RW_WRITE		0x1
94*7c478bd9Sstevel@tonic-gate #define	DR_RW_IO_RW		0x2	/* I/O space on Pentium and beyond */
95*7c478bd9Sstevel@tonic-gate #define	DR_RW_READ		0x3
96*7c478bd9Sstevel@tonic-gate #define	DR_LEN_MASK		0xC	/* Two bits specify data length */
97*7c478bd9Sstevel@tonic-gate #define	DR_LEN_1		0x0	/* Settings for data length */
98*7c478bd9Sstevel@tonic-gate #define	DR_LEN_2		0x4
99*7c478bd9Sstevel@tonic-gate #define	DR_LEN_4		0xC
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
102*7c478bd9Sstevel@tonic-gate }
103*7c478bd9Sstevel@tonic-gate #endif
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_DEBUGREG_H */
106