pcb.h revision 210780
1219820Sjeff/*-
2219820Sjeff * Copyright (c) 2003 Peter Wemm.
3219820Sjeff * Copyright (c) 1990 The Regents of the University of California.
4219820Sjeff * All rights reserved.
5219820Sjeff *
6219820Sjeff * This code is derived from software contributed to Berkeley by
7219820Sjeff * William Jolitz.
8219820Sjeff *
9219820Sjeff * Redistribution and use in source and binary forms, with or without
10219820Sjeff * modification, are permitted provided that the following conditions
11219820Sjeff * are met:
12219820Sjeff * 1. Redistributions of source code must retain the above copyright
13219820Sjeff *    notice, this list of conditions and the following disclaimer.
14219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright
15219820Sjeff *    notice, this list of conditions and the following disclaimer in the
16219820Sjeff *    documentation and/or other materials provided with the distribution.
17219820Sjeff * 4. Neither the name of the University nor the names of its contributors
18219820Sjeff *    may be used to endorse or promote products derived from this software
19219820Sjeff *    without specific prior written permission.
20219820Sjeff *
21219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22219820Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23219820Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24219820Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25219820Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26219820Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27219820Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28219820Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29219820Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30219820Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31219820Sjeff * SUCH DAMAGE.
32219820Sjeff *
33219820Sjeff *	from: @(#)pcb.h	5.10 (Berkeley) 5/12/91
34219820Sjeff * $FreeBSD: head/sys/amd64/include/pcb.h 210780 2010-08-02 18:12:30Z jkim $
35219820Sjeff */
36219820Sjeff
37219820Sjeff#ifndef _AMD64_PCB_H_
38219820Sjeff#define _AMD64_PCB_H_
39219820Sjeff
40219820Sjeff/*
41219820Sjeff * AMD64 process control block
42219820Sjeff */
43219820Sjeff#include <machine/fpu.h>
44219820Sjeff#include <machine/segments.h>
45219820Sjeff
46219820Sjeffstruct pcb {
47219820Sjeff	register_t	pcb_r15;
48219820Sjeff	register_t	pcb_r14;
49219820Sjeff	register_t	pcb_r13;
50219820Sjeff	register_t	pcb_r12;
51219820Sjeff	register_t	pcb_rbp;
52219820Sjeff	register_t	pcb_rsp;
53219820Sjeff	register_t	pcb_rbx;
54219820Sjeff	register_t	pcb_rip;
55219820Sjeff	register_t	pcb_fsbase;
56219820Sjeff	register_t	pcb_gsbase;
57219820Sjeff	register_t	pcb_kgsbase;
58219820Sjeff	register_t	pcb_cr0;
59219820Sjeff	register_t	pcb_cr2;
60219820Sjeff	register_t	pcb_cr3;
61219820Sjeff	register_t	pcb_cr4;
62219820Sjeff	register_t	pcb_dr0;
63219820Sjeff	register_t	pcb_dr1;
64219820Sjeff	register_t	pcb_dr2;
65219820Sjeff	register_t	pcb_dr3;
66219820Sjeff	register_t	pcb_dr6;
67219820Sjeff	register_t	pcb_dr7;
68219820Sjeff
69219820Sjeff	u_long		pcb_flags;
70219820Sjeff#define	PCB_DBREGS	0x02	/* process using debug registers */
71219820Sjeff#define	PCB_KERNFPU	0x04	/* kernel uses fpu */
72219820Sjeff#define	PCB_FPUINITDONE	0x08	/* fpu state is initialized */
73219820Sjeff#define	PCB_USERFPUINITDONE 0x10 /* fpu user state is initialized */
74219820Sjeff#define	PCB_GS32BIT	0x20	/* linux gs switch */
75219820Sjeff#define	PCB_32BIT	0x40	/* process has 32 bit context (segs etc) */
76219820Sjeff#define	PCB_FULLCTX	0x80	/* full context restore on sysret */
77219820Sjeff
78219820Sjeff	uint16_t	pcb_initial_fpucw;
79219820Sjeff
80219820Sjeff	caddr_t		pcb_onfault; /* copyin/out fault recovery */
81219820Sjeff
82219820Sjeff	/* 32-bit segment descriptor */
83219820Sjeff	struct user_segment_descriptor pcb_gs32sd;
84219820Sjeff	/* local tss, with i/o bitmap; NULL for common */
85219820Sjeff	struct amd64tss *pcb_tssp;
86219820Sjeff	struct	savefpu	*pcb_save;
87219820Sjeff	char		pcb_full_iret;
88219820Sjeff
89219820Sjeff	struct region_descriptor pcb_gdt;
90219820Sjeff	struct region_descriptor pcb_idt;
91219820Sjeff	struct region_descriptor pcb_ldt;
92219820Sjeff	uint16_t	pcb_tr;
93219820Sjeff
94219820Sjeff	struct	savefpu pcb_user_save;
95219820Sjeff};
96219820Sjeff
97219820Sjeff#ifdef _KERNEL
98219820Sjeffstruct trapframe;
99219820Sjeff
100219820Sjeffvoid	makectx(struct trapframe *, struct pcb *);
101219820Sjeffint	savectx(struct pcb *);
102219820Sjeff#endif
103219820Sjeff
104219820Sjeff#endif /* _AMD64_PCB_H_ */
105219820Sjeff