sysarch.h revision 1.1 1 1.1 ad /* $NetBSD: sysarch.h,v 1.1 2007/04/16 19:12:19 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 #ifdef _KERNEL
43 1.1 ad #define _X86_SYSARCH_L(x) x86_##x
44 1.1 ad #define _X86_SYSARCH_U(x) X86_##x
45 1.1 ad #define X86_GET_LDT 0
46 1.1 ad #define X86_SET_LDT 1
47 1.1 ad #define X86_IOPL 2
48 1.1 ad #define X86_GET_IOPERM 3
49 1.1 ad #define X86_SET_IOPERM 4
50 1.1 ad #define X86_OLD_VM86 5
51 1.1 ad #define X86_PMC_INFO 8
52 1.1 ad #define X86_PMC_STARTSTOP 9
53 1.1 ad #define X86_PMC_READ 10
54 1.1 ad #define X86_GET_MTRR 11
55 1.1 ad #define X86_SET_MTRR 12
56 1.1 ad #define X86_VM86 13
57 1.1 ad #elif defined(i386)
58 1.1 ad #define _X86_SYSARCH_L(x) i386_##x
59 1.1 ad #define _X86_SYSARCH_U(x) I386_##x
60 1.1 ad #define I386_GET_LDT X86_GET_LDT
61 1.1 ad #define I386_SET_LDT X86_SET_LDT
62 1.1 ad #define I386_IOPL X86_IOPL
63 1.1 ad #define I386_GET_IOPERM X86_GET_IOPERM
64 1.1 ad #define I386_SET_IOPERM X86_SET_IOPERM
65 1.1 ad #define I386_OLD_VM86 X86_OLD_VM86
66 1.1 ad #define I386_PMC_INFO X86_PMC_INFO
67 1.1 ad #define I386_PMC_STARTSTOP X86_PMC_STARTSTOP
68 1.1 ad #define I386_PMC_READ X86_PMC_READ
69 1.1 ad #define I386_GET_MTRR X86_GET_MTRR
70 1.1 ad #define I386_SET_MTRR X86_SET_MTRR
71 1.1 ad #define I386_VM86 X86_VM86
72 1.1 ad #else
73 1.1 ad #define _X86_SYSARCH_L(x) x86_64_##x
74 1.1 ad #define _X86_SYSARCH_U(x) X86_64_##x
75 1.1 ad #define X86_64_GET_LDT X86_GET_LDT
76 1.1 ad #define X86_64_SET_LDT X86_SET_LDT
77 1.1 ad #define X86_64_IOPL X86_IOPL
78 1.1 ad #define X86_64_GET_IOPERM X86_GET_IOPERM
79 1.1 ad #define X86_64_SET_IOPERM X86_SET_IOPERM
80 1.1 ad #define X86_64_OLD_VM86 X86_OLD_VM86
81 1.1 ad #define X86_64_PMC_INFO X86_PMC_INFO
82 1.1 ad #define X86_64_PMC_STARTSTOP X86_PMC_STARTSTOP
83 1.1 ad #define X86_64_PMC_READ X86_PMC_READ
84 1.1 ad #define X86_64_GET_MTRR X86_GET_MTRR
85 1.1 ad #define X86_64_SET_MTRR X86_SET_MTRR
86 1.1 ad #define X86_64_VM86 X86_VM86
87 1.1 ad #endif
88 1.1 ad
89 1.1 ad /*
90 1.1 ad * Architecture specific syscalls (x86)
91 1.1 ad */
92 1.1 ad
93 1.1 ad struct _X86_SYSARCH_L(get_ldt_args) {
94 1.1 ad int start;
95 1.1 ad union descriptor *desc;
96 1.1 ad int num;
97 1.1 ad };
98 1.1 ad
99 1.1 ad struct _X86_SYSARCH_L(set_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(get_mtrr_args) {
106 1.1 ad struct mtrr *mtrrp;
107 1.1 ad int *n;
108 1.1 ad };
109 1.1 ad
110 1.1 ad struct _X86_SYSARCH_L(set_mtrr_args) {
111 1.1 ad struct mtrr *mtrrp;
112 1.1 ad int *n;
113 1.1 ad };
114 1.1 ad
115 1.1 ad struct _X86_SYSARCH_L(iopl_args) {
116 1.1 ad int iopl;
117 1.1 ad };
118 1.1 ad
119 1.1 ad struct _X86_SYSARCH_L(get_ioperm_args) {
120 1.1 ad u_long *iomap;
121 1.1 ad };
122 1.1 ad
123 1.1 ad struct _X86_SYSARCH_L(set_ioperm_args) {
124 1.1 ad u_long *iomap;
125 1.1 ad };
126 1.1 ad
127 1.1 ad struct _X86_SYSARCH_L(pmc_info_args) {
128 1.1 ad int type;
129 1.1 ad int flags;
130 1.1 ad };
131 1.1 ad
132 1.1 ad #define PMC_TYPE_NONE 0
133 1.1 ad #define PMC_TYPE_I586 1
134 1.1 ad #define PMC_TYPE_I686 2
135 1.1 ad #define PMC_TYPE_K7 3
136 1.1 ad
137 1.1 ad #define PMC_INFO_HASTSC 0x01
138 1.1 ad
139 1.1 ad #ifdef i386
140 1.1 ad #define PMC_NCOUNTERS 4
141 1.1 ad #else
142 1.1 ad #define PMC_NCOUNTERS 2
143 1.1 ad #endif
144 1.1 ad
145 1.1 ad struct _X86_SYSARCH_L(pmc_startstop_args) {
146 1.1 ad int counter;
147 1.1 ad uint64_t val;
148 1.1 ad uint8_t event;
149 1.1 ad uint8_t unit;
150 1.1 ad uint8_t compare;
151 1.1 ad uint8_t flags;
152 1.1 ad };
153 1.1 ad
154 1.1 ad #define PMC_SETUP_KERNEL 0x01
155 1.1 ad #define PMC_SETUP_USER 0x02
156 1.1 ad #define PMC_SETUP_EDGE 0x04
157 1.1 ad #define PMC_SETUP_INV 0x08
158 1.1 ad
159 1.1 ad struct _X86_SYSARCH_L(pmc_read_args) {
160 1.1 ad int counter;
161 1.1 ad uint64_t val;
162 1.1 ad uint64_t time;
163 1.1 ad };
164 1.1 ad
165 1.1 ad struct mtrr;
166 1.1 ad
167 1.1 ad #ifdef _KERNEL
168 1.1 ad int x86_iopl(struct lwp *, void *, register_t *);
169 1.1 ad int x86_get_mtrr(struct lwp *, void *, register_t *);
170 1.1 ad int x86_set_mtrr(struct lwp *, void *, register_t *);
171 1.1 ad int x86_get_ldt(struct lwp *l, void *, register_t *);
172 1.1 ad int x86_set_ldt(struct lwp *l, void *, register_t *);
173 1.1 ad #else
174 1.1 ad #include <sys/cdefs.h>
175 1.1 ad __BEGIN_DECLS
176 1.1 ad int _X86_SYSARCH_L(get_ldt)(int, union descriptor *, int);
177 1.1 ad int _X86_SYSARCH_L(set_ldt)(int, union descriptor *, int);
178 1.1 ad int _X86_SYSARCH_L(iopl)(int);
179 1.1 ad int _X86_SYSARCH_L(pmc_info)(struct _X86_SYSARCH_L(pmc_info_args *));
180 1.1 ad int _X86_SYSARCH_L(pmc_startstop)(struct _X86_SYSARCH_L(pmc_startstop_args *));
181 1.1 ad int _X86_SYSARCH_L(pmc_read)(struct _X86_SYSARCH_L(pmc_read_args *));
182 1.1 ad int _X86_SYSARCH_L(set_mtrr)(struct mtrr *, int *);
183 1.1 ad int _X86_SYSARCH_L(get_mtrr)(struct mtrr *, int *);
184 1.1 ad int sysarch(int, void *);
185 1.1 ad __END_DECLS
186 1.1 ad #endif
187 1.1 ad
188 1.1 ad #endif /* !_X86_SYSARCH_H_ */
189