privregs.h revision ddece0baf7ff3a228bcd106c2bb2303ac0c9af89
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _AMD64_SYS_PRIVREGS_H
#define _AMD64_SYS_PRIVREGS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* This file describes the cpu's privileged register set, and
* how the machine state is saved on the stack when a trap occurs.
*/
#if !defined(__amd64)
#error "non-amd64 code depends on amd64 privileged header!"
#endif
#ifndef _ASM
/*
* This is NOT the structure to use for general purpose debugging;
* see /proc for that. This is NOT the structure to use to decode
*/
struct regs {
/*
* Extra frame for mdb to follow through high level interrupts and
* system traps. Set them to 0 to terminate stacktrace.
*/
/*
* fsbase and gsbase are sampled on every exception in DEBUG kernels
* only. They remain in the non-DEBUG kernel to avoid any flag days.
*/
/*
* (the rest of these are defined by the hardware)
*/
};
#ifdef _KERNEL
#endif /* _KERNEL */
#else /* !_ASM */
#if defined(_MACHDEP)
#include <sys/machprivregs.h>
#ifdef DEBUG
#define __SAVE_BASES \
rdmsr; \
rdmsr; \
#else
#define __SAVE_BASES
#endif
/*
* Create a struct regs on the stack suitable for an
* interrupt trap.
*
* Assumes that the trap handler has already pushed an
* appropriate r_err and r_trapno
*/
#define __SAVE_REGS \
#define __RESTORE_REGS \
/*
* Push register state onto the stack. If we've
* interrupted userland, do a swapgs as well.
*/
#define INTR_PUSH \
__SAVE_REGS; \
je 6f; \
SWAPGS; \
6: CLEAN_CS
#define INTR_POP \
je 5f; \
je 8f; \
5: SWAPGS; \
#define USER_POP \
SWAPGS; \
#define USER32_POP \
SWAPGS; \
#define DFTRAP_PUSH \
#endif /* _MACHDEP */
/*
* Used to set rflags to known values at the head of an
* interrupt gate handler, i.e. interrupts are -already- disabled.
*/
#define INTGATE_INIT_KERNEL_FLAGS \
#endif /* !_ASM */
#include <sys/controlregs.h>
{
"movq %%cr8, %0"
: "=r" (value));
return (value);
}
{
"movq %0, %%cr8"
: /* no output */
: "r" (value));
}
#else
#endif /* !defined(__lint) && defined(__GNUC__) */
#endif /* _KERNEL && !_ASM */
/* Control register layout for panic dump */
#define CREGSZ 0x68
#define CREG_GDT 0
#define CREG_IDT 0x10
#define CREG_LDT 0x20
#define CREG_TASKR 0x28
#define CREG_CR0 0x30
#define CREG_CR2 0x38
#define CREG_CR3 0x40
#define CREG_CR4 0x48
#define CREG_CR8 0x50
#define CREG_KGSBASE 0x58
#define CREG_EFER 0x60
#if !defined(_ASM) && defined(_INT64_TYPE)
struct cregs {
};
#if defined(_KERNEL)
#endif /* _KERNEL */
#endif /* !_ASM && _INT64_TYPE */
#ifdef __cplusplus
}
#endif
#endif /* !_AMD64_SYS_PRIVREGS_H */