sysarch.h revision 1.9.36.1 1 1.9.36.1 skrll /* $NetBSD: sysarch.h,v 1.9.36.1 2017/08/28 17:51:56 skrll Exp $ */
2 1.1 ad
3 1.1 ad /*-
4 1.1 ad * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 1.1 ad * All rights reserved.
6 1.1 ad *
7 1.1 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1 ad * by Andrew Doran.
9 1.1 ad *
10 1.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1 ad * modification, are permitted provided that the following conditions
12 1.1 ad * are met:
13 1.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1 ad * documentation and/or other materials provided with the distribution.
18 1.1 ad *
19 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 ad * POSSIBILITY OF SUCH DAMAGE.
30 1.1 ad */
31 1.1 ad
32 1.1 ad #ifndef _X86_SYSARCH_H_
33 1.1 ad #define _X86_SYSARCH_H_
34 1.1 ad
35 1.1 ad #define X86_GET_LDT 0
36 1.1 ad #define X86_SET_LDT 1
37 1.9.36.1 skrll #define X86_IOPL 2
38 1.9.36.1 skrll #define X86_GET_IOPERM 3
39 1.9.36.1 skrll #define X86_SET_IOPERM 4
40 1.9.36.1 skrll #define X86_OLD_VM86 5
41 1.9.36.1 skrll #define X86_PMC_INFO 8
42 1.9.36.1 skrll #define X86_PMC_STARTSTOP 9
43 1.9.36.1 skrll #define X86_PMC_READ 10
44 1.1 ad #define X86_GET_MTRR 11
45 1.1 ad #define X86_SET_MTRR 12
46 1.9.36.1 skrll #define X86_VM86 13
47 1.9.36.1 skrll #define X86_GET_GSBASE 14
48 1.9.36.1 skrll #define X86_GET_FSBASE 15
49 1.9.36.1 skrll #define X86_SET_GSBASE 16
50 1.9.36.1 skrll #define X86_SET_FSBASE 17
51 1.2 ad
52 1.2 ad #ifdef _KERNEL
53 1.9.36.1 skrll #define _X86_SYSARCH_L(x) x86_##x
54 1.9.36.1 skrll #define _X86_SYSARCH_U(x) X86_##x
55 1.4 ragge #elif defined(__i386__)
56 1.9.36.1 skrll #define _X86_SYSARCH_L(x) i386_##x
57 1.9.36.1 skrll #define _X86_SYSARCH_U(x) I386_##x
58 1.1 ad #define I386_GET_LDT X86_GET_LDT
59 1.1 ad #define I386_SET_LDT X86_SET_LDT
60 1.9.36.1 skrll #define I386_IOPL X86_IOPL
61 1.9.36.1 skrll #define I386_GET_IOPERM X86_GET_IOPERM
62 1.9.36.1 skrll #define I386_SET_IOPERM X86_SET_IOPERM
63 1.9.36.1 skrll #define I386_OLD_VM86 X86_OLD_VM86
64 1.9.36.1 skrll #define I386_PMC_INFO X86_PMC_INFO
65 1.9.36.1 skrll #define I386_PMC_STARTSTOP X86_PMC_STARTSTOP
66 1.9.36.1 skrll #define I386_PMC_READ X86_PMC_READ
67 1.1 ad #define I386_GET_MTRR X86_GET_MTRR
68 1.1 ad #define I386_SET_MTRR X86_SET_MTRR
69 1.9.36.1 skrll #define I386_VM86 X86_VM86
70 1.9.36.1 skrll #define I386_GET_GSBASE X86_GET_GSBASE
71 1.9.36.1 skrll #define I386_GET_FSBASE X86_GET_FSBASE
72 1.9.36.1 skrll #define I386_SET_GSBASE X86_SET_GSBASE
73 1.9.36.1 skrll #define I386_SET_FSBASE X86_SET_FSBASE
74 1.1 ad #else
75 1.9.36.1 skrll #define _X86_SYSARCH_L(x) x86_64_##x
76 1.9.36.1 skrll #define _X86_SYSARCH_U(x) X86_64_##x
77 1.1 ad #define X86_64_GET_LDT X86_GET_LDT
78 1.1 ad #define X86_64_SET_LDT X86_SET_LDT
79 1.9.36.1 skrll #define X86_64_IOPL X86_IOPL
80 1.9.36.1 skrll #define X86_64_GET_IOPERM X86_GET_IOPERM
81 1.9.36.1 skrll #define X86_64_SET_IOPERM X86_SET_IOPERM
82 1.9.36.1 skrll #define X86_64_OLD_VM86 X86_OLD_VM86
83 1.9.36.1 skrll #define X86_64_PMC_INFO X86_PMC_INFO
84 1.9.36.1 skrll #define X86_64_PMC_STARTSTOP X86_PMC_STARTSTOP
85 1.9.36.1 skrll #define X86_64_PMC_READ X86_PMC_READ
86 1.1 ad #define X86_64_GET_MTRR X86_GET_MTRR
87 1.1 ad #define X86_64_SET_MTRR X86_SET_MTRR
88 1.9.36.1 skrll #define X86_64_VM86 X86_VM86
89 1.6 ad #define X86_64_GET_GSBASE X86_GET_GSBASE
90 1.9.36.1 skrll #define X86_64_GET_FSBASE X86_GET_FSBASE
91 1.6 ad #define X86_64_SET_GSBASE X86_SET_GSBASE
92 1.9.36.1 skrll #define X86_64_SET_FSBASE X86_SET_FSBASE
93 1.1 ad #endif
94 1.1 ad
95 1.1 ad /*
96 1.1 ad * Architecture specific syscalls (x86)
97 1.1 ad */
98 1.1 ad
99 1.1 ad struct _X86_SYSARCH_L(get_ldt_args) {
100 1.1 ad int start;
101 1.1 ad union descriptor *desc;
102 1.1 ad int num;
103 1.1 ad };
104 1.1 ad
105 1.1 ad struct _X86_SYSARCH_L(set_ldt_args) {
106 1.1 ad int start;
107 1.1 ad union descriptor *desc;
108 1.1 ad int num;
109 1.1 ad };
110 1.1 ad
111 1.1 ad struct _X86_SYSARCH_L(get_mtrr_args) {
112 1.1 ad struct mtrr *mtrrp;
113 1.1 ad int *n;
114 1.1 ad };
115 1.1 ad
116 1.1 ad struct _X86_SYSARCH_L(set_mtrr_args) {
117 1.1 ad struct mtrr *mtrrp;
118 1.1 ad int *n;
119 1.1 ad };
120 1.1 ad
121 1.1 ad struct _X86_SYSARCH_L(iopl_args) {
122 1.1 ad int iopl;
123 1.1 ad };
124 1.1 ad
125 1.1 ad struct _X86_SYSARCH_L(get_ioperm_args) {
126 1.1 ad u_long *iomap;
127 1.1 ad };
128 1.1 ad
129 1.1 ad struct _X86_SYSARCH_L(set_ioperm_args) {
130 1.1 ad u_long *iomap;
131 1.1 ad };
132 1.1 ad
133 1.1 ad struct _X86_SYSARCH_L(pmc_info_args) {
134 1.9.36.1 skrll int vers;
135 1.9.36.1 skrll int type;
136 1.9.36.1 skrll uint32_t nctrs;
137 1.9.36.1 skrll uint64_t nsamp;
138 1.1 ad };
139 1.1 ad
140 1.9.36.1 skrll #define PMC_VERSION 1
141 1.9.36.1 skrll
142 1.1 ad #define PMC_TYPE_NONE 0
143 1.1 ad #define PMC_TYPE_I586 1
144 1.1 ad #define PMC_TYPE_I686 2
145 1.1 ad #define PMC_TYPE_K7 3
146 1.9.36.1 skrll #define PMC_TYPE_F10H 4
147 1.1 ad
148 1.1 ad #define PMC_INFO_HASTSC 0x01
149 1.1 ad
150 1.1 ad #define PMC_NCOUNTERS 4
151 1.1 ad
152 1.1 ad struct _X86_SYSARCH_L(pmc_startstop_args) {
153 1.9.36.1 skrll uint32_t counter;
154 1.1 ad uint64_t val;
155 1.9.36.1 skrll uint32_t event;
156 1.9.36.1 skrll uint32_t unit;
157 1.9.36.1 skrll uint32_t compare;
158 1.9.36.1 skrll uint32_t flags;
159 1.1 ad };
160 1.1 ad
161 1.1 ad #define PMC_SETUP_KERNEL 0x01
162 1.1 ad #define PMC_SETUP_USER 0x02
163 1.1 ad #define PMC_SETUP_EDGE 0x04
164 1.1 ad #define PMC_SETUP_INV 0x08
165 1.1 ad
166 1.9.36.1 skrll typedef struct {
167 1.9.36.1 skrll uint64_t ctrval;
168 1.9.36.1 skrll uint32_t overfl;
169 1.9.36.1 skrll } x86_pmc_cpuval_t;
170 1.9.36.1 skrll
171 1.1 ad struct _X86_SYSARCH_L(pmc_read_args) {
172 1.9.36.1 skrll uint32_t counter;
173 1.9.36.1 skrll x86_pmc_cpuval_t *values;
174 1.9.36.1 skrll uint32_t nval;
175 1.1 ad };
176 1.1 ad
177 1.1 ad struct mtrr;
178 1.1 ad
179 1.1 ad #ifdef _KERNEL
180 1.1 ad int x86_iopl(struct lwp *, void *, register_t *);
181 1.1 ad int x86_get_mtrr(struct lwp *, void *, register_t *);
182 1.1 ad int x86_set_mtrr(struct lwp *, void *, register_t *);
183 1.9 chs int x86_get_ldt(struct lwp *, void *, register_t *);
184 1.9 chs int x86_get_ldt1(struct lwp *, struct x86_get_ldt_args *, union descriptor *);
185 1.9 chs int x86_set_ldt(struct lwp *, void *, register_t *);
186 1.9 chs int x86_set_ldt1(struct lwp *, struct x86_set_ldt_args *, union descriptor *);
187 1.9 chs int x86_set_sdbase(void *, char, lwp_t *, bool);
188 1.9 chs int x86_get_sdbase(void *, char);
189 1.1 ad #else
190 1.1 ad #include <sys/cdefs.h>
191 1.1 ad __BEGIN_DECLS
192 1.1 ad int _X86_SYSARCH_L(get_ldt)(int, union descriptor *, int);
193 1.1 ad int _X86_SYSARCH_L(set_ldt)(int, union descriptor *, int);
194 1.1 ad int _X86_SYSARCH_L(iopl)(int);
195 1.1 ad int _X86_SYSARCH_L(pmc_info)(struct _X86_SYSARCH_L(pmc_info_args *));
196 1.1 ad int _X86_SYSARCH_L(pmc_startstop)(struct _X86_SYSARCH_L(pmc_startstop_args *));
197 1.1 ad int _X86_SYSARCH_L(pmc_read)(struct _X86_SYSARCH_L(pmc_read_args *));
198 1.1 ad int _X86_SYSARCH_L(set_mtrr)(struct mtrr *, int *);
199 1.1 ad int _X86_SYSARCH_L(get_mtrr)(struct mtrr *, int *);
200 1.1 ad int sysarch(int, void *);
201 1.1 ad __END_DECLS
202 1.1 ad #endif
203 1.1 ad
204 1.1 ad #endif /* !_X86_SYSARCH_H_ */
205