4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _IA32_SYS_PRIVREGS_H
28 #define _IA32_SYS_PRIVREGS_H
35 * This file describes the cpu's privileged register set, and
36 * how the machine state is saved on the stack when a trap occurs.
40 #error "non-i386 code depends on i386 privileged header!"
46 * This is NOT the structure to use for general purpose debugging;
47 * see /proc for that. This is NOT the structure to use to decode
48 * the ucontext or grovel about in a core file; see <sys/regset.h>.
53 * Extra frame for mdb to follow through high level interrupts and
54 * system traps. Set them to 0 to terminate stacktrace.
56 greg_t r_savfp
; /* a copy of %ebp */
57 greg_t r_savpc
; /* a copy of %eip */
80 #define r_r0 r_eax /* r0 for portability */
81 #define r_r1 r_edx /* r1 for portability */
82 #define r_fp r_ebp /* system frame pointer */
83 #define r_sp r_uesp /* user stack pointer */
84 #define r_pc r_eip /* user's instruction pointer */
85 #define r_ps r_efl /* user's EFLAGS */
87 #define GREG_NUM 8 /* Number of regs between %edi and %eax */
90 #define lwptoregs(lwp) ((struct regs *)((lwp)->lwp_regs))
97 #include <sys/machprivregs.h>
100 * Save current frame on the stack. Uses %eax.
102 #define __FRAME_PUSH \
104 movl REGOFF_EIP(%esp), %eax; \
105 movl %eax, REGOFF_SAVPC(%esp); \
106 movl %ebp, REGOFF_SAVFP(%esp);
109 * Save segment registers on the stack.
111 #define __SEGREGS_PUSH \
113 movw %ds, 12(%esp); \
119 * Load segment register with kernel selectors.
120 * %gs must be the last one to be set to make the
121 * check in cmnint valid.
123 #define __SEGREGS_LOAD_KERNEL \
124 movw $KDS_SEL, %cx; \
127 movw $KFS_SEL, %cx; \
128 movw $KGS_SEL, %dx; \
133 * Restore segment registers off the stack.
135 * NOTE THE ORDER IS VITAL!
137 * Also note the subtle interdependency with kern_gpfault()
138 * that needs to disassemble these instructions to diagnose
139 * what happened when things (like bad segment register
140 * values) go horribly wrong.
142 #define __SEGREGS_POP \
146 movw 12(%esp), %ds; \
150 * Macros for saving all registers necessary on interrupt entry,
151 * and restoring them on exit.
158 cmpw $KGS_SEL, REGOFF_GS(%esp); \
160 movl $0, REGOFF_SAVFP(%esp); \
161 __SEGREGS_LOAD_KERNEL \
166 addl $8, %esp; /* get TRAPNO and ERR off the stack */
168 #define INTR_POP_USER \
169 addl $8, %esp; /* get extra frame off the stack */ \
173 #define INTR_POP_KERNEL \
174 addl $24, %esp; /* skip extra frame and segment registers */ \
177 * Macros for saving all registers necessary on system call entry,
178 * and restoring them on exit.
180 #define SYSCALL_PUSH \
188 movl %ecx, REGOFF_EFL(%esp); \
189 movl $0, REGOFF_SAVPC(%esp); \
190 movl $0, REGOFF_SAVFP(%esp); \
191 __SEGREGS_LOAD_KERNEL; \
193 #define SYSENTER_PUSH \
198 movl $0, REGOFF_SAVPC(%esp); \
199 movl $0, REGOFF_SAVFP(%esp); \
200 __SEGREGS_LOAD_KERNEL
202 #define SYSCALL_POP \
205 #endif /* _MACHDEP */
208 * This is used to set eflags to known values at the head of an
209 * interrupt gate handler, i.e. interrupts are -already- disabled.
211 #define INTGATE_INIT_KERNEL_FLAGS \
217 #include <sys/controlregs.h>
219 /* Control register layout for panic dump */
225 #define CREG_TASKR 18
231 #if !defined(_ASM) && defined(_INT64_TYPE)
233 typedef uint64_t creg64_t
;
247 extern void getcregs(struct cregs
*);
250 #endif /* !_ASM && _INT64_TYPE */
256 #endif /* !_IA32_SYS_PRIVREGS_H */