1 /* $NetBSD: sysarch.h,v 1.7 2008/04/28 20:23:40 martin Exp $ */
4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _X86_SYSARCH_H_
33 #define _X86_SYSARCH_H_
38 #define X86_GET_IOPERM 3
39 #define X86_SET_IOPERM 4
40 #define X86_OLD_VM86 5
41 #define X86_PMC_INFO 8
42 #define X86_PMC_STARTSTOP 9
43 #define X86_PMC_READ 10
44 #define X86_GET_MTRR 11
45 #define X86_SET_MTRR 12
47 #define X86_GET_GSBASE 14
48 #define X86_GET_FSBASE 15
49 #define X86_SET_GSBASE 16
50 #define X86_SET_FSBASE 17
53 #define _X86_SYSARCH_L(x) x86_##x
54 #define _X86_SYSARCH_U(x) X86_##x
55 #elif defined(__i386__)
56 #define _X86_SYSARCH_L(x) i386_##x
57 #define _X86_SYSARCH_U(x) I386_##x
58 #define I386_GET_LDT X86_GET_LDT
59 #define I386_SET_LDT X86_SET_LDT
60 #define I386_IOPL X86_IOPL
61 #define I386_GET_IOPERM X86_GET_IOPERM
62 #define I386_SET_IOPERM X86_SET_IOPERM
63 #define I386_OLD_VM86 X86_OLD_VM86
64 #define I386_PMC_INFO X86_PMC_INFO
65 #define I386_PMC_STARTSTOP X86_PMC_STARTSTOP
66 #define I386_PMC_READ X86_PMC_READ
67 #define I386_GET_MTRR X86_GET_MTRR
68 #define I386_SET_MTRR X86_SET_MTRR
69 #define I386_VM86 X86_VM86
70 #define I386_GET_GSBASE X86_GET_GSBASE
71 #define I386_GET_FSBASE X86_GET_FSBASE
72 #define I386_SET_GSBASE X86_SET_GSBASE
73 #define I386_SET_FSBASE X86_SET_FSBASE
75 #define _X86_SYSARCH_L(x) x86_64_##x
76 #define _X86_SYSARCH_U(x) X86_64_##x
77 #define X86_64_GET_LDT X86_GET_LDT
78 #define X86_64_SET_LDT X86_SET_LDT
79 #define X86_64_IOPL X86_IOPL
80 #define X86_64_GET_IOPERM X86_GET_IOPERM
81 #define X86_64_SET_IOPERM X86_SET_IOPERM
82 #define X86_64_OLD_VM86 X86_OLD_VM86
83 #define X86_64_PMC_INFO X86_PMC_INFO
84 #define X86_64_PMC_STARTSTOP X86_PMC_STARTSTOP
85 #define X86_64_PMC_READ X86_PMC_READ
86 #define X86_64_GET_MTRR X86_GET_MTRR
87 #define X86_64_SET_MTRR X86_SET_MTRR
88 #define X86_64_VM86 X86_VM86
89 #define X86_64_GET_GSBASE X86_GET_GSBASE
90 #define X86_64_GET_FSBASE X86_GET_FSBASE
91 #define X86_64_SET_GSBASE X86_SET_GSBASE
92 #define X86_64_SET_FSBASE X86_SET_FSBASE
96 * Architecture specific syscalls (x86)
99 struct _X86_SYSARCH_L(get_ldt_args
) {
101 union descriptor
*desc
;
105 struct _X86_SYSARCH_L(set_ldt_args
) {
107 union descriptor
*desc
;
111 struct _X86_SYSARCH_L(get_mtrr_args
) {
116 struct _X86_SYSARCH_L(set_mtrr_args
) {
121 struct _X86_SYSARCH_L(iopl_args
) {
125 struct _X86_SYSARCH_L(get_ioperm_args
) {
129 struct _X86_SYSARCH_L(set_ioperm_args
) {
133 struct _X86_SYSARCH_L(pmc_info_args
) {
138 #define PMC_TYPE_NONE 0
139 #define PMC_TYPE_I586 1
140 #define PMC_TYPE_I686 2
141 #define PMC_TYPE_K7 3
143 #define PMC_INFO_HASTSC 0x01
146 #define PMC_NCOUNTERS 4
148 #define PMC_NCOUNTERS 2
151 struct _X86_SYSARCH_L(pmc_startstop_args
) {
160 #define PMC_SETUP_KERNEL 0x01
161 #define PMC_SETUP_USER 0x02
162 #define PMC_SETUP_EDGE 0x04
163 #define PMC_SETUP_INV 0x08
165 struct _X86_SYSARCH_L(pmc_read_args
) {
174 int x86_iopl(struct lwp
*, void *, register_t
*);
175 int x86_get_mtrr(struct lwp
*, void *, register_t
*);
176 int x86_set_mtrr(struct lwp
*, void *, register_t
*);
177 int x86_get_ldt(struct lwp
*l
, void *, register_t
*);
178 int x86_get_ldt1(struct lwp
*l
, struct x86_get_ldt_args
*, union descriptor
*);
179 int x86_set_ldt(struct lwp
*l
, void *, register_t
*);
180 int x86_set_ldt1(struct lwp
*l
, struct x86_set_ldt_args
*, union descriptor
*);
182 #include <sys/cdefs.h>
184 int _X86_SYSARCH_L(get_ldt
)(int, union descriptor
*, int);
185 int _X86_SYSARCH_L(set_ldt
)(int, union descriptor
*, int);
186 int _X86_SYSARCH_L(iopl
)(int);
187 int _X86_SYSARCH_L(pmc_info
)(struct _X86_SYSARCH_L(pmc_info_args
*));
188 int _X86_SYSARCH_L(pmc_startstop
)(struct _X86_SYSARCH_L(pmc_startstop_args
*));
189 int _X86_SYSARCH_L(pmc_read
)(struct _X86_SYSARCH_L(pmc_read_args
*));
190 int _X86_SYSARCH_L(set_mtrr
)(struct mtrr
*, int *);
191 int _X86_SYSARCH_L(get_mtrr
)(struct mtrr
*, int *);
192 int sysarch(int, void *);
196 #endif /* !_X86_SYSARCH_H_ */