xref: /netbsd-src/sys/arch/amd64/include/pcb.h (revision 5d43782cf097e6c99e4b112d64060ceed67e03cf)
1*5d43782cSmaxv /*	$NetBSD: pcb.h,v 1.32 2020/03/17 17:18:49 maxv Exp $	*/
281918bf8Sfvdl 
3d3526213Smaxv /*
481918bf8Sfvdl  * Copyright (c) 1998 The NetBSD Foundation, Inc.
581918bf8Sfvdl  * All rights reserved.
681918bf8Sfvdl  *
781918bf8Sfvdl  * This code is derived from software contributed to The NetBSD Foundation
881918bf8Sfvdl  * by Charles M. Hannum.
981918bf8Sfvdl  *
1081918bf8Sfvdl  * Redistribution and use in source and binary forms, with or without
1181918bf8Sfvdl  * modification, are permitted provided that the following conditions
1281918bf8Sfvdl  * are met:
1381918bf8Sfvdl  * 1. Redistributions of source code must retain the above copyright
1481918bf8Sfvdl  *    notice, this list of conditions and the following disclaimer.
1581918bf8Sfvdl  * 2. Redistributions in binary form must reproduce the above copyright
1681918bf8Sfvdl  *    notice, this list of conditions and the following disclaimer in the
1781918bf8Sfvdl  *    documentation and/or other materials provided with the distribution.
1881918bf8Sfvdl  *
1981918bf8Sfvdl  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2081918bf8Sfvdl  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2181918bf8Sfvdl  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2281918bf8Sfvdl  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2381918bf8Sfvdl  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2481918bf8Sfvdl  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2581918bf8Sfvdl  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2681918bf8Sfvdl  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2781918bf8Sfvdl  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2881918bf8Sfvdl  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2981918bf8Sfvdl  * POSSIBILITY OF SUCH DAMAGE.
3081918bf8Sfvdl  */
3181918bf8Sfvdl 
32d3526213Smaxv /*
3381918bf8Sfvdl  * Copyright (c) 1990 The Regents of the University of California.
3481918bf8Sfvdl  * All rights reserved.
3581918bf8Sfvdl  *
3681918bf8Sfvdl  * This code is derived from software contributed to Berkeley by
3781918bf8Sfvdl  * William Jolitz.
3881918bf8Sfvdl  *
3981918bf8Sfvdl  * Redistribution and use in source and binary forms, with or without
4081918bf8Sfvdl  * modification, are permitted provided that the following conditions
4181918bf8Sfvdl  * are met:
4281918bf8Sfvdl  * 1. Redistributions of source code must retain the above copyright
4381918bf8Sfvdl  *    notice, this list of conditions and the following disclaimer.
4481918bf8Sfvdl  * 2. Redistributions in binary form must reproduce the above copyright
4581918bf8Sfvdl  *    notice, this list of conditions and the following disclaimer in the
4681918bf8Sfvdl  *    documentation and/or other materials provided with the distribution.
47aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
4881918bf8Sfvdl  *    may be used to endorse or promote products derived from this software
4981918bf8Sfvdl  *    without specific prior written permission.
5081918bf8Sfvdl  *
5181918bf8Sfvdl  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5281918bf8Sfvdl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5381918bf8Sfvdl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5481918bf8Sfvdl  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5581918bf8Sfvdl  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5681918bf8Sfvdl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5781918bf8Sfvdl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5881918bf8Sfvdl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5981918bf8Sfvdl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6081918bf8Sfvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6181918bf8Sfvdl  * SUCH DAMAGE.
6281918bf8Sfvdl  *
6381918bf8Sfvdl  *	@(#)pcb.h	5.10 (Berkeley) 5/12/91
6481918bf8Sfvdl  */
6581918bf8Sfvdl 
6681918bf8Sfvdl /*
6781918bf8Sfvdl  * XXXfvdl these copyrights don't really match anymore
6881918bf8Sfvdl  */
6981918bf8Sfvdl 
7081918bf8Sfvdl #ifndef _AMD64_PCB_H_
7181918bf8Sfvdl #define _AMD64_PCB_H_
7281918bf8Sfvdl 
73433b5ddeSmrg #ifdef __x86_64__
74433b5ddeSmrg 
758b623c15Sdsl #include <x86/cpu_extended_state.h>
76988eb7edSkamil #include <amd64/reg.h>
7781918bf8Sfvdl 
7881918bf8Sfvdl #define	NIOPORTS	1024		/* # of ports we allow to be mapped */
7981918bf8Sfvdl 
80*5d43782cSmaxv /*
81*5d43782cSmaxv  * IMPORTANT NOTE: this structure, including the variable-sized FPU state at
82*5d43782cSmaxv  * the end, must fit within one page.
83*5d43782cSmaxv  */
8481918bf8Sfvdl struct pcb {
858f2e8760Schristos 	int	  pcb_flags;
864ee9da62Smaxv #define	PCB_COMPAT32	0x01
87d30a34e8Smaxv #define	PCB_DBREGS	0x02
885ed45d6cSad 	u_int	  pcb_cr0;		/* saved image of CR0 */
89a0fc30e9Scegger 	uint64_t pcb_rsp0;
90a0fc30e9Scegger 	uint64_t pcb_cr2;		/* page fault address (CR2) */
91a0fc30e9Scegger 	uint64_t pcb_cr3;
92a0fc30e9Scegger 	uint64_t pcb_rsp;
93a0fc30e9Scegger 	uint64_t pcb_rbp;
9453524e44Schristos 	void     *pcb_onfault;		/* copyin/out fault recovery */
9569aa2aa9Sfvdl 	uint64_t  pcb_fs;
96ffa744f4Schs 	uint64_t  pcb_gs;
97988eb7edSkamil 	struct dbreg *pcb_dbregs;
98d3526213Smaxv 	uint16_t pcb_fpu_dflt_cw;
9935f1be57Syamt 	int pcb_iopl;
1008b623c15Sdsl 
101d3526213Smaxv 	uint32_t pcb_unused[8];		/* unused */
1028b623c15Sdsl 
1038b623c15Sdsl 	union savefpu	pcb_savefpu __aligned(64); /* floating point state */
1048b623c15Sdsl 	/* **** DO NOT ADD ANYTHING HERE **** */
10581918bf8Sfvdl };
106e181cc9bSchristos #ifndef __lint__
1078b623c15Sdsl __CTASSERT(sizeof(struct pcb) - sizeof (union savefpu) ==  128);
108e181cc9bSchristos #endif
10981918bf8Sfvdl 
110433b5ddeSmrg #else	/*	__x86_64__	*/
111433b5ddeSmrg 
112433b5ddeSmrg #include <i386/pcb.h>
113433b5ddeSmrg 
114433b5ddeSmrg #endif	/*	__x86_64__	*/
115433b5ddeSmrg 
11681918bf8Sfvdl #endif /* _AMD64_PCB_H_ */
117