sysarch.h revision 1.2 1 1.2 ad /* $NetBSD: sysarch.h,v 1.2 2007/04/16 19:25:04 ad 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 * 3. All advertising materials mentioning features or use of this software
19 1.1 ad * must display the following acknowledgement:
20 1.1 ad * This product includes software developed by the NetBSD
21 1.1 ad * Foundation, Inc. and its contributors.
22 1.1 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 ad * contributors may be used to endorse or promote products derived
24 1.1 ad * from this software without specific prior written permission.
25 1.1 ad *
26 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1 ad */
38 1.1 ad
39 1.1 ad #ifndef _X86_SYSARCH_H_
40 1.1 ad #define _X86_SYSARCH_H_
41 1.1 ad
42 1.1 ad #define X86_GET_LDT 0
43 1.1 ad #define X86_SET_LDT 1
44 1.1 ad #define X86_IOPL 2
45 1.1 ad #define X86_GET_IOPERM 3
46 1.1 ad #define X86_SET_IOPERM 4
47 1.1 ad #define X86_OLD_VM86 5
48 1.1 ad #define X86_PMC_INFO 8
49 1.1 ad #define X86_PMC_STARTSTOP 9
50 1.1 ad #define X86_PMC_READ 10
51 1.1 ad #define X86_GET_MTRR 11
52 1.1 ad #define X86_SET_MTRR 12
53 1.1 ad #define X86_VM86 13
54 1.2 ad
55 1.2 ad #ifdef _KERNEL
56 1.2 ad #define _X86_SYSARCH_L(x) x86_##x
57 1.2 ad #define _X86_SYSARCH_U(x) X86_##x
58 1.1 ad #elif defined(i386)
59 1.1 ad #define _X86_SYSARCH_L(x) i386_##x
60 1.1 ad #define _X86_SYSARCH_U(x) I386_##x
61 1.1 ad #define I386_GET_LDT X86_GET_LDT
62 1.1 ad #define I386_SET_LDT X86_SET_LDT
63 1.1 ad #define I386_IOPL X86_IOPL
64 1.1 ad #define I386_GET_IOPERM X86_GET_IOPERM
65 1.1 ad #define I386_SET_IOPERM X86_SET_IOPERM
66 1.1 ad #define I386_OLD_VM86 X86_OLD_VM86
67 1.1 ad #define I386_PMC_INFO X86_PMC_INFO
68 1.1 ad #define I386_PMC_STARTSTOP X86_PMC_STARTSTOP
69 1.1 ad #define I386_PMC_READ X86_PMC_READ
70 1.1 ad #define I386_GET_MTRR X86_GET_MTRR
71 1.1 ad #define I386_SET_MTRR X86_SET_MTRR
72 1.1 ad #define I386_VM86 X86_VM86
73 1.1 ad #else
74 1.1 ad #define _X86_SYSARCH_L(x) x86_64_##x
75 1.1 ad #define _X86_SYSARCH_U(x) X86_64_##x
76 1.1 ad #define X86_64_GET_LDT X86_GET_LDT
77 1.1 ad #define X86_64_SET_LDT X86_SET_LDT
78 1.1 ad #define X86_64_IOPL X86_IOPL
79 1.1 ad #define X86_64_GET_IOPERM X86_GET_IOPERM
80 1.1 ad #define X86_64_SET_IOPERM X86_SET_IOPERM
81 1.1 ad #define X86_64_OLD_VM86 X86_OLD_VM86
82 1.1 ad #define X86_64_PMC_INFO X86_PMC_INFO
83 1.1 ad #define X86_64_PMC_STARTSTOP X86_PMC_STARTSTOP
84 1.1 ad #define X86_64_PMC_READ X86_PMC_READ
85 1.1 ad #define X86_64_GET_MTRR X86_GET_MTRR
86 1.1 ad #define X86_64_SET_MTRR X86_SET_MTRR
87 1.1 ad #define X86_64_VM86 X86_VM86
88 1.1 ad #endif
89 1.1 ad
90 1.1 ad /*
91 1.1 ad * Architecture specific syscalls (x86)
92 1.1 ad */
93 1.1 ad
94 1.1 ad struct _X86_SYSARCH_L(get_ldt_args) {
95 1.1 ad int start;
96 1.1 ad union descriptor *desc;
97 1.1 ad int num;
98 1.1 ad };
99 1.1 ad
100 1.1 ad struct _X86_SYSARCH_L(set_ldt_args) {
101 1.1 ad int start;
102 1.1 ad union descriptor *desc;
103 1.1 ad int num;
104 1.1 ad };
105 1.1 ad
106 1.1 ad struct _X86_SYSARCH_L(get_mtrr_args) {
107 1.1 ad struct mtrr *mtrrp;
108 1.1 ad int *n;
109 1.1 ad };
110 1.1 ad
111 1.1 ad struct _X86_SYSARCH_L(set_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(iopl_args) {
117 1.1 ad int iopl;
118 1.1 ad };
119 1.1 ad
120 1.1 ad struct _X86_SYSARCH_L(get_ioperm_args) {
121 1.1 ad u_long *iomap;
122 1.1 ad };
123 1.1 ad
124 1.1 ad struct _X86_SYSARCH_L(set_ioperm_args) {
125 1.1 ad u_long *iomap;
126 1.1 ad };
127 1.1 ad
128 1.1 ad struct _X86_SYSARCH_L(pmc_info_args) {
129 1.1 ad int type;
130 1.1 ad int flags;
131 1.1 ad };
132 1.1 ad
133 1.1 ad #define PMC_TYPE_NONE 0
134 1.1 ad #define PMC_TYPE_I586 1
135 1.1 ad #define PMC_TYPE_I686 2
136 1.1 ad #define PMC_TYPE_K7 3
137 1.1 ad
138 1.1 ad #define PMC_INFO_HASTSC 0x01
139 1.1 ad
140 1.1 ad #ifdef i386
141 1.1 ad #define PMC_NCOUNTERS 4
142 1.1 ad #else
143 1.1 ad #define PMC_NCOUNTERS 2
144 1.1 ad #endif
145 1.1 ad
146 1.1 ad struct _X86_SYSARCH_L(pmc_startstop_args) {
147 1.1 ad int counter;
148 1.1 ad uint64_t val;
149 1.1 ad uint8_t event;
150 1.1 ad uint8_t unit;
151 1.1 ad uint8_t compare;
152 1.1 ad uint8_t flags;
153 1.1 ad };
154 1.1 ad
155 1.1 ad #define PMC_SETUP_KERNEL 0x01
156 1.1 ad #define PMC_SETUP_USER 0x02
157 1.1 ad #define PMC_SETUP_EDGE 0x04
158 1.1 ad #define PMC_SETUP_INV 0x08
159 1.1 ad
160 1.1 ad struct _X86_SYSARCH_L(pmc_read_args) {
161 1.1 ad int counter;
162 1.1 ad uint64_t val;
163 1.1 ad uint64_t time;
164 1.1 ad };
165 1.1 ad
166 1.1 ad struct mtrr;
167 1.1 ad
168 1.1 ad #ifdef _KERNEL
169 1.1 ad int x86_iopl(struct lwp *, void *, register_t *);
170 1.1 ad int x86_get_mtrr(struct lwp *, void *, register_t *);
171 1.1 ad int x86_set_mtrr(struct lwp *, void *, register_t *);
172 1.1 ad int x86_get_ldt(struct lwp *l, void *, register_t *);
173 1.1 ad int x86_set_ldt(struct lwp *l, void *, register_t *);
174 1.1 ad #else
175 1.1 ad #include <sys/cdefs.h>
176 1.1 ad __BEGIN_DECLS
177 1.1 ad int _X86_SYSARCH_L(get_ldt)(int, union descriptor *, int);
178 1.1 ad int _X86_SYSARCH_L(set_ldt)(int, union descriptor *, int);
179 1.1 ad int _X86_SYSARCH_L(iopl)(int);
180 1.1 ad int _X86_SYSARCH_L(pmc_info)(struct _X86_SYSARCH_L(pmc_info_args *));
181 1.1 ad int _X86_SYSARCH_L(pmc_startstop)(struct _X86_SYSARCH_L(pmc_startstop_args *));
182 1.1 ad int _X86_SYSARCH_L(pmc_read)(struct _X86_SYSARCH_L(pmc_read_args *));
183 1.1 ad int _X86_SYSARCH_L(set_mtrr)(struct mtrr *, int *);
184 1.1 ad int _X86_SYSARCH_L(get_mtrr)(struct mtrr *, int *);
185 1.1 ad int sysarch(int, void *);
186 1.1 ad __END_DECLS
187 1.1 ad #endif
188 1.1 ad
189 1.1 ad #endif /* !_X86_SYSARCH_H_ */
190