xref: /freebsd/sys/x86/include/sysarch.h (revision e7a9df16e6541a68ab21e51a5d0badb5feef1894)
1dfb1c113STijl Coosemans /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4dfb1c113STijl Coosemans  * Copyright (c) 1993 The Regents of the University of California.
5dfb1c113STijl Coosemans  * All rights reserved.
6dfb1c113STijl Coosemans  *
7dfb1c113STijl Coosemans  * Redistribution and use in source and binary forms, with or without
8dfb1c113STijl Coosemans  * modification, are permitted provided that the following conditions
9dfb1c113STijl Coosemans  * are met:
10dfb1c113STijl Coosemans  * 1. Redistributions of source code must retain the above copyright
11dfb1c113STijl Coosemans  *    notice, this list of conditions and the following disclaimer.
12dfb1c113STijl Coosemans  * 2. Redistributions in binary form must reproduce the above copyright
13dfb1c113STijl Coosemans  *    notice, this list of conditions and the following disclaimer in the
14dfb1c113STijl Coosemans  *    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
16dfb1c113STijl Coosemans  *    may be used to endorse or promote products derived from this software
17dfb1c113STijl Coosemans  *    without specific prior written permission.
18dfb1c113STijl Coosemans  *
19dfb1c113STijl Coosemans  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20dfb1c113STijl Coosemans  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21dfb1c113STijl Coosemans  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22dfb1c113STijl Coosemans  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23dfb1c113STijl Coosemans  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24dfb1c113STijl Coosemans  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25dfb1c113STijl Coosemans  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26dfb1c113STijl Coosemans  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27dfb1c113STijl Coosemans  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28dfb1c113STijl Coosemans  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29dfb1c113STijl Coosemans  * SUCH DAMAGE.
30dfb1c113STijl Coosemans  *
31dfb1c113STijl Coosemans  * $FreeBSD$
32dfb1c113STijl Coosemans  */
33dfb1c113STijl Coosemans 
34dfb1c113STijl Coosemans /*
35dfb1c113STijl Coosemans  * Architecture specific syscalls (X86)
36dfb1c113STijl Coosemans  */
37dfb1c113STijl Coosemans #ifndef _MACHINE_SYSARCH_H_
38dfb1c113STijl Coosemans #define _MACHINE_SYSARCH_H_
39dfb1c113STijl Coosemans 
40dfb1c113STijl Coosemans #include <sys/cdefs.h>
41dfb1c113STijl Coosemans 
42dfb1c113STijl Coosemans #define I386_GET_LDT	0
43dfb1c113STijl Coosemans #define I386_SET_LDT	1
44dfb1c113STijl Coosemans #define	LDT_AUTO_ALLOC	0xffffffff
45dfb1c113STijl Coosemans 				/* I386_IOPL */
46dfb1c113STijl Coosemans #define I386_GET_IOPERM	3
47dfb1c113STijl Coosemans #define I386_SET_IOPERM	4
48dfb1c113STijl Coosemans 				/* xxxxx */
49dfb1c113STijl Coosemans #define	I386_VM86		6	/* XXX Not implementable on amd64 */
50dfb1c113STijl Coosemans #define	I386_GET_FSBASE		7
51dfb1c113STijl Coosemans #define	I386_SET_FSBASE		8
52dfb1c113STijl Coosemans #define	I386_GET_GSBASE		9
53dfb1c113STijl Coosemans #define	I386_SET_GSBASE		10
54dfb1c113STijl Coosemans #define	I386_GET_XFPUSTATE	11
55*e7a9df16SKonstantin Belousov #define	I386_SET_PKRU		12
56*e7a9df16SKonstantin Belousov #define	I386_CLEAR_PKRU		13
57dfb1c113STijl Coosemans 
58dfb1c113STijl Coosemans /* Leave space for 0-127 for to avoid translating syscalls */
59dfb1c113STijl Coosemans #define	AMD64_GET_FSBASE	128
60dfb1c113STijl Coosemans #define	AMD64_SET_FSBASE	129
61dfb1c113STijl Coosemans #define	AMD64_GET_GSBASE	130
62dfb1c113STijl Coosemans #define	AMD64_SET_GSBASE	131
63dfb1c113STijl Coosemans #define	AMD64_GET_XFPUSTATE	132
64*e7a9df16SKonstantin Belousov #define	AMD64_SET_PKRU		133
65*e7a9df16SKonstantin Belousov #define	AMD64_CLEAR_PKRU	134
66*e7a9df16SKonstantin Belousov 
67*e7a9df16SKonstantin Belousov /* Flags for AMD64_SET_PKRU */
68*e7a9df16SKonstantin Belousov #define	AMD64_PKRU_EXCL		0x0001
69*e7a9df16SKonstantin Belousov #define	AMD64_PKRU_PERSIST	0x0002
70dfb1c113STijl Coosemans 
71dfb1c113STijl Coosemans struct i386_ioperm_args {
72dfb1c113STijl Coosemans 	unsigned int start;
73dfb1c113STijl Coosemans 	unsigned int length;
74dfb1c113STijl Coosemans 	int	enable;
75dfb1c113STijl Coosemans };
76dfb1c113STijl Coosemans 
77dfb1c113STijl Coosemans #ifdef __i386__
78dfb1c113STijl Coosemans struct i386_ldt_args {
79dfb1c113STijl Coosemans 	unsigned int start;
80dfb1c113STijl Coosemans 	union descriptor *descs;
81dfb1c113STijl Coosemans 	unsigned int num;
82dfb1c113STijl Coosemans };
83dfb1c113STijl Coosemans 
84dfb1c113STijl Coosemans struct i386_vm86_args {
85dfb1c113STijl Coosemans 	int	sub_op;			/* sub-operation to perform */
86dfb1c113STijl Coosemans 	char	*sub_args;		/* args */
87dfb1c113STijl Coosemans };
88dfb1c113STijl Coosemans 
89dfb1c113STijl Coosemans struct i386_get_xfpustate {
90dfb1c113STijl Coosemans 	void *addr;
91dfb1c113STijl Coosemans 	int len;
92dfb1c113STijl Coosemans };
93dfb1c113STijl Coosemans #else
94dfb1c113STijl Coosemans struct i386_ldt_args {
95dfb1c113STijl Coosemans 	unsigned int start;
96dfb1c113STijl Coosemans 	struct user_segment_descriptor *descs __packed;
97dfb1c113STijl Coosemans 	unsigned int num;
98dfb1c113STijl Coosemans };
99dfb1c113STijl Coosemans 
100dfb1c113STijl Coosemans struct i386_get_xfpustate {
101dfb1c113STijl Coosemans 	unsigned int addr;
102dfb1c113STijl Coosemans 	int len;
103dfb1c113STijl Coosemans };
104dfb1c113STijl Coosemans 
105*e7a9df16SKonstantin Belousov struct i386_set_pkru {
106*e7a9df16SKonstantin Belousov 	unsigned int addr;
107*e7a9df16SKonstantin Belousov 	unsigned int len;
108*e7a9df16SKonstantin Belousov 	unsigned int keyidx;
109*e7a9df16SKonstantin Belousov 	int flags;
110*e7a9df16SKonstantin Belousov };
111*e7a9df16SKonstantin Belousov 
112dfb1c113STijl Coosemans struct amd64_get_xfpustate {
113dfb1c113STijl Coosemans 	void *addr;
114dfb1c113STijl Coosemans 	int len;
115dfb1c113STijl Coosemans };
116dfb1c113STijl Coosemans #endif
117dfb1c113STijl Coosemans 
118*e7a9df16SKonstantin Belousov struct amd64_set_pkru {
119*e7a9df16SKonstantin Belousov 	void *addr;
120*e7a9df16SKonstantin Belousov 	unsigned long len;
121*e7a9df16SKonstantin Belousov 	unsigned int keyidx;
122*e7a9df16SKonstantin Belousov 	int flags;
123*e7a9df16SKonstantin Belousov };
124*e7a9df16SKonstantin Belousov 
125dfb1c113STijl Coosemans #ifndef _KERNEL
126dfb1c113STijl Coosemans union descriptor;
127dfb1c113STijl Coosemans struct dbreg;
128dfb1c113STijl Coosemans 
129dfb1c113STijl Coosemans __BEGIN_DECLS
130dfb1c113STijl Coosemans int i386_get_ldt(int, union descriptor *, int);
131dfb1c113STijl Coosemans int i386_set_ldt(int, union descriptor *, int);
132dfb1c113STijl Coosemans int i386_get_ioperm(unsigned int, unsigned int *, int *);
133dfb1c113STijl Coosemans int i386_set_ioperm(unsigned int, unsigned int, int);
134dfb1c113STijl Coosemans int i386_vm86(int, void *);
135dfb1c113STijl Coosemans int i386_get_fsbase(void **);
136dfb1c113STijl Coosemans int i386_get_gsbase(void **);
137dfb1c113STijl Coosemans int i386_set_fsbase(void *);
138dfb1c113STijl Coosemans int i386_set_gsbase(void *);
139dfb1c113STijl Coosemans int i386_set_watch(int, unsigned int, int, int, struct dbreg *);
140dfb1c113STijl Coosemans int i386_clr_watch(int, struct dbreg *);
141dfb1c113STijl Coosemans int amd64_get_fsbase(void **);
142dfb1c113STijl Coosemans int amd64_get_gsbase(void **);
143dfb1c113STijl Coosemans int amd64_set_fsbase(void *);
144dfb1c113STijl Coosemans int amd64_set_gsbase(void *);
145dfb1c113STijl Coosemans int sysarch(int, void *);
146dfb1c113STijl Coosemans __END_DECLS
147dfb1c113STijl Coosemans #else
148dfb1c113STijl Coosemans struct thread;
149dfb1c113STijl Coosemans union descriptor;
150dfb1c113STijl Coosemans 
151dfb1c113STijl Coosemans int i386_get_ldt(struct thread *, struct i386_ldt_args *);
152dfb1c113STijl Coosemans int i386_set_ldt(struct thread *, struct i386_ldt_args *, union descriptor *);
153dfb1c113STijl Coosemans int i386_get_ioperm(struct thread *, struct i386_ioperm_args *);
154dfb1c113STijl Coosemans int i386_set_ioperm(struct thread *, struct i386_ioperm_args *);
155dfb1c113STijl Coosemans int amd64_get_ldt(struct thread *, struct i386_ldt_args *);
156dfb1c113STijl Coosemans int amd64_set_ldt(struct thread *, struct i386_ldt_args *,
157dfb1c113STijl Coosemans     struct user_segment_descriptor *);
158dfb1c113STijl Coosemans int amd64_get_ioperm(struct thread *, struct i386_ioperm_args *);
159dfb1c113STijl Coosemans int amd64_set_ioperm(struct thread *, struct i386_ioperm_args *);
160dfb1c113STijl Coosemans #endif
161dfb1c113STijl Coosemans 
162dfb1c113STijl Coosemans #endif /* !_MACHINE_SYSARCH_H_ */
163