pcb.h revision 208833
14Srgrimes/*-
2122296Speter * Copyright (c) 2003 Peter Wemm.
34Srgrimes * Copyright (c) 1990 The Regents of the University of California.
44Srgrimes * All rights reserved.
54Srgrimes *
64Srgrimes * This code is derived from software contributed to Berkeley by
74Srgrimes * William Jolitz.
84Srgrimes *
94Srgrimes * Redistribution and use in source and binary forms, with or without
104Srgrimes * modification, are permitted provided that the following conditions
114Srgrimes * are met:
124Srgrimes * 1. Redistributions of source code must retain the above copyright
134Srgrimes *    notice, this list of conditions and the following disclaimer.
144Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
154Srgrimes *    notice, this list of conditions and the following disclaimer in the
164Srgrimes *    documentation and/or other materials provided with the distribution.
174Srgrimes * 4. Neither the name of the University nor the names of its contributors
184Srgrimes *    may be used to endorse or promote products derived from this software
194Srgrimes *    without specific prior written permission.
204Srgrimes *
214Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
224Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
234Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
244Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
254Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
264Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
274Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
284Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
294Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
304Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
314Srgrimes * SUCH DAMAGE.
324Srgrimes *
33557Srgrimes *	from: @(#)pcb.h	5.10 (Berkeley) 5/12/91
3450477Speter * $FreeBSD: head/sys/amd64/include/pcb.h 208833 2010-06-05 15:59:59Z kib $
354Srgrimes */
364Srgrimes
37122296Speter#ifndef _AMD64_PCB_H_
38122296Speter#define _AMD64_PCB_H_
39557Srgrimes
404Srgrimes/*
41122278Speter * AMD64 process control block
424Srgrimes */
43122278Speter#include <machine/fpu.h>
44168035Sjkim#include <machine/segments.h>
454Srgrimes
464Srgrimesstruct pcb {
47114349Speter	register_t	pcb_cr3;
48114349Speter	register_t	pcb_r15;
49114349Speter	register_t	pcb_r14;
50114349Speter	register_t	pcb_r13;
51114349Speter	register_t	pcb_r12;
52114349Speter	register_t	pcb_rbp;
53114349Speter	register_t	pcb_rsp;
54114349Speter	register_t	pcb_rbx;
55114349Speter	register_t	pcb_rip;
56114928Speter	register_t	pcb_fsbase;
57114928Speter	register_t	pcb_gsbase;
58177532Speter	u_long		pcb_flags;
59189411Sjhb#define	PCB_DBREGS	0x02	/* process using debug registers */
60208833Skib#define	PCB_KERNFPU	0x04	/* kernel uses fpu */
61189411Sjhb#define	PCB_FPUINITDONE	0x08	/* fpu state is initialized */
62208833Skib#define	PCB_USERFPUINITDONE 0x10 /* fpu user state is initialized */
63189411Sjhb#define	PCB_GS32BIT	0x20	/* linux gs switch */
64189411Sjhb#define	PCB_32BIT	0x40	/* process has 32 bit context (segs etc) */
65189411Sjhb#define	PCB_FULLCTX	0x80	/* full context restore on sysret */
66189411Sjhb
67125176Speter	u_int64_t	pcb_dr0;
68125176Speter	u_int64_t	pcb_dr1;
69125176Speter	u_int64_t	pcb_dr2;
70125176Speter	u_int64_t	pcb_dr3;
71125176Speter	u_int64_t	pcb_dr6;
72125176Speter	u_int64_t	pcb_dr7;
7348691Sjlemon
74208833Skib	struct	savefpu pcb_user_save;
75189423Sjhb	uint16_t	pcb_initial_fpucw;
7648691Sjlemon
77195486Skib	caddr_t		pcb_onfault; /* copyin/out fault recovery */
78168035Sjkim
79168035Sjkim	/* 32-bit segment descriptor */
80168035Sjkim	struct user_segment_descriptor	pcb_gs32sd;
81190620Skib	/* local tss, with i/o bitmap; NULL for common */
82190620Skib	struct amd64tss *pcb_tssp;
83208833Skib	struct	savefpu	*pcb_save;
84195486Skib	char		pcb_full_iret;
854Srgrimes};
864Srgrimes
87189903Sjkimstruct xpcb {
88189903Sjkim	struct pcb	xpcb_pcb;
89189903Sjkim	register_t	xpcb_cr0;
90189903Sjkim	register_t	xpcb_cr2;
91189903Sjkim	register_t	xpcb_cr4;
92189903Sjkim	register_t	xpcb_kgsbase;
93189903Sjkim	struct region_descriptor xpcb_gdt;
94189903Sjkim	struct region_descriptor xpcb_idt;
95189903Sjkim	struct region_descriptor xpcb_ldt;
96189903Sjkim	uint16_t	xpcb_tr;
97189903Sjkim};
98189903Sjkim
9955205Speter#ifdef _KERNEL
100131905Smarcelstruct trapframe;
101131905Smarcel
102131905Smarcelvoid	makectx(struct trapframe *, struct pcb *);
10392761Salfredvoid	savectx(struct pcb *);
104189903Sjkimint	savectx2(struct xpcb *);
1054Srgrimes#endif
106557Srgrimes
107122296Speter#endif /* _AMD64_PCB_H_ */
108