Home | History | Annotate | Line # | Download | only in include
sysarch.h revision 1.9
      1  1.9    chs /*	$NetBSD: sysarch.h,v 1.9 2010/07/07 01:14:53 chs 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.1     ad #define	X86_IOPL		2
     38  1.1     ad #define	X86_GET_IOPERM		3
     39  1.1     ad #define	X86_SET_IOPERM		4
     40  1.1     ad #define	X86_OLD_VM86		5
     41  1.1     ad #define	X86_PMC_INFO		8
     42  1.1     ad #define	X86_PMC_STARTSTOP	9
     43  1.1     ad #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.1     ad #define	X86_VM86		13
     47  1.6     ad #define	X86_GET_GSBASE		14
     48  1.6     ad #define	X86_GET_FSBASE		15
     49  1.6     ad #define	X86_SET_GSBASE		16
     50  1.6     ad #define	X86_SET_FSBASE		17
     51  1.2     ad 
     52  1.2     ad #ifdef _KERNEL
     53  1.2     ad #define	_X86_SYSARCH_L(x)	x86_##x
     54  1.2     ad #define	_X86_SYSARCH_U(x)	X86_##x
     55  1.4  ragge #elif defined(__i386__)
     56  1.1     ad #define	_X86_SYSARCH_L(x)	i386_##x
     57  1.1     ad #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.1     ad #define	I386_IOPL		X86_IOPL
     61  1.1     ad #define	I386_GET_IOPERM		X86_GET_IOPERM
     62  1.1     ad #define	I386_SET_IOPERM		X86_SET_IOPERM
     63  1.1     ad #define	I386_OLD_VM86		X86_OLD_VM86
     64  1.1     ad #define	I386_PMC_INFO		X86_PMC_INFO
     65  1.1     ad #define	I386_PMC_STARTSTOP	X86_PMC_STARTSTOP
     66  1.1     ad #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.1     ad #define	I386_VM86		X86_VM86
     70  1.6     ad #define	I386_GET_GSBASE		X86_GET_GSBASE
     71  1.6     ad #define	I386_GET_FSBASE		X86_GET_FSBASE
     72  1.6     ad #define	I386_SET_GSBASE		X86_SET_GSBASE
     73  1.6     ad #define	I386_SET_FSBASE		X86_SET_FSBASE
     74  1.1     ad #else
     75  1.1     ad #define	_X86_SYSARCH_L(x)	x86_64_##x
     76  1.1     ad #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.1     ad #define	X86_64_IOPL		X86_IOPL
     80  1.1     ad #define	X86_64_GET_IOPERM	X86_GET_IOPERM
     81  1.1     ad #define	X86_64_SET_IOPERM	X86_SET_IOPERM
     82  1.1     ad #define	X86_64_OLD_VM86		X86_OLD_VM86
     83  1.1     ad #define	X86_64_PMC_INFO		X86_PMC_INFO
     84  1.1     ad #define	X86_64_PMC_STARTSTOP	X86_PMC_STARTSTOP
     85  1.1     ad #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.1     ad #define	X86_64_VM86		X86_VM86
     89  1.6     ad #define X86_64_GET_GSBASE	X86_GET_GSBASE
     90  1.6     ad #define	X86_64_GET_FSBASE	X86_GET_FSBASE
     91  1.6     ad #define X86_64_SET_GSBASE	X86_SET_GSBASE
     92  1.6     ad #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.1     ad 	int	type;
    135  1.1     ad 	int	flags;
    136  1.1     ad };
    137  1.1     ad 
    138  1.1     ad #define	PMC_TYPE_NONE		0
    139  1.1     ad #define	PMC_TYPE_I586		1
    140  1.1     ad #define	PMC_TYPE_I686		2
    141  1.1     ad #define	PMC_TYPE_K7		3
    142  1.1     ad 
    143  1.1     ad #define	PMC_INFO_HASTSC		0x01
    144  1.1     ad 
    145  1.4  ragge #ifdef __i386__
    146  1.1     ad #define	PMC_NCOUNTERS		4
    147  1.1     ad #else
    148  1.1     ad #define	PMC_NCOUNTERS		2
    149  1.1     ad #endif
    150  1.1     ad 
    151  1.1     ad struct _X86_SYSARCH_L(pmc_startstop_args) {
    152  1.1     ad 	int counter;
    153  1.1     ad 	uint64_t val;
    154  1.1     ad 	uint8_t event;
    155  1.1     ad 	uint8_t unit;
    156  1.1     ad 	uint8_t compare;
    157  1.1     ad 	uint8_t flags;
    158  1.1     ad };
    159  1.1     ad 
    160  1.1     ad #define	PMC_SETUP_KERNEL	0x01
    161  1.1     ad #define	PMC_SETUP_USER		0x02
    162  1.1     ad #define	PMC_SETUP_EDGE		0x04
    163  1.1     ad #define	PMC_SETUP_INV		0x08
    164  1.1     ad 
    165  1.1     ad struct _X86_SYSARCH_L(pmc_read_args) {
    166  1.1     ad 	int counter;
    167  1.1     ad 	uint64_t val;
    168  1.1     ad 	uint64_t time;
    169  1.1     ad };
    170  1.1     ad 
    171  1.1     ad struct mtrr;
    172  1.1     ad 
    173  1.1     ad #ifdef _KERNEL
    174  1.1     ad int x86_iopl(struct lwp *, void *, register_t *);
    175  1.1     ad int x86_get_mtrr(struct lwp *, void *, register_t *);
    176  1.1     ad int x86_set_mtrr(struct lwp *, void *, register_t *);
    177  1.9    chs int x86_get_ldt(struct lwp *, void *, register_t *);
    178  1.9    chs int x86_get_ldt1(struct lwp *, struct x86_get_ldt_args *, union descriptor *);
    179  1.9    chs int x86_set_ldt(struct lwp *, void *, register_t *);
    180  1.9    chs int x86_set_ldt1(struct lwp *, struct x86_set_ldt_args *, union descriptor *);
    181  1.9    chs int x86_set_sdbase(void *, char, lwp_t *, bool);
    182  1.9    chs int x86_get_sdbase(void *, char);
    183  1.1     ad #else
    184  1.1     ad #include <sys/cdefs.h>
    185  1.1     ad __BEGIN_DECLS
    186  1.1     ad int _X86_SYSARCH_L(get_ldt)(int, union descriptor *, int);
    187  1.1     ad int _X86_SYSARCH_L(set_ldt)(int, union descriptor *, int);
    188  1.1     ad int _X86_SYSARCH_L(iopl)(int);
    189  1.1     ad int _X86_SYSARCH_L(pmc_info)(struct _X86_SYSARCH_L(pmc_info_args *));
    190  1.1     ad int _X86_SYSARCH_L(pmc_startstop)(struct _X86_SYSARCH_L(pmc_startstop_args *));
    191  1.1     ad int _X86_SYSARCH_L(pmc_read)(struct _X86_SYSARCH_L(pmc_read_args *));
    192  1.1     ad int _X86_SYSARCH_L(set_mtrr)(struct mtrr *, int *);
    193  1.1     ad int _X86_SYSARCH_L(get_mtrr)(struct mtrr *, int *);
    194  1.1     ad int sysarch(int, void *);
    195  1.1     ad __END_DECLS
    196  1.1     ad #endif
    197  1.1     ad 
    198  1.1     ad #endif /* !_X86_SYSARCH_H_ */
    199