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